Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(MODULES-7439) - Implementing beaker-testmode_switcher #1095

Merged
merged 2 commits into from
Jul 18, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
.git/
.*.sw[op]
.metadata
.yardoc
Expand Down
1 change: 1 addition & 0 deletions .pdkignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
.git/
.*.sw[op]
.metadata
.yardoc
Expand Down
3 changes: 3 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ RSpec/MessageSpies:
Style/Documentation:
Exclude:
- lib/puppet/parser/functions/**/*
- spec/**/*
Style/WordArray:
EnforcedStyle: brackets
Style/CollectionMethods:
Expand All @@ -84,6 +85,8 @@ Style/StringMethods:
Enabled: true
Layout/EndOfLine:
Enabled: false
Layout/IndentHeredoc:
Enabled: false
Metrics/AbcSize:
Enabled: false
Metrics/BlockLength:
Expand Down
1 change: 1 addition & 0 deletions .sync.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ Gemfile:
from_env: BEAKER_HOSTGENERATOR_VERSION
- gem: beaker-rspec
from_env: BEAKER_RSPEC_VERSION
- gem: beaker-testmode_switcher
':development':
- gem: puppet-lint-i18n

Expand Down
16 changes: 8 additions & 8 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ script:
- 'bundle exec rake $CHECK'
bundler_args: --without system_tests
rvm:
- 2.4.1
- 2.4.4
env:
global:
- BEAKER_PUPPET_COLLECTION=puppet5 PUPPET_GEM_VERSION="~> 5.0"
Expand All @@ -23,16 +23,16 @@ matrix:
-
bundler_args:
dist: trusty
env: PUPPET_INSTALL_TYPE=agent BEAKER_debug=true BEAKER_PUPPET_COLLECTION=puppet5 BEAKER_set=docker/centos-7
rvm: 2.4.1
env: PUPPET_INSTALL_TYPE=agent BEAKER_debug=true BEAKER_PUPPET_COLLECTION=puppet5 BEAKER_set=docker/centos-7 BEAKER_TESTMODE=apply
rvm: 2.4.4
script: bundle exec rake beaker
services: docker
sudo: required
-
bundler_args:
dist: trusty
env: PUPPET_INSTALL_TYPE=agent BEAKER_debug=true BEAKER_PUPPET_COLLECTION=puppet5 BEAKER_set=docker/ubuntu-14.04
rvm: 2.4.1
env: PUPPET_INSTALL_TYPE=agent BEAKER_debug=true BEAKER_PUPPET_COLLECTION=puppet5 BEAKER_set=docker/ubuntu-14.04 BEAKER_TESTMODE=apply
rvm: 2.4.4
script: bundle exec rake beaker
services: docker
sudo: required
Expand All @@ -45,9 +45,9 @@ matrix:
rvm: 2.1.9
branches:
only:
- master
- /^v\d/
- release
- master
- /^v\d/
- release
notifications:
email: false
deploy:
Expand Down
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ group :development do
gem "puppet-module-posix-dev-r#{minor_version}", require: false, platforms: [:ruby]
gem "puppet-module-win-default-r#{minor_version}", require: false, platforms: [:mswin, :mingw, :x64_mingw]
gem "puppet-module-win-dev-r#{minor_version}", require: false, platforms: [:mswin, :mingw, :x64_mingw]
gem "puppet-blacksmith", '~> 3.4', require: false, platforms: [:ruby]
gem "puppet-lint-i18n", require: false
end
group :system_tests do
Expand All @@ -44,6 +43,7 @@ group :system_tests do
gem "beaker-pe", require: false
gem "beaker-hostgenerator"
gem "beaker-rspec"
gem "beaker-testmode_switcher", require: false
end

puppet_version = ENV['PUPPET_GEM_VERSION']
Expand Down
69 changes: 69 additions & 0 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,76 @@
require 'puppetlabs_spec_helper/rake_tasks'
require 'puppet-syntax/tasks/puppet-syntax'
require 'puppet_blacksmith/rake_tasks' if Bundler.rubygems.find_name('puppet-blacksmith').any?
require 'github_changelog_generator/task' if Bundler.rubygems.find_name('github_changelog_generator').any?
require 'puppet_pot_generator/rake_tasks'

def changelog_user
return unless Rake.application.top_level_tasks.include? "changelog"
returnVal = nil || JSON.load(File.read('metadata.json'))['author']
raise "unable to find the changelog_user in .sync.yml, or the author in metadata.json" if returnVal.nil?
puts "GitHubChangelogGenerator user:#{returnVal}"
returnVal
end

def changelog_project
return unless Rake.application.top_level_tasks.include? "changelog"
returnVal = nil || JSON.load(File.read('metadata.json'))['name']
raise "unable to find the changelog_project in .sync.yml or the name in metadata.json" if returnVal.nil?
puts "GitHubChangelogGenerator project:#{returnVal}"
returnVal
end

def changelog_future_release
return unless Rake.application.top_level_tasks.include? "changelog"
returnVal = JSON.load(File.read('metadata.json'))['version']
raise "unable to find the future_release (version) in metadata.json" if returnVal.nil?
puts "GitHubChangelogGenerator future_release:#{returnVal}"
returnVal
end

PuppetLint.configuration.send('disable_relative')

if Bundler.rubygems.find_name('github_changelog_generator').any?
GitHubChangelogGenerator::RakeTask.new :changelog do |config|
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?
config.user = "#{changelog_user}"
config.project = "#{changelog_project}"
config.future_release = "#{changelog_future_release}"
config.exclude_labels = ['maintenance']
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)."
config.add_pr_wo_labels = true
config.issues = false
config.merge_prefix = "### UNCATEGORIZED PRS; GO LABEL THEM"
config.configure_sections = {
"Changed" => {
"prefix" => "### Changed",
"labels" => ["backwards-incompatible"],
},
"Added" => {
"prefix" => "### Added",
"labels" => ["feature", "enhancement"],
},
"Fixed" => {
"prefix" => "### Fixed",
"labels" => ["bugfix"],
},
}
end
else
desc 'Generate a Changelog from GitHub'
task :changelog do
raise <<EOM
The changelog tasks depends on unreleased features of the github_changelog_generator gem.
Please manually add it to your .sync.yml for now, and run `pdk update`:
---
Gemfile:
optional:
':development':
- gem: 'github_changelog_generator'
git: 'https://github.com/skywinder/github-changelog-generator'
ref: '20ee04ba1234e9e83eb2ffb5056e23d641c7a018'
condition: "Gem::Version.new(RUBY_VERSION.dup) >= Gem::Version.new('2.2.2')"
EOM
end
end

2 changes: 1 addition & 1 deletion metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,6 @@
],
"description": "MySQL module",
"template-url": "https://github.com/puppetlabs/pdk-templates",
"template-ref": "heads/master-0-g34e3266",
"template-ref": "heads/master-0-g6b0d497",
"pdk-version": "1.5.0"
}
8 changes: 4 additions & 4 deletions spec/acceptance/locales_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class { 'mysql::server':
end

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

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

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

it 'displays Japanese error' do
apply_manifest(pp, expect_failures: true) do |r|
execute_manifest(pp, expect_failures: true) do |r|
expect(r.stderr).to match(%r{無効なデータベースのユーザ"name@localhost}i)
end
end
Expand Down
10 changes: 5 additions & 5 deletions spec/acceptance/mysql_backup_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ class { 'mysql::server::backup':
}
MANIFEST
it 'when configuring mysql backups' do
apply_manifest(pp, catch_failures: true)
apply_manifest(pp, catch_failures: true)
execute_manifest(pp, catch_failures: true)
execute_manifest(pp, catch_failures: true)
end
end

Expand Down Expand Up @@ -104,8 +104,8 @@ class { 'mysql::server::backup':
}
MANIFEST
it 'when configuring mysql backups' do
apply_manifest(pp, catch_failures: true)
apply_manifest(pp, catch_failures: true)
execute_manifest(pp, catch_failures: true)
execute_manifest(pp, catch_failures: true)
end
end

Expand Down Expand Up @@ -187,7 +187,7 @@ class { 'mysql::server::backup':
}
MANIFEST
it 'when configuring mysql backups with triggers and routines' do
apply_manifest(pp, catch_failures: true)
execute_manifest(pp, catch_failures: true)
end

it 'runs mysqlbackup.sh with no errors' do
Expand Down
2 changes: 1 addition & 1 deletion spec/acceptance/mysql_helper.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
def pre_run
apply_manifest("class { 'mysql::server': root_password => 'password' }", catch_failures: true)
execute_manifest("class { 'mysql::server': root_password => 'password' }", catch_failures: true)
@mysql_version = (on default, 'mysql --version').output.chomp.match(%r{\d+\.\d+\.\d+})[0]
end

Expand Down
2 changes: 1 addition & 1 deletion spec/acceptance/mysql_server_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ class { 'mysql::server':
let(:pp) { "class { 'mysql::server': root_password => '#{password}' }" }

it 'does not display the password' do
result = apply_manifest(pp, catch_failures: true)
result = execute_manifest(pp, catch_failures: true)
# this does not actually prove anything, as show_diff in the puppet config defaults to false.
expect(result.stdout).not_to match %r{#{password}}
end
Expand Down
2 changes: 1 addition & 1 deletion spec/acceptance/sql_task_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class { 'mysql::server': root_password => 'password' }
MANIFEST

it 'sets up a mysql instance' do
apply_manifest_on(hosts, pp, catch_failures: true)
execute_manifest_on(hosts, pp, catch_failures: true)
end

it 'execute arbitary sql' do
Expand Down
8 changes: 4 additions & 4 deletions spec/acceptance/types/mysql_database_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
class { 'mysql::server': }
MANIFEST
it 'works with no errors' do
apply_manifest(pp, catch_failures: true)
execute_manifest(pp, catch_failures: true)
end
end

Expand All @@ -17,7 +17,7 @@ class { 'mysql::server': }
}
MANIFEST
it 'works without errors' do
apply_manifest(pp, catch_failures: true)
execute_manifest(pp, catch_failures: true)
end

it 'finds the database #stdout' do
Expand All @@ -44,8 +44,8 @@ class { 'mysql::server': }
}
MANIFEST
it 'creates two db of different types idempotently' do
apply_manifest(pp, catch_failures: true)
apply_manifest(pp, catch_changes: true)
execute_manifest(pp, catch_failures: true)
execute_manifest(pp, catch_changes: true)
end

it 'finds latin1 db #stdout' do
Expand Down
Loading