Add param to config RPM repo to install ODL from 29/55629/1
authorDaniel Farrell <dfarrell@redhat.com>
Fri, 3 Jun 2016 01:09:00 +0000 (21:09 -0400)
committerDaniel Farrell <dfarrell@redhat.com>
Wed, 19 Apr 2017 19:18:40 +0000 (15:18 -0400)
Param allows user to change which version of ODL installed without
changes to puppet-opendaylight. Even better than limiting to a specific
version, the new rpm_repo param allows the user to select a the latest
RPM from a major release or SR, or a fixed and official release.

This patch includes the feature changes, rspec-puppet test changes,
Beaker test changes, in-code docs and README docs.

Change-Id: Ie01dafd485318d98410a2847e53ebd819a5cf7c3
Signed-off-by: Daniel Farrell <dfarrell@redhat.com>
CHANGELOG
README.markdown
Rakefile
manifests/init.pp
manifests/install.pp
manifests/params.pp
metadata.json
spec/classes/opendaylight_spec.rb
spec/spec_helper.rb
spec/spec_helper_acceptance.rb

index cfa15fbe6c4e7ac42b2364ed5dd851cf76dc4221..0ef4e8bd1129cd2531050dd5f83e24a34c8391c2 100644 (file)
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -32,3 +32,5 @@
 - Update ODL to Beryllium SR2
 2016-06-01 Release 3.6.1
 - Minor bump due to Puppetforge issue
+2016-06-02 Release 3.7.0
+- Add param to configure ODL RPM repo
index d13293adbeee49f05d678e38afca3fc608887291..825814b4931f16d16603f11d67b53a660ca160b9 100644 (file)
@@ -13,6 +13,7 @@
 1. [Usage](#usage)
   * [Karaf Features](#karaf-features)
   * [Install Method](#install-method)
+  * [RPM Repo](#rpm-repo)
   * [Ports](#ports)
   * [Log Verbosity](#log-verbosity)
   * [Enabling ODL OVSDB L3](#enabling-odl-ovsdb-l3)
@@ -151,6 +152,34 @@ class { 'opendaylight':
 }
 ```
 
+### RPM Repo
+
+The `rpm_repo` param can be used to configure which RPM repository
+OpenDaylight is installed from.
+
+```puppet
+class { 'opendaylight':
+  rpm_repo => 'opendaylight-40-release',
+}
+```
+
+The naming convention follows the naming convention of the CentOS Community
+Build System, which is where upstream ODL hosts its RPMs. The
+`opendaylight-40-release` example above would install OpenDaylight Beryllium
+4.0.0 from the [nfv7-opendaylight-40-release][19] repo. Repo names ending in
+`-release` will always contain well-tested, officially released versions of
+OpenDaylight. Repos ending in `-testing` contain frequent, but unstable and
+unofficial, releases. The ODL version given in repo names shows which major
+and minor version it is pinned to. The `opendaylight-40-release` repo will
+always provide OpenDaylight Beryllium 4.0, whereas `opendaylight-4-release`
+will provide the latest release with major version 4 (which could include
+Service Releases, like SR2 4.2).
+
+For a full list of OpenDaylight releases and their CBS repos, see the
+[OpenDaylight Deployment wiki][20].
+
+This is only read when `install_method` is `rpm`.
+
 ### Ports
 
 To change the port on which OpenDaylight's northbound listens for REST API
@@ -418,3 +447,5 @@ See our [git commit history][17] for contributor information.
 [16]: https://github.com/dfarrell07/puppet-opendaylight/releases
 [17]: https://github.com/dfarrell07/puppet-opendaylight/commits/master
 [18]: http://cbs.centos.org/repos/nfv7-opendaylight-42-release/x86_64/os/Packages/
+[19]: http://cbs.centos.org/repos/nfv7-opendaylight-40-release/x86_64/os/Packages/ OpenDaylight Beryllium CentOS CBS repo
+[20]: https://wiki.opendaylight.org/view/Deployment#RPM OpenDaylight RPMs and their repos
index 5db4e15aa912af81ac9b42a3a65d4d952e1108be..f8b14c1440b9b92fc0e30024677756d94809a716 100644 (file)
--- a/Rakefile
+++ b/Rakefile
@@ -47,9 +47,19 @@ task :test => [
   :metadata,
 ]
 
-desc "Run Beaker tests against CentOS 7 node."
-task :centos do
-  sh "RS_SET=centos-7 INSTALL_METHOD=rpm bundle exec rake beaker"
+desc "Run Beaker tests against CentOS 7 with latest Beryllium RPM"
+task :centos_odl4testing do
+  sh "RS_SET=centos-7 INSTALL_METHOD=rpm RPM_REPO='opendaylight-4-testing' bundle exec rake beaker"
+end
+
+desc "Run Beaker tests against CentOS 7 with Beryllium SR2 4.2."
+task :centos_odl42 do
+  sh "RS_SET=centos-7 INSTALL_METHOD=rpm RPM_REPO='opendaylight-42-release' bundle exec rake beaker"
+end
+
+desc "Run Beaker tests against CentOS 7 with Beryllium 4.0."
+task :centos_odl40 do
+  sh "RS_SET=centos-7 INSTALL_METHOD=rpm RPM_REPO='opendaylight-40-release' bundle exec rake beaker"
 end
 
 desc "Run Beaker tests against CentOS 7 using tarball install."
@@ -61,7 +71,7 @@ end
 # the actually-functional systemd-container installed on centos:7
 # https://github.com/CentOS/sig-cloud-instance-build/commit/3bf1e7bbf14deaa8c047c1dfbead6d0e8d0665f2
 desc "Run Beaker tests against CentOS 7 Docker node."
-task :centos_7_docker do
+task :centos_docker do
   sh "RS_SET=centos-7-docker INSTALL_METHOD=rpm bundle exec rake beaker"
 end
 
index 71ef7213e874cc175a08ff6f8b4fb5c190b6cfd5..17b2a8f730e4eaf2fd42f5a3a946f52cc1d4eda3 100644 (file)
@@ -13,6 +13,8 @@
 #   IP for ODL northbound REST interface to bind to.
 # [*install_method *]
 #   How to install OpenDaylight. Current options are "rpm" and "tarball", default is RPM.
+# [*rpm_repo*]
+#   OpenDaylight CentOS CBS repo to install RPM from (opendaylight-4-testing, opendaylight-40-release, ...).
 # [*tarball_url*]
 #   If installing from a tarball, use this one. Defaults to latest ODL.
 # [*unitfile_url*]
@@ -34,6 +36,7 @@ class opendaylight (
   $odl_rest_port = $::opendaylight::params::odl_rest_port,
   $odl_bind_ip = $::opendaylight::params::odl_bind_ip,
   $install_method = $::opendaylight::params::install_method,
+  $rpm_repo = $::opendaylight::params::rpm_repo,
   $tarball_url = $::opendaylight::params::tarball_url,
   $unitfile_url = $::opendaylight::params::unitfile_url,
   $enable_l3 = $::opendaylight::params::enable_l3,
index 41a5d33c2ce4f92b319ce7a9e823c3f63591d3e6..7514818e332876294a98c0ed5aa6baade25ce140 100644 (file)
@@ -8,21 +8,14 @@
 #
 class opendaylight::install {
   if $opendaylight::install_method == 'rpm' {
-    # Choose Yum URL based on OS (CentOS vs Fedora)
-    # NB: Currently using the CentOS CBS for both Fedora and CentOS
-    $base_url = $::operatingsystem ? {
-      'CentOS' => 'http://cbs.centos.org/repos/nfv7-opendaylight-42-release/$basearch/os/',
-      'Fedora' => 'http://cbs.centos.org/repos/nfv7-opendaylight-42-release/$basearch/os/',
-    }
-
     # Add OpenDaylight's Yum repository
-    yumrepo { 'opendaylight-42-release':
+    yumrepo { $opendaylight::rpm_repo:
       # 'ensure' isn't supported with Puppet <3.5
       # Seems to default to present, but docs don't say
       # https://docs.puppetlabs.com/references/3.4.0/type.html#yumrepo
       # https://docs.puppetlabs.com/references/3.5.0/type.html#yumrepo
-      baseurl  => $base_url,
-      descr    => 'CentOS CBS OpenDaylight Berillium testing repository',
+      baseurl  => "http://cbs.centos.org/repos/nfv7-${opendaylight::rpm_repo}/\$basearch/os/",
+      descr    => 'OpenDaylight SDN Controller',
       enabled  => 1,
       # NB: RPM signing is an active TODO, but is not done. We will enable
       #     this gpgcheck once the RPM supports it.
@@ -33,7 +26,7 @@ class opendaylight::install {
     # Install the OpenDaylight RPM
     package { 'opendaylight':
       ensure  => present,
-      require => Yumrepo['opendaylight-42-release'],
+      require => Yumrepo[$opendaylight::rpm_repo],
     }
     ->
     # Configure the systemd file to force ipv4 binds (instead of ipv6)
index 5fa3143603272db4fef58f5eb0fb69598d107599..e43b25fc17dd919e25404c8e8cf53af9be7c9c8b 100644 (file)
@@ -13,6 +13,7 @@ class opendaylight::params {
   $odl_rest_port = '8080'
   $odl_bind_ip = '0.0.0.0'
   $install_method = 'rpm'
+  $rpm_repo = 'opendaylight-42-release'
   $tarball_url = 'https://nexus.opendaylight.org/content/repositories/opendaylight.release/org/opendaylight/integration/distribution-karaf/0.4.2-Beryllium-SR2/distribution-karaf-0.4.2-Beryllium-SR2.tar.gz'
   $unitfile_url = 'https://github.com/dfarrell07/opendaylight-systemd/archive/master/opendaylight-unitfile.tar.gz'
   $odl_rest_port = '8080'
index 236a65ee2094b2cfe4501dd0456de64df5ef1050..a79f80c2b6985e84a51c7ab5e7f720facd9ba9b6 100644 (file)
@@ -1,6 +1,6 @@
 {
   "name": "dfarrell07-opendaylight",
-  "version": "3.6.1",
+  "version": "3.7.0",
   "author": "Daniel Farrell",
   "summary": "Puppet module that installs and configures the OpenDaylight SDN controller",
   "license": "BSD-2-Clause",
index 21a4ab738c345debe579ccffe712b5c86a16c0ff..20783e961d5b02fe49c7faa6068ef218cba3548f 100644 (file)
@@ -549,24 +549,48 @@ describe 'opendaylight' do
     operatingsystemmajrelease = '7'
 
     # All tests for RPM install method
-    context 'RPM' do
-      let(:facts) {{
-        :osfamily => osfamily,
-        :operatingsystem => operatingsystem,
-        :operatingsystemmajrelease => operatingsystemmajrelease,
-      }}
+    describe 'RPM' do
+      context 'installing default RPM' do
+        let(:facts) {{
+          :osfamily => osfamily,
+          :operatingsystem => operatingsystem,
+          :operatingsystemmajrelease => operatingsystemmajrelease,
+        }}
 
-      let(:params) {{
-        :install_method => 'rpm',
-      }}
+        let(:params) {{
+          :install_method => 'rpm',
+        }}
 
-      # Run shared tests applicable to all supported OSs
-      # Note that this function is defined in spec_helper
-      generic_tests
+        # Run shared tests applicable to all supported OSs
+        # Note that this function is defined in spec_helper
+        generic_tests
 
-      # Run test that specialize in checking RPM-based installs
-      # Note that this function is defined in spec_helper
-      rpm_install_tests
+        # Run test that specialize in checking RPM-based installs
+        # Note that this function is defined in spec_helper
+        rpm_install_tests
+      end
+
+      context 'installing Beryllium RPM' do
+        rpm_repo = 'opendaylight-40-release'
+        let(:facts) {{
+          :osfamily => osfamily,
+          :operatingsystem => operatingsystem,
+          :operatingsystemmajrelease => operatingsystemmajrelease,
+        }}
+
+        let(:params) {{
+          :install_method => 'rpm',
+          :rpm_repo => rpm_repo,
+        }}
+
+        # Run shared tests applicable to all supported OSs
+        # Note that this function is defined in spec_helper
+        generic_tests
+
+        # Run test that specialize in checking RPM-based installs
+        # Note that this function is defined in spec_helper
+        rpm_install_tests(rpm_repo: rpm_repo)
+      end
     end
 
     # All tests for tarball install method
index a251e12449ebd02a6293b0d1430cb796cf2df136..b80c1013b320befbea7d6f96b90d8ad0cffae268 100644 (file)
@@ -234,6 +234,7 @@ def tarball_install_tests(options = {})
   tarball_url = options.fetch(:tarball_url, 'https://nexus.opendaylight.org/content/repositories/opendaylight.release/org/opendaylight/integration/distribution-karaf/0.4.2-Beryllium-SR2/distribution-karaf-0.4.2-Beryllium-SR2.tar.gz')
   unitfile_url = options.fetch(:unitfile_url, 'https://github.com/dfarrell07/opendaylight-systemd/archive/master/opendaylight-unitfile.tar.gz')
   osfamily = options.fetch(:osfamily, 'RedHat')
+  rpm_repo = options.fetch(:rpm_repo, 'opendaylight-42-release')
 
   # Confirm presence of tarball-related resources
   it { should contain_archive('opendaylight') }
@@ -355,43 +356,33 @@ def tarball_install_tests(options = {})
   end
 
   # Verify that there are no unexpected resources from RPM-type installs
-  it { should_not contain_yumrepo('opendaylight-42-release') }
+  it { should_not contain_yumrepo(rpm_repo) }
   it { should_not contain_package('opendaylight') }
 end
 
 def rpm_install_tests(options = {})
   # Extract params
-  # Choose Yum URL based on OS (CentOS vs Fedora)
-  # NB: Currently using the CentOS CBS for both Fedora and CentOS
-  operatingsystem  = options.fetch(:operatingsystem, 'CentOS')
-  case operatingsystem
-  when 'CentOS'
-    yum_repo = 'http://cbs.centos.org/repos/nfv7-opendaylight-42-release/$basearch/os/'
-  when 'Fedora'
-    yum_repo = 'http://cbs.centos.org/repos/nfv7-opendaylight-42-release/$basearch/os/'
-  else
-    fail("Unknown operatingsystem: #{operatingsystem}")
-  end
+  rpm_repo = options.fetch(:rpm_repo, 'opendaylight-42-release')
 
   # Default to CentOS 7 Yum repo URL
 
   # Confirm presence of RPM-related resources
-  it { should contain_yumrepo('opendaylight-42-release') }
+  it { should contain_yumrepo(rpm_repo) }
   it { should contain_package('opendaylight') }
 
   # Confirm relationships between RPM-related resources
-  it { should contain_package('opendaylight').that_requires('Yumrepo[opendaylight-42-release]') }
-  it { should contain_yumrepo('opendaylight-42-release').that_comes_before('Package[opendaylight]') }
+  it { should contain_package('opendaylight').that_requires("Yumrepo[#{rpm_repo}]") }
+  it { should contain_yumrepo(rpm_repo).that_comes_before('Package[opendaylight]') }
 
   # Confirm properties of RPM-related resources
   # NB: These hashes don't work with Ruby 1.8.7, but we
   #   don't support 1.8.7 so that's okay. See issue #36.
   it {
-    should contain_yumrepo('opendaylight-42-release').with(
+    should contain_yumrepo(rpm_repo).with(
       'enabled'     => '1',
       'gpgcheck'    => '0',
-      'descr'       => 'CentOS CBS OpenDaylight Berillium testing repository',
-      'baseurl'     => yum_repo,
+      'descr'       => 'OpenDaylight SDN Controller',
+      'baseurl'     => "http://cbs.centos.org/repos/nfv7-#{rpm_repo}/$basearch/os/",
     )
   }
   it {
@@ -405,6 +396,7 @@ end
 def unsupported_os_tests(options = {})
   # Extract params
   expected_msg = options.fetch(:expected_msg)
+  rpm_repo = options.fetch(:rpm_repo, 'opendaylight-42-release')
 
   # Confirm that classes fail on unsupported OSs
   it { expect { should contain_class('opendaylight') }.to raise_error(Puppet::Error, /#{expected_msg}/) }
@@ -413,7 +405,7 @@ def unsupported_os_tests(options = {})
   it { expect { should contain_class('opendaylight::service') }.to raise_error(Puppet::Error, /#{expected_msg}/) }
 
   # Confirm that other resources fail on unsupported OSs
-  it { expect { should contain_yumrepo('opendaylight-42-release') }.to raise_error(Puppet::Error, /#{expected_msg}/) }
+  it { expect { should contain_yumrepo(rpm_repo) }.to raise_error(Puppet::Error, /#{expected_msg}/) }
   it { expect { should contain_package('opendaylight') }.to raise_error(Puppet::Error, /#{expected_msg}/) }
   it { expect { should contain_service('opendaylight') }.to raise_error(Puppet::Error, /#{expected_msg}/) }
   it { expect { should contain_file('org.apache.karaf.features.cfg') }.to raise_error(Puppet::Error, /#{expected_msg}/) }
index ee6e264a289d1df0ad76c3023ff215c769d6aab3..7fbe70e853bf2f91f79f317617531ba030dfe3eb 100644 (file)
@@ -46,12 +46,17 @@ end
 #   http://serverspec.org/resource_types.html
 
 def install_odl(options = {})
+  # Install params are passed via environment var, set in Rakefile
+  # Changing the installed version of ODL via `puppet apply` is not supported
+  # by puppet-odl, so it's not possible to vary these params in the same
+  # Beaker test run. Do a different run passing different env vars.
+  install_method = ENV['INSTALL_METHOD']
+  rpm_repo = ENV['RPM_REPO']
+
   # NB: These param defaults should match the ones used by the opendaylight
   #   class, which are defined in opendaylight::params
   # TODO: Remove this possible source of bugs^^
   # Extract params if given, defaulting to odl class defaults if not
-  # Default install method is passed via environment var, set in Rakefile
-  install_method = options.fetch(:install_method, ENV['INSTALL_METHOD'])
   extra_features = options.fetch(:extra_features, [])
   default_features = options.fetch(:default_features,
     ['config', 'standard', 'region', 'package', 'kar', 'ssh', 'management'])
@@ -64,6 +69,7 @@ def install_odl(options = {})
     pp = <<-EOS
     class { 'opendaylight':
       install_method => #{install_method},
+      rpm_repo => #{rpm_repo},
       default_features => #{default_features},
       extra_features => #{extra_features},
       odl_rest_port=> #{odl_rest_port},
@@ -302,7 +308,9 @@ end
 
 # Shared function that handles validations specific to RPM-type installs
 def rpm_validations()
-  describe yumrepo('opendaylight-42-release') do
+  rpm_repo = ENV['RPM_REPO']
+
+  describe yumrepo(rpm_repo) do
     it { should exist }
     it { should be_enabled }
   end
@@ -314,13 +322,15 @@ end
 
 # Shared function that handles validations specific to tarball-type installs
 def tarball_validations()
+  rpm_repo = ENV['RPM_REPO']
+
   describe package('opendaylight') do
     it { should_not be_installed }
   end
 
   # Repo checks break (not fail) when yum doesn't make sense (Ubuntu)
   if ['centos-7', 'fedora-22', 'fedora-23', 'fedora-23-docker'].include? ENV['RS_SET']
-    describe yumrepo('opendaylight-42-release') do
+    describe yumrepo(rpm_repo) do
       it { should_not exist }
       it { should_not be_enabled }
     end