Add Karaf feature tests to refactored RSpec tests
[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         # This is the Fedora Yum repo URL
14         yum_repo = 'https://copr-be.cloud.fedoraproject.org/results/dfarrell07/OpenDaylight/fedora-$releasever-$basearch/'
15
16         # All tests for supported versions of Fedora
17         ['20', '21'].each do |operatingsystemmajrelease|
18           context "#{operatingsystemmajrelease}" do
19             let(:facts) {{
20               :osfamily => osfamily,
21               :operatingsystem => operatingsystem,
22               :operatingsystemmajrelease => operatingsystemmajrelease,
23             }}
24             # TODO: Call supported-OS-specific tests
25             it { should compile }
26           end
27         end
28
29         # All tests for unsupported versions of Fedora
30         ['18', '19', '22'].each do |operatingsystemmajrelease|
31           context "#{operatingsystemmajrelease}" do
32             let(:facts) {{
33               :osfamily => osfamily,
34               :operatingsystem => operatingsystem,
35               :operatingsystemmajrelease => operatingsystemmajrelease,
36             }}
37             # Run shared tests applicable to all unsupported OSs
38             # Note that this function is defined in spec_helper
39             unsupported_os_tests("Unsupported OS: #{operatingsystem} #{operatingsystemmajrelease}")
40           end
41         end
42       end
43
44       # All tests for CentOS
45       describe 'CentOS' do
46         operatingsystem = 'CentOS'
47
48         # This is the CentOS 7 Yum repo URL
49         yum_repo = 'https://copr-be.cloud.fedoraproject.org/results/dfarrell07/OpenDaylight/epel-7-$basearch/'
50
51         # All tests for supported versions of CentOS
52         ['7'].each do |operatingsystemmajrelease|
53           context "#{operatingsystemmajrelease}" do
54             let(:facts) {{
55               :osfamily => osfamily,
56               :operatingsystem => operatingsystem,
57               :operatingsystemmajrelease => operatingsystemmajrelease,
58             }}
59             # TODO: Call supported-OS-specific tests
60             it { should compile }
61           end
62         end
63
64         # All tests for unsupported versions of CentOS
65         ['5', '6', '8'].each do |operatingsystemmajrelease|
66           context "#{operatingsystemmajrelease}" do
67             let(:facts) {{
68               :osfamily => osfamily,
69               :operatingsystem => operatingsystem,
70               :operatingsystemmajrelease => operatingsystemmajrelease,
71             }}
72             # Run shared tests applicable to all unsupported OSs
73             # Note that this function is defined in spec_helper
74             unsupported_os_tests("Unsupported OS: #{operatingsystem} #{operatingsystemmajrelease}")
75           end
76         end
77       end
78     end
79
80     # All tests for unsupported OS families
81     ['Debian', 'Suse', 'Solaris'].each do |osfamily|
82       context "OS family #{osfamily}" do
83         let(:facts) {{
84           :osfamily => osfamily,
85         }}
86
87         # Run shared tests applicable to all unsupported OSs
88         # Note that this function is defined in spec_helper
89         unsupported_os_tests("Unsupported OS family: #{osfamily}")
90       end
91     end
92   end
93
94   # All Karaf feature tests
95   describe 'Karaf feature tests' do
96     # All Karaf feature tests assume CentOS 7
97     osfamily = 'RedHat'
98     operatingsystem = 'CentOS'
99     operatingsystemmajrelease = '7'
100     # This is the CentOS 7 Yum repo URL
101     yum_repo = 'https://copr-be.cloud.fedoraproject.org/results/dfarrell07/OpenDaylight/epel-7-$basearch/'
102     describe "using default features" do
103       # NB: This list should be the same as the one in opendaylight::params
104       default_features = ['config', 'standard', 'region', 'package', 'kar', 'ssh', 'management']
105       context "and not passing extra features" do
106         let(:facts) {{
107           :osfamily => osfamily,
108           :operatingsystem => operatingsystem,
109           :operatingsystemmajrelease => operatingsystemmajrelease,
110         }}
111
112         let(:params) {{ }}
113
114         # Run shared tests applicable to all supported OSs
115         # Note that this function is defined in spec_helper
116         supported_os_tests(yum_repo, default_features)
117       end
118
119       context "and passing extra features" do
120         let(:facts) {{
121           :osfamily => osfamily,
122           :operatingsystem => operatingsystem,
123           :operatingsystemmajrelease => operatingsystemmajrelease,
124         }}
125
126         # These are real but arbitrarily chosen features
127         extra_features = ["odl-base-all", "odl-ovsdb-all"]
128         let(:params) {{
129           :extra_features => extra_features,
130         }}
131
132         # Run shared tests applicable to all supported OSs
133         # Note that this function is defined in spec_helper
134         supported_os_tests(yum_repo, default_features + extra_features)
135       end
136     end
137
138     describe "overriding default features" do
139       default_features = ["standard", "ssh"]
140       context "and not passing extra features" do
141         let(:facts) {{
142           :osfamily => osfamily,
143           :operatingsystem => operatingsystem,
144           :operatingsystemmajrelease => operatingsystemmajrelease,
145         }}
146
147         extra_features = []
148         let(:params) {{
149           :default_features => default_features,
150         }}
151
152         # Run shared tests applicable to all supported OSs
153         # Note that this function is defined in spec_helper
154         supported_os_tests(yum_repo, default_features)
155       end
156
157       context "and passing extra features" do
158         let(:facts) {{
159           :osfamily => osfamily,
160           :operatingsystem => operatingsystem,
161           :operatingsystemmajrelease => operatingsystemmajrelease,
162         }}
163
164         # These are real but arbitrarily chosen features
165         extra_features = ["odl-base-all", "odl-ovsdb-all"]
166         let(:params) {{
167           :default_features => default_features,
168           :extra_features => extra_features,
169         }}
170
171         # Run shared tests applicable to all supported OSs
172         # Note that this function is defined in spec_helper
173         supported_os_tests(yum_repo, default_features + extra_features)
174       end
175     end
176   end
177 end