Skip to content

Commit ba01b5f

Browse files
author
Helen
authored
Merge pull request #1095 from pmcmaw/ma_loc_testing
(MODULES-7439) - Implementing beaker-testmode_switcher
2 parents 51bd650 + 3263791 commit ba01b5f

21 files changed

+150
-66
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
.git/
12
.*.sw[op]
23
.metadata
34
.yardoc

.pdkignore

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
.git/
12
.*.sw[op]
23
.metadata
34
.yardoc

.rubocop.yml

+3
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ RSpec/MessageSpies:
7474
Style/Documentation:
7575
Exclude:
7676
- lib/puppet/parser/functions/**/*
77+
- spec/**/*
7778
Style/WordArray:
7879
EnforcedStyle: brackets
7980
Style/CollectionMethods:
@@ -84,6 +85,8 @@ Style/StringMethods:
8485
Enabled: true
8586
Layout/EndOfLine:
8687
Enabled: false
88+
Layout/IndentHeredoc:
89+
Enabled: false
8790
Metrics/AbcSize:
8891
Enabled: false
8992
Metrics/BlockLength:

.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

.travis.yml

+8-8
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ script:
1313
- 'bundle exec rake $CHECK'
1414
bundler_args: --without system_tests
1515
rvm:
16-
- 2.4.1
16+
- 2.4.4
1717
env:
1818
global:
1919
- BEAKER_PUPPET_COLLECTION=puppet5 PUPPET_GEM_VERSION="~> 5.0"
@@ -23,16 +23,16 @@ matrix:
2323
-
2424
bundler_args:
2525
dist: trusty
26-
env: PUPPET_INSTALL_TYPE=agent BEAKER_debug=true BEAKER_PUPPET_COLLECTION=puppet5 BEAKER_set=docker/centos-7
27-
rvm: 2.4.1
26+
env: PUPPET_INSTALL_TYPE=agent BEAKER_debug=true BEAKER_PUPPET_COLLECTION=puppet5 BEAKER_set=docker/centos-7 BEAKER_TESTMODE=apply
27+
rvm: 2.4.4
2828
script: bundle exec rake beaker
2929
services: docker
3030
sudo: required
3131
-
3232
bundler_args:
3333
dist: trusty
34-
env: PUPPET_INSTALL_TYPE=agent BEAKER_debug=true BEAKER_PUPPET_COLLECTION=puppet5 BEAKER_set=docker/ubuntu-14.04
35-
rvm: 2.4.1
34+
env: PUPPET_INSTALL_TYPE=agent BEAKER_debug=true BEAKER_PUPPET_COLLECTION=puppet5 BEAKER_set=docker/ubuntu-14.04 BEAKER_TESTMODE=apply
35+
rvm: 2.4.4
3636
script: bundle exec rake beaker
3737
services: docker
3838
sudo: required
@@ -45,9 +45,9 @@ matrix:
4545
rvm: 2.1.9
4646
branches:
4747
only:
48-
- master
49-
- /^v\d/
50-
- release
48+
- master
49+
- /^v\d/
50+
- release
5151
notifications:
5252
email: false
5353
deploy:

Gemfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ group :development do
3333
gem "puppet-module-posix-dev-r#{minor_version}", require: false, platforms: [:ruby]
3434
gem "puppet-module-win-default-r#{minor_version}", require: false, platforms: [:mswin, :mingw, :x64_mingw]
3535
gem "puppet-module-win-dev-r#{minor_version}", require: false, platforms: [:mswin, :mingw, :x64_mingw]
36-
gem "puppet-blacksmith", '~> 3.4', require: false, platforms: [:ruby]
3736
gem "puppet-lint-i18n", require: false
3837
end
3938
group :system_tests do
@@ -44,6 +43,7 @@ group :system_tests do
4443
gem "beaker-pe", require: false
4544
gem "beaker-hostgenerator"
4645
gem "beaker-rspec"
46+
gem "beaker-testmode_switcher", require: false
4747
end
4848

4949
puppet_version = ENV['PUPPET_GEM_VERSION']

Rakefile

+69
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,76 @@
11
require 'puppetlabs_spec_helper/rake_tasks'
22
require 'puppet-syntax/tasks/puppet-syntax'
33
require 'puppet_blacksmith/rake_tasks' if Bundler.rubygems.find_name('puppet-blacksmith').any?
4+
require 'github_changelog_generator/task' if Bundler.rubygems.find_name('github_changelog_generator').any?
45
require 'puppet_pot_generator/rake_tasks'
56

7+
def changelog_user
8+
return unless Rake.application.top_level_tasks.include? "changelog"
9+
returnVal = nil || JSON.load(File.read('metadata.json'))['author']
10+
raise "unable to find the changelog_user in .sync.yml, or the author in metadata.json" if returnVal.nil?
11+
puts "GitHubChangelogGenerator user:#{returnVal}"
12+
returnVal
13+
end
14+
15+
def changelog_project
16+
return unless Rake.application.top_level_tasks.include? "changelog"
17+
returnVal = nil || JSON.load(File.read('metadata.json'))['name']
18+
raise "unable to find the changelog_project in .sync.yml or the name in metadata.json" if returnVal.nil?
19+
puts "GitHubChangelogGenerator project:#{returnVal}"
20+
returnVal
21+
end
22+
23+
def changelog_future_release
24+
return unless Rake.application.top_level_tasks.include? "changelog"
25+
returnVal = JSON.load(File.read('metadata.json'))['version']
26+
raise "unable to find the future_release (version) in metadata.json" if returnVal.nil?
27+
puts "GitHubChangelogGenerator future_release:#{returnVal}"
28+
returnVal
29+
end
30+
631
PuppetLint.configuration.send('disable_relative')
732

33+
if Bundler.rubygems.find_name('github_changelog_generator').any?
34+
GitHubChangelogGenerator::RakeTask.new :changelog do |config|
35+
raise "Set CHANGELOG_GITHUB_TOKEN environment variable eg 'export CHANGELOG_GITHUB_TOKEN=valid_token_here'" if Rake.application.top_level_tasks.include? "changelog" and ENV['CHANGELOG_GITHUB_TOKEN'].nil?
36+
config.user = "#{changelog_user}"
37+
config.project = "#{changelog_project}"
38+
config.future_release = "#{changelog_future_release}"
39+
config.exclude_labels = ['maintenance']
40+
config.header = "# Change log\n\nAll notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org)."
41+
config.add_pr_wo_labels = true
42+
config.issues = false
43+
config.merge_prefix = "### UNCATEGORIZED PRS; GO LABEL THEM"
44+
config.configure_sections = {
45+
"Changed" => {
46+
"prefix" => "### Changed",
47+
"labels" => ["backwards-incompatible"],
48+
},
49+
"Added" => {
50+
"prefix" => "### Added",
51+
"labels" => ["feature", "enhancement"],
52+
},
53+
"Fixed" => {
54+
"prefix" => "### Fixed",
55+
"labels" => ["bugfix"],
56+
},
57+
}
58+
end
59+
else
60+
desc 'Generate a Changelog from GitHub'
61+
task :changelog do
62+
raise <<EOM
63+
The changelog tasks depends on unreleased features of the github_changelog_generator gem.
64+
Please manually add it to your .sync.yml for now, and run `pdk update`:
65+
---
66+
Gemfile:
67+
optional:
68+
':development':
69+
- gem: 'github_changelog_generator'
70+
git: 'https://github.com/skywinder/github-changelog-generator'
71+
ref: '20ee04ba1234e9e83eb2ffb5056e23d641c7a018'
72+
condition: "Gem::Version.new(RUBY_VERSION.dup) >= Gem::Version.new('2.2.2')"
73+
EOM
74+
end
75+
end
76+

metadata.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,6 @@
8383
],
8484
"description": "MySQL module",
8585
"template-url": "https://github.com/puppetlabs/pdk-templates",
86-
"template-ref": "heads/master-0-g34e3266",
86+
"template-ref": "heads/master-0-g6b0d497",
8787
"pdk-version": "1.5.0"
8888
}

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

0 commit comments

Comments
 (0)