Parametrize the logging pattern to use
[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 console' do
555       let(:facts) {{
556         :osfamily => osfamily,
557         :operatingsystem => operatingsystem,
558         :operatingsystemmajrelease => operatingsystemmajrelease,
559       }}
560
561       let(:params) {{
562         :log_mechanism => 'console',
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(log_mechanism: 'console')
571     end
572
573     context 'log to console customizing pattern' do
574       let(:facts) {{
575         :osfamily => osfamily,
576         :operatingsystem => operatingsystem,
577         :operatingsystemmajrelease => operatingsystemmajrelease,
578       }}
579
580       let(:params) {{
581         :log_mechanism => 'console',
582         :log_pattern => '%d{ISO8601} | %-5p | %-16t | %m%n',
583       }}
584
585       # Run shared tests applicable to all supported OSs
586       # Note that this function is defined in spec_helper
587       generic_tests
588
589       # Run test specific to log settings
590       log_settings(log_mechanism: 'console',
591                    log_pattern: '%d{ISO8601} | %-5p | %-16t | %m%n')
592     end
593
594     context 'setting inactivity probe' do
595       let(:facts) {{
596         :osfamily => osfamily,
597         :operatingsystem => operatingsystem,
598         :operatingsystemmajrelease => operatingsystemmajrelease,
599       }}
600
601       let(:params) {{
602         :inactivity_probe => 99999,
603       }}
604
605       # Run shared tests applicable to all supported OSs
606       # Note that this function is defined in spec_helper
607       generic_tests
608     end
609   end
610
611   # All OVSDB HA enable/disable tests
612   describe 'OVSDB HA enable/disable tests' do
613     # Non-OS-type tests assume CentOS 7
614     #   See issue #43 for reasoning:
615     #   https://github.com/dfarrell07/puppet-opendaylight/issues/43#issue-57343159
616     osfamily = 'RedHat'
617     operatingsystem = 'CentOS'
618     operatingsystemmajrelease = '7'
619     context 'using enable_ha default' do
620       let(:facts) {{
621         :osfamily => osfamily,
622         :operatingsystem => operatingsystem,
623         :operatingsystemmajrelease => operatingsystemmajrelease,
624       }}
625
626       let(:params) {{ }}
627
628       # Run shared tests applicable to all supported OSs
629       # Note that this function is defined in spec_helper
630       generic_tests
631
632       # Run test that specialize in checking ODL OVSDB HA config
633       # Note that this function is defined in spec_helper
634       enable_ha_tests
635     end
636
637     context 'using false for enable_ha' do
638       let(:facts) {{
639         :osfamily => osfamily,
640         :operatingsystem => operatingsystem,
641         :operatingsystemmajrelease => operatingsystemmajrelease,
642       }}
643
644       let(:params) {{
645         :enable_ha => false,
646       }}
647
648       # Run shared tests applicable to all supported OSs
649       # Note that this function is defined in spec_helper
650       generic_tests
651
652       # Run test that specialize in checking ODL OVSDB HA config
653       # Note that this function is defined in spec_helper
654       enable_ha_tests(enable_ha: false)
655     end
656
657     context 'using true for enable_ha' do
658       context 'using ha_node_count >=2' do
659         let(:facts) {{
660           :osfamily => osfamily,
661           :operatingsystem => operatingsystem,
662           :operatingsystemmajrelease => operatingsystemmajrelease,
663         }}
664
665         let(:params) {{
666           :enable_ha => true,
667           :ha_node_ips => ['0.0.0.0', '127.0.0.1']
668         }}
669
670         # Run shared tests applicable to all supported OSs
671         # Note that this function is defined in spec_helper
672         generic_tests
673
674         # Run test that specialize in checking ODL OVSDB HA config
675         # Note that this function is defined in spec_helper
676         enable_ha_tests(enable_ha: true, ha_node_ips: ['0.0.0.0', '127.0.0.1'])
677       end
678
679       context 'using custom modules for sharding' do
680         let(:facts) {{
681           :osfamily => osfamily,
682           :operatingsystem => operatingsystem,
683           :operatingsystemmajrelease => operatingsystemmajrelease,
684         }}
685
686         let(:params) {{
687           :enable_ha => true,
688           :ha_node_ips => ['0.0.0.0', '127.0.0.1'],
689           :ha_db_modules => {'default' => false, 'topology' => 'urn:opendaylight:topology'}
690         }}
691
692         # Run shared tests applicable to all supported OSs
693         # Note that this function is defined in spec_helper
694         generic_tests
695
696         # Run test that specialize in checking ODL OVSDB HA config
697         # Note that this function is defined in spec_helper
698         enable_ha_tests(enable_ha: true, ha_node_ips: ['0.0.0.0', '127.0.0.1'])
699       end
700     end
701   end
702
703
704   # All install method tests
705   describe 'install method tests' do
706
707     # All tests for RPM install method
708     describe 'RPM' do
709       # Non-OS-type tests assume CentOS 7
710       #   See issue #43 for reasoning:
711       #   https://github.com/dfarrell07/puppet-opendaylight/issues/43#issue-57343159
712       osfamily = 'RedHat'
713       operatingsystem = 'CentOS'
714       operatingsystemrelease = '7.0'
715       operatingsystemmajrelease = '7'
716
717       context 'installing from default repo' do
718         let(:facts) {{
719           :osfamily => osfamily,
720           :operatingsystem => operatingsystem,
721           :operatingsystemmajrelease => operatingsystemmajrelease,
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         rpm_install_tests
731       end
732
733       context 'installing from Nexus repo' do
734         rpm_repo = 'https://nexus.opendaylight.org/content/repositories/opendaylight-fluorine-epel-7-$basearch-devel'
735         let(:facts) {{
736           :osfamily => osfamily,
737           :operatingsystem => operatingsystem,
738           :operatingsystemmajrelease => operatingsystemmajrelease,
739         }}
740
741         let(:params) {{
742           :rpm_repo => rpm_repo,
743         }}
744
745         # Run shared tests applicable to all supported OSs
746         # Note that this function is defined in spec_helper
747         generic_tests
748
749         # Run test that specialize in checking RPM-based installs
750         # Note that this function is defined in spec_helper
751         rpm_install_tests(rpm_repo: rpm_repo)
752       end
753     end
754
755     # All tests for Deb install method
756     describe 'Deb' do
757       osfamily = 'Debian'
758       operatingsystem = 'Ubuntu'
759       operatingsystemrelease = '16.04'
760       operatingsystemmajrelease = '16'
761       lsbdistcodename = 'xenial'
762
763       context 'installing Deb' do
764         let(:facts) {{
765           :osfamily => osfamily,
766           :operatingsystem => operatingsystem,
767           :operatingsystemrelease => operatingsystemrelease,
768           :operatingsystemmajrelease => operatingsystemmajrelease,
769           :lsbdistid => operatingsystem,
770           :lsbdistrelease => operatingsystemrelease,
771           :lsbmajdistrelease => operatingsystemmajrelease,
772           :lsbdistcodename => lsbdistcodename,
773           :puppetversion => Puppet.version,
774         }}
775
776         # Run shared tests applicable to all supported OSs
777         # Note that this function is defined in spec_helper
778         generic_tests
779
780         # Run test that specialize in checking RPM-based installs
781         # Note that this function is defined in spec_helper
782         deb_install_tests
783       end
784
785       context 'installing Nitrogen Deb' do
786         deb_repo = 'ppa:odl-team/nitrogen'
787         let(:facts) {{
788           :osfamily => osfamily,
789           :operatingsystem => operatingsystem,
790           :operatingsystemrelease => operatingsystemrelease,
791           :operatingsystemmajrelease => operatingsystemmajrelease,
792           :lsbdistid => operatingsystem,
793           :lsbdistrelease => operatingsystemrelease,
794           :lsbmajdistrelease => operatingsystemmajrelease,
795           :lsbdistcodename => lsbdistcodename,
796           :puppetversion => Puppet.version,
797         }}
798
799         let(:params) {{
800           :deb_repo => deb_repo,
801         }}
802
803         # Run shared tests applicable to all supported OSs
804         # Note that this function is defined in spec_helper
805         generic_tests
806
807         # Run test that specialize in checking RPM-based installs
808         # Note that this function is defined in spec_helper
809         deb_install_tests(deb_repo: deb_repo)
810       end
811     end
812   end
813
814   # SNAT Mechanism tests
815   describe 'SNAT mechanism tests' do
816     # Non-OS-type tests assume CentOS 7
817     #   See issue #43 for reasoning:
818     #   https://github.com/dfarrell07/puppet-opendaylight/issues/43#issue-57343159
819     osfamily = 'RedHat'
820     operatingsystem = 'CentOS'
821     operatingsystemmajrelease = '7'
822     context 'using controller' do
823       let(:facts) {{
824         :osfamily => osfamily,
825         :operatingsystem => operatingsystem,
826         :operatingsystemmajrelease => operatingsystemmajrelease,
827       }}
828
829       let(:params) {{
830         :extra_features => ['odl-netvirt-openstack'],
831       }}
832
833       # Run shared tests applicable to all supported OSs
834       # Note that this function is defined in spec_helper
835       generic_tests
836
837       # Run test that specialize in checking security groups
838       # Note that this function is defined in spec_helper
839       snat_mechanism_tests
840     end
841
842     context 'using conntrack' do
843       let(:facts) {{
844         :osfamily => osfamily,
845         :operatingsystem => operatingsystem,
846         :operatingsystemmajrelease => operatingsystemmajrelease,
847       }}
848
849       let(:params) {{
850         :snat_mechanism => 'conntrack',
851         :extra_features => ['odl-netvirt-openstack'],
852       }}
853
854       # Run shared tests applicable to all supported OSs
855       # Note that this function is defined in spec_helper
856       generic_tests
857
858       # Run test that specialize in checking security groups
859       # Note that this function is defined in spec_helper
860       snat_mechanism_tests('conntrack')
861     end
862   end
863
864   # SFC tests
865   describe 'SFC tests' do
866     # Non-OS-type tests assume CentOS 7
867     #   See issue #43 for reasoning:
868     #   https://github.com/dfarrell07/puppet-opendaylight/issues/43#issue-57343159
869     osfamily = 'RedHat'
870     operatingsystem = 'CentOS'
871     operatingsystemmajrelease = '7'
872     context 'not using odl-netvirt-sfc feature' do
873       let(:facts) {{
874         :osfamily => osfamily,
875         :operatingsystem => operatingsystem,
876         :operatingsystemmajrelease => operatingsystemmajrelease,
877       }}
878
879       let(:params) {{ }}
880
881       # Run shared tests applicable to all supported OSs
882       # Note that this function is defined in spec_helper
883       generic_tests
884
885       # Run test that specialize in checking security groups
886       # Note that this function is defined in spec_helper
887       sfc_tests
888     end
889
890     context 'using odl-netvirt-sfc feature' do
891       let(:facts) {{
892         :osfamily => osfamily,
893         :operatingsystem => operatingsystem,
894         :operatingsystemmajrelease => operatingsystemmajrelease,
895       }}
896
897       let(:params) {{
898         :extra_features => ['odl-netvirt-sfc'],
899       }}
900
901       # Run shared tests applicable to all supported OSs
902       # Note that this function is defined in spec_helper
903       generic_tests
904
905       # Run test that specialize in checking security groups
906       # Note that this function is defined in spec_helper
907       sfc_tests(extra_features: ['odl-netvirt-sfc'])
908     end
909   end
910
911   # DSCP marking tests
912   describe 'DSCP marking tests' do
913     # Non-OS-type tests assume CentOS 7
914     #   See issue #43 for reasoning:
915     #   https://github.com/dfarrell07/puppet-opendaylight/issues/43#issue-57343159
916     osfamily = 'RedHat'
917     operatingsystem = 'CentOS'
918     operatingsystemmajrelease = '7'
919     context 'use default value' do
920       let(:facts) {{
921         :osfamily => osfamily,
922         :operatingsystem => operatingsystem,
923         :operatingsystemmajrelease => operatingsystemmajrelease,
924       }}
925
926       let(:params) {{ }}
927
928       # Run shared tests applicable to all supported OSs
929       # Note that this function is defined in spec_helper
930       generic_tests
931
932       # Run test that specialize in checking security groups
933       # Note that this function is defined in spec_helper
934       dscp_tests
935     end
936
937     context 'inherit DSCP values' do
938       let(:facts) {{
939         :osfamily => osfamily,
940         :operatingsystem => operatingsystem,
941         :operatingsystemmajrelease => operatingsystemmajrelease,
942       }}
943
944       let(:params) {{
945         :inherit_dscp_marking => :true,
946       }}
947
948       # Run shared tests applicable to all supported OSs
949       # Note that this function is defined in spec_helper
950       generic_tests
951
952       # Run test that specialize in checking security groups
953       # Note that this function is defined in spec_helper
954       dscp_tests(inherit_dscp_marking: true)
955     end
956   end
957
958   # VPP routing node config tests
959   describe 'VPP routing node tests' do
960     # Non-OS-type tests assume CentOS 7
961     #   See issue #43 for reasoning:
962     #   https://github.com/dfarrell07/puppet-opendaylight/issues/43#issue-57343159
963     osfamily = 'RedHat'
964     operatingsystem = 'CentOS'
965     operatingsystemmajrelease = '7'
966     context 'using default - no routing node' do
967       let(:facts) {{
968         :osfamily => osfamily,
969         :operatingsystem => operatingsystem,
970         :operatingsystemmajrelease => operatingsystemmajrelease,
971       }}
972
973       let(:params) {{ }}
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       vpp_routing_node_tests
982     end
983
984     context 'using node name for routing node' do
985       let(:facts) {{
986         :osfamily => osfamily,
987         :operatingsystem => operatingsystem,
988         :operatingsystemmajrelease => operatingsystemmajrelease,
989       }}
990
991       let(:params) {{
992         :vpp_routing_node => 'test-node-1',
993       }}
994
995       # Run shared tests applicable to all supported OSs
996       # Note that this function is defined in spec_helper
997       generic_tests
998
999       # Run test that specialize in checking routing-node config
1000       # Note that this function is defined in spec_helper
1001       vpp_routing_node_tests(routing_node: 'test-node-1')
1002     end
1003   end
1004
1005   # ODL username/password tests
1006   describe 'ODL username/password tests' do
1007     # Non-OS-type tests assume CentOS 7
1008     #   See issue #43 for reasoning:
1009     #   https://github.com/dfarrell07/puppet-opendaylight/issues/43#issue-57343159
1010     osfamily = 'RedHat'
1011     operatingsystem = 'CentOS'
1012     operatingsystemmajrelease = '7'
1013     context 'using default username/password' do
1014       let(:facts) {{
1015         :osfamily => osfamily,
1016         :operatingsystem => operatingsystem,
1017         :operatingsystemmajrelease => operatingsystemmajrelease,
1018       }}
1019
1020       let(:params) {{ }}
1021
1022       # Run shared tests applicable to all supported OSs
1023       # Note that this function is defined in spec_helper
1024       generic_tests
1025
1026       # Run test that specialize in checking username/password config
1027       # Note that this function is defined in spec_helper
1028       username_password_tests('admin','admin')
1029     end
1030
1031     context 'specifying non-default username/password' do
1032       let(:facts) {{
1033         :osfamily => osfamily,
1034         :operatingsystem => operatingsystem,
1035         :operatingsystemmajrelease => operatingsystemmajrelease,
1036       }}
1037
1038       let(:params) {{
1039         :username => 'test',
1040         :password => 'test'
1041       }}
1042
1043       # Run shared tests applicable to all supported OSs
1044       # Note that this function is defined in spec_helper
1045       generic_tests
1046
1047       # Run test that specialize in checking routing-node config
1048       # Note that this function is defined in spec_helper
1049       username_password_tests('test', 'test')
1050     end
1051   end
1052
1053   # websocket address tests
1054   describe 'ODL websocket address tests' do
1055     # Non-OS-type tests assume CentOS 7
1056     #   See issue #43 for reasoning:
1057     #   https://github.com/dfarrell07/puppet-opendaylight/issues/43#issue-57343159
1058     osfamily = 'RedHat'
1059     operatingsystem = 'CentOS'
1060     operatingsystemmajrelease = '7'
1061     context 'using default websocket address' do
1062       let(:facts) {{
1063         :osfamily => osfamily,
1064         :operatingsystem => operatingsystem,
1065         :operatingsystemmajrelease => operatingsystemmajrelease,
1066       }}
1067
1068       let(:params) {{ }}
1069
1070       # Run shared tests applicable to all supported OSs
1071       # Note that this function is defined in spec_helper
1072       generic_tests
1073
1074       # Run test that specialize in checking websocket address
1075       # Note that this function is defined in spec_helper
1076       odl_websocket_address_tests
1077     end
1078
1079     context 'overriding websocket address' do
1080       let(:facts) {{
1081         :osfamily => osfamily,
1082         :operatingsystem => operatingsystem,
1083         :operatingsystemmajrelease => operatingsystemmajrelease,
1084       }}
1085
1086       let(:params) {{
1087        :odl_bind_ip => '127.0.0.1'
1088        }}
1089
1090       # Run shared tests applicable to all supported OSs
1091       # Note that this function is defined in spec_helper
1092       generic_tests(odl_bind_ip: '127.0.0.1')
1093
1094       # Run test that specialize in checking websocket address
1095       # Note that this function is defined in spec_helper
1096       odl_websocket_address_tests(odl_bind_ip: '127.0.0.1')
1097     end
1098   end
1099
1100   # TLS tests
1101   describe 'ODL TLS tests' do
1102     # Non-OS-type tests assume CentOS 7
1103     #   See issue #43 for reasoning:
1104     #   https://github.com/dfarrell07/puppet-opendaylight/issues/43#issue-57343159
1105     osfamily = 'RedHat'
1106     operatingsystem = 'CentOS'
1107     operatingsystemmajrelease = '7'
1108     context 'enabling TLS without required keystore password (negative test)' do
1109       let(:facts) {{
1110         :osfamily => osfamily,
1111         :operatingsystem => operatingsystem,
1112         :operatingsystemmajrelease => operatingsystemmajrelease,
1113       }}
1114
1115       let(:params) {{
1116        :enable_tls => :true
1117        }}
1118
1119       # Run test that specialize in checking TLS
1120       # Note that this function is defined in spec_helper
1121       odl_tls_tests(enable_tls:true)
1122     end
1123     context 'enabling TLS with required params' do
1124       let(:facts) {{
1125         :osfamily => osfamily,
1126         :operatingsystem => operatingsystem,
1127         :operatingsystemmajrelease => operatingsystemmajrelease,
1128       }}
1129
1130       let(:params) {{
1131        :enable_tls => true,
1132        :tls_keystore_password => '123456',
1133        }}
1134
1135       # Run shared tests applicable to all supported OSs
1136       # Note that this function is defined in spec_helper
1137       generic_tests
1138
1139       # Run test that specialize in checking TLS
1140       # Note that this function is defined in spec_helper
1141       odl_tls_tests(enable_tls:true, tls_keystore_password:'123456')
1142     end
1143   end
1144
1145   describe 'polling enablement settings' do
1146     # Non-OS-type tests assume CentOS 7
1147     #   See issue #43 for reasoning:
1148     #   https://github.com/dfarrell07/puppet-opendaylight/issues/43#issue-57343159
1149     osfamily = 'RedHat'
1150     operatingsystem = 'CentOS'
1151     operatingsystemmajrelease = '7'
1152
1153     # Default statistics polling off
1154     context 'do not poll ovs statistics' do
1155       let(:facts) {{
1156         :osfamily => osfamily,
1157         :operatingsystem => operatingsystem,
1158         :operatingsystemmajrelease => operatingsystemmajrelease,
1159       }}
1160
1161       let(:params) {{ }}
1162
1163       # Run shared tests applicable to all supported OSs
1164       # Note that this function is defined in spec_helper
1165       generic_tests
1166
1167       # Run test specific to log settings
1168       stats_polling_enablement_tests
1169     end
1170
1171     # Default statistics polling on
1172     context 'poll ovs statistics' do
1173       let(:facts) {{
1174         :osfamily => osfamily,
1175         :operatingsystem => operatingsystem,
1176         :operatingsystemmajrelease => operatingsystemmajrelease,
1177       }}
1178
1179       let(:params) {{
1180        :stats_polling_enabled => true,
1181        }}
1182
1183       # Run shared tests applicable to all supported OSs
1184       # Note that this function is defined in spec_helper
1185       generic_tests
1186
1187       # Run test specific to log settings
1188       stats_polling_enablement_tests(stats_polling_enabled:true)
1189     end
1190   end
1191
1192   describe 'Different IPv support tests' do
1193     # Non-OS-type tests assume CentOS 7
1194     #   See issue #43 for reasoning:
1195     #   https://github.com/dfarrell07/puppet-opendaylight/issues/43#issue-57343159
1196     osfamily = 'RedHat'
1197     operatingsystem = 'CentOS'
1198     operatingsystemmajrelease = '7'
1199
1200     context 'IPv6 deployment' do
1201       let(:facts) {{
1202         :osfamily => osfamily,
1203         :operatingsystem => operatingsystem,
1204         :operatingsystemmajrelease => operatingsystemmajrelease,
1205       }}
1206
1207       let(:params) {{
1208         :odl_bind_ip => '::1'
1209         }}
1210
1211       # Run shared tests applicable to all supported OSs
1212       # Note that this function is defined in spec_helper
1213       generic_tests(odl_bind_ip:'::1')
1214     end
1215
1216     context 'IPv4 deployment' do
1217       let(:facts) {{
1218         :osfamily => osfamily,
1219         :operatingsystem => operatingsystem,
1220         :operatingsystemmajrelease => operatingsystemmajrelease,
1221       }}
1222
1223       let(:params) {{
1224         :odl_bind_ip => '127.0.0.1'
1225         }}
1226
1227       # Run shared tests applicable to all supported OSs
1228       # Note that this function is defined in spec_helper
1229       generic_tests(odl_bind_ip:'127.0.0.1')
1230     end
1231   end
1232 end