Fix bind IP config for REST
[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 'log file size and rollover' do
78     context 'using default size and rollover' do
79       # Call specialized helper fn to install OpenDaylight
80       install_odl
81
82       # Call specialized helper fn for log file settings validations
83       log_file_settings_validations
84     end
85
86     context 'customising size' do
87       # Call specialized helper fn to install OpenDaylight
88       install_odl(log_max_size: '1GB')
89
90       # Call specialized helper fn for log file settings validations
91       log_file_settings_validations(log_max_size: '1GB')
92     end
93
94     context 'customising rollover' do
95       # Call specialized helper fn to install OpenDaylight
96       install_odl(log_max_rollover: 3)
97
98       # Call specialized helper fn for log file settings validations
99       log_file_settings_validations(log_max_rollover: 3)
100     end
101
102     context 'customising size and rollover' do
103       # Call specialized helper fn to install OpenDaylight
104       install_odl(log_max_size: '1GB',
105                   log_max_rollover: 3)
106
107       # Call specialized helper fn for log file settings validations
108       log_file_settings_validations(log_max_size: '1GB',
109                                     log_max_rollover: 3)
110     end
111   end
112
113   describe 'testing REST port config file' do
114     context 'using default port' do
115       # Call specialized helper fn to install OpenDaylight
116       install_odl
117
118       # Call specialized helper fn for REST port config validations
119       port_config_validations
120     end
121
122     context 'overriding default port' do
123       # Call specialized helper fn to install OpenDaylight
124       install_odl(odl_rest_port: 7777)
125
126       # Call specialized helper fn for REST port config validations
127       port_config_validations(odl_rest_port: 7777)
128     end
129   end
130
131   describe 'testing custom logging verbosity' do
132     context 'using default log levels' do
133       # Call specialized helper fn to install OpenDaylight
134       install_odl
135
136       # Call specialized helper fn for custom logger verbosity validations
137       log_level_validations
138     end
139
140     context 'adding one custom log level' do
141       custom_log_levels = { 'org.opendaylight.ovsdb' => 'TRACE' }
142
143       # Call specialized helper fn to install OpenDaylight
144       install_odl(log_levels: custom_log_levels)
145
146       # Call specialized helper fn for custom logger verbosity validations
147       log_level_validations(log_levels: custom_log_levels)
148     end
149
150     context 'adding two custom log level' do
151       custom_log_levels = { 'org.opendaylight.ovsdb' => 'TRACE',
152                             'org.opendaylight.ovsdb.lib' => 'INFO' }
153
154       # Call specialized helper fn to install OpenDaylight
155       install_odl(log_levels: custom_log_levels)
156
157       # Call specialized helper fn for custom logger verbosity validations
158       log_level_validations(log_levels: custom_log_levels)
159     end
160   end
161
162   describe 'testing odl username/password' do
163     bind_ip = '127.0.0.1'
164     context 'using default username/password' do
165     context 'using non-default bind ip' do
166       # Call specialized helper fn to install OpenDaylight
167       install_odl({:odl_bind_ip => bind_ip, :extra_features => ['odl-restconf']})
168
169       # Call specialized helper fn for username/password validations
170       username_password_validations
171     end
172     end
173   end
174
175   describe 'testing odl HA configuration' do
176     bind_ip = '127.0.0.1'
177     odl_ips = ['127.0.0.1', '127.0.0.2', '127.0.0.3']
178     context 'using default modules' do
179       install_odl(odl_bind_ip: bind_ip, enable_ha: true, ha_node_ips: odl_ips)
180
181       enable_ha_validations(odl_bind_ip: bind_ip, enable_ha: true,
182                             ha_node_ips: odl_ips)
183     end
184
185     context 'specifying datastore modules' do
186       db_modules = {
187         'default' => false,
188         'topology' => 'urn:opendaylight:topology'
189       }
190       install_odl(odl_bind_ip: bind_ip, enable_ha: true, ha_node_ips: odl_ips,
191                   ha_db_modules: db_modules)
192       enable_ha_validations(odl_bind_ip: bind_ip, enable_ha: true,
193                             ha_node_ips: odl_ips, ha_db_modules: db_modules)
194     end
195   end
196
197   describe 'testing configuring SNAT' do
198     context 'using default SNAT mechanism' do
199       # Call specialized helper fn to install OpenDaylight
200       install_odl(extra_features: ['odl-netvirt-openstack'])
201
202       # Call specialized helper fn for SNAT config validations
203       snat_mechanism_validations
204     end
205
206     context 'using conntrack SNAT' do
207       # Call specialized helper fn to install OpenDaylight
208       install_odl(extra_features: ['odl-netvirt-openstack'], snat_mechanism: 'conntrack')
209
210       # Call specialized helper fn for SNAT mechanism validations
211       snat_mechanism_validations(snat_mechanism: 'conntrack')
212     end
213   end
214
215   describe 'testing configuring SFC' do
216     context 'using SFC feature' do
217       # Call specialized helper fn to install OpenDaylight
218       install_odl(extra_features: ['odl-netvirt-sfc'])
219
220       # Call specialized helper fn for SFC config validations
221       sfc_validations
222     end
223   end
224 end