1 require 'beaker-rspec/spec_helper'
2 require 'beaker-rspec/helpers/serverspec'
4 # Install Puppet on all Beaker hosts
5 unless ENV['BEAKER_provision'] == 'no'
16 RSpec.configure do |c|
18 proj_root = File.expand_path(File.join(File.dirname(__FILE__), '..'))
20 # Readable test descriptions
21 c.formatter = :documentation
23 # Configure all nodes in nodeset
25 # Install opendaylight module on any/all Beaker hosts
26 # TODO: Should this be done in host.each loop?
27 puppet_module_install(:source => proj_root, :module_name => 'opendaylight')
29 # Install stdlib, a dependency of the odl mod
30 # TODO: Why is 1 an acceptable exit code?
31 on host, puppet('module', 'install', 'puppetlabs-stdlib'), { :acceptable_exit_codes => [0,1] }
32 # Install archive, a dependency of the odl mod use for tarball-type installs
33 # TODO: I'd prefer not to use gini-archive. See:
34 # https://github.com/dfarrell07/puppet-opendaylight/issues/52
35 on host, puppet('module', 'install', 'gini-archive'), { :acceptable_exit_codes => [0] }
41 # NB: These are a library of helper fns used by the Beaker tests
44 def install_odl(options = {})
45 # NB: These param defaults should match the ones used by the opendaylight
46 # class, which are defined in opendaylight::params
47 # TODO: Remove this possible source of bugs^^
48 # Extract params if given, defaulting to odl class defaults if not
49 install_method = options.fetch(:install_method, 'rpm')
50 extra_features = options.fetch(:extra_features, [])
51 default_features = options.fetch(:default_features, ['config', 'standard', 'region',
52 'package', 'kar', 'ssh', 'management'])
54 # Build script for consumption by Puppet apply
55 it 'should work idempotently with no errors' do
57 class { 'opendaylight':
58 install_method => #{install_method},
59 default_features => #{default_features},
60 extra_features => #{extra_features},
64 # TODO: Apply to host selectively based on install method
66 # Run it twice and test for idempotency
67 apply_manifest(pp, :catch_failures => true)
68 apply_manifest(pp, :catch_changes => true)
72 # Shared function that handles generic validations
73 # These should be common for all odl class param combos
74 def generic_validations()
75 # TODO: It'd be nice to do this independently of install dir name
76 describe file('/opt/opendaylight-0.2.2/') do
77 it { should be_directory }
78 it { should be_owned_by 'odl' }
79 it { should be_grouped_into 'odl' }
80 it { should be_mode '775' }
83 describe service('opendaylight') do
84 it { should be_enabled }
85 it { should be_enabled.with_level(3) }
86 it { should be_running }
89 # OpenDaylight will appear as a Java process
90 describe process('java') do
91 it { should be_running }
94 # TODO: It'd be nice to do this independently of install dir name
95 describe user('odl') do
97 it { should belong_to_group 'odl' }
98 it { should have_home_directory '/opt/opendaylight-0.2.2' }
101 describe file('/home/odl') do
102 # Home dir shouldn't be created for odl user
103 it { should_not be_directory }
106 describe file('/usr/lib/systemd/system/opendaylight.service') do
107 it { should be_file }
108 it { should be_owned_by 'root' }
109 it { should be_grouped_into 'root' }
110 it { should be_mode '644' }
114 # Shared function for validations related to the Karaf config file
115 def karaf_config_validations(options = {})
116 # NB: These param defaults should match the ones used by the opendaylight
117 # class, which are defined in opendaylight::params
118 # TODO: Remove this possible source of bugs^^
119 extra_features = options.fetch(:extra_features, [])
120 default_features = options.fetch(:default_features, ['config', 'standard', 'region',
121 'package', 'kar', 'ssh', 'management'])
123 # Create one list of all of the features
124 features = default_features + extra_features
126 # TODO: It'd be nice to do this independently of install dir name
127 describe file('/opt/opendaylight-0.2.2/etc/org.apache.karaf.features.cfg') do
128 it { should be_file }
129 it { should be_owned_by 'odl' }
130 it { should be_grouped_into 'odl' }
131 it { should be_mode '775' }
132 its(:content) { should match /^featuresBoot=#{features.join(",")}/ }
136 # Shared function that handles validations specific to RPM-type installs
137 def rpm_validations()
138 describe yumrepo('opendaylight') do
140 it { should be_enabled }
143 describe package('opendaylight') do
144 it { should be_installed }