623f030239488f680588693012f0726314b18e89
[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         # Run shared tests applicable to all supported OSs
17         # Note that this function is defined in spec_helper
18         supported_os_tests
19
20         # The yum repo URLs for Fedora and CentOS are different, so check here
21         it { should contain_yumrepo('opendaylight').with_baseurl('https://copr-be.cloud.fedoraproject.org/results/dfarrell07/OpenDaylight/fedora-$releasever-$basearch/') }
22
23       end
24     end
25     ['7'].each do |operatingsystemmajrelease|
26       operatingsystem = 'CentOS'
27       describe "opendaylight class without any params on #{osfamily}:#{operatingsystem} #{operatingsystemmajrelease}" do
28         let(:params) {{ }}
29         let(:facts) {{
30           :osfamily => osfamily,
31           :operatingsystem => operatingsystem,
32           :operatingsystemmajrelease => operatingsystemmajrelease,
33         }}
34
35         # Run shared tests applicable to all supported OSs
36         # Note that this function is defined in spec_helper
37         supported_os_tests
38
39         # The yum repo URLs for Fedora and CentOS are different, so check here
40         it { should contain_yumrepo('opendaylight').with_baseurl('https://copr-be.cloud.fedoraproject.org/results/dfarrell07/OpenDaylight/epel-7-$basearch/') }
41       end
42     end
43   end
44
45   context 'unsupported operating systems' do
46     # Test unsupported versions of Fedora
47     ['18', '19', '22'].each do |operatingsystemmajrelease|
48       osfamily = 'RedHat'
49       operatingsystem = 'Fedora'
50       describe "opendaylight class without any params on #{osfamily}:#{operatingsystem} #{operatingsystemmajrelease}" do
51         let(:facts) {{
52           :osfamily => osfamily,
53           :operatingsystem => operatingsystem,
54           :operatingsystemmajrelease => operatingsystemmajrelease,
55         }}
56
57         # Run shared tests applicable to all unsupported OSs
58         # Note that this function is defined in spec_helper
59         unsupported_os_tests(operatingsystem, operatingsystemmajrelease)
60
61       end
62     end
63
64     # Test unsupported versions of CentOS
65     ['5', '6', '8'].each do |operatingsystemmajrelease|
66       osfamily = 'RedHat'
67       operatingsystem = 'CentOS'
68       describe "opendaylight class without any params on #{osfamily}:#{operatingsystem} #{operatingsystemmajrelease}" do
69         let(:facts) {{
70           :osfamily => osfamily,
71           :operatingsystem => operatingsystem,
72           :operatingsystemmajrelease => operatingsystemmajrelease,
73         }}
74
75         # Run shared tests applicable to all unsupported OSs
76         # Note that this function is defined in spec_helper
77         unsupported_os_tests(operatingsystem, operatingsystemmajrelease)
78
79       end
80     end
81
82     # Test unsupported OS families
83     ['Debian', 'Suse', 'Solaris'].each do |osfamily|
84       describe "opendaylight class without any params on #{osfamily}" do
85         let(:facts) {{
86           :osfamily => osfamily,
87         }}
88
89         # Confirm that classes fail on unsupported OS families
90         it { expect { should contain_class('opendaylight') }.to raise_error(Puppet::Error, /Unsupported OS family: #{osfamily}/) }
91         it { expect { should contain_class('opendaylight::install') }.to raise_error(Puppet::Error, /Unsupported OS family: #{osfamily}/) }
92         it { expect { should contain_class('opendaylight::config') }.to raise_error(Puppet::Error, /Unsupported OS family: #{osfamily}/) }
93         it { expect { should contain_class('opendaylight::service') }.to raise_error(Puppet::Error, /Unsupported OS family: #{osfamily}/) }
94
95         # Confirm that other resources fail on unsupported OS families
96         it { expect { should contain_yumrepo('opendaylight') }.to raise_error(Puppet::Error, /Unsupported OS family: #{osfamily}/) }
97         it { expect { should contain_package('opendaylight') }.to raise_error(Puppet::Error, /Unsupported OS family: #{osfamily}/) }
98         it { expect { should contain_service('opendaylight') }.to raise_error(Puppet::Error, /Unsupported OS family: #{osfamily}/) }
99         it { expect { should contain_file('org.apache.karaf.features.cfg') }.to raise_error(Puppet::Error, /Unsupported OS family: #{osfamily}/) }
100       end
101     end
102   end
103 end