Skip to content

Commit 7e07d07

Browse files
committed
Add acceptance testing, esure=>absent, simplfify
* Add acceptance testing * Add support for `ensure=>absent` to completely remove us from the system * Simplify puppet logic somewhat * Other misc fixes, see below Tickets fixed: * albatrossflavour#54 * albatrossflavour#57 * albatrossflavour#58 * albatrossflavour#66 * albatrossflavour#70
1 parent cb22290 commit 7e07d07

31 files changed

+614
-167
lines changed

.fixtures.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
# This file can be used to install module depdencies for unit testing
2-
# See https://github.com/puppetlabs/puppetlabs_spec_helper#using-fixtures for details
31
---
42
fixtures:
53
forge_modules:
6-
# stdlib: "puppetlabs/stdlib"
4+
stdlib:
5+
repo: puppetlabs-stdlib
6+
ref: 5.0.0

.gitignore

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,4 @@
2222
/convert_report.txt
2323
/update_report.txt
2424
.DS_Store
25-
*.bak
25+
.Puppetfile.pdqtest

.gitlab-ci.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ before_script:
1616
- bundle install --without system_tests --path vendor/bundle --jobs $(nproc)
1717

1818
parallel_spec-Ruby 2.1.9-Puppet ~> 4.0:
19-
stage: syntax
19+
stage: unit
2020
image: ruby:2.1.9
2121
script:
2222
- bundle exec rake parallel_spec
@@ -32,7 +32,7 @@ syntax lint metadata_lint check:symlinks check:git_ignore check:dot_underscore c
3232
PUPPET_GEM_VERSION: '~> 5.5'
3333

3434
parallel_spec-Ruby 2.4.4-Puppet ~> 5.5:
35-
stage: syntax
35+
stage: unit
3636
image: ruby:2.4.4
3737
script:
3838
- bundle exec rake parallel_spec

.pdqtest/Gemfile

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
source 'https://rubygems.org'
2+
gem 'pdqtest', '~> 1.9.9beta5'
3+
gem 'puppet'
4+
gem 'puppet-strings'

.pdqtest/Gemfile.lock

+92
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
GEM
2+
remote: https://rubygems.org/
3+
specs:
4+
colored (1.2)
5+
cri (2.6.1)
6+
colored (~> 1.2)
7+
deep_merge (1.2.1)
8+
docker-api (1.34.2)
9+
excon (>= 0.47.0)
10+
multi_json
11+
escort (0.4.0)
12+
nesty
13+
excon (0.62.0)
14+
facter (2.5.1)
15+
faraday (0.13.1)
16+
multipart-post (>= 1.2, < 3)
17+
faraday_middleware (0.12.2)
18+
faraday (>= 0.7.4, < 1.0)
19+
fast_gettext (1.1.2)
20+
gettext (3.2.9)
21+
locale (>= 2.0.5)
22+
text (>= 1.3.0)
23+
gettext-setup (0.30)
24+
fast_gettext (~> 1.1.0)
25+
gettext (>= 3.0.2)
26+
locale
27+
hiera (3.4.5)
28+
hocon (1.2.5)
29+
httpclient (2.8.3)
30+
little-plugger (1.1.4)
31+
locale (2.1.2)
32+
log4r (1.1.10)
33+
logging (2.2.2)
34+
little-plugger (~> 1.1)
35+
multi_json (~> 1.10)
36+
minitar (0.6.1)
37+
multi_json (1.13.1)
38+
multipart-post (2.0.0)
39+
nesty (1.0.2)
40+
pdqtest (1.9.9beta5)
41+
deep_merge (~> 1.2)
42+
docker-api (= 1.34.2)
43+
escort (= 0.4.0)
44+
logging (~> 2.2)
45+
minitar (= 0.6.1)
46+
r10k (= 2.6.4)
47+
rake (= 12.3.1)
48+
thor (~> 0.19)
49+
puppet (6.0.0)
50+
facter (> 2.0.1, < 4)
51+
fast_gettext (~> 1.1.2)
52+
hiera (>= 3.2.1, < 4)
53+
httpclient (~> 2.8)
54+
locale (~> 2.1)
55+
multi_json (~> 1.10)
56+
puppet-resource_api (~> 1.5)
57+
semantic_puppet (~> 1.0)
58+
puppet-resource_api (1.6.0)
59+
hocon (>= 1.0)
60+
puppet-strings (2.1.0)
61+
rgen
62+
yard (~> 0.9.5)
63+
puppet_forge (2.2.9)
64+
faraday (>= 0.9.0, < 0.14.0)
65+
faraday_middleware (>= 0.9.0, < 0.13.0)
66+
gettext-setup (~> 0.11)
67+
minitar
68+
semantic_puppet (~> 1.0)
69+
r10k (2.6.4)
70+
colored (= 1.2)
71+
cri (~> 2.6.1)
72+
gettext-setup (~> 0.5)
73+
log4r (= 1.1.10)
74+
multi_json (~> 1.10)
75+
puppet_forge (~> 2.2.8)
76+
rake (12.3.1)
77+
rgen (0.8.2)
78+
semantic_puppet (1.0.2)
79+
text (1.3.1)
80+
thor (0.20.0)
81+
yard (0.9.16)
82+
83+
PLATFORMS
84+
ruby
85+
86+
DEPENDENCIES
87+
pdqtest (~> 1.9.9beta5)
88+
puppet
89+
puppet-strings
90+
91+
BUNDLED WITH
92+
1.16.1

.puppet-lint.rc

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
--fail-on-warnings
2+
--no-double_quoted_strings-check
3+
--no-80chars-check
4+
--no-variable_scope-check
5+
--no-quoted_booleans-check

.rubocop.yml

+3-5
Original file line numberDiff line numberDiff line change
@@ -44,14 +44,12 @@ Style/FormatStringToken:
4444
Description: Following the main puppet project's style, prefer the simpler template
4545
tokens over annotated ones.
4646
EnforcedStyle: template
47-
Style/HashSyntax:
48-
Enabled: false
4947
Style/Lambda:
5048
Description: Prefer the keyword for easier discoverability.
5149
EnforcedStyle: literal
5250
Style/RegexpLiteral:
5351
Description: Community preference. See https://github.com/voxpupuli/modulesync_config/issues/168
54-
EnforcedStyle: mixed
52+
EnforcedStyle: percent_r
5553
Style/TernaryParentheses:
5654
Description: Checks for use of parentheses around ternary conditions. Enforce parentheses
5755
on complex expressions for better readability, but seriously consider breaking
@@ -84,6 +82,8 @@ Style/StringMethods:
8482
Enabled: true
8583
Layout/EndOfLine:
8684
Enabled: false
85+
Layout/IndentHeredoc:
86+
Enabled: false
8787
Metrics/AbcSize:
8888
Enabled: false
8989
Metrics/BlockLength:
@@ -116,5 +116,3 @@ Style/IfUnlessModifier:
116116
Enabled: false
117117
Style/SymbolProc:
118118
Enabled: false
119-
Style/RedundantReturn:
120-
Enabled: false

.sync.yaml

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
---
2+
".travis.yml":
3+
:unmanaged: true

.travis.yml

+19-37
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,27 @@
1+
# .travis.yml
2+
#
3+
# To debug travis locally:
4+
# https://docs.travis-ci.com/user/common-build-problems/#Running-a-Container-Based-Docker-Image-Locally
15
---
26
sudo: false
3-
dist: trusty
7+
8+
# Don't process the PDK Gemfile - causes big problems!
9+
gemfile: .pdqtest/Gemfile
10+
11+
bundler_args: --path .pdqtest
412
language: ruby
13+
services:
14+
- docker
515
cache: bundler
616
before_install:
7-
- bundle -v
8-
- rm -f Gemfile.lock
9-
- gem update --system
10-
- gem --version
11-
- bundle -v
17+
- wget https://apt.puppetlabs.com/puppet5-release-trusty.deb
18+
- sudo dpkg -i puppet5-release-trusty.deb
19+
- sudo apt-get update
20+
- sudo apt install -y pdk
21+
22+
# travis itself does the bundle isntall for us, so we are ready to run now
1223
script:
13-
- 'bundle exec rake $CHECK'
14-
bundler_args: --without system_tests
24+
- make setup
25+
- make
1526
rvm:
1627
- 2.4.1
17-
env:
18-
global:
19-
- BEAKER_PUPPET_COLLECTION=puppet5 PUPPET_GEM_VERSION="~> 5.0"
20-
matrix:
21-
fast_finish: true
22-
include:
23-
-
24-
env: CHECK="syntax lint metadata_lint check:symlinks check:git_ignore check:dot_underscore check:test_file rubocop"
25-
-
26-
env: CHECK=parallel_spec
27-
-
28-
env: PUPPET_GEM_VERSION="~> 4.0" CHECK=parallel_spec
29-
rvm: 2.1.9
30-
branches:
31-
only:
32-
- master
33-
- development
34-
- /^v\d/
35-
notifications:
36-
email: true
37-
deploy:
38-
provider: puppetforge
39-
user: puppet
40-
password:
41-
secure: ""
42-
on:
43-
tags: true
44-
all_branches: true
45-
condition: "$DEPLOY_TO_FORGE = yes"

Makefile

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
all:
2+
cd .pdqtest && pwd && bundle exec pdqtest all
3+
$(MAKE) docs
4+
5+
fast:
6+
cd .pdqtest && pwd && bundle exec pdqtest fast
7+
8+
shell:
9+
cd .pdqtest && pwd && bundle exec pdqtest --keep-container acceptance
10+
11+
setup:
12+
cd .pdqtest && pwd && bundle exec pdqtest setup
13+
14+
shellnopuppet:
15+
cd .pdqtest && pwd && bundle exec pdqtest shell
16+
17+
logical:
18+
cd .pdqtest && pwd && bundle exec pdqtest syntax
19+
cd .pdqtest && pwd && bundle exec pdqtest rspec
20+
$(MAKE) docs
21+
22+
#nastyhack:
23+
# # fix for - https://tickets.puppetlabs.com/browse/PDK-1192
24+
# find vendor -iname '*.pp' -exec rm {} \;
25+
26+
pdqtestbundle:
27+
# Install all gems into _normal world_ bundle so we can use all of em
28+
cd .pdqtest && pwd && bundle install
29+
30+
docs:
31+
cd .pdqtest && pwd && bundle exec "cd ..&& puppet strings"
32+
33+
34+
Gemfile.local:
35+
echo "[🐌] Creating symlink and running pdk bundle..."
36+
ln -s Gemfile.project Gemfile.local
37+
$(MAKE) pdkbundle
38+
39+
pdkbundle:
40+
pdk bundle install

Rakefile

+69
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,75 @@
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?
5+
6+
def changelog_user
7+
return unless Rake.application.top_level_tasks.include? "changelog"
8+
returnVal = nil || JSON.load(File.read('metadata.json'))['author']
9+
raise "unable to find the changelog_user in .sync.yml, or the author in metadata.json" if returnVal.nil?
10+
puts "GitHubChangelogGenerator user:#{returnVal}"
11+
returnVal
12+
end
13+
14+
def changelog_project
15+
return unless Rake.application.top_level_tasks.include? "changelog"
16+
returnVal = nil || JSON.load(File.read('metadata.json'))['name']
17+
raise "unable to find the changelog_project in .sync.yml or the name in metadata.json" if returnVal.nil?
18+
puts "GitHubChangelogGenerator project:#{returnVal}"
19+
returnVal
20+
end
21+
22+
def changelog_future_release
23+
return unless Rake.application.top_level_tasks.include? "changelog"
24+
returnVal = JSON.load(File.read('metadata.json'))['version']
25+
raise "unable to find the future_release (version) in metadata.json" if returnVal.nil?
26+
puts "GitHubChangelogGenerator future_release:#{returnVal}"
27+
returnVal
28+
end
429

530
PuppetLint.configuration.send('disable_relative')
631

32+
if Bundler.rubygems.find_name('github_changelog_generator').any?
33+
GitHubChangelogGenerator::RakeTask.new :changelog do |config|
34+
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?
35+
config.user = "#{changelog_user}"
36+
config.project = "#{changelog_project}"
37+
config.future_release = "#{changelog_future_release}"
38+
config.exclude_labels = ['maintenance']
39+
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)."
40+
config.add_pr_wo_labels = true
41+
config.issues = false
42+
config.merge_prefix = "### UNCATEGORIZED PRS; GO LABEL THEM"
43+
config.configure_sections = {
44+
"Changed" => {
45+
"prefix" => "### Changed",
46+
"labels" => ["backwards-incompatible"],
47+
},
48+
"Added" => {
49+
"prefix" => "### Added",
50+
"labels" => ["feature", "enhancement"],
51+
},
52+
"Fixed" => {
53+
"prefix" => "### Fixed",
54+
"labels" => ["bugfix"],
55+
},
56+
}
57+
end
58+
else
59+
desc 'Generate a Changelog from GitHub'
60+
task :changelog do
61+
raise <<EOM
62+
The changelog tasks depends on unreleased features of the github_changelog_generator gem.
63+
Please manually add it to your .sync.yml for now, and run `pdk update`:
64+
---
65+
Gemfile:
66+
optional:
67+
':development':
68+
- gem: 'github_changelog_generator'
69+
git: 'https://github.com/skywinder/github-changelog-generator'
70+
ref: '20ee04ba1234e9e83eb2ffb5056e23d641c7a018'
71+
condition: "Gem::Version.new(RUBY_VERSION.dup) >= Gem::Version.new('2.2.2')"
72+
EOM
73+
end
74+
end
75+

bitbucket-pipelines.yml

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
image: ruby:2.3.5
2+
3+
pipelines:
4+
default:
5+
- step:
6+
caches:
7+
- bundler
8+
script:
9+
- ruby --version
10+
- bundler --version
11+
- bundle install
12+
- make logical
13+
14+
definitions:
15+
caches:
16+
bundler: vendor/bundle

examples/blackout.pp

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# @PDQTest
2+
3+
exec { 'run the update script and make sure it fails':
4+
command => 'bash -c "printf \'{}\' | /testcase/tasks/patch_server.rb > /tmp/output.txt ; true"',
5+
path => '/bin:/usr/bin',
6+
creates => "/tmp/output.txt",
7+
}

examples/init.pp

+15-1
Original file line numberDiff line numberDiff line change
@@ -1 +1,15 @@
1-
include os_patching
1+
# @PDQTest
2+
class { 'os_patching':
3+
patch_window => 'Week3',
4+
reboot_override => 'smart',
5+
blackout_windows => {
6+
'End of year change freeze' => {
7+
'start' => '2018-12-15T00:00:00+10:00',
8+
'end' => '2019-01-15T23:59:59+10:00',
9+
},
10+
'End of DST' => {
11+
'start' => '2019-04-07T00:00:00+10:00',
12+
'end' => '2019-04-08T23:59:59+10:00',
13+
}
14+
},
15+
}

0 commit comments

Comments
 (0)