Skip to content

Commit 8a674e8

Browse files
committed
(MODULES-7439) - Implementing beaker-testmode_switcher
1 parent 51bd650 commit 8a674e8

11 files changed

+57
-54
lines changed

.sync.yml

+1
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ Gemfile:
3030
from_env: BEAKER_HOSTGENERATOR_VERSION
3131
- gem: beaker-rspec
3232
from_env: BEAKER_RSPEC_VERSION
33+
- gem: beaker-testmode_switcher
3334
':development':
3435
- gem: puppet-lint-i18n
3536

spec/acceptance/locales_spec.rb

+4-4
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ class { 'mysql::server':
3838
end
3939

4040
it 'displays Japanese error' do
41-
apply_manifest(pp, catch_error: true) do |r|
41+
execute_manifest(pp, catch_error: true) do |r|
4242
expect(r.stderr).to match(%r{`old_root_password`属性は廃止予定であり、今後のリリースで廃止されます。}i)
4343
end
4444
end
@@ -61,7 +61,7 @@ class { 'mysql::server::backup':
6161
end
6262

6363
it 'displays Japanese failure' do
64-
apply_manifest(pp, catch_failures: true) do |r|
64+
execute_manifest(pp, catch_failures: true) do |r|
6565
expect(r.stderr).to match(%r{'prescript'オプションは、現在、mysqldumpバックアッププロバイダ向けには実装されていません。}i)
6666
end
6767
end
@@ -80,7 +80,7 @@ class { 'mysql::server::backup':
8080
end
8181

8282
it 'displays Japanese failure' do
83-
apply_manifest(pp, expect_failures: true) do |r|
83+
execute_manifest(pp, expect_failures: true) do |r|
8484
expect(r.stderr).to match(%r{MySQLユーザ名は最大\d{2}文字に制限されています。}i)
8585
end
8686
end
@@ -96,7 +96,7 @@ class { 'mysql::server::backup':
9696
end
9797

9898
it 'displays Japanese error' do
99-
apply_manifest(pp, expect_failures: true) do |r|
99+
execute_manifest(pp, expect_failures: true) do |r|
100100
expect(r.stderr).to match(%r{無効なデータベースのユーザ"name@localhost}i)
101101
end
102102
end

spec/acceptance/mysql_backup_spec.rb

+5-5
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ class { 'mysql::server::backup':
2929
}
3030
MANIFEST
3131
it 'when configuring mysql backups' do
32-
apply_manifest(pp, catch_failures: true)
33-
apply_manifest(pp, catch_failures: true)
32+
execute_manifest(pp, catch_failures: true)
33+
execute_manifest(pp, catch_failures: true)
3434
end
3535
end
3636

@@ -104,8 +104,8 @@ class { 'mysql::server::backup':
104104
}
105105
MANIFEST
106106
it 'when configuring mysql backups' do
107-
apply_manifest(pp, catch_failures: true)
108-
apply_manifest(pp, catch_failures: true)
107+
execute_manifest(pp, catch_failures: true)
108+
execute_manifest(pp, catch_failures: true)
109109
end
110110
end
111111

@@ -187,7 +187,7 @@ class { 'mysql::server::backup':
187187
}
188188
MANIFEST
189189
it 'when configuring mysql backups with triggers and routines' do
190-
apply_manifest(pp, catch_failures: true)
190+
execute_manifest(pp, catch_failures: true)
191191
end
192192

193193
it 'runs mysqlbackup.sh with no errors' do

spec/acceptance/mysql_helper.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
def pre_run
2-
apply_manifest("class { 'mysql::server': root_password => 'password' }", catch_failures: true)
2+
execute_manifest("class { 'mysql::server': root_password => 'password' }", catch_failures: true)
33
@mysql_version = (on default, 'mysql --version').output.chomp.match(%r{\d+\.\d+\.\d+})[0]
44
end
55

spec/acceptance/mysql_server_spec.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ class { 'mysql::server':
9898
let(:pp) { "class { 'mysql::server': root_password => '#{password}' }" }
9999

100100
it 'does not display the password' do
101-
result = apply_manifest(pp, catch_failures: true)
101+
result = execute_manifest(pp, catch_failures: true)
102102
# this does not actually prove anything, as show_diff in the puppet config defaults to false.
103103
expect(result.stdout).not_to match %r{#{password}}
104104
end

spec/acceptance/sql_task_spec.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ class { 'mysql::server': root_password => 'password' }
1212
MANIFEST
1313

1414
it 'sets up a mysql instance' do
15-
apply_manifest_on(hosts, pp, catch_failures: true)
15+
execute_manifest_on(hosts, pp, catch_failures: true)
1616
end
1717

1818
it 'execute arbitary sql' do

spec/acceptance/types/mysql_database_spec.rb

+4-4
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
class { 'mysql::server': }
77
MANIFEST
88
it 'works with no errors' do
9-
apply_manifest(pp, catch_failures: true)
9+
execute_manifest(pp, catch_failures: true)
1010
end
1111
end
1212

@@ -17,7 +17,7 @@ class { 'mysql::server': }
1717
}
1818
MANIFEST
1919
it 'works without errors' do
20-
apply_manifest(pp, catch_failures: true)
20+
execute_manifest(pp, catch_failures: true)
2121
end
2222

2323
it 'finds the database #stdout' do
@@ -44,8 +44,8 @@ class { 'mysql::server': }
4444
}
4545
MANIFEST
4646
it 'creates two db of different types idempotently' do
47-
apply_manifest(pp, catch_failures: true)
48-
apply_manifest(pp, catch_changes: true)
47+
execute_manifest(pp, catch_failures: true)
48+
execute_manifest(pp, catch_changes: true)
4949
end
5050

5151
it 'finds latin1 db #stdout' do

spec/acceptance/types/mysql_grant_spec.rb

+27-27
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ class { 'mysql::server':
1010
}
1111
MANIFEST
1212

13-
apply_manifest(pp, catch_failures: true)
13+
execute_manifest(pp, catch_failures: true)
1414
end
1515

1616
describe 'missing privileges for user' do
@@ -26,7 +26,7 @@ class { 'mysql::server':
2626
}
2727
MANIFEST
2828
it 'fails' do
29-
expect(apply_manifest(pp, expect_failures: true).stderr).to match(%r{`privileges` `parameter` is required})
29+
expect(execute_manifest(pp, expect_failures: true).stderr).to match(%r{`privileges` `parameter` is required})
3030
end
3131

3232
it 'does not find the user' do
@@ -47,7 +47,7 @@ class { 'mysql::server':
4747
}
4848
MANIFEST
4949
it 'fails' do
50-
apply_manifest(pp, expect_failures: true)
50+
execute_manifest(pp, expect_failures: true)
5151
end
5252

5353
it 'does not find the user' do
@@ -69,7 +69,7 @@ class { 'mysql::server':
6969
}
7070
MANIFEST
7171
it 'works without errors' do
72-
apply_manifest(pp, catch_failures: true)
72+
execute_manifest(pp, catch_failures: true)
7373
end
7474

7575
it 'finds the user #stdout' do
@@ -98,7 +98,7 @@ class { 'mysql::server':
9898
}
9999
MANIFEST
100100
it 'works without errors' do
101-
apply_manifest(pp, catch_failures: true)
101+
execute_manifest(pp, catch_failures: true)
102102
end
103103

104104
it 'finds the user #stdout' do
@@ -128,7 +128,7 @@ class { 'mysql::server':
128128
}
129129
MANIFEST
130130
it 'works without errors' do
131-
apply_manifest(pp, catch_failures: true)
131+
execute_manifest(pp, catch_failures: true)
132132
end
133133

134134
it 'finds the user #stdout' do
@@ -157,7 +157,7 @@ class { 'mysql::server':
157157
}
158158
MANIFEST
159159
it 'fails' do
160-
expect(apply_manifest(pp, expect_failures: true).stderr).to match(%r{`table` `parameter` is required.})
160+
expect(execute_manifest(pp, expect_failures: true).stderr).to match(%r{`table` `parameter` is required.})
161161
end
162162
end
163163

@@ -176,7 +176,7 @@ class { 'mysql::server':
176176
}
177177
MANIFEST
178178
it 'onlies try to apply ALL' do
179-
apply_manifest(pp, catch_failures: true)
179+
execute_manifest(pp, catch_failures: true)
180180
end
181181

182182
it 'finds the user #stdout' do
@@ -246,7 +246,7 @@ class { 'mysql::server':
246246
}
247247
MANIFEST
248248
it 'applies' do
249-
apply_manifest(pp, catch_failures: true)
249+
execute_manifest(pp, catch_failures: true)
250250
end
251251

252252
it 'finds short hostname #stdout' do
@@ -383,8 +383,8 @@ class { 'mysql::server':
383383
}
384384
MANIFEST
385385
it 'setup mysql::server' do
386-
apply_manifest(pp, catch_failures: true)
387-
apply_manifest(pp, catch_changes: true)
386+
execute_manifest(pp, catch_failures: true)
387+
execute_manifest(pp, catch_changes: true)
388388
end
389389
end
390390

@@ -401,7 +401,7 @@ class { 'mysql::server':
401401
}
402402
MANIFEST
403403
it 'create ALL privs' do
404-
apply_manifest(pp_one, catch_failures: true)
404+
execute_manifest(pp_one, catch_failures: true)
405405
end
406406

407407
pp_two = <<-MANIFEST
@@ -416,7 +416,7 @@ class { 'mysql::server':
416416
}
417417
MANIFEST
418418
it 'create lowercase all privs' do
419-
expect(apply_manifest(pp_two, catch_failures: true).exit_code).to eq(0)
419+
expect(execute_manifest(pp_two, catch_failures: true).exit_code).to eq(0)
420420
end
421421
end
422422

@@ -439,7 +439,7 @@ class { 'mysql::server':
439439
}
440440
MANIFEST
441441
it 'works without errors' do
442-
apply_manifest(pp, catch_failures: true)
442+
execute_manifest(pp, catch_failures: true)
443443
end
444444

445445
it 'finds the user #stdout' do
@@ -475,7 +475,7 @@ class { 'mysql::server':
475475
}
476476
EOS
477477

478-
apply_manifest(pp, catch_failures: true)
478+
execute_manifest(pp, catch_failures: true)
479479
end
480480
# rubocop:enable RSpec/ExampleLength
481481
it 'finds the user' do
@@ -504,7 +504,7 @@ class { 'mysql::server':
504504
}
505505
MANIFEST
506506
it 'works without errors when version greater than 5.5.0' do
507-
apply_manifest(pp, catch_failures: true)
507+
execute_manifest(pp, catch_failures: true)
508508
end
509509

510510
it 'finds the user #stdout' do
@@ -533,7 +533,7 @@ class { 'mysql::server':
533533
}
534534
MANIFEST
535535
it 'works without errors' do
536-
apply_manifest(pp, catch_failures: true)
536+
execute_manifest(pp, catch_failures: true)
537537
end
538538

539539
it 'finds the user #stdout' do
@@ -562,7 +562,7 @@ class { 'mysql::server':
562562
}
563563
MANIFEST
564564
it 'fails' do
565-
expect(apply_manifest(pp, expect_failures: true).stderr).to match(%r{`privileges` `parameter`: PROXY can only be specified by itself})
565+
expect(execute_manifest(pp, expect_failures: true).stderr).to match(%r{`privileges` `parameter`: PROXY can only be specified by itself})
566566
end
567567

568568
it 'does not find the user' do
@@ -584,7 +584,7 @@ class { 'mysql::server':
584584
}
585585
MANIFEST
586586
it 'fails' do
587-
expect(apply_manifest(pp, expect_failures: true).stderr).to match(%r{PROXY user not supported on mysql versions < 5\.5\.0}i)
587+
expect(execute_manifest(pp, expect_failures: true).stderr).to match(%r{PROXY user not supported on mysql versions < 5\.5\.0}i)
588588
end
589589

590590
it 'does not find the user' do
@@ -606,7 +606,7 @@ class { 'mysql::server':
606606
}
607607
MANIFEST
608608
it 'fails' do
609-
expect(apply_manifest(pp, expect_failures: true).stderr).to match(%r{`table` `property` for PROXY should be specified as proxy_user@proxy_host.})
609+
expect(execute_manifest(pp, expect_failures: true).stderr).to match(%r{`table` `property` for PROXY should be specified as proxy_user@proxy_host.})
610610
end
611611

612612
it 'does not find the user' do
@@ -625,7 +625,7 @@ class { 'mysql::server':
625625
}
626626
MANIFEST
627627
it 'setup mysql::server' do
628-
apply_manifest(pp_one, catch_failures: true)
628+
execute_manifest(pp_one, catch_failures: true)
629629
end
630630

631631
pp_two = <<-MANIFEST
@@ -651,7 +651,7 @@ class { 'mysql::server':
651651
}
652652
MANIFEST
653653
it 'applies' do
654-
apply_manifest(pp_two, catch_failures: true)
654+
execute_manifest(pp_two, catch_failures: true)
655655
end
656656

657657
it 'fails with fqdn' do
@@ -687,7 +687,7 @@ class { 'mysql::server':
687687
it 'fails to execute while applying' do
688688
mysql_cmd = shell('which mysql').stdout.chomp
689689
shell("mv #{mysql_cmd} #{mysql_cmd}.bak")
690-
expect(apply_manifest(pp_three, expect_failures: true).stderr).to match(%r{Could not find a suitable provider for mysql_grant})
690+
expect(execute_manifest(pp_three, expect_failures: true).stderr).to match(%r{Could not find a suitable provider for mysql_grant})
691691
shell("mv #{mysql_cmd}.bak #{mysql_cmd}")
692692
end
693693

@@ -697,7 +697,7 @@ class { 'mysql::server':
697697
}
698698
MANIFEST
699699
it 'reset mysql::server config' do
700-
apply_manifest(pp_four, catch_failures: true)
700+
execute_manifest(pp_four, catch_failures: true)
701701
end
702702
end
703703

@@ -707,7 +707,7 @@ class { 'mysql::server':
707707
class { 'mysql::server': override_options => { 'root_password' => 'password' } }
708708
MANIFEST
709709
it 'setup mysql server' do
710-
apply_manifest(pp_one, catch_failures: true)
710+
execute_manifest(pp_one, catch_failures: true)
711711
end
712712

713713
pp_two = <<-MANIFEST
@@ -722,7 +722,7 @@ class { 'mysql::server': override_options => { 'root_password' => 'password' } }
722722
}
723723
MANIFEST
724724
it 'creates grant on missing table will fail' do
725-
expect(apply_manifest(pp_two, expect_failures: true).stderr).to match(%r{Table 'grant_spec_db\.grant_spec_table' doesn't exist})
725+
expect(execute_manifest(pp_two, expect_failures: true).stderr).to match(%r{Table 'grant_spec_db\.grant_spec_table' doesn't exist})
726726
end
727727

728728
pp_three = <<-MANIFEST
@@ -738,7 +738,7 @@ class { 'mysql::server': override_options => { 'root_password' => 'password' } }
738738
}
739739
MANIFEST
740740
it 'creates table' do
741-
apply_manifest(pp_three, catch_failures: true)
741+
execute_manifest(pp_three, catch_failures: true)
742742
end
743743

744744
it 'has the table' do

spec/acceptance/types/mysql_plugin_spec.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
class { 'mysql::server': }
3838
MANIFEST
3939

40-
apply_manifest(pp, catch_failures: true)
40+
execute_manifest(pp, catch_failures: true)
4141
end
4242
end
4343

@@ -49,7 +49,7 @@ class { 'mysql::server': }
4949
}
5050
MANIFEST
5151
it 'works without errors' do
52-
apply_manifest(pp, catch_failures: true)
52+
execute_manifest(pp, catch_failures: true)
5353
end
5454

5555
it 'finds the plugin #stdout' do

0 commit comments

Comments
 (0)