|
2 | 2 |
|
3 | 3 | require 'spec_helper_acceptance' |
4 | 4 |
|
5 | | -support_bin_dir = '/root/mysql_login_path' |
6 | | -mysql_version = if (os[:family] == 'redhat' && os[:release].to_i == 8) || (os[:family] == 'debian' && os[:release] =~ %r{9|10|11}) |
7 | | - '8.0' |
8 | | - elsif os[:family] == 'ubuntu' && os[:release] =~ %r{18\.04|20\.04} |
9 | | - '5.7' |
10 | | - else |
11 | | - '5.6' |
12 | | - end |
| 5 | +describe 'mysql_login_path' do |
| 6 | + begin |
| 7 | + # mysql_config_editor is not supported on mariadb |
| 8 | + # all tests should be skipped |
| 9 | + run_shell('mysql_config_editor -V') |
| 10 | + rescue |
| 11 | + return |
| 12 | + end |
13 | 13 |
|
14 | | -describe 'mysql_login_path', unless: "#{os[:family]}-#{os[:release].to_i}".include?('suse') do |
15 | | - before(:all) do |
16 | | - run_shell("rm -rf #{support_bin_dir}") |
17 | | - bolt_upload_file('spec/support/mysql_login_path', support_bin_dir) |
18 | | - run_shell("cp #{support_bin_dir}/mysql-#{mysql_version}/my_print_defaults /usr/bin/.") |
19 | | - run_shell("cp #{support_bin_dir}/mysql-#{mysql_version}/mysql_config_editor /usr/bin/.") |
| 14 | + let(:base_pp) do |
| 15 | + <<-MANIFEST |
| 16 | + user { 'loginpath_test': |
| 17 | + ensure => present, |
| 18 | + managehome => true, |
| 19 | + } |
| 20 | + MANIFEST |
20 | 21 | end |
21 | 22 |
|
22 | 23 | after(:all) do |
|
29 | 30 | } |
30 | 31 | MANIFEST |
31 | 32 | apply_manifest(pp_cleanup, catch_failures: true) |
32 | | - run_shell("rm -rf #{support_bin_dir}") |
33 | | - end |
34 | | - |
35 | | - describe 'setup' do |
36 | | - pp = <<-MANIFEST |
37 | | - user { 'loginpath_test': |
38 | | - ensure => present, |
39 | | - managehome => true, |
40 | | - } |
41 | | - MANIFEST |
42 | | - it 'works with no errors' do |
43 | | - apply_manifest(pp, catch_failures: true) |
44 | | - end |
45 | | - |
46 | | - it 'finds mysql_config_editor binary for the provider' do |
47 | | - run_shell('mysql_config_editor -V') do |r| |
48 | | - expect(r.stdout).to match(%r{Ver.*#{mysql_version}.*x86_64}) |
49 | | - end |
50 | | - end |
51 | | - |
52 | | - it 'finds my_print_defaults binary for the provider' do |
53 | | - run_shell('my_print_defaults -V') do |r| |
54 | | - expect(r.exit_status).to eq(0) |
55 | | - end |
56 | | - end |
57 | 33 | end |
58 | 34 |
|
59 | 35 | context 'for user root' do |
60 | 36 | describe 'add login path' do |
61 | | - pp = <<-MANIFEST |
| 37 | + let(:pp) do |
| 38 | + <<-MANIFEST |
| 39 | + #{base_pp} |
62 | 40 | mysql_login_path { 'local_socket': |
63 | 41 | owner => root, |
64 | 42 | host => 'localhost', |
|
75 | 53 | port => 3306, |
76 | 54 | ensure => present, |
77 | 55 | } |
78 | | - MANIFEST |
| 56 | + MANIFEST |
| 57 | + end |
| 58 | + |
79 | 59 | it 'works without errors' do |
80 | 60 | apply_manifest(pp, catch_failures: true) |
81 | 61 | end |
|
102 | 82 | end |
103 | 83 |
|
104 | 84 | describe 'update login path' do |
105 | | - pp = <<-MANIFEST |
| 85 | + let(:pp) do |
| 86 | + <<-MANIFEST |
| 87 | + #{base_pp} |
106 | 88 | mysql_login_path { 'local_tcp-root': |
107 | 89 | owner => root, |
108 | 90 | host => '10.0.0.1', |
|
111 | 93 | port => 3307, |
112 | 94 | ensure => present, |
113 | 95 | } |
114 | | - MANIFEST |
115 | | - pp2 = <<-MANIFEST |
| 96 | + MANIFEST |
| 97 | + end |
| 98 | + |
| 99 | + let(:pp2) do |
| 100 | + <<-MANIFEST |
116 | 101 | mysql_login_path { 'local_tcp-root': |
117 | 102 | ensure => present, |
118 | 103 | host => '192.168.0.1' |
119 | 104 | } |
120 | | - MANIFEST |
| 105 | + MANIFEST |
| 106 | + end |
| 107 | + |
121 | 108 | it 'works without errors' do |
122 | 109 | apply_manifest(pp, catch_failures: true) |
123 | 110 | end |
|
193 | 180 |
|
194 | 181 | context 'for user loginpath_test' do |
195 | 182 | describe 'add login path' do |
196 | | - pp = <<-MANIFEST |
| 183 | + let(:pp) do |
| 184 | + <<-MANIFEST |
| 185 | + #{base_pp} |
197 | 186 | mysql_login_path { 'local_tcp': |
198 | 187 | owner => loginpath_test, |
199 | 188 | host => '10.0.0.2', |
|
202 | 191 | port => 3306, |
203 | 192 | ensure => present, |
204 | 193 | } |
205 | | - MANIFEST |
| 194 | + MANIFEST |
| 195 | + end |
| 196 | + |
206 | 197 | it 'works without errors' do |
207 | 198 | apply_manifest(pp, catch_failures: true) |
208 | 199 | end |
|
225 | 216 | end |
226 | 217 |
|
227 | 218 | describe 'update login path' do |
228 | | - pp = <<-MANIFEST |
| 219 | + let(:pp) do |
| 220 | + <<-MANIFEST |
| 221 | + #{base_pp} |
229 | 222 | mysql_login_path { 'local_tcp-loginpath_test': |
230 | 223 | host => '10.0.0.3', |
231 | 224 | user => 'other2', |
232 | 225 | password => Sensitive('password'), |
233 | 226 | port => 3307, |
234 | 227 | ensure => present, |
235 | 228 | } |
236 | | - MANIFEST |
| 229 | + MANIFEST |
| 230 | + end |
| 231 | + |
237 | 232 | it 'works without errors' do |
238 | 233 | apply_manifest(pp, catch_failures: true) |
239 | 234 | end |
|
256 | 251 | end |
257 | 252 |
|
258 | 253 | describe 'delete login path' do |
259 | | - pp = <<-MANIFEST |
| 254 | + let(:pp) do |
| 255 | + <<-MANIFEST |
| 256 | + #{base_pp} |
260 | 257 | mysql_login_path { 'local_tcp': |
261 | 258 | owner => loginpath_test, |
262 | 259 | ensure => absent, |
263 | 260 | } |
264 | | - MANIFEST |
| 261 | + MANIFEST |
| 262 | + end |
| 263 | + |
265 | 264 | it 'works without errors' do |
266 | 265 | apply_manifest(pp, catch_failures: true) |
267 | 266 | end |
|
0 commit comments