forked from puppetlabs/puppetlabs-mysql
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmycnf_template_spec.rb
164 lines (125 loc) · 5.16 KB
/
mycnf_template_spec.rb
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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
require 'spec_helper'
describe 'mysql::server' do
on_supported_os.each do |os, facts|
context "my.cnf template - on #{os}" do
let(:facts) do
facts.merge(root_home: '/root')
end
context 'normal entry' do
let(:params) { { override_options: { 'mysqld' => { 'socket' => '/var/lib/mysql/mysql.sock' } } } }
it do
is_expected.to contain_file('mysql-config-file').with(mode: '0644',
selinux_ignore_defaults: true).with_content(%r{socket = \/var\/lib\/mysql\/mysql.sock})
end
end
describe 'array entry' do
let(:params) { { override_options: { 'mysqld' => { 'replicate-do-db' => ['base1', 'base2'] } } } }
it do
is_expected.to contain_file('mysql-config-file').with_content(
%r{.*replicate-do-db = base1\nreplicate-do-db = base2.*},
)
end
end
describe 'skip-name-resolve set to an empty string' do
let(:params) { { override_options: { 'mysqld' => { 'skip-name-resolve' => '' } } } }
it { is_expected.to contain_file('mysql-config-file').with_content(%r{^skip-name-resolve$}) }
end
describe 'ssl set to true' do
let(:params) { { override_options: { 'mysqld' => { 'ssl' => true } } } }
it { is_expected.to contain_file('mysql-config-file').with_content(%r{ssl}) }
it { is_expected.to contain_file('mysql-config-file').without_content(%r{ssl = true}) }
end
describe 'ssl set to false' do
let(:params) { { override_options: { 'mysqld' => { 'ssl' => false } } } }
it { is_expected.to contain_file('mysql-config-file').with_content(%r{ssl = false}) }
end
# ssl-disable (and ssl) are special cased within mysql.
describe 'possibility of disabling ssl completely' do
let(:params) { { override_options: { 'mysqld' => { 'ssl' => true, 'ssl-disable' => true } } } }
it { is_expected.to contain_file('mysql-config-file').without_content(%r{ssl = true}) }
end
describe 'a non ssl option set to true' do
let(:params) { { override_options: { 'mysqld' => { 'test' => true } } } }
it { is_expected.to contain_file('mysql-config-file').with_content(%r{^test$}) }
it { is_expected.to contain_file('mysql-config-file').without_content(%r{test = true}) }
end
context 'with includedir' do
let(:params) { { includedir: '/etc/my.cnf.d' } }
it 'makes the directory' do
is_expected.to contain_file('/etc/my.cnf.d').with(ensure: :directory,
mode: '0755')
end
it { is_expected.to contain_file('mysql-config-file').with_content(%r{!includedir}) }
end
context 'without includedir' do
let(:params) { { includedir: '' } }
it 'shouldnt contain the directory' do
is_expected.not_to contain_file('mysql-config-file').with(ensure: :directory,
mode: '0755')
end
it { is_expected.to contain_file('mysql-config-file').without_content(%r{!includedir}) }
end
context 'with file mode 0644' do
let(:params) { { 'config_file_mode' => '0644' } }
it do
is_expected.to contain_file('mysql-config-file').with(mode: '0644')
end
end
context 'with file mode 0664' do
let(:params) { { 'config_file_mode' => '0664' } }
it do
is_expected.to contain_file('mysql-config-file').with(mode: '0664')
end
end
context 'with file mode 0660' do
let(:params) { { 'config_file_mode' => '0660' } }
it do
is_expected.to contain_file('mysql-config-file').with(mode: '0660')
end
end
context 'with file mode 0641' do
let(:params) { { 'config_file_mode' => '0641' } }
it do
is_expected.to contain_file('mysql-config-file').with(mode: '0641')
end
end
context 'with file mode 0610' do
let(:params) { { 'config_file_mode' => '0610' } }
it do
is_expected.to contain_file('mysql-config-file').with(mode: '0610')
end
end
context 'with file 0600' do
let(:params) { { 'config_file_mode' => '0600' } }
it do
is_expected.to contain_file('mysql-config-file').with(mode: '0600')
end
end
context 'user owner 12345' do
let(:params) { { 'mycnf_owner' => '12345' } }
it do
is_expected.to contain_file('mysql-config-file').with(
owner: '12345',
)
end
end
context 'group owner 12345' do
let(:params) { { 'mycnf_group' => '12345' } }
it do
is_expected.to contain_file('mysql-config-file').with(
group: '12345',
)
end
end
context 'user and group owner 12345' do
let(:params) { { 'mycnf_owner' => '12345', 'mycnf_group' => '12345' } }
it do
is_expected.to contain_file('mysql-config-file').with(
owner: '12345',
group: '12345',
)
end
end
end
end
end