Renamed main ODL test class. Closes #11
[integration/packaging/puppet-opendaylight.git] / spec / classes / opendaylight_spec.rb
1 require 'spec_helper'
2
3 describe 'opendaylight' do
4   context 'supported operating systems' do
5     osfamily = 'RedHat'
6     ['20', '21'].each do |operatingsystemmajrelease|
7       operatingsystem = 'Fedora'
8       describe "opendaylight class without any params on #{osfamily}:#{operatingsystem} #{operatingsystemmajrelease}" do
9         let(:params) {{ }}
10         let(:facts) {{
11           :osfamily => osfamily,
12           :operatingsystem => operatingsystem,
13           :operatingsystemmajrelease => operatingsystemmajrelease,
14         }}
15
16         # Confirm that module compiles
17         it { should compile }
18         it { should compile.with_all_deps }
19
20         # Confirm presence of classes
21         it { should contain_class('opendaylight') }
22         it { should contain_class('opendaylight::params') }
23         it { should contain_class('opendaylight::install') }
24         it { should contain_class('opendaylight::config') }
25         it { should contain_class('opendaylight::service') }
26
27         # Confirm relationships between classes
28         it { should contain_class('opendaylight::install').that_comes_before('opendaylight::config') }
29         it { should contain_class('opendaylight::config').that_requires('opendaylight::install') }
30         it { should contain_class('opendaylight::config').that_notifies('opendaylight::service') }
31         it { should contain_class('opendaylight::service').that_subscribes_to('opendaylight::config') }
32         it { should contain_class('opendaylight::service').that_comes_before('opendaylight') }
33         it { should contain_class('opendaylight').that_requires('opendaylight::service') }
34
35         # Confirm presense of other resources
36         it { should contain_service('opendaylight') }
37         it { should contain_yumrepo('opendaylight') }
38         it { should contain_package('opendaylight') }
39
40         # Confirm relationships between other resources
41         it { should contain_package('opendaylight').that_requires('Yumrepo[opendaylight]') }
42         it { should contain_yumrepo('opendaylight').that_comes_before('Package[opendaylight]') }
43
44         # Confirm properties of other resources
45         # There's a more elegant way to do these long sets of checks
46         #   using multi-line hashes, but it breaks in Ruby 1.8.7
47         it { should contain_yumrepo('opendaylight').with_enabled('1').with_gpgcheck('0').with_descr('OpenDaylight SDN controller').with_baseurl('https://copr-be.cloud.fedoraproject.org/results/dfarrell07/OpenDaylight/fedora-$releasever-$basearch/') }
48         it { should contain_package('opendaylight').with_ensure('present') }
49         it { should contain_service('opendaylight').with_ensure('running').with_enable('true').with_hasstatus('true').with_hasrestart('true') }
50       end
51     end
52     ['7'].each do |operatingsystemmajrelease|
53       operatingsystem = 'CentOS'
54       describe "opendaylight class without any params on #{osfamily}:#{operatingsystem} #{operatingsystemmajrelease}" do
55         let(:params) {{ }}
56         let(:facts) {{
57           :osfamily => osfamily,
58           :operatingsystem => operatingsystem,
59           :operatingsystemmajrelease => operatingsystemmajrelease,
60         }}
61
62         # Confirm that module compiles
63         it { should compile }
64         it { should compile.with_all_deps }
65
66         # Confirm presence of classes
67         it { should contain_class('opendaylight') }
68         it { should contain_class('opendaylight::params') }
69         it { should contain_class('opendaylight::install') }
70         it { should contain_class('opendaylight::config') }
71         it { should contain_class('opendaylight::service') }
72
73         # Confirm relationships between classes
74         it { should contain_class('opendaylight::install').that_comes_before('opendaylight::config') }
75         it { should contain_class('opendaylight::config').that_requires('opendaylight::install') }
76         it { should contain_class('opendaylight::config').that_notifies('opendaylight::service') }
77         it { should contain_class('opendaylight::service').that_subscribes_to('opendaylight::config') }
78         it { should contain_class('opendaylight::service').that_comes_before('opendaylight') }
79         it { should contain_class('opendaylight').that_requires('opendaylight::service') }
80
81         # Confirm presense of other resources
82         it { should contain_service('opendaylight') }
83         it { should contain_yumrepo('opendaylight') }
84         it { should contain_package('opendaylight') }
85
86         # Confirm relationships between other resources
87         it { should contain_package('opendaylight').that_requires('Yumrepo[opendaylight]') }
88         it { should contain_yumrepo('opendaylight').that_comes_before('Package[opendaylight]') }
89
90         # Confirm properties of other resources
91         # There's a more elegant way to do these long sets of checks
92         #   using multi-line hashes, but it breaks in Ruby 1.8.7
93         it { should contain_yumrepo('opendaylight').with_enabled('1').with_gpgcheck('0').with_descr('OpenDaylight SDN controller').with_baseurl('https://copr-be.cloud.fedoraproject.org/results/dfarrell07/OpenDaylight/epel-7-$basearch/') }
94         it { should contain_package('opendaylight').with_ensure('present') }
95         it { should contain_service('opendaylight').with_ensure('running').with_enable('true').with_hasstatus('true').with_hasrestart('true') }
96       end
97     end
98   end
99
100   context 'unsupported operating systems' do
101     # Test unsupported versions of Fedora
102     ['18', '19', '22'].each do |operatingsystemmajrelease|
103       osfamily = 'RedHat'
104       operatingsystem = 'Fedora'
105       describe "opendaylight class without any params on #{osfamily}:#{operatingsystem} #{operatingsystemmajrelease}" do
106         let(:facts) {{
107           :osfamily => osfamily,
108           :operatingsystem => operatingsystem,
109           :operatingsystemmajrelease => operatingsystemmajrelease,
110         }}
111
112         # Confirm that classes fail on unsupported OSs
113         it { expect { should contain_class('opendaylight') }.to raise_error(Puppet::Error, /Unsupported OS: #{operatingsystem} #{operatingsystemmajrelease}/) }
114         it { expect { should contain_class('opendaylight::install') }.to raise_error(Puppet::Error, /Unsupported OS: #{operatingsystem} #{operatingsystemmajrelease}/) }
115         it { expect { should contain_class('opendaylight::config') }.to raise_error(Puppet::Error, /Unsupported OS: #{operatingsystem} #{operatingsystemmajrelease}/) }
116         it { expect { should contain_class('opendaylight::service') }.to raise_error(Puppet::Error, /Unsupported OS: #{operatingsystem} #{operatingsystemmajrelease}/) }
117
118         # Confirm that other resources fail on unsupported OSs
119         it { expect { should contain_yumrepo('opendaylight') }.to raise_error(Puppet::Error, /Unsupported OS: #{operatingsystem} #{operatingsystemmajrelease}/) }
120         it { expect { should contain_package('opendaylight') }.to raise_error(Puppet::Error, /Unsupported OS: #{operatingsystem} #{operatingsystemmajrelease}/) }
121         it { expect { should contain_service('opendaylight') }.to raise_error(Puppet::Error, /Unsupported OS: #{operatingsystem} #{operatingsystemmajrelease}/) }
122       end
123     end
124
125     # Test unsupported versions of CentOS
126     ['5', '6', '8'].each do |operatingsystemmajrelease|
127       osfamily = 'RedHat'
128       operatingsystem = 'CentOS'
129       describe "opendaylight class without any params on #{osfamily}:#{operatingsystem} #{operatingsystemmajrelease}" do
130         let(:facts) {{
131           :osfamily => osfamily,
132           :operatingsystem => operatingsystem,
133           :operatingsystemmajrelease => operatingsystemmajrelease,
134         }}
135
136         # Confirm that classes fail on unsupported OSs
137         it { expect { should contain_class('opendaylight') }.to raise_error(Puppet::Error, /Unsupported OS: #{operatingsystem} #{operatingsystemmajrelease}/) }
138         it { expect { should contain_class('opendaylight::install') }.to raise_error(Puppet::Error, /Unsupported OS: #{operatingsystem} #{operatingsystemmajrelease}/) }
139         it { expect { should contain_class('opendaylight::config') }.to raise_error(Puppet::Error, /Unsupported OS: #{operatingsystem} #{operatingsystemmajrelease}/) }
140         it { expect { should contain_class('opendaylight::service') }.to raise_error(Puppet::Error, /Unsupported OS: #{operatingsystem} #{operatingsystemmajrelease}/) }
141
142         # Confirm that other resources fail on unsupported OSs
143         it { expect { should contain_yumrepo('opendaylight') }.to raise_error(Puppet::Error, /Unsupported OS: #{operatingsystem} #{operatingsystemmajrelease}/) }
144         it { expect { should contain_package('opendaylight') }.to raise_error(Puppet::Error, /Unsupported OS: #{operatingsystem} #{operatingsystemmajrelease}/) }
145         it { expect { should contain_service('opendaylight') }.to raise_error(Puppet::Error, /Unsupported OS: #{operatingsystem} #{operatingsystemmajrelease}/) }
146       end
147     end
148
149     # Test unsupported OS families
150     ['Debian', 'Suse', 'Solaris'].each do |osfamily|
151       describe "opendaylight class without any params on #{osfamily}" do
152         let(:facts) {{
153           :osfamily => osfamily,
154         }}
155
156         # Confirm that classes fail on unsupported OS families
157         it { expect { should contain_class('opendaylight') }.to raise_error(Puppet::Error, /Unsupported OS family: #{osfamily}/) }
158         it { expect { should contain_class('opendaylight::install') }.to raise_error(Puppet::Error, /Unsupported OS family: #{osfamily}/) }
159         it { expect { should contain_class('opendaylight::config') }.to raise_error(Puppet::Error, /Unsupported OS family: #{osfamily}/) }
160         it { expect { should contain_class('opendaylight::service') }.to raise_error(Puppet::Error, /Unsupported OS family: #{osfamily}/) }
161
162         # Confirm that other resources fail on unsupported OS families
163         it { expect { should contain_yumrepo('opendaylight') }.to raise_error(Puppet::Error, /Unsupported OS family: #{osfamily}/) }
164         it { expect { should contain_package('opendaylight') }.to raise_error(Puppet::Error, /Unsupported OS family: #{osfamily}/) }
165         it { expect { should contain_service('opendaylight') }.to raise_error(Puppet::Error, /Unsupported OS family: #{osfamily}/) }
166       end
167     end
168   end
169 end