Bump Puppet version 4.x to 5.x
[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_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_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_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 IP/REST port tests
329   describe 'IP and 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 and IP 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         :odl_bind_ip => '127.0.0.1'
364       }}
365
366       # Run shared tests applicable to all supported OSs
367       # Note that this function is defined in spec_helper
368       generic_tests(odl_bind_ip: '127.0.0.1')
369
370       # Run test that specialize in checking ODL REST port config
371       # Note that this function is defined in spec_helper
372       odl_rest_port_tests(odl_rest_port: 7777, odl_bind_ip: '127.0.0.1')
373     end
374   end
375
376   # All custom log level tests
377   describe 'custom log level tests' do
378     # Non-OS-type tests assume CentOS 7
379     #   See issue #43 for reasoning:
380     #   https://github.com/dfarrell07/puppet-opendaylight/issues/43#issue-57343159
381     osfamily = 'RedHat'
382     operatingsystem = 'CentOS'
383     operatingsystemmajrelease = '7'
384     context 'using default log levels' do
385       let(:facts) {{
386         :osfamily => osfamily,
387         :operatingsystem => operatingsystem,
388         :operatingsystemmajrelease => operatingsystemmajrelease,
389       }}
390
391       let(:params) {{ }}
392
393       # Run shared tests applicable to all supported OSs
394       # Note that this function is defined in spec_helper
395       generic_tests
396
397       # Run test that specialize in checking custom log level config
398       # Note that this function is defined in spec_helper
399       log_level_tests
400     end
401
402     context 'adding one custom log level' do
403       let(:facts) {{
404         :osfamily => osfamily,
405         :operatingsystem => operatingsystem,
406         :operatingsystemmajrelease => operatingsystemmajrelease,
407       }}
408
409       custom_log_levels = { 'org.opendaylight.ovsdb' => 'TRACE' }
410
411       let(:params) {{
412         :log_levels => custom_log_levels,
413       }}
414
415       # Run shared tests applicable to all supported OSs
416       # Note that this function is defined in spec_helper
417       generic_tests
418
419       # Run test that specialize in checking log level config
420       # Note that this function is defined in spec_helper
421       log_level_tests(log_levels: custom_log_levels)
422     end
423
424     context 'adding two custom log levels' do
425       let(:facts) {{
426         :osfamily => osfamily,
427         :operatingsystem => operatingsystem,
428         :operatingsystemmajrelease => operatingsystemmajrelease,
429       }}
430
431       custom_log_levels = { 'org.opendaylight.ovsdb' => 'TRACE',
432                          'org.opendaylight.ovsdb.lib' => 'INFO' }
433
434       let(:params) {{
435         :log_levels => custom_log_levels,
436       }}
437
438       # Run shared tests applicable to all supported OSs
439       # Note that this function is defined in spec_helper
440       generic_tests
441
442       # Run test that specialize in checking log level config
443       # Note that this function is defined in spec_helper
444       log_level_tests(log_levels: custom_log_levels)
445     end
446   end
447
448   describe 'log mechanism settings' 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
456     # All custom log file size and rollover tests
457     context 'log to file using default size and rollover' do
458       let(:facts) {{
459         :osfamily => osfamily,
460         :operatingsystem => operatingsystem,
461         :operatingsystemmajrelease => operatingsystemmajrelease,
462       }}
463
464       let(:params) {{ }}
465
466       # Run shared tests applicable to all supported OSs
467       # Note that this function is defined in spec_helper
468       generic_tests
469
470       # Run test specific to log settings
471       log_settings
472     end
473
474     context 'log to file customizing size' do
475       let(:facts) {{
476         :osfamily => osfamily,
477         :operatingsystem => operatingsystem,
478         :operatingsystemmajrelease => operatingsystemmajrelease,
479       }}
480
481       let(:params) {{
482         :log_max_size => '1GB',
483       }}
484
485       # Run shared tests applicable to all supported OSs
486       # Note that this function is defined in spec_helper
487       generic_tests
488
489       # Run test specific to log settings
490       log_settings(log_max_size: '1GB')
491     end
492
493     context 'log to file customizing rollover' do
494       let(:facts) {{
495         :osfamily => osfamily,
496         :operatingsystem => operatingsystem,
497         :operatingsystemmajrelease => operatingsystemmajrelease,
498       }}
499
500       let(:params) {{
501         :log_max_rollover => 3,
502       }}
503
504       # Run shared tests applicable to all supported OSs
505       # Note that this function is defined in spec_helper
506       generic_tests
507
508       # Run test specific to log settings
509       log_settings(log_max_rollover: 3)
510     end
511
512     context 'log to file customizing size and rollover' do
513       let(:facts) {{
514         :osfamily => osfamily,
515         :operatingsystem => operatingsystem,
516         :operatingsystemmajrelease => operatingsystemmajrelease,
517       }}
518
519       let(:params) {{
520         :log_max_size => '1GB',
521         :log_max_rollover => 3,
522         :log_rollover_fileindex => 'min'
523       }}
524
525       # Run shared tests applicable to all supported OSs
526       # Note that this function is defined in spec_helper
527       generic_tests
528
529       # Run test specific to log settings
530       log_settings(log_max_size: '1GB',
531                    log_max_rollover: 3,
532                    log_rollover_fileindex: 'min')
533     end
534
535     context 'log to file customizing pattern' do
536       let(:facts) {{
537         :osfamily => osfamily,
538         :operatingsystem => operatingsystem,
539         :operatingsystemmajrelease => operatingsystemmajrelease,
540       }}
541
542       let(:params) {{
543         :log_pattern => '%d{ISO8601} | %-5p | %-16t | %m%n',
544       }}
545
546       # Run shared tests applicable to all supported OSs
547       # Note that this function is defined in spec_helper
548       generic_tests
549
550       # Run test specific to log settings
551       log_settings(log_pattern: '%d{ISO8601} | %-5p | %-16t | %m%n')
552     end
553
554     context 'log to file enabling the PaxOsgi appender' do
555       let(:facts) {{
556         :osfamily => osfamily,
557         :operatingsystem => operatingsystem,
558         :operatingsystemmajrelease => operatingsystemmajrelease,
559       }}
560
561       let(:params) {{
562         :enable_paxosgi_logger => true,
563       }}
564
565       # Run shared tests applicable to all supported OSs
566       # Note that this function is defined in spec_helper
567       generic_tests
568
569       # Run test specific to log settings
570       log_settings(enable_paxosgi_logger: true)
571     end
572
573     context 'log to file disabling the PaxOsgi appender' do
574       let(:facts) {{
575         :osfamily => osfamily,
576         :operatingsystem => operatingsystem,
577         :operatingsystemmajrelease => operatingsystemmajrelease,
578       }}
579
580       let(:params) {{
581         :enable_paxosgi_logger => false,
582       }}
583
584       # Run shared tests applicable to all supported OSs
585       # Note that this function is defined in spec_helper
586       generic_tests
587
588       # Run test specific to log settings
589       log_settings(enable_paxosgi_logger: false)
590     end
591
592     context 'log to console' do
593       let(:facts) {{
594         :osfamily => osfamily,
595         :operatingsystem => operatingsystem,
596         :operatingsystemmajrelease => operatingsystemmajrelease,
597       }}
598
599       let(:params) {{
600         :log_mechanism => 'console',
601       }}
602
603       # Run shared tests applicable to all supported OSs
604       # Note that this function is defined in spec_helper
605       generic_tests
606
607       # Run test specific to log settings
608       log_settings(log_mechanism: 'console')
609     end
610
611     context 'log to console customizing pattern' do
612       let(:facts) {{
613         :osfamily => osfamily,
614         :operatingsystem => operatingsystem,
615         :operatingsystemmajrelease => operatingsystemmajrelease,
616       }}
617
618       let(:params) {{
619         :log_mechanism => 'console',
620         :log_pattern => '%d{ISO8601} | %-5p | %-16t | %m%n',
621       }}
622
623       # Run shared tests applicable to all supported OSs
624       # Note that this function is defined in spec_helper
625       generic_tests
626
627       # Run test specific to log settings
628       log_settings(log_mechanism: 'console',
629                    log_pattern: '%d{ISO8601} | %-5p | %-16t | %m%n')
630     end
631
632     context 'log to console enabling the PaxOsgi appender' do
633       let(:facts) {{
634         :osfamily => osfamily,
635         :operatingsystem => operatingsystem,
636         :operatingsystemmajrelease => operatingsystemmajrelease,
637       }}
638
639       let(:params) {{
640         :log_mechanism => 'console',
641         :enable_paxosgi_logger => true,
642       }}
643
644       # Run shared tests applicable to all supported OSs
645       # Note that this function is defined in spec_helper
646       generic_tests
647
648       # Run test specific to log settings
649       log_settings(log_mechanism: 'console',
650                    enable_paxosgi_logger: true)
651     end
652
653     context 'log to console disabling the PaxOsgi appender' do
654       let(:facts) {{
655         :osfamily => osfamily,
656         :operatingsystem => operatingsystem,
657         :operatingsystemmajrelease => operatingsystemmajrelease,
658       }}
659
660       let(:params) {{
661         :log_mechanism => 'console',
662         :enable_paxosgi_logger => false,
663       }}
664
665       # Run shared tests applicable to all supported OSs
666       # Note that this function is defined in spec_helper
667       generic_tests
668
669       # Run test specific to log settings
670       log_settings(log_mechanism: 'console',
671                    enable_paxosgi_logger: false)
672     end
673
674     context 'setting inactivity probe' do
675       let(:facts) {{
676         :osfamily => osfamily,
677         :operatingsystem => operatingsystem,
678         :operatingsystemmajrelease => operatingsystemmajrelease,
679       }}
680
681       let(:params) {{
682         :inactivity_probe => 99999,
683       }}
684
685       # Run shared tests applicable to all supported OSs
686       # Note that this function is defined in spec_helper
687       generic_tests
688     end
689   end
690
691   # All OVSDB HA enable/disable tests
692   describe 'OVSDB HA enable/disable tests' do
693     # Non-OS-type tests assume CentOS 7
694     #   See issue #43 for reasoning:
695     #   https://github.com/dfarrell07/puppet-opendaylight/issues/43#issue-57343159
696     osfamily = 'RedHat'
697     operatingsystem = 'CentOS'
698     operatingsystemmajrelease = '7'
699     context 'using enable_ha default' do
700       let(:facts) {{
701         :osfamily => osfamily,
702         :operatingsystem => operatingsystem,
703         :operatingsystemmajrelease => operatingsystemmajrelease,
704       }}
705
706       let(:params) {{ }}
707
708       # Run shared tests applicable to all supported OSs
709       # Note that this function is defined in spec_helper
710       generic_tests
711
712       # Run test that specialize in checking ODL OVSDB HA config
713       # Note that this function is defined in spec_helper
714       enable_ha_tests
715     end
716
717     context 'using false for enable_ha' do
718       let(:facts) {{
719         :osfamily => osfamily,
720         :operatingsystem => operatingsystem,
721         :operatingsystemmajrelease => operatingsystemmajrelease,
722       }}
723
724       let(:params) {{
725         :enable_ha => false,
726       }}
727
728       # Run shared tests applicable to all supported OSs
729       # Note that this function is defined in spec_helper
730       generic_tests
731
732       # Run test that specialize in checking ODL OVSDB HA config
733       # Note that this function is defined in spec_helper
734       enable_ha_tests(enable_ha: false)
735     end
736
737     context 'using true for enable_ha' do
738       context 'using ha_node_count >=2' do
739         let(:facts) {{
740           :osfamily => osfamily,
741           :operatingsystem => operatingsystem,
742           :operatingsystemmajrelease => operatingsystemmajrelease,
743         }}
744
745         let(:params) {{
746           :enable_ha => true,
747           :ha_node_ips => ['0.0.0.0', '127.0.0.1']
748         }}
749
750         # Run shared tests applicable to all supported OSs
751         # Note that this function is defined in spec_helper
752         generic_tests
753
754         # Run test that specialize in checking ODL OVSDB HA config
755         # Note that this function is defined in spec_helper
756         enable_ha_tests(enable_ha: true, ha_node_ips: ['0.0.0.0', '127.0.0.1'])
757       end
758
759       context 'using custom modules for sharding' do
760         let(:facts) {{
761           :osfamily => osfamily,
762           :operatingsystem => operatingsystem,
763           :operatingsystemmajrelease => operatingsystemmajrelease,
764         }}
765
766         let(:params) {{
767           :enable_ha => true,
768           :ha_node_ips => ['0.0.0.0', '127.0.0.1'],
769           :ha_db_modules => {'default' => false, 'topology' => 'urn:opendaylight:topology'}
770         }}
771
772         # Run shared tests applicable to all supported OSs
773         # Note that this function is defined in spec_helper
774         generic_tests
775
776         # Run test that specialize in checking ODL OVSDB HA config
777         # Note that this function is defined in spec_helper
778         enable_ha_tests(enable_ha: true, ha_node_ips: ['0.0.0.0', '127.0.0.1'])
779       end
780     end
781   end
782
783
784   # All install method tests
785   describe 'install method tests' do
786
787     # All tests for RPM install method
788     describe 'RPM' do
789       # Non-OS-type tests assume CentOS 7
790       #   See issue #43 for reasoning:
791       #   https://github.com/dfarrell07/puppet-opendaylight/issues/43#issue-57343159
792       osfamily = 'RedHat'
793       operatingsystem = 'CentOS'
794       operatingsystemrelease = '7.0'
795       operatingsystemmajrelease = '7'
796
797       context 'installing from default repo' do
798         let(:facts) {{
799           :osfamily => osfamily,
800           :operatingsystem => operatingsystem,
801           :operatingsystemmajrelease => operatingsystemmajrelease,
802         }}
803
804         # Run shared tests applicable to all supported OSs
805         # Note that this function is defined in spec_helper
806         generic_tests
807
808         # Run test that specialize in checking RPM-based installs
809         # Note that this function is defined in spec_helper
810         rpm_install_tests
811       end
812
813       context 'installing from Nexus repo' do
814         rpm_repo = 'https://nexus.opendaylight.org/content/repositories/opendaylight-neon-epel-7-$basearch-devel'
815         let(:facts) {{
816           :osfamily => osfamily,
817           :operatingsystem => operatingsystem,
818           :operatingsystemmajrelease => operatingsystemmajrelease,
819         }}
820
821         let(:params) {{
822           :rpm_repo => rpm_repo,
823         }}
824
825         # Run shared tests applicable to all supported OSs
826         # Note that this function is defined in spec_helper
827         generic_tests
828
829         # Run test that specialize in checking RPM-based installs
830         # Note that this function is defined in spec_helper
831         rpm_install_tests(rpm_repo: rpm_repo)
832       end
833     end
834
835     # All tests for Deb install method
836     describe 'Deb' do
837       osfamily = 'Debian'
838       operatingsystem = 'Ubuntu'
839       operatingsystemrelease = '16.04'
840       operatingsystemmajrelease = '16'
841       lsbdistcodename = 'xenial'
842
843       context 'installing Deb' do
844         let(:facts) {{
845           :osfamily => osfamily,
846           :operatingsystem => operatingsystem,
847           :operatingsystemrelease => operatingsystemrelease,
848           :operatingsystemmajrelease => operatingsystemmajrelease,
849           :lsbdistid => operatingsystem,
850           :lsbdistrelease => operatingsystemrelease,
851           :lsbmajdistrelease => operatingsystemmajrelease,
852           :lsbdistcodename => lsbdistcodename,
853           :puppetversion => Puppet.version,
854         }}
855
856         # Run shared tests applicable to all supported OSs
857         # Note that this function is defined in spec_helper
858         generic_tests
859
860         # Run test that specialize in checking RPM-based installs
861         # Note that this function is defined in spec_helper
862         deb_install_tests
863       end
864
865       context 'installing Nitrogen Deb' do
866         deb_repo = 'ppa:odl-team/nitrogen'
867         let(:facts) {{
868           :osfamily => osfamily,
869           :operatingsystem => operatingsystem,
870           :operatingsystemrelease => operatingsystemrelease,
871           :operatingsystemmajrelease => operatingsystemmajrelease,
872           :lsbdistid => operatingsystem,
873           :lsbdistrelease => operatingsystemrelease,
874           :lsbmajdistrelease => operatingsystemmajrelease,
875           :lsbdistcodename => lsbdistcodename,
876           :puppetversion => Puppet.version,
877         }}
878
879         let(:params) {{
880           :deb_repo => deb_repo,
881         }}
882
883         # Run shared tests applicable to all supported OSs
884         # Note that this function is defined in spec_helper
885         generic_tests
886
887         # Run test that specialize in checking RPM-based installs
888         # Note that this function is defined in spec_helper
889         deb_install_tests(deb_repo: deb_repo)
890       end
891     end
892   end
893
894   # SNAT Mechanism tests
895   describe 'SNAT mechanism tests' do
896     # Non-OS-type tests assume CentOS 7
897     #   See issue #43 for reasoning:
898     #   https://github.com/dfarrell07/puppet-opendaylight/issues/43#issue-57343159
899     osfamily = 'RedHat'
900     operatingsystem = 'CentOS'
901     operatingsystemmajrelease = '7'
902     context 'using controller' do
903       let(:facts) {{
904         :osfamily => osfamily,
905         :operatingsystem => operatingsystem,
906         :operatingsystemmajrelease => operatingsystemmajrelease,
907       }}
908
909       let(:params) {{
910         :extra_features => ['odl-netvirt-openstack'],
911       }}
912
913       # Run shared tests applicable to all supported OSs
914       # Note that this function is defined in spec_helper
915       generic_tests
916
917       # Run test that specialize in checking security groups
918       # Note that this function is defined in spec_helper
919       snat_mechanism_tests
920     end
921
922     context 'using conntrack' do
923       let(:facts) {{
924         :osfamily => osfamily,
925         :operatingsystem => operatingsystem,
926         :operatingsystemmajrelease => operatingsystemmajrelease,
927       }}
928
929       let(:params) {{
930         :snat_mechanism => 'conntrack',
931         :extra_features => ['odl-netvirt-openstack'],
932       }}
933
934       # Run shared tests applicable to all supported OSs
935       # Note that this function is defined in spec_helper
936       generic_tests
937
938       # Run test that specialize in checking security groups
939       # Note that this function is defined in spec_helper
940       snat_mechanism_tests('conntrack')
941     end
942   end
943
944   # SFC tests
945   describe 'SFC tests' do
946     # Non-OS-type tests assume CentOS 7
947     #   See issue #43 for reasoning:
948     #   https://github.com/dfarrell07/puppet-opendaylight/issues/43#issue-57343159
949     osfamily = 'RedHat'
950     operatingsystem = 'CentOS'
951     operatingsystemmajrelease = '7'
952     context 'not using odl-netvirt-sfc feature' do
953       let(:facts) {{
954         :osfamily => osfamily,
955         :operatingsystem => operatingsystem,
956         :operatingsystemmajrelease => operatingsystemmajrelease,
957       }}
958
959       let(:params) {{ }}
960
961       # Run shared tests applicable to all supported OSs
962       # Note that this function is defined in spec_helper
963       generic_tests
964
965       # Run test that specialize in checking security groups
966       # Note that this function is defined in spec_helper
967       sfc_tests
968     end
969
970     context 'using odl-netvirt-sfc feature' do
971       let(:facts) {{
972         :osfamily => osfamily,
973         :operatingsystem => operatingsystem,
974         :operatingsystemmajrelease => operatingsystemmajrelease,
975       }}
976
977       let(:params) {{
978         :extra_features => ['odl-netvirt-sfc'],
979       }}
980
981       # Run shared tests applicable to all supported OSs
982       # Note that this function is defined in spec_helper
983       generic_tests
984
985       # Run test that specialize in checking security groups
986       # Note that this function is defined in spec_helper
987       sfc_tests(extra_features: ['odl-netvirt-sfc'])
988     end
989   end
990
991   # DSCP marking tests
992   describe 'DSCP marking tests' do
993     # Non-OS-type tests assume CentOS 7
994     #   See issue #43 for reasoning:
995     #   https://github.com/dfarrell07/puppet-opendaylight/issues/43#issue-57343159
996     osfamily = 'RedHat'
997     operatingsystem = 'CentOS'
998     operatingsystemmajrelease = '7'
999     context 'use default value' do
1000       let(:facts) {{
1001         :osfamily => osfamily,
1002         :operatingsystem => operatingsystem,
1003         :operatingsystemmajrelease => operatingsystemmajrelease,
1004       }}
1005
1006       let(:params) {{ }}
1007
1008       # Run shared tests applicable to all supported OSs
1009       # Note that this function is defined in spec_helper
1010       generic_tests
1011
1012       # Run test that specialize in checking security groups
1013       # Note that this function is defined in spec_helper
1014       dscp_tests
1015     end
1016
1017     context 'inherit DSCP values' do
1018       let(:facts) {{
1019         :osfamily => osfamily,
1020         :operatingsystem => operatingsystem,
1021         :operatingsystemmajrelease => operatingsystemmajrelease,
1022       }}
1023
1024       let(:params) {{
1025         :inherit_dscp_marking => :true,
1026       }}
1027
1028       # Run shared tests applicable to all supported OSs
1029       # Note that this function is defined in spec_helper
1030       generic_tests
1031
1032       # Run test that specialize in checking security groups
1033       # Note that this function is defined in spec_helper
1034       dscp_tests(inherit_dscp_marking: true)
1035     end
1036   end
1037
1038   # VPP routing node config tests
1039   describe 'VPP routing node tests' do
1040     # Non-OS-type tests assume CentOS 7
1041     #   See issue #43 for reasoning:
1042     #   https://github.com/dfarrell07/puppet-opendaylight/issues/43#issue-57343159
1043     osfamily = 'RedHat'
1044     operatingsystem = 'CentOS'
1045     operatingsystemmajrelease = '7'
1046     context 'using default - no routing node' do
1047       let(:facts) {{
1048         :osfamily => osfamily,
1049         :operatingsystem => operatingsystem,
1050         :operatingsystemmajrelease => operatingsystemmajrelease,
1051       }}
1052
1053       let(:params) {{ }}
1054
1055       # Run shared tests applicable to all supported OSs
1056       # Note that this function is defined in spec_helper
1057       generic_tests
1058
1059       # Run test that specialize in checking routing-node config
1060       # Note that this function is defined in spec_helper
1061       vpp_routing_node_tests
1062     end
1063
1064     context 'using node name for routing node' do
1065       let(:facts) {{
1066         :osfamily => osfamily,
1067         :operatingsystem => operatingsystem,
1068         :operatingsystemmajrelease => operatingsystemmajrelease,
1069       }}
1070
1071       let(:params) {{
1072         :vpp_routing_node => 'test-node-1',
1073       }}
1074
1075       # Run shared tests applicable to all supported OSs
1076       # Note that this function is defined in spec_helper
1077       generic_tests
1078
1079       # Run test that specialize in checking routing-node config
1080       # Note that this function is defined in spec_helper
1081       vpp_routing_node_tests(routing_node: 'test-node-1')
1082     end
1083   end
1084
1085   # ODL username/password tests
1086   describe 'ODL username/password tests' do
1087     # Non-OS-type tests assume CentOS 7
1088     #   See issue #43 for reasoning:
1089     #   https://github.com/dfarrell07/puppet-opendaylight/issues/43#issue-57343159
1090     osfamily = 'RedHat'
1091     operatingsystem = 'CentOS'
1092     operatingsystemmajrelease = '7'
1093     context 'using default username/password' do
1094       let(:facts) {{
1095         :osfamily => osfamily,
1096         :operatingsystem => operatingsystem,
1097         :operatingsystemmajrelease => operatingsystemmajrelease,
1098       }}
1099
1100       let(:params) {{ }}
1101
1102       # Run shared tests applicable to all supported OSs
1103       # Note that this function is defined in spec_helper
1104       generic_tests
1105
1106       # Run test that specialize in checking username/password config
1107       # Note that this function is defined in spec_helper
1108       username_password_tests('admin','admin')
1109     end
1110
1111     context 'specifying non-default username/password' do
1112       let(:facts) {{
1113         :osfamily => osfamily,
1114         :operatingsystem => operatingsystem,
1115         :operatingsystemmajrelease => operatingsystemmajrelease,
1116       }}
1117
1118       let(:params) {{
1119         :username => 'test',
1120         :password => 'test'
1121       }}
1122
1123       # Run shared tests applicable to all supported OSs
1124       # Note that this function is defined in spec_helper
1125       generic_tests
1126
1127       # Run test that specialize in checking routing-node config
1128       # Note that this function is defined in spec_helper
1129       username_password_tests('test', 'test')
1130     end
1131   end
1132
1133   # websocket address tests
1134   describe 'ODL websocket address tests' do
1135     # Non-OS-type tests assume CentOS 7
1136     #   See issue #43 for reasoning:
1137     #   https://github.com/dfarrell07/puppet-opendaylight/issues/43#issue-57343159
1138     osfamily = 'RedHat'
1139     operatingsystem = 'CentOS'
1140     operatingsystemmajrelease = '7'
1141     context 'using default websocket address' do
1142       let(:facts) {{
1143         :osfamily => osfamily,
1144         :operatingsystem => operatingsystem,
1145         :operatingsystemmajrelease => operatingsystemmajrelease,
1146       }}
1147
1148       let(:params) {{ }}
1149
1150       # Run shared tests applicable to all supported OSs
1151       # Note that this function is defined in spec_helper
1152       generic_tests
1153
1154       # Run test that specialize in checking websocket address
1155       # Note that this function is defined in spec_helper
1156       odl_websocket_address_tests
1157     end
1158
1159     context 'overriding websocket address' do
1160       let(:facts) {{
1161         :osfamily => osfamily,
1162         :operatingsystem => operatingsystem,
1163         :operatingsystemmajrelease => operatingsystemmajrelease,
1164       }}
1165
1166       let(:params) {{
1167        :odl_bind_ip => '127.0.0.1'
1168        }}
1169
1170       # Run shared tests applicable to all supported OSs
1171       # Note that this function is defined in spec_helper
1172       generic_tests(odl_bind_ip: '127.0.0.1')
1173
1174       # Run test that specialize in checking websocket address
1175       # Note that this function is defined in spec_helper
1176       odl_websocket_address_tests(odl_bind_ip: '127.0.0.1')
1177     end
1178   end
1179
1180   # TLS tests
1181   describe 'ODL TLS tests' do
1182     # Non-OS-type tests assume CentOS 7
1183     #   See issue #43 for reasoning:
1184     #   https://github.com/dfarrell07/puppet-opendaylight/issues/43#issue-57343159
1185     osfamily = 'RedHat'
1186     operatingsystem = 'CentOS'
1187     operatingsystemmajrelease = '7'
1188     context 'enabling TLS without required keystore password (negative test)' do
1189       let(:facts) {{
1190         :osfamily => osfamily,
1191         :operatingsystem => operatingsystem,
1192         :operatingsystemmajrelease => operatingsystemmajrelease,
1193       }}
1194
1195       let(:params) {{
1196        :enable_tls => :true
1197        }}
1198
1199       # Run test that specialize in checking TLS
1200       # Note that this function is defined in spec_helper
1201       odl_tls_tests(enable_tls:true)
1202     end
1203     context 'enabling TLS with required params' do
1204       let(:facts) {{
1205         :osfamily => osfamily,
1206         :operatingsystem => operatingsystem,
1207         :operatingsystemmajrelease => operatingsystemmajrelease,
1208       }}
1209
1210       let(:params) {{
1211        :enable_tls => true,
1212        :tls_keystore_password => '123456',
1213        }}
1214
1215       # Run shared tests applicable to all supported OSs
1216       # Note that this function is defined in spec_helper
1217       generic_tests
1218
1219       # Run test that specialize in checking TLS
1220       # Note that this function is defined in spec_helper
1221       odl_tls_tests(enable_tls:true, tls_keystore_password:'123456')
1222     end
1223   end
1224
1225   describe 'polling enablement settings' do
1226     # Non-OS-type tests assume CentOS 7
1227     #   See issue #43 for reasoning:
1228     #   https://github.com/dfarrell07/puppet-opendaylight/issues/43#issue-57343159
1229     osfamily = 'RedHat'
1230     operatingsystem = 'CentOS'
1231     operatingsystemmajrelease = '7'
1232
1233     # Default statistics polling off
1234     context 'do not poll ovs statistics' do
1235       let(:facts) {{
1236         :osfamily => osfamily,
1237         :operatingsystem => operatingsystem,
1238         :operatingsystemmajrelease => operatingsystemmajrelease,
1239       }}
1240
1241       let(:params) {{ }}
1242
1243       # Run shared tests applicable to all supported OSs
1244       # Note that this function is defined in spec_helper
1245       generic_tests
1246
1247       # Run test specific to log settings
1248       stats_polling_enablement_tests
1249     end
1250
1251     # Default statistics polling on
1252     context 'poll ovs statistics' do
1253       let(:facts) {{
1254         :osfamily => osfamily,
1255         :operatingsystem => operatingsystem,
1256         :operatingsystemmajrelease => operatingsystemmajrelease,
1257       }}
1258
1259       let(:params) {{
1260        :stats_polling_enabled => true,
1261        }}
1262
1263       # Run shared tests applicable to all supported OSs
1264       # Note that this function is defined in spec_helper
1265       generic_tests
1266
1267       # Run test specific to log settings
1268       stats_polling_enablement_tests(stats_polling_enabled:true)
1269     end
1270   end
1271
1272   describe 'Different IPv support tests' do
1273     # Non-OS-type tests assume CentOS 7
1274     #   See issue #43 for reasoning:
1275     #   https://github.com/dfarrell07/puppet-opendaylight/issues/43#issue-57343159
1276     osfamily = 'RedHat'
1277     operatingsystem = 'CentOS'
1278     operatingsystemmajrelease = '7'
1279
1280     context 'IPv6 deployment' do
1281       let(:facts) {{
1282         :osfamily => osfamily,
1283         :operatingsystem => operatingsystem,
1284         :operatingsystemmajrelease => operatingsystemmajrelease,
1285       }}
1286
1287       let(:params) {{
1288         :odl_bind_ip => '::1'
1289         }}
1290
1291       # Run shared tests applicable to all supported OSs
1292       # Note that this function is defined in spec_helper
1293       generic_tests(odl_bind_ip:'::1')
1294     end
1295
1296     context 'IPv4 deployment' do
1297       let(:facts) {{
1298         :osfamily => osfamily,
1299         :operatingsystem => operatingsystem,
1300         :operatingsystemmajrelease => operatingsystemmajrelease,
1301       }}
1302
1303       let(:params) {{
1304         :odl_bind_ip => '127.0.0.1'
1305         }}
1306
1307       # Run shared tests applicable to all supported OSs
1308       # Note that this function is defined in spec_helper
1309       generic_tests(odl_bind_ip:'127.0.0.1')
1310     end
1311   end
1312 end