eb4910da0949d84c1271f63936ae348b167fde14
[integration/packaging/puppet-opendaylight.git] / spec / classes / opendaylight_spec.rb
1 require 'spec_helper'
2
3 describe 'opendaylight' do
4   # All tests that check OS support/not-support
5   describe 'OS support tests' do
6     # All tests for OSs in the Red Hat family (CentOS, Fedora)
7     describe 'OS family Red Hat ' do
8       osfamily = 'RedHat'
9       # All tests for Fedora
10       describe 'Fedora' do
11         operatingsystem = 'Fedora'
12
13         # All tests for supported versions of Fedora
14         ['25', '26'].each do |operatingsystemmajrelease|
15           context "#{operatingsystemmajrelease}" do
16             let(:facts) {{
17               :osfamily => osfamily,
18               :operatingsystem => operatingsystem,
19               :operatingsystemmajrelease => operatingsystemmajrelease,
20             }}
21             # Run shared tests applicable to all supported OSs
22             # Note that this function is defined in spec_helper
23             generic_tests
24
25             # Run tests that specialize in checking rpm-based installs
26             # NB: Only testing defaults here, specialized rpm tests elsewhere
27             # Note that this function is defined in spec_helper
28             rpm_install_tests(operatingsystem: operatingsystem)
29
30             # Run tests that specialize in checking Karaf feature installs
31             # NB: Only testing defaults here, specialized Karaf tests elsewhere
32             # Note that this function is defined in spec_helper
33             karaf_feature_tests
34
35             # Run tests that specialize in checking ODL's REST port config
36             # NB: Only testing defaults here, specialized log level tests elsewhere
37             # Note that this function is defined in spec_helper
38             odl_rest_port_tests
39
40             # Run tests that specialize in checking custom log level config
41             # NB: Only testing defaults here, specialized log level tests elsewhere
42             # Note that this function is defined in spec_helper
43             log_level_tests
44
45             # Run tests that specialize in checking ODL OVSDB HA config
46             # NB: Only testing defaults here, specialized enabling HA tests elsewhere
47             # Note that this function is defined in spec_helper
48             enable_ha_tests
49
50             # Run tests that specialize in checking log file settings
51             # NB: Only testing defaults here, specialized log file settings tests elsewhere
52             # Note that this function is defined in spec_helper
53             log_file_settings
54           end
55         end
56
57         # All tests for unsupported versions of Fedora
58         ['23'].each do |operatingsystemmajrelease|
59           context "#{operatingsystemmajrelease}" do
60             let(:facts) {{
61               :osfamily => osfamily,
62               :operatingsystem => operatingsystem,
63               :operatingsystemmajrelease => operatingsystemmajrelease,
64             }}
65             # Run shared tests applicable to all unsupported OSs
66             # Note that this function is defined in spec_helper
67             expected_msg = "Unsupported OS: #{operatingsystem} #{operatingsystemmajrelease}"
68             unsupported_os_tests(expected_msg: expected_msg)
69           end
70         end
71       end
72
73       # All tests for CentOS
74       describe 'CentOS' do
75         operatingsystem = 'CentOS'
76
77         # All tests for supported versions of CentOS
78         ['7'].each do |operatingsystemmajrelease|
79           context "#{operatingsystemmajrelease}" do
80             let(:facts) {{
81               :osfamily => osfamily,
82               :operatingsystem => operatingsystem,
83               :operatingsystemmajrelease => operatingsystemmajrelease,
84             }}
85             # Run shared tests applicable to all supported OSs
86             # Note that this function is defined in spec_helper
87             generic_tests
88
89             # Run test that specialize in checking rpm-based installs
90             # NB: Only testing defaults here, specialized rpm tests elsewhere
91             # Note that this function is defined in spec_helper
92             rpm_install_tests
93
94             # Run test that specialize in checking Karaf feature installs
95             # NB: Only testing defaults here, specialized Karaf tests elsewhere
96             # Note that this function is defined in spec_helper
97             karaf_feature_tests
98
99             # Run tests that specialize in checking ODL's REST port config
100             # NB: Only testing defaults here, specialized log level tests elsewhere
101             # Note that this function is defined in spec_helper
102             odl_rest_port_tests
103
104             # Run test that specialize in checking custom log level config
105             # NB: Only testing defaults here, specialized log level tests elsewhere
106             # Note that this function is defined in spec_helper
107             log_level_tests
108
109             # Run tests that specialize in checking ODL OVSDB HA config
110             # NB: Only testing defaults here, specialized enabling HA tests elsewhere
111             # Note that this function is defined in spec_helper
112             enable_ha_tests
113
114             # Run tests that specialize in checking log file settings
115             # NB: Only testing defaults here, specialized log file settings tests elsewhere
116             # Note that this function is defined in spec_helper
117             log_file_settings
118           end
119         end
120
121         # All tests for unsupported versions of CentOS
122         ['6'].each do |operatingsystemmajrelease|
123           context "#{operatingsystemmajrelease}" do
124             let(:facts) {{
125               :osfamily => osfamily,
126               :operatingsystem => operatingsystem,
127               :operatingsystemmajrelease => operatingsystemmajrelease,
128             }}
129             # Run shared tests applicable to all unsupported OSs
130             # Note that this function is defined in spec_helper
131             expected_msg = "Unsupported OS: #{operatingsystem} #{operatingsystemmajrelease}"
132             unsupported_os_tests(expected_msg: expected_msg)
133           end
134         end
135       end
136     end
137
138     # All tests for OSs in the Debian family (Ubuntu)
139     describe 'OS family Debian' do
140       osfamily = 'Debian'
141
142       # All tests for Ubuntu 16.04
143       describe 'Ubuntu' do
144         operatingsystem = 'Ubuntu'
145
146         # All tests for supported versions of Ubuntu
147         ['16.04'].each do |operatingsystemrelease|
148           context "#{operatingsystemrelease}" do
149             let(:facts) {{
150               :osfamily => osfamily,
151               :operatingsystem => operatingsystem,
152               :operatingsystemrelease => operatingsystemrelease,
153               :lsbdistid => operatingsystem,
154               :lsbdistrelease => operatingsystemrelease,
155               :lsbdistcodename => 'xenial',
156               :puppetversion => '4.9.0',
157               :path => ['/usr/local/bin', '/usr/bin', '/bin'],
158             }}
159
160             # Run shared tests applicable to all supported OSs
161             # Note that this function is defined in spec_helper
162             generic_tests
163
164             # Run test that specialize in checking deb-based installs
165             # Note that this function is defined in spec_helper
166             deb_install_tests
167
168             # Run test that specialize in checking Karaf feature installs
169             # NB: Only testing defaults here, specialized Karaf tests elsewhere
170             # Note that this function is defined in spec_helper
171             karaf_feature_tests
172
173             # Run tests that specialize in checking ODL's REST port config
174             # NB: Only testing defaults here, specialized log level tests elsewhere
175             # Note that this function is defined in spec_helper
176             odl_rest_port_tests
177
178             # Run test that specialize in checking custom log level config
179             # NB: Only testing defaults here, specialized log level tests elsewhere
180             # Note that this function is defined in spec_helper
181             log_level_tests
182
183             # Run tests that specialize in checking ODL OVSDB HA config
184             # NB: Only testing defaults here, specialized enabling HA tests elsewhere
185             # Note that this function is defined in spec_helper
186             enable_ha_tests
187
188             # Run tests that specialize in checking log file settings
189             # NB: Only testing defaults here, specialized log file settings tests elsewhere
190             # Note that this function is defined in spec_helper
191             log_file_settings
192           end
193         end
194
195         # All tests for unsupported versions of Ubuntu
196         ['12.04', '14.04', '15.10'].each do |operatingsystemrelease|
197           context "#{operatingsystemrelease}" do
198             let(:facts) {{
199               :osfamily => osfamily,
200               :operatingsystem => operatingsystem,
201               :operatingsystemrelease => operatingsystemrelease,
202               :lsbdistid => operatingsystem,
203               :lsbdistrelease => operatingsystemrelease,
204               :lsbdistcodename => 'xenial',
205               :puppetversion => '4.9.0',
206             }}
207             # Run shared tests applicable to all unsupported OSs
208             # Note that this function is defined in spec_helper
209             expected_msg = "Unsupported OS: #{operatingsystem} #{operatingsystemrelease}"
210             unsupported_os_tests(expected_msg: expected_msg)
211           end
212         end
213       end
214     end
215
216     # All tests for unsupported OS families
217     ['Suse', 'Solaris'].each do |osfamily|
218       context "OS family #{osfamily}" do
219         let(:facts) {{
220           :osfamily => osfamily,
221         }}
222
223         # Run shared tests applicable to all unsupported OSs
224         # Note that this function is defined in spec_helper
225         expected_msg = "Unsupported OS family: #{osfamily}"
226         unsupported_os_tests(expected_msg: expected_msg)
227       end
228     end
229   end
230
231   # All Karaf feature tests
232   describe 'Karaf feature tests' do
233     # Non-OS-type tests assume CentOS 7
234     #   See issue #43 for reasoning:
235     #   https://github.com/dfarrell07/puppet-opendaylight/issues/43#issue-57343159
236     osfamily = 'RedHat'
237     operatingsystem = 'CentOS'
238     operatingsystemmajrelease = '7'
239     describe 'using default features' do
240       context 'and not passing extra features' do
241         let(:facts) {{
242           :osfamily => osfamily,
243           :operatingsystem => operatingsystem,
244           :operatingsystemmajrelease => operatingsystemmajrelease,
245         }}
246
247         let(:params) {{ }}
248
249         # Run shared tests applicable to all supported OSs
250         # Note that this function is defined in spec_helper
251         generic_tests
252
253         # Run test that specialize in checking Karaf feature installs
254         # Note that this function is defined in spec_helper
255         karaf_feature_tests
256       end
257
258       context 'and passing extra features' do
259         let(:facts) {{
260           :osfamily => osfamily,
261           :operatingsystem => operatingsystem,
262           :operatingsystemmajrelease => operatingsystemmajrelease,
263         }}
264
265         # These are real but arbitrarily chosen features
266         extra_features = ['odl-base-all', 'odl-ovsdb-all']
267         let(:params) {{
268           :extra_features => extra_features,
269         }}
270
271         # Run shared tests applicable to all supported OSs
272         # Note that this function is defined in spec_helper
273         generic_tests
274
275         # Run test that specialize in checking Karaf feature installs
276         # Note that this function is defined in spec_helper
277         karaf_feature_tests(extra_features: extra_features)
278       end
279     end
280
281     describe 'overriding default features' do
282       default_features = ['standard', 'ssh']
283       context 'and not passing extra features' do
284         let(:facts) {{
285           :osfamily => osfamily,
286           :operatingsystem => operatingsystem,
287           :operatingsystemmajrelease => operatingsystemmajrelease,
288         }}
289
290         let(:params) {{
291           :default_features => default_features,
292         }}
293
294         # Run shared tests applicable to all supported OSs
295         # Note that this function is defined in spec_helper
296         generic_tests
297
298         # Run test that specialize in checking Karaf feature installs
299         # Note that this function is defined in spec_helper
300         karaf_feature_tests(default_features: default_features)
301       end
302
303       context 'and passing extra features' do
304         let(:facts) {{
305           :osfamily => osfamily,
306           :operatingsystem => operatingsystem,
307           :operatingsystemmajrelease => operatingsystemmajrelease,
308         }}
309
310         # These are real but arbitrarily chosen features
311         extra_features = ['odl-base-all', 'odl-ovsdb-all']
312         let(:params) {{
313           :default_features => default_features,
314           :extra_features => extra_features,
315         }}
316
317         # Run shared tests applicable to all supported OSs
318         # Note that this function is defined in spec_helper
319         generic_tests
320
321         # Run test that specialize in checking Karaf feature installs
322         # Note that this function is defined in spec_helper
323         karaf_feature_tests(default_features: default_features, extra_features: extra_features)
324       end
325     end
326   end
327
328   # All ODL REST port tests
329   describe 'REST port tests' do
330     # Non-OS-type tests assume CentOS 7
331     #   See issue #43 for reasoning:
332     #   https://github.com/dfarrell07/puppet-opendaylight/issues/43#issue-57343159
333     osfamily = 'RedHat'
334     operatingsystem = 'CentOS'
335     operatingsystemmajrelease = '7'
336     context 'using default REST port' do
337       let(:facts) {{
338         :osfamily => osfamily,
339         :operatingsystem => operatingsystem,
340         :operatingsystemmajrelease => operatingsystemmajrelease,
341       }}
342
343       let(:params) {{ }}
344
345       # Run shared tests applicable to all supported OSs
346       # Note that this function is defined in spec_helper
347       generic_tests
348
349       # Run test that specialize in checking ODL REST port config
350       # Note that this function is defined in spec_helper
351       odl_rest_port_tests
352     end
353
354     context 'overriding default REST port' do
355       let(:facts) {{
356         :osfamily => osfamily,
357         :operatingsystem => operatingsystem,
358         :operatingsystemmajrelease => operatingsystemmajrelease,
359       }}
360
361       let(:params) {{
362         :odl_rest_port => 7777,
363       }}
364
365       # Run shared tests applicable to all supported OSs
366       # Note that this function is defined in spec_helper
367       generic_tests
368
369       # Run test that specialize in checking ODL REST port config
370       # Note that this function is defined in spec_helper
371       odl_rest_port_tests(odl_rest_port: 7777)
372     end
373   end
374
375   # All custom log level tests
376   describe 'custom log level tests' do
377     # Non-OS-type tests assume CentOS 7
378     #   See issue #43 for reasoning:
379     #   https://github.com/dfarrell07/puppet-opendaylight/issues/43#issue-57343159
380     osfamily = 'RedHat'
381     operatingsystem = 'CentOS'
382     operatingsystemmajrelease = '7'
383     context 'using default log levels' do
384       let(:facts) {{
385         :osfamily => osfamily,
386         :operatingsystem => operatingsystem,
387         :operatingsystemmajrelease => operatingsystemmajrelease,
388       }}
389
390       let(:params) {{ }}
391
392       # Run shared tests applicable to all supported OSs
393       # Note that this function is defined in spec_helper
394       generic_tests
395
396       # Run test that specialize in checking custom log level config
397       # Note that this function is defined in spec_helper
398       log_level_tests
399     end
400
401     context 'adding one custom log level' do
402       let(:facts) {{
403         :osfamily => osfamily,
404         :operatingsystem => operatingsystem,
405         :operatingsystemmajrelease => operatingsystemmajrelease,
406       }}
407
408       custom_log_levels = { 'org.opendaylight.ovsdb' => 'TRACE' }
409
410       let(:params) {{
411         :log_levels => custom_log_levels,
412       }}
413
414       # Run shared tests applicable to all supported OSs
415       # Note that this function is defined in spec_helper
416       generic_tests
417
418       # Run test that specialize in checking log level config
419       # Note that this function is defined in spec_helper
420       log_level_tests(log_levels: custom_log_levels)
421     end
422
423     context 'adding two custom log levels' do
424       let(:facts) {{
425         :osfamily => osfamily,
426         :operatingsystem => operatingsystem,
427         :operatingsystemmajrelease => operatingsystemmajrelease,
428       }}
429
430       custom_log_levels = { 'org.opendaylight.ovsdb' => 'TRACE',
431                          'org.opendaylight.ovsdb.lib' => 'INFO' }
432
433       let(:params) {{
434         :log_levels => custom_log_levels,
435       }}
436
437       # Run shared tests applicable to all supported OSs
438       # Note that this function is defined in spec_helper
439       generic_tests
440
441       # Run test that specialize in checking log level config
442       # Note that this function is defined in spec_helper
443       log_level_tests(log_levels: custom_log_levels)
444     end
445   end
446
447   # All custom log file size and rollover tests
448   describe 'log file size and rollover' do
449     # Non-OS-type tests assume CentOS 7
450     #   See issue #43 for reasoning:
451     #   https://github.com/dfarrell07/puppet-opendaylight/issues/43#issue-57343159
452     osfamily = 'RedHat'
453     operatingsystem = 'CentOS'
454     operatingsystemmajrelease = '7'
455     context 'using default size and rollover' do
456       let(:facts) {{
457         :osfamily => osfamily,
458         :operatingsystem => operatingsystem,
459         :operatingsystemmajrelease => operatingsystemmajrelease,
460       }}
461
462       let(:params) {{ }}
463
464       # Run shared tests applicable to all supported OSs
465       # Note that this function is defined in spec_helper
466       generic_tests
467
468       # Run test specific to log file settings
469       log_file_settings
470     end
471
472     context 'customizing size' do
473       let(:facts) {{
474         :osfamily => osfamily,
475         :operatingsystem => operatingsystem,
476         :operatingsystemmajrelease => operatingsystemmajrelease,
477       }}
478
479       let(:params) {{
480         :log_max_size => '1GB',
481       }}
482
483       # Run shared tests applicable to all supported OSs
484       # Note that this function is defined in spec_helper
485       generic_tests
486
487       # Run test specific to log file settings
488       log_file_settings(log_max_size: '1GB')
489     end
490
491     context 'customizing rollover' do
492       let(:facts) {{
493         :osfamily => osfamily,
494         :operatingsystem => operatingsystem,
495         :operatingsystemmajrelease => operatingsystemmajrelease,
496       }}
497
498       let(:params) {{
499         :log_max_rollover => 3,
500       }}
501
502       # Run shared tests applicable to all supported OSs
503       # Note that this function is defined in spec_helper
504       generic_tests
505
506       # Run test specific to log file settings
507       log_file_settings(log_max_rollover: 3)
508     end
509
510     context 'customizing size and rollover' do
511       let(:facts) {{
512         :osfamily => osfamily,
513         :operatingsystem => operatingsystem,
514         :operatingsystemmajrelease => operatingsystemmajrelease,
515       }}
516
517       let(:params) {{
518         :log_max_size => '1GB',
519         :log_max_rollover => 3,
520       }}
521
522       # Run shared tests applicable to all supported OSs
523       # Note that this function is defined in spec_helper
524       generic_tests
525
526       # Run test specific to log file settings
527       log_file_settings(log_max_size: '1GB',
528                         log_max_rollover: 3)
529     end
530   end
531
532   # All OVSDB HA enable/disable tests
533   describe 'OVSDB HA enable/disable tests' do
534     # Non-OS-type tests assume CentOS 7
535     #   See issue #43 for reasoning:
536     #   https://github.com/dfarrell07/puppet-opendaylight/issues/43#issue-57343159
537     osfamily = 'RedHat'
538     operatingsystem = 'CentOS'
539     operatingsystemmajrelease = '7'
540     context 'using enable_ha default' do
541       let(:facts) {{
542         :osfamily => osfamily,
543         :operatingsystem => operatingsystem,
544         :operatingsystemmajrelease => operatingsystemmajrelease,
545       }}
546
547       let(:params) {{ }}
548
549       # Run shared tests applicable to all supported OSs
550       # Note that this function is defined in spec_helper
551       generic_tests
552
553       # Run test that specialize in checking ODL OVSDB HA config
554       # Note that this function is defined in spec_helper
555       enable_ha_tests
556     end
557
558     context 'using false for enable_ha' do
559       let(:facts) {{
560         :osfamily => osfamily,
561         :operatingsystem => operatingsystem,
562         :operatingsystemmajrelease => operatingsystemmajrelease,
563       }}
564
565       let(:params) {{
566         :enable_ha => false,
567       }}
568
569       # Run shared tests applicable to all supported OSs
570       # Note that this function is defined in spec_helper
571       generic_tests
572
573       # Run test that specialize in checking ODL OVSDB HA config
574       # Note that this function is defined in spec_helper
575       enable_ha_tests(enable_ha: false)
576     end
577
578     context 'using true for enable_ha' do
579       context 'using ha_node_count >=2' do
580         let(:facts) {{
581           :osfamily => osfamily,
582           :operatingsystem => operatingsystem,
583           :operatingsystemmajrelease => operatingsystemmajrelease,
584         }}
585
586         let(:params) {{
587           :enable_ha => true,
588           :ha_node_ips => ['0.0.0.0', '127.0.0.1']
589         }}
590
591         # Run shared tests applicable to all supported OSs
592         # Note that this function is defined in spec_helper
593         generic_tests
594
595         # Run test that specialize in checking ODL OVSDB HA config
596         # Note that this function is defined in spec_helper
597         enable_ha_tests(enable_ha: true, ha_node_ips: ['0.0.0.0', '127.0.0.1'])
598       end
599
600       context 'using custom modules for sharding' do
601         let(:facts) {{
602           :osfamily => osfamily,
603           :operatingsystem => operatingsystem,
604           :operatingsystemmajrelease => operatingsystemmajrelease,
605         }}
606
607         let(:params) {{
608           :enable_ha => true,
609           :ha_node_ips => ['0.0.0.0', '127.0.0.1'],
610           :ha_db_modules => {'default' => false, 'topology' => 'urn:opendaylight:topology'}
611         }}
612
613         # Run shared tests applicable to all supported OSs
614         # Note that this function is defined in spec_helper
615         generic_tests
616
617         # Run test that specialize in checking ODL OVSDB HA config
618         # Note that this function is defined in spec_helper
619         enable_ha_tests(enable_ha: true, ha_node_ips: ['0.0.0.0', '127.0.0.1'])
620       end
621     end
622   end
623
624
625   # All install method tests
626   describe 'install method tests' do
627
628     # All tests for RPM install method
629     describe 'RPM' do
630       # Non-OS-type tests assume CentOS 7
631       #   See issue #43 for reasoning:
632       #   https://github.com/dfarrell07/puppet-opendaylight/issues/43#issue-57343159
633       osfamily = 'RedHat'
634       operatingsystem = 'CentOS'
635       operatingsystemrelease = '7.0'
636       operatingsystemmajrelease = '7'
637
638       context 'installing default RPM' do
639         let(:facts) {{
640           :osfamily => osfamily,
641           :operatingsystem => operatingsystem,
642           :operatingsystemmajrelease => operatingsystemmajrelease,
643         }}
644
645         # Run shared tests applicable to all supported OSs
646         # Note that this function is defined in spec_helper
647         generic_tests
648
649         # Run test that specialize in checking RPM-based installs
650         # Note that this function is defined in spec_helper
651         rpm_install_tests
652       end
653
654       context 'installing Beryllium RPM' do
655         rpm_repo = 'opendaylight-40-release'
656         let(:facts) {{
657           :osfamily => osfamily,
658           :operatingsystem => operatingsystem,
659           :operatingsystemmajrelease => operatingsystemmajrelease,
660         }}
661
662         let(:params) {{
663           :rpm_repo => rpm_repo,
664         }}
665
666         # Run shared tests applicable to all supported OSs
667         # Note that this function is defined in spec_helper
668         generic_tests
669
670         # Run test that specialize in checking RPM-based installs
671         # Note that this function is defined in spec_helper
672         rpm_install_tests(rpm_repo: rpm_repo)
673       end
674     end
675
676     # All tests for Deb install method
677     describe 'Deb' do
678       osfamily = 'Debian'
679       operatingsystem = 'Ubuntu'
680       operatingsystemrelease = '16.04'
681       operatingsystemmajrelease = '16'
682       lsbdistcodename = 'xenial'
683
684       context 'installing Deb' do
685         let(:facts) {{
686           :osfamily => osfamily,
687           :operatingsystem => operatingsystem,
688           :operatingsystemrelease => operatingsystemrelease,
689           :operatingsystemmajrelease => operatingsystemmajrelease,
690           :lsbdistid => operatingsystem,
691           :lsbdistrelease => operatingsystemrelease,
692           :lsbmajdistrelease => operatingsystemmajrelease,
693           :lsbdistcodename => lsbdistcodename,
694           :puppetversion => Puppet.version,
695         }}
696
697         # Run shared tests applicable to all supported OSs
698         # Note that this function is defined in spec_helper
699         generic_tests
700
701         # Run test that specialize in checking RPM-based installs
702         # Note that this function is defined in spec_helper
703         deb_install_tests
704       end
705
706       context 'installing Carbon Deb' do
707         deb_repo = 'ppa:odl-team/carbon'
708         let(:facts) {{
709           :osfamily => osfamily,
710           :operatingsystem => operatingsystem,
711           :operatingsystemrelease => operatingsystemrelease,
712           :operatingsystemmajrelease => operatingsystemmajrelease,
713           :lsbdistid => operatingsystem,
714           :lsbdistrelease => operatingsystemrelease,
715           :lsbmajdistrelease => operatingsystemmajrelease,
716           :lsbdistcodename => lsbdistcodename,
717           :puppetversion => Puppet.version,
718         }}
719
720         let(:params) {{
721           :deb_repo => deb_repo,
722         }}
723
724         # Run shared tests applicable to all supported OSs
725         # Note that this function is defined in spec_helper
726         generic_tests
727
728         # Run test that specialize in checking RPM-based installs
729         # Note that this function is defined in spec_helper
730         deb_install_tests(deb_repo: deb_repo)
731       end
732     end
733
734   end
735
736   # Security Group Tests
737   describe 'security group tests' do
738     # Non-OS-type tests assume CentOS 7
739     #   See issue #43 for reasoning:
740     #   https://github.com/dfarrell07/puppet-opendaylight/issues/43#issue-57343159
741     osfamily = 'RedHat'
742     operatingsystem = 'CentOS'
743     operatingsystemmajrelease = '7'
744     context 'using supported stateful' do
745       let(:facts) {{
746         :osfamily => osfamily,
747         :operatingsystem => operatingsystem,
748         :operatingsystemmajrelease => operatingsystemmajrelease,
749         :operatingsystemrelease => '7.3',
750       }}
751
752       let(:params) {{
753         :security_group_mode => 'stateful',
754         :extra_features      => ['odl-netvirt-openstack'],
755       }}
756
757       # Run shared tests applicable to all supported OSs
758       # Note that this function is defined in spec_helper
759       generic_tests
760
761       # Run test that specialize in checking security groups
762       # Note that this function is defined in spec_helper
763       enable_sg_tests('stateful', '7.3')
764     end
765
766     context 'using unsupported stateful' do
767       let(:facts) {{
768         :osfamily => osfamily,
769         :operatingsystem => operatingsystem,
770         :operatingsystemmajrelease => operatingsystemmajrelease,
771         :operatingsystemrelease => '7.2.1511',
772       }}
773
774       let(:params) {{
775         :security_group_mode => 'stateful',
776         :extra_features      => ['odl-netvirt-openstack'],
777       }}
778
779       # Run shared tests applicable to all supported OSs
780       # Note that this function is defined in spec_helper
781       generic_tests
782
783       # Run test that specialize in checking security groups
784       # Note that this function is defined in spec_helper
785       enable_sg_tests('stateful', '7.2.1511')
786     end
787
788     context 'using transparent with unsupported stateful' do
789       let(:facts) {{
790         :osfamily => osfamily,
791         :operatingsystem => operatingsystem,
792         :operatingsystemmajrelease => operatingsystemmajrelease,
793         :operatingsystemrelease => '7.2.1511',
794       }}
795
796       let(:params) {{
797         :security_group_mode => 'transparent',
798         :extra_features      => ['odl-netvirt-openstack'],
799       }}
800
801       # Run shared tests applicable to all supported OSs
802       # Note that this function is defined in spec_helper
803       generic_tests
804
805       # Run test that specialize in checking security groups
806       # Note that this function is defined in spec_helper
807       enable_sg_tests('transparent', '7.2.1511')
808     end
809   end
810
811   # SNAT Mechanism tests
812   describe 'SNAT mechanism tests' do
813     # Non-OS-type tests assume CentO
814     #   See issue #43 for reasoning:
815     #   https://github.com/dfarrell07/puppet-opendaylight/issues/43#issue-57343159
816     osfamily = 'RedHat'
817     operatingsystem = 'CentOS'
818     operatingsystemmajrelease = '7'
819     context 'using controller' do
820       let(:facts) {{
821         :osfamily => osfamily,
822         :operatingsystem => operatingsystem,
823         :operatingsystemmajrelease => operatingsystemmajrelease,
824       }}
825
826       let(:params) {{
827         :extra_features => ['odl-netvirt-openstack'],
828       }}
829
830       # Run shared tests applicable to all supported OSs
831       # Note that this function is defined in spec_helper
832       generic_tests
833
834       # Run test that specialize in checking security groups
835       # Note that this function is defined in spec_helper
836       snat_mechanism_tests
837     end
838
839     context 'using conntrack' do
840       let(:facts) {{
841         :osfamily => osfamily,
842         :operatingsystem => operatingsystem,
843         :operatingsystemmajrelease => operatingsystemmajrelease,
844       }}
845
846       let(:params) {{
847         :snat_mechanism => 'conntrack',
848         :extra_features => ['odl-netvirt-openstack'],
849       }}
850
851       # Run shared tests applicable to all supported OSs
852       # Note that this function is defined in spec_helper
853       generic_tests
854
855       # Run test that specialize in checking security groups
856       # Note that this function is defined in spec_helper
857       snat_mechanism_tests('conntrack')
858     end
859   end
860
861   # SFC tests
862   describe 'SFC tests' do
863     # Non-OS-type tests assume CentO
864     #   See issue #43 for reasoning:
865     #   https://github.com/dfarrell07/puppet-opendaylight/issues/43#issue-57343159
866     osfamily = 'RedHat'
867     operatingsystem = 'CentOS'
868     operatingsystemmajrelease = '7'
869     context 'using odl-netvirt-sfc feature' do
870       let(:facts) {{
871         :osfamily => osfamily,
872         :operatingsystem => operatingsystem,
873         :operatingsystemmajrelease => operatingsystemmajrelease,
874       }}
875
876       let(:params) {{
877         :extra_features => ['odl-netvirt-sfc'],
878       }}
879
880       # Run shared tests applicable to all supported OSs
881       # Note that this function is defined in spec_helper
882       generic_tests
883
884       # Run test that specialize in checking security groups
885       # Note that this function is defined in spec_helper
886       sfc_tests
887     end
888   end
889
890   # VPP routing node config tests
891   describe 'VPP routing node tests' do
892     # Non-OS-type tests assume CentOS 7
893     #   See issue #43 for reasoning:
894     #   https://github.com/dfarrell07/puppet-opendaylight/issues/43#issue-57343159
895     osfamily = 'RedHat'
896     operatingsystem = 'CentOS'
897     operatingsystemmajrelease = '7'
898     context 'using default - no routing node' do
899       let(:facts) {{
900         :osfamily => osfamily,
901         :operatingsystem => operatingsystem,
902         :operatingsystemmajrelease => operatingsystemmajrelease,
903       }}
904
905       let(:params) {{ }}
906
907       # Run shared tests applicable to all supported OSs
908       # Note that this function is defined in spec_helper
909       generic_tests
910
911       # Run test that specialize in checking routing-node config
912       # Note that this function is defined in spec_helper
913       vpp_routing_node_tests
914     end
915
916     context 'using node name for routing node' do
917       let(:facts) {{
918         :osfamily => osfamily,
919         :operatingsystem => operatingsystem,
920         :operatingsystemmajrelease => operatingsystemmajrelease,
921       }}
922
923       let(:params) {{
924         :vpp_routing_node => 'test-node-1',
925       }}
926
927       # Run shared tests applicable to all supported OSs
928       # Note that this function is defined in spec_helper
929       generic_tests
930
931       # Run test that specialize in checking routing-node config
932       # Note that this function is defined in spec_helper
933       vpp_routing_node_tests(routing_node: 'test-node-1')
934     end
935   end
936
937   # ODL username/password tests
938   describe 'ODL username/password tests' do
939     # Non-OS-type tests assume CentOS 7
940     #   See issue #43 for reasoning:
941     #   https://github.com/dfarrell07/puppet-opendaylight/issues/43#issue-57343159
942     osfamily = 'RedHat'
943     operatingsystem = 'CentOS'
944     operatingsystemmajrelease = '7'
945     context 'using default username/password' do
946       let(:facts) {{
947         :osfamily => osfamily,
948         :operatingsystem => operatingsystem,
949         :operatingsystemmajrelease => operatingsystemmajrelease,
950       }}
951
952       let(:params) {{ }}
953
954       # Run shared tests applicable to all supported OSs
955       # Note that this function is defined in spec_helper
956       generic_tests
957
958       # Run test that specialize in checking username/password config
959       # Note that this function is defined in spec_helper
960       username_password_tests('admin','admin')
961     end
962
963     context 'specifying non-default username/password' do
964       let(:facts) {{
965         :osfamily => osfamily,
966         :operatingsystem => operatingsystem,
967         :operatingsystemmajrelease => operatingsystemmajrelease,
968       }}
969
970       let(:params) {{
971         :username => 'test',
972         :password => 'test'
973       }}
974
975       # Run shared tests applicable to all supported OSs
976       # Note that this function is defined in spec_helper
977       generic_tests
978
979       # Run test that specialize in checking routing-node config
980       # Note that this function is defined in spec_helper
981       username_password_tests('test', 'test')
982     end
983   end
984 end