Allow full customization of ODL RPM repo
[integration/packaging/puppet-opendaylight.git] / spec / spec_helper.rb
index 12eb8e4e7ed971f1874313bf3cdf3d51658e6438..f0355eb3bf74e2d19f521e5d6c511b193ed98889 100644 (file)
@@ -85,7 +85,7 @@ def karaf_feature_tests(options = {})
   # Extract params
   # NB: This default list should be the same as the one in opendaylight::params
   # TODO: Remove this possible source of bugs^^
-  default_features = options.fetch(:default_features, ['config', 'standard', 'region', 'package', 'kar', 'ssh', 'management'])
+  default_features = options.fetch(:default_features, ['standard', 'wrap', 'ssh'])
   extra_features = options.fetch(:extra_features, [])
 
   # The order of this list concat matters
@@ -118,19 +118,27 @@ def odl_rest_port_tests(options = {})
   # NB: This default value should be the same as one in opendaylight::params
   # TODO: Remove this possible source of bugs^^
   odl_rest_port = options.fetch(:odl_rest_port, 8080)
-
+  odl_bind_ip = options.fetch(:odl_bind_ip, '0.0.0.0')
   # Confirm properties of ODL REST port config file
   # 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_file('jetty.xml').with(
-      'ensure'      => 'file',
-      'path'        => '/opt/opendaylight/etc/jetty.xml',
-      'owner'   => 'odl',
-      'group'   => 'odl',
-      'content'     => /Property name="jetty.port" default="#{odl_rest_port}"/
-    )
+    should contain_augeas('ODL REST Port')
   }
+
+  if not odl_bind_ip.eql? '0.0.0.0'
+    it {
+      should contain_augeas('ODL REST IP')
+      should contain_file_line('org.ops4j.pax.web.cfg').with(
+        'path'  => '/opt/opendaylight/etc/org.ops4j.pax.web.cfg',
+        'line'  => "org.ops4j.pax.web.listening.addresses = #{odl_bind_ip}",
+      )
+    }
+  else
+    it {
+      should_not contain_augeas('ODL REST IP')
+    }
+  end
 end
 
 def log_level_tests(options = {})
@@ -220,28 +228,28 @@ end
 
 def rpm_install_tests(options = {})
   # Extract params
-  rpm_repo = options.fetch(:rpm_repo, 'opendaylight-6-testing')
+  rpm_repo = options.fetch(:rpm_repo, 'http://cbs.centos.org/repos/nfv7-opendaylight-8-testing/$basearch/os/')
   java_opts = options.fetch(:java_opts, '-Djava.net.preferIPv4Stack=true')
 
   # Default to CentOS 7 Yum repo URL
 
   # Confirm presence of RPM-related resources
-  it { should contain_yumrepo(rpm_repo) }
+  it { should contain_yumrepo('opendaylight') }
   it { should contain_package('opendaylight') }
 
   # Confirm relationships between RPM-related resources
-  it { should contain_package('opendaylight').that_requires("Yumrepo[#{rpm_repo}]") }
-  it { should contain_yumrepo(rpm_repo).that_comes_before('Package[opendaylight]') }
+  it { should contain_package('opendaylight').that_requires('Yumrepo[opendaylight]') }
+  it { should contain_yumrepo('opendaylight').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(rpm_repo).with(
+    should contain_yumrepo('opendaylight').with(
       'enabled'     => '1',
       'gpgcheck'    => '0',
       'descr'       => 'OpenDaylight SDN Controller',
-      'baseurl'     => "http://cbs.centos.org/repos/nfv7-#{rpm_repo}/$basearch/os/",
+      'baseurl'     => "#{rpm_repo}",
     )
   }
   it {
@@ -284,7 +292,7 @@ end
 def unsupported_os_tests(options = {})
   # Extract params
   expected_msg = options.fetch(:expected_msg)
-  rpm_repo = options.fetch(:rpm_repo, 'opendaylight-6-testing')
+  rpm_repo = options.fetch(:rpm_repo, 'http://cbs.centos.org/repos/nfv7-opendaylight-8-testing/$basearch/os/')
 
   # Confirm that classes fail on unsupported OSs
   it { expect { should contain_class('opendaylight') }.to raise_error(Puppet::Error, /#{expected_msg}/) }
@@ -293,63 +301,52 @@ 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(rpm_repo) }.to raise_error(Puppet::Error, /#{expected_msg}/) }
+  it { expect { should contain_yumrepo('opendaylight') }.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}/) }
 end
 
-# Shared tests that specialize in testing security group mode
-def enable_sg_tests(sg_mode='stateful', os_release)
-  # Extract params
-  # NB: This default value should be the same as one in opendaylight::params
-  # TODO: Remove this possible source of bugs^^
-
+# Shared tests that specialize in testing SNAT mechanism
+def snat_mechanism_tests(snat_mechanism='controller')
   it { should contain_file('/opt/opendaylight/etc/opendaylight') }
   it { should contain_file('/opt/opendaylight/etc/opendaylight/datastore')}
   it { should contain_file('/opt/opendaylight/etc/opendaylight/datastore/initial')}
   it { should contain_file('/opt/opendaylight/etc/opendaylight/datastore/initial/config')}
 
-  if os_release != '7.3' and sg_mode == 'stateful'
-    # Confirm sg_mode becomes learn
-    it {
-      should contain_file('netvirt-aclservice-config.xml').with(
-        'ensure'      => 'file',
-        'path'        => '/opt/opendaylight/etc/opendaylight/datastore/initial/config/netvirt-aclservice-config.xml',
-        'owner'   => 'odl',
-        'group'   => 'odl',
-        'content'     => /learn/
-      )
-    }
-  else
-    # Confirm other sg_mode is passed correctly
-    it {
-      should contain_file('netvirt-aclservice-config.xml').with(
-        'ensure'      => 'file',
-        'path'        => '/opt/opendaylight/etc/opendaylight/datastore/initial/config/netvirt-aclservice-config.xml',
-        'owner'   => 'odl',
-        'group'   => 'odl',
-        'content'     => /#{sg_mode}/
+  # Confirm snat_mechanism
+  it {
+    should contain_file('netvirt-natservice-config.xml').with(
+      'ensure'      => 'file',
+      'path'        => '/opt/opendaylight/etc/opendaylight/datastore/initial/config/netvirt-natservice-config.xml',
+      'owner'   => 'odl',
+      'group'   => 'odl',
+      'content'     =>  /<nat-mode>#{snat_mechanism}<\/nat-mode>/
       )
     }
-  end
 end
 
-# Shared tests that specialize in testing SNAT mechanism
-def snat_mechanism_tests(snat_mechanism='controller')
+# Shared tests that specialize in testing SFC Config
+def sfc_tests()
   it { should contain_file('/opt/opendaylight/etc/opendaylight') }
   it { should contain_file('/opt/opendaylight/etc/opendaylight/datastore')}
   it { should contain_file('/opt/opendaylight/etc/opendaylight/datastore/initial')}
   it { should contain_file('/opt/opendaylight/etc/opendaylight/datastore/initial/config')}
 
-  # Confirm snat_mechanism
   it {
-    should contain_file('netvirt-natservice-config.xml').with(
-      'ensure'      => 'file',
-      'path'        => '/opt/opendaylight/etc/opendaylight/datastore/initial/config/netvirt-natservice-config.xml',
+    should contain_file('netvirt-elanmanager-config.xml').with(
+      'ensure'  => 'file',
+      'path'    => '/opt/opendaylight/etc/opendaylight/datastore/initial/config/netvirt-elanmanager-config.xml',
       'owner'   => 'odl',
       'group'   => 'odl',
-      'content'     =>  /<nat-mode>#{snat_mechanism}<\/nat-mode>/
+      'source'  => 'puppet:///modules/opendaylight/netvirt-elanmanager-config.xml'
+      )
+    should contain_file('genius-itm-config.xml').with(
+      'ensure'  => 'file',
+      'path'    => '/opt/opendaylight/etc/opendaylight/datastore/initial/config/genius-itm-config.xml',
+      'owner'   => 'odl',
+      'group'   => 'odl',
+      'source'  => 'puppet:///modules/opendaylight/genius-itm-config.xml'
       )
     }
 end