Merge "Add "direct" option for logging to console."
[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 REST port tests
329   describe 'REST port tests' do
330     # Non-OS-type tests assume CentOS 7
331     #   See issue #43 for reasoning:
332     #   https://github.com/dfarrell07/puppet-opendaylight/issues/43#issue-57343159
333     osfamily = 'RedHat'
334     operatingsystem = 'CentOS'
335     operatingsystemmajrelease = '7'
336     context 'using default REST port' do
337       let(:facts) {{
338         :osfamily => osfamily,
339         :operatingsystem => operatingsystem,
340         :operatingsystemmajrelease => operatingsystemmajrelease,
341       }}
342
343       let(:params) {{ }}
344
345       # Run shared tests applicable to all supported OSs
346       # Note that this function is defined in spec_helper
347       generic_tests
348
349       # Run test that specialize in checking ODL REST port config
350       # Note that this function is defined in spec_helper
351       odl_rest_port_tests
352     end
353
354     context 'overriding default REST 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
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       }}
523
524       # Run shared tests applicable to all supported OSs
525       # Note that this function is defined in spec_helper
526       generic_tests
527
528       # Run test specific to log settings
529       log_settings(log_max_size: '1GB',
530                         log_max_rollover: 3)
531     end
532
533     context 'log to console' do
534       let(:facts) {{
535         :osfamily => osfamily,
536         :operatingsystem => operatingsystem,
537         :operatingsystemmajrelease => operatingsystemmajrelease,
538       }}
539
540       let(:params) {{
541         :log_mechanism => 'console',
542       }}
543
544       # Run shared tests applicable to all supported OSs
545       # Note that this function is defined in spec_helper
546       generic_tests
547
548       # Run test specific to log settings
549       log_settings(log_mechanism: 'console')
550     end
551   end
552
553   # All OVSDB HA enable/disable tests
554   describe 'OVSDB HA enable/disable tests' do
555     # Non-OS-type tests assume CentOS 7
556     #   See issue #43 for reasoning:
557     #   https://github.com/dfarrell07/puppet-opendaylight/issues/43#issue-57343159
558     osfamily = 'RedHat'
559     operatingsystem = 'CentOS'
560     operatingsystemmajrelease = '7'
561     context 'using enable_ha default' do
562       let(:facts) {{
563         :osfamily => osfamily,
564         :operatingsystem => operatingsystem,
565         :operatingsystemmajrelease => operatingsystemmajrelease,
566       }}
567
568       let(:params) {{ }}
569
570       # Run shared tests applicable to all supported OSs
571       # Note that this function is defined in spec_helper
572       generic_tests
573
574       # Run test that specialize in checking ODL OVSDB HA config
575       # Note that this function is defined in spec_helper
576       enable_ha_tests
577     end
578
579     context 'using false for enable_ha' do
580       let(:facts) {{
581         :osfamily => osfamily,
582         :operatingsystem => operatingsystem,
583         :operatingsystemmajrelease => operatingsystemmajrelease,
584       }}
585
586       let(:params) {{
587         :enable_ha => false,
588       }}
589
590       # Run shared tests applicable to all supported OSs
591       # Note that this function is defined in spec_helper
592       generic_tests
593
594       # Run test that specialize in checking ODL OVSDB HA config
595       # Note that this function is defined in spec_helper
596       enable_ha_tests(enable_ha: false)
597     end
598
599     context 'using true for enable_ha' do
600       context 'using ha_node_count >=2' do
601         let(:facts) {{
602           :osfamily => osfamily,
603           :operatingsystem => operatingsystem,
604           :operatingsystemmajrelease => operatingsystemmajrelease,
605         }}
606
607         let(:params) {{
608           :enable_ha => true,
609           :ha_node_ips => ['0.0.0.0', '127.0.0.1']
610         }}
611
612         # Run shared tests applicable to all supported OSs
613         # Note that this function is defined in spec_helper
614         generic_tests
615
616         # Run test that specialize in checking ODL OVSDB HA config
617         # Note that this function is defined in spec_helper
618         enable_ha_tests(enable_ha: true, ha_node_ips: ['0.0.0.0', '127.0.0.1'])
619       end
620
621       context 'using custom modules for sharding' do
622         let(:facts) {{
623           :osfamily => osfamily,
624           :operatingsystem => operatingsystem,
625           :operatingsystemmajrelease => operatingsystemmajrelease,
626         }}
627
628         let(:params) {{
629           :enable_ha => true,
630           :ha_node_ips => ['0.0.0.0', '127.0.0.1'],
631           :ha_db_modules => {'default' => false, 'topology' => 'urn:opendaylight:topology'}
632         }}
633
634         # Run shared tests applicable to all supported OSs
635         # Note that this function is defined in spec_helper
636         generic_tests
637
638         # Run test that specialize in checking ODL OVSDB HA config
639         # Note that this function is defined in spec_helper
640         enable_ha_tests(enable_ha: true, ha_node_ips: ['0.0.0.0', '127.0.0.1'])
641       end
642     end
643   end
644
645
646   # All install method tests
647   describe 'install method tests' do
648
649     # All tests for RPM install method
650     describe 'RPM' do
651       # Non-OS-type tests assume CentOS 7
652       #   See issue #43 for reasoning:
653       #   https://github.com/dfarrell07/puppet-opendaylight/issues/43#issue-57343159
654       osfamily = 'RedHat'
655       operatingsystem = 'CentOS'
656       operatingsystemrelease = '7.0'
657       operatingsystemmajrelease = '7'
658
659       context 'installing from default repo' do
660         let(:facts) {{
661           :osfamily => osfamily,
662           :operatingsystem => operatingsystem,
663           :operatingsystemmajrelease => operatingsystemmajrelease,
664         }}
665
666         # Run shared tests applicable to all supported OSs
667         # Note that this function is defined in spec_helper
668         generic_tests
669
670         # Run test that specialize in checking RPM-based installs
671         # Note that this function is defined in spec_helper
672         rpm_install_tests
673       end
674
675       context 'installing from Nexus repo' do
676         rpm_repo = 'https://nexus.opendaylight.org/content/repositories/opendaylight-fluorine-epel-7-$basearch-devel'
677         let(:facts) {{
678           :osfamily => osfamily,
679           :operatingsystem => operatingsystem,
680           :operatingsystemmajrelease => operatingsystemmajrelease,
681         }}
682
683         let(:params) {{
684           :rpm_repo => rpm_repo,
685         }}
686
687         # Run shared tests applicable to all supported OSs
688         # Note that this function is defined in spec_helper
689         generic_tests
690
691         # Run test that specialize in checking RPM-based installs
692         # Note that this function is defined in spec_helper
693         rpm_install_tests(rpm_repo: rpm_repo)
694       end
695     end
696
697     # All tests for Deb install method
698     describe 'Deb' do
699       osfamily = 'Debian'
700       operatingsystem = 'Ubuntu'
701       operatingsystemrelease = '16.04'
702       operatingsystemmajrelease = '16'
703       lsbdistcodename = 'xenial'
704
705       context 'installing Deb' do
706         let(:facts) {{
707           :osfamily => osfamily,
708           :operatingsystem => operatingsystem,
709           :operatingsystemrelease => operatingsystemrelease,
710           :operatingsystemmajrelease => operatingsystemmajrelease,
711           :lsbdistid => operatingsystem,
712           :lsbdistrelease => operatingsystemrelease,
713           :lsbmajdistrelease => operatingsystemmajrelease,
714           :lsbdistcodename => lsbdistcodename,
715           :puppetversion => Puppet.version,
716         }}
717
718         # Run shared tests applicable to all supported OSs
719         # Note that this function is defined in spec_helper
720         generic_tests
721
722         # Run test that specialize in checking RPM-based installs
723         # Note that this function is defined in spec_helper
724         deb_install_tests
725       end
726
727       context 'installing Nitrogen Deb' do
728         deb_repo = 'ppa:odl-team/nitrogen'
729         let(:facts) {{
730           :osfamily => osfamily,
731           :operatingsystem => operatingsystem,
732           :operatingsystemrelease => operatingsystemrelease,
733           :operatingsystemmajrelease => operatingsystemmajrelease,
734           :lsbdistid => operatingsystem,
735           :lsbdistrelease => operatingsystemrelease,
736           :lsbmajdistrelease => operatingsystemmajrelease,
737           :lsbdistcodename => lsbdistcodename,
738           :puppetversion => Puppet.version,
739         }}
740
741         let(:params) {{
742           :deb_repo => deb_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         deb_install_tests(deb_repo: deb_repo)
752       end
753     end
754   end
755
756   # SNAT Mechanism tests
757   describe 'SNAT mechanism tests' do
758     # Non-OS-type tests assume CentOS 7
759     #   See issue #43 for reasoning:
760     #   https://github.com/dfarrell07/puppet-opendaylight/issues/43#issue-57343159
761     osfamily = 'RedHat'
762     operatingsystem = 'CentOS'
763     operatingsystemmajrelease = '7'
764     context 'using controller' do
765       let(:facts) {{
766         :osfamily => osfamily,
767         :operatingsystem => operatingsystem,
768         :operatingsystemmajrelease => operatingsystemmajrelease,
769       }}
770
771       let(:params) {{
772         :extra_features => ['odl-netvirt-openstack'],
773       }}
774
775       # Run shared tests applicable to all supported OSs
776       # Note that this function is defined in spec_helper
777       generic_tests
778
779       # Run test that specialize in checking security groups
780       # Note that this function is defined in spec_helper
781       snat_mechanism_tests
782     end
783
784     context 'using conntrack' do
785       let(:facts) {{
786         :osfamily => osfamily,
787         :operatingsystem => operatingsystem,
788         :operatingsystemmajrelease => operatingsystemmajrelease,
789       }}
790
791       let(:params) {{
792         :snat_mechanism => 'conntrack',
793         :extra_features => ['odl-netvirt-openstack'],
794       }}
795
796       # Run shared tests applicable to all supported OSs
797       # Note that this function is defined in spec_helper
798       generic_tests
799
800       # Run test that specialize in checking security groups
801       # Note that this function is defined in spec_helper
802       snat_mechanism_tests('conntrack')
803     end
804   end
805
806   # SFC tests
807   describe 'SFC tests' do
808     # Non-OS-type tests assume CentOS 7
809     #   See issue #43 for reasoning:
810     #   https://github.com/dfarrell07/puppet-opendaylight/issues/43#issue-57343159
811     osfamily = 'RedHat'
812     operatingsystem = 'CentOS'
813     operatingsystemmajrelease = '7'
814     context 'not using odl-netvirt-sfc feature' do
815       let(:facts) {{
816         :osfamily => osfamily,
817         :operatingsystem => operatingsystem,
818         :operatingsystemmajrelease => operatingsystemmajrelease,
819       }}
820
821       let(:params) {{ }}
822
823       # Run shared tests applicable to all supported OSs
824       # Note that this function is defined in spec_helper
825       generic_tests
826
827       # Run test that specialize in checking security groups
828       # Note that this function is defined in spec_helper
829       sfc_tests
830     end
831
832     context 'using odl-netvirt-sfc feature' do
833       let(:facts) {{
834         :osfamily => osfamily,
835         :operatingsystem => operatingsystem,
836         :operatingsystemmajrelease => operatingsystemmajrelease,
837       }}
838
839       let(:params) {{
840         :extra_features => ['odl-netvirt-sfc'],
841       }}
842
843       # Run shared tests applicable to all supported OSs
844       # Note that this function is defined in spec_helper
845       generic_tests
846
847       # Run test that specialize in checking security groups
848       # Note that this function is defined in spec_helper
849       sfc_tests(extra_features: ['odl-netvirt-sfc'])
850     end
851   end
852
853   # DSCP marking tests
854   describe 'DSCP marking tests' do
855     # Non-OS-type tests assume CentOS 7
856     #   See issue #43 for reasoning:
857     #   https://github.com/dfarrell07/puppet-opendaylight/issues/43#issue-57343159
858     osfamily = 'RedHat'
859     operatingsystem = 'CentOS'
860     operatingsystemmajrelease = '7'
861     context 'use default value' do
862       let(:facts) {{
863         :osfamily => osfamily,
864         :operatingsystem => operatingsystem,
865         :operatingsystemmajrelease => operatingsystemmajrelease,
866       }}
867
868       let(:params) {{ }}
869
870       # Run shared tests applicable to all supported OSs
871       # Note that this function is defined in spec_helper
872       generic_tests
873
874       # Run test that specialize in checking security groups
875       # Note that this function is defined in spec_helper
876       dscp_tests
877     end
878
879     context 'inherit DSCP values' do
880       let(:facts) {{
881         :osfamily => osfamily,
882         :operatingsystem => operatingsystem,
883         :operatingsystemmajrelease => operatingsystemmajrelease,
884       }}
885
886       let(:params) {{
887         :inherit_dscp_marking => :true,
888       }}
889
890       # Run shared tests applicable to all supported OSs
891       # Note that this function is defined in spec_helper
892       generic_tests
893
894       # Run test that specialize in checking security groups
895       # Note that this function is defined in spec_helper
896       dscp_tests(inherit_dscp_marking: true)
897     end
898   end
899
900   # VPP routing node config tests
901   describe 'VPP routing node tests' do
902     # Non-OS-type tests assume CentOS 7
903     #   See issue #43 for reasoning:
904     #   https://github.com/dfarrell07/puppet-opendaylight/issues/43#issue-57343159
905     osfamily = 'RedHat'
906     operatingsystem = 'CentOS'
907     operatingsystemmajrelease = '7'
908     context 'using default - no routing node' do
909       let(:facts) {{
910         :osfamily => osfamily,
911         :operatingsystem => operatingsystem,
912         :operatingsystemmajrelease => operatingsystemmajrelease,
913       }}
914
915       let(:params) {{ }}
916
917       # Run shared tests applicable to all supported OSs
918       # Note that this function is defined in spec_helper
919       generic_tests
920
921       # Run test that specialize in checking routing-node config
922       # Note that this function is defined in spec_helper
923       vpp_routing_node_tests
924     end
925
926     context 'using node name for routing node' do
927       let(:facts) {{
928         :osfamily => osfamily,
929         :operatingsystem => operatingsystem,
930         :operatingsystemmajrelease => operatingsystemmajrelease,
931       }}
932
933       let(:params) {{
934         :vpp_routing_node => 'test-node-1',
935       }}
936
937       # Run shared tests applicable to all supported OSs
938       # Note that this function is defined in spec_helper
939       generic_tests
940
941       # Run test that specialize in checking routing-node config
942       # Note that this function is defined in spec_helper
943       vpp_routing_node_tests(routing_node: 'test-node-1')
944     end
945   end
946
947   # ODL username/password tests
948   describe 'ODL username/password tests' do
949     # Non-OS-type tests assume CentOS 7
950     #   See issue #43 for reasoning:
951     #   https://github.com/dfarrell07/puppet-opendaylight/issues/43#issue-57343159
952     osfamily = 'RedHat'
953     operatingsystem = 'CentOS'
954     operatingsystemmajrelease = '7'
955     context 'using default username/password' do
956       let(:facts) {{
957         :osfamily => osfamily,
958         :operatingsystem => operatingsystem,
959         :operatingsystemmajrelease => operatingsystemmajrelease,
960       }}
961
962       let(:params) {{ }}
963
964       # Run shared tests applicable to all supported OSs
965       # Note that this function is defined in spec_helper
966       generic_tests
967
968       # Run test that specialize in checking username/password config
969       # Note that this function is defined in spec_helper
970       username_password_tests('admin','admin')
971     end
972
973     context 'specifying non-default username/password' do
974       let(:facts) {{
975         :osfamily => osfamily,
976         :operatingsystem => operatingsystem,
977         :operatingsystemmajrelease => operatingsystemmajrelease,
978       }}
979
980       let(:params) {{
981         :username => 'test',
982         :password => 'test'
983       }}
984
985       # Run shared tests applicable to all supported OSs
986       # Note that this function is defined in spec_helper
987       generic_tests
988
989       # Run test that specialize in checking routing-node config
990       # Note that this function is defined in spec_helper
991       username_password_tests('test', 'test')
992     end
993   end
994
995   # websocket address tests
996   describe 'ODL websocket address tests' do
997     # Non-OS-type tests assume CentOS 7
998     #   See issue #43 for reasoning:
999     #   https://github.com/dfarrell07/puppet-opendaylight/issues/43#issue-57343159
1000     osfamily = 'RedHat'
1001     operatingsystem = 'CentOS'
1002     operatingsystemmajrelease = '7'
1003     context 'using default websocket address' do
1004       let(:facts) {{
1005         :osfamily => osfamily,
1006         :operatingsystem => operatingsystem,
1007         :operatingsystemmajrelease => operatingsystemmajrelease,
1008       }}
1009
1010       let(:params) {{ }}
1011
1012       # Run shared tests applicable to all supported OSs
1013       # Note that this function is defined in spec_helper
1014       generic_tests
1015
1016       # Run test that specialize in checking websocket address
1017       # Note that this function is defined in spec_helper
1018       odl_websocket_address_tests
1019     end
1020
1021     context 'overriding websocket address' do
1022       let(:facts) {{
1023         :osfamily => osfamily,
1024         :operatingsystem => operatingsystem,
1025         :operatingsystemmajrelease => operatingsystemmajrelease,
1026       }}
1027
1028       let(:params) {{
1029        :odl_bind_ip => '127.0.0.1'
1030        }}
1031
1032       # Run shared tests applicable to all supported OSs
1033       # Note that this function is defined in spec_helper
1034       generic_tests
1035
1036       # Run test that specialize in checking websocket address
1037       # Note that this function is defined in spec_helper
1038       odl_websocket_address_tests(odl_bind_ip: '127.0.0.1')
1039     end
1040   end
1041
1042   # TLS tests
1043   describe 'ODL TLS tests' do
1044     # Non-OS-type tests assume CentOS 7
1045     #   See issue #43 for reasoning:
1046     #   https://github.com/dfarrell07/puppet-opendaylight/issues/43#issue-57343159
1047     osfamily = 'RedHat'
1048     operatingsystem = 'CentOS'
1049     operatingsystemmajrelease = '7'
1050     context 'enabling TLS without required keystore password (negative test)' do
1051       let(:facts) {{
1052         :osfamily => osfamily,
1053         :operatingsystem => operatingsystem,
1054         :operatingsystemmajrelease => operatingsystemmajrelease,
1055       }}
1056
1057       let(:params) {{
1058        :enable_tls => :true
1059        }}
1060
1061       # Run test that specialize in checking TLS
1062       # Note that this function is defined in spec_helper
1063       odl_tls_tests(enable_tls:true)
1064     end
1065     context 'enabling TLS with required params' do
1066       let(:facts) {{
1067         :osfamily => osfamily,
1068         :operatingsystem => operatingsystem,
1069         :operatingsystemmajrelease => operatingsystemmajrelease,
1070       }}
1071
1072       let(:params) {{
1073        :enable_tls => true,
1074        :tls_keystore_password => '123456',
1075        }}
1076
1077       # Run shared tests applicable to all supported OSs
1078       # Note that this function is defined in spec_helper
1079       generic_tests
1080
1081       # Run test that specialize in checking TLS
1082       # Note that this function is defined in spec_helper
1083       odl_tls_tests(enable_tls:true, tls_keystore_password:'123456')
1084     end
1085   end
1086 end