-
-
Notifications
You must be signed in to change notification settings - Fork 440
Expand file tree
/
Copy pathmongos_spec.rb
More file actions
105 lines (82 loc) · 3.1 KB
/
mongos_spec.rb
File metadata and controls
105 lines (82 loc) · 3.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
# frozen_string_literal: true
require 'spec_helper'
describe 'mongodb::mongos' do
on_supported_os.each do |os, facts|
context "on #{os}" do
let(:facts) { facts }
package_name = 'mongodb-org-mongos'
config_file = '/etc/mongos.conf'
context 'with defaults' do
it { is_expected.to compile.with_all_deps }
# install
it { is_expected.to contain_class('mongodb::mongos::install') }
it { is_expected.to contain_package('mongodb_mongos').with_ensure('present').with_name(package_name).with_tag('mongodb_package') }
# config
it { is_expected.to contain_class('mongodb::mongos::config') }
expected_content = <<~CONFIG
configdb = 127.0.0.1:27019
fork = true
pidfilepath = /var/run/mongodb/mongos.pid
logpath = /var/log/mongodb/mongos.log
unixSocketPrefix = /var/run/mongodb
CONFIG
it { is_expected.to contain_file(config_file).with_content(expected_content) }
# service
it { is_expected.to contain_class('mongodb::mongos::service') }
it { is_expected.to contain_service('mongos') }
it {
is_expected.to contain_systemd__unit_file('mongos.service')
.with_content(%r{RuntimeDirectory=mongodb})
.with_content(%r{RuntimeDirectoryMode=0755})
}
end
describe 'with specific bind_ip values' do
let :params do
{
bind_ip: ['127.0.0.1', '10.1.1.13'],
}
end
it { is_expected.to contain_file(config_file).with_content(%r{^bind_ip = 127\.0\.0\.1,10\.1\.1\.13$}) }
end
context 'package_name => mongo-foo' do
let(:params) do
{
package_name: 'mongo-foo',
}
end
it { is_expected.to compile.with_all_deps }
it { is_expected.to contain_package('mongodb_mongos').with_name('mongo-foo').with_ensure('present').with_tag('mongodb_package') }
end
context 'service_manage => false' do
let(:params) do
{
service_manage: false,
}
end
it { is_expected.to compile.with_all_deps }
it { is_expected.not_to contain_service('mongos') }
end
context 'package_ensure => purged' do
let(:params) do
{
package_ensure: 'purged',
}
end
it { is_expected.to compile.with_all_deps }
# install
it { is_expected.to contain_class('mongodb::mongos::install') }
if facts[:os]['family'] == 'Suse'
it { is_expected.to contain_package('mongodb_mongos').with_ensure('absent') }
else
it { is_expected.to contain_package('mongodb_mongos').with_ensure('purged') }
end
# config
it { is_expected.to contain_class('mongodb::mongos::config') }
it { is_expected.to contain_file(config_file).with_ensure('absent') }
# service
it { is_expected.to contain_class('mongodb::mongos::service') }
it { is_expected.to contain_service('mongos').with_ensure('stopped').with_enable(false) }
end
end
end
end