|
7 | 7 | context "on #{os}" do |
8 | 8 | let(:facts) { facts } |
9 | 9 |
|
10 | | - case facts[:os]['family'] |
11 | | - when 'Debian' |
12 | | - package_name = if facts[:os]['release']['major'] =~ %r{(10)} |
| 10 | + package_name = case facts[:os]['family'] |
| 11 | + when 'Debian' |
| 12 | + if facts[:os]['release']['major'] =~ %r{(10)} |
13 | 13 | 'mongodb-org-mongos' |
14 | 14 | else |
15 | 15 | 'mongodb-server' |
16 | 16 | end |
17 | | - config_file = '/etc/mongodb-shard.conf' |
18 | | - else |
19 | | - package_name = 'mongodb-org-mongos' |
20 | | - config_file = '/etc/mongos.conf' |
21 | | - end |
| 17 | + else |
| 18 | + 'mongodb-org-mongos' |
| 19 | + end |
| 20 | + config_file = '/etc/mongos.conf' |
22 | 21 |
|
23 | 22 | context 'with defaults' do |
24 | 23 | it { is_expected.to compile.with_all_deps } |
|
27 | 26 | it { is_expected.to contain_class('mongodb::mongos::install') } |
28 | 27 |
|
29 | 28 | if facts[:os]['release']['major'] =~ %r{(10)} |
30 | | - it { is_expected.to contain_package('mongodb_mongos').with_ensure('4.4.8').with_name(package_name).with_tag('mongodb_package') } |
| 29 | + it { is_expected.to contain_package('mongodb_mongos').with_ensure('4.4.29').with_name(package_name).with_tag('mongodb_package') } |
31 | 30 | else |
32 | 31 | it { is_expected.to contain_package('mongodb_mongos').with_ensure('present').with_name(package_name).with_tag('mongodb_package') } |
33 | 32 | end |
34 | 33 |
|
35 | 34 | # config |
36 | 35 | it { is_expected.to contain_class('mongodb::mongos::config') } |
37 | 36 |
|
38 | | - case facts[:osfamily] |
39 | | - when 'RedHat', 'Suse' |
40 | | - expected_content = <<~CONFIG |
41 | | - configdb = 127.0.0.1:27019 |
42 | | - fork = true |
43 | | - pidfilepath = /var/run/mongodb/mongos.pid |
44 | | - logpath = /var/log/mongodb/mongos.log |
45 | | - unixSocketPrefix = /var/run/mongodb |
46 | | - CONFIG |
47 | | - |
48 | | - it { is_expected.to contain_file('/etc/mongos.conf').with_content(expected_content) } |
49 | | - when 'Debian' |
50 | | - expected_content = <<~CONFIG |
51 | | - configdb = 127.0.0.1:27019 |
52 | | - CONFIG |
53 | | - |
54 | | - it { is_expected.to contain_file('/etc/mongodb-shard.conf').with_content(expected_content) } |
55 | | - end |
| 37 | + expected_content = <<~CONFIG |
| 38 | + configdb = 127.0.0.1:27019 |
| 39 | + fork = true |
| 40 | + pidfilepath = /var/run/mongodb/mongos.pid |
| 41 | + logpath = /var/log/mongodb/mongos.log |
| 42 | + unixSocketPrefix = /var/run/mongodb |
| 43 | + CONFIG |
| 44 | + it { is_expected.to contain_file(config_file).with_content(expected_content) } |
56 | 45 |
|
57 | 46 | # service |
58 | 47 | it { is_expected.to contain_class('mongodb::mongos::service') } |
59 | | - |
60 | | - if facts[:osfamily] == 'RedHat' || facts[:osfamily] == 'Suse' |
61 | | - it { is_expected.to contain_file('/etc/sysconfig/mongos') } |
62 | | - else |
63 | | - it { is_expected.not_to contain_file('/etc/sysconfig/mongos') } |
64 | | - end |
65 | | - |
66 | | - if facts[:osfamily] == 'Debian' |
67 | | - it { is_expected.to contain_file('/etc/init.d/mongos') } |
68 | | - else |
69 | | - it { is_expected.not_to contain_file('/etc/init.d/mongos') } |
70 | | - end |
71 | | - |
72 | 48 | it { is_expected.to contain_service('mongos') } |
73 | 49 | end |
74 | 50 |
|
|
92 | 68 | it { is_expected.to compile.with_all_deps } |
93 | 69 |
|
94 | 70 | if facts[:os]['release']['major'] =~ %r{(10)} |
95 | | - it { is_expected.to contain_package('mongodb_mongos').with_name('mongo-foo').with_ensure('4.4.8').with_tag('mongodb_package') } |
| 71 | + it { is_expected.to contain_package('mongodb_mongos').with_name('mongo-foo').with_ensure('4.4.29').with_tag('mongodb_package') } |
96 | 72 | else |
97 | 73 | it { is_expected.to contain_package('mongodb_mongos').with_name('mongo-foo').with_ensure('present').with_tag('mongodb_package') } |
98 | 74 | end |
|
106 | 82 | end |
107 | 83 |
|
108 | 84 | it { is_expected.to compile.with_all_deps } |
109 | | - it { is_expected.not_to contain_file('/etc/sysconfig/mongos') } |
110 | | - it { is_expected.not_to contain_file('/etc/init.d/mongos') } |
111 | 85 | it { is_expected.not_to contain_service('mongos') } |
112 | 86 | end |
113 | 87 |
|
|
131 | 105 |
|
132 | 106 | # config |
133 | 107 | it { is_expected.to contain_class('mongodb::mongos::config') } |
134 | | - |
135 | | - case facts[:osfamily] |
136 | | - when 'RedHat', 'Suse' |
137 | | - it { is_expected.to contain_file('/etc/mongos.conf').with_ensure('absent') } |
138 | | - when 'Debian' |
139 | | - it { is_expected.to contain_file('/etc/mongodb-shard.conf').with_ensure('absent') } |
140 | | - end |
141 | | - |
142 | | - if facts[:osfamily] == 'RedHat' || facts[:osfamily] == 'Suse' |
143 | | - it { is_expected.to contain_file('/etc/sysconfig/mongos').with_ensure('absent') } |
144 | | - else |
145 | | - it { is_expected.not_to contain_file('/etc/sysconfig/mongos') } |
146 | | - end |
147 | | - |
148 | | - if facts[:osfamily] == 'Debian' |
149 | | - it { is_expected.to contain_file('/etc/init.d/mongos').with_ensure('absent') } |
150 | | - else |
151 | | - it { is_expected.not_to contain_file('/etc/init.d/mongos') } |
152 | | - end |
| 108 | + it { is_expected.to contain_file(config_file).with_ensure('absent') } |
153 | 109 |
|
154 | 110 | # service |
155 | 111 | it { is_expected.to contain_class('mongodb::mongos::service') } |
156 | | - |
157 | 112 | it { is_expected.to contain_service('mongos').with_ensure('stopped').with_enable(false) } |
158 | 113 | end |
159 | 114 | end |
|
0 commit comments