341bf2ca5a1d7c76782650a66af12ff9e898bfac
[integration/packaging/puppet-opendaylight.git] / spec / acceptance / class_spec.rb
1 require 'spec_helper_acceptance'
2
3 # NB: There are a large number of helper functions used in these tests.
4 # They make this code much more friendly, but may need to be referenced.
5 #   The serverspec helpers (`should`, `be_running`...) are documented here:
6 #     http://serverspec.org/resource_types.html
7 #   Custom helpers (`install_odl`, `*_validations`) are in:
8 #     <this module>/spec/spec_helper_acceptance.rb
9
10 describe 'opendaylight class' do
11   describe 'testing install methods' do
12     # Call specialized helper fn to install OpenDaylight
13     install_odl
14
15     # Run checks specific to install type, via env var passed from Rakefile
16     if :osfamily == 'RedHat'
17       # Call specialized helper fn for RPM-type install validations
18       rpm_validations
19     elsif :osfamily == 'Debian'
20       # Call specialized helper fn for Deb-type install validations
21       deb_validations
22     end
23
24     # Use helper fn to run generic validations
25     generic_validations
26   end
27
28   describe 'testing Karaf config file' do
29     describe 'using default features' do
30       context 'and not passing extra features' do
31         # Call specialized helper fn to install OpenDaylight
32         install_odl
33
34         # Call specialized helper fn for Karaf config validations
35         karaf_config_validations
36       end
37
38       context 'and passing extra features' do
39         # These are real but arbitrarily chosen features
40         extra_features = ['odl-base-all', 'odl-ovsdb-all']
41
42         # Call specialized helper fn to install OpenDaylight
43         install_odl(extra_features: extra_features)
44
45         # Call specialized helper fn for Karaf config validations
46         karaf_config_validations(extra_features: extra_features)
47       end
48     end
49
50     describe 'overriding default features' do
51       # These are real but arbitrarily chosen features
52       default_features = ['standard', 'ssh']
53
54       context 'and not passing extra features' do
55         # Call specialized helper fn to install OpenDaylight
56         install_odl(default_features: default_features)
57
58         # Call specialized helper fn for Karaf config validations
59         karaf_config_validations(default_features: default_features)
60       end
61
62       context 'and passing extra features' do
63         # These are real but arbitrarily chosen features
64         extra_features = ['odl-base-all', 'odl-ovsdb-all']
65
66         # Call specialized helper fn to install OpenDaylight
67         install_odl(default_features: default_features,
68                     extra_features: extra_features)
69
70         # Call specialized helper fn for Karaf config validations
71         karaf_config_validations(default_features: default_features,
72                                  extra_features: extra_features)
73       end
74     end
75   end
76
77   describe 'testing REST port config file' do
78     context 'using default port' do
79       # Call specialized helper fn to install OpenDaylight
80       install_odl
81
82       # Call specialized helper fn for REST port config validations
83       port_config_validations
84     end
85
86     context 'overriding default port' do
87       # Call specialized helper fn to install OpenDaylight
88       install_odl(odl_rest_port: 7777)
89
90       # Call specialized helper fn for REST port config validations
91       port_config_validations(odl_rest_port: 7777)
92     end
93   end
94
95   describe 'testing custom logging verbosity' do
96     context 'using default log levels' do
97       # Call specialized helper fn to install OpenDaylight
98       install_odl
99
100       # Call specialized helper fn for custom logger verbosity validations
101       log_level_validations
102     end
103
104     context 'adding one custom log level' do
105       custom_log_levels = { 'org.opendaylight.ovsdb' => 'TRACE' }
106
107       # Call specialized helper fn to install OpenDaylight
108       install_odl(log_levels: custom_log_levels)
109
110       # Call specialized helper fn for custom logger verbosity validations
111       log_level_validations(log_levels: custom_log_levels)
112     end
113
114     context 'adding two custom log level' do
115       custom_log_levels = { 'org.opendaylight.ovsdb' => 'TRACE',
116                             'org.opendaylight.ovsdb.lib' => 'INFO' }
117
118       # Call specialized helper fn to install OpenDaylight
119       install_odl(log_levels: custom_log_levels)
120
121       # Call specialized helper fn for custom logger verbosity validations
122       log_level_validations(log_levels: custom_log_levels)
123     end
124   end
125
126   describe 'testing odl username/password' do
127     context 'using default username/password' do
128     context 'using default log levels' do
129       # Call specialized helper fn to install OpenDaylight
130       install_odl({:extra_features => ['odl-restconf']})
131
132       # Call specialized helper fn for username/password validations
133       username_password_validations
134     end
135     end
136   end
137 end