require 'spec_helper_acceptance'
-# Note that helpers (`should`, `be_running`...) are documented here:
-# http://serverspec.org/resource_types.html
-describe 'opendaylight class' do
+# NB: There are a large number of helper functions used in these tests.
+# They make this code much more friendly, but may need to be referenced.
+# The serverspec helpers (`should`, `be_running`...) are documented here:
+# http://serverspec.org/resource_types.html
+# Custom helpers (`install_odl`, `*_validations`) are in:
+# <this module>/spec/spec_helper_acceptance.rb
- context 'default parameters' do
- # Using puppet_apply as a helper
- it 'should work idempotently with no errors' do
- pp = <<-EOS
- class { 'opendaylight': }
- EOS
+describe 'opendaylight class' do
+ describe 'testing install methods' do
+ # Call specialized helper fn to install OpenDaylight
+ install_odl
- # Run it twice and test for idempotency
- apply_manifest(pp, :catch_failures => true)
- apply_manifest(pp, :catch_changes => true)
+ # Run checks specific to install type, via env var passed from Rakefile
+ if ENV['INSTALL_METHOD'] == 'tarball'
+ # Call specialized helper fn for tarball-type install validations
+ tarball_validations
+ else
+ # Call specialized helper fn for RPM-type install validations
+ rpm_validations
end
- describe file('/opt/opendaylight-0.2.1/etc/org.apache.karaf.features.cfg') do
- it { should be_file }
- it { should contain 'featuresBoot' }
- end
+ # Use helper fn to run generic validations
+ generic_validations
+ end
- describe yumrepo('opendaylight') do
- it { should exist }
- it { should be_enabled }
- end
+ describe 'testing Karaf config file' do
+ describe 'using default features' do
+ context 'and not passing extra features' do
+ # Call specialized helper fn to install OpenDaylight
+ install_odl
- describe package('opendaylight') do
- it { should be_installed }
- end
+ # Call specialized helper fn for Karaf config validations
+ karaf_config_validations
+ end
+
+ context 'and passing extra features' do
+ # These are real but arbitrarily chosen features
+ extra_features = ['odl-base-all', 'odl-ovsdb-all']
+
+ # Call specialized helper fn to install OpenDaylight
+ install_odl(extra_features: extra_features)
- describe service('opendaylight') do
- it { should be_enabled }
- it { should be_enabled.with_level(3) }
- it { should be_running }
+ # Call specialized helper fn for Karaf config validations
+ karaf_config_validations(extra_features: extra_features)
+ end
end
- # OpenDaylight will appear as a Java process
- describe process('java') do
- it { should be_running }
+ describe 'overriding default features' do
+ # These are real but arbitrarily chosen features
+ default_features = ['standard', 'ssh']
+
+ context 'and not passing extra features' do
+ # Call specialized helper fn to install OpenDaylight
+ install_odl(default_features: default_features)
+
+ # Call specialized helper fn for Karaf config validations
+ karaf_config_validations(default_features: default_features)
+ end
+
+ context 'and passing extra features' do
+ # These are real but arbitrarily chosen features
+ extra_features = ['odl-base-all', 'odl-ovsdb-all']
+
+ # Call specialized helper fn to install OpenDaylight
+ install_odl(default_features: default_features,
+ extra_features: extra_features)
+
+ # Call specialized helper fn for Karaf config validations
+ karaf_config_validations(default_features: default_features,
+ extra_features: extra_features)
+ end
end
+ end
- describe user('odl') do
- it { should exist }
- it { should belong_to_group 'odl' }
- # This dir will not be created because of -M switch in ODL's RPM.
- # Should really be called a `login_dir` by serverspec, as it's
- # checking `getent passwd odl` for a login dir vs looking at
- # `/home/` to see if `odl/` exists.
- it { should have_home_directory '/home/odl' }
+ describe 'testing REST port config file' do
+ context 'using default port' do
+ # Call specialized helper fn to install OpenDaylight
+ install_odl
+
+ # Call specialized helper fn for REST port config validations
+ port_config_validations
end
- describe file('/home/odl') do
- # Home dir shouldn't be created for odl user
- it { should_not be_directory }
+ context 'overriding default port' do
+ # Call specialized helper fn to install OpenDaylight
+ install_odl(odl_rest_port: 7777)
+
+ # Call specialized helper fn for REST port config validations
+ port_config_validations(odl_rest_port: 7777)
end
end
end