pdqtest 1.9.9beta5 → 1.9.9beta6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/doc/tips_and_tricks.md +1 -0
- data/doc/upgrade_1_2.md +157 -0
- data/exe/pdqtest +21 -31
- data/lib/pdqtest/fastcheck.rb +8 -2
- data/lib/pdqtest/instance.rb +16 -1
- data/lib/pdqtest/pdk.rb +1 -1
- data/lib/pdqtest/skeleton.rb +9 -10
- data/lib/pdqtest/upgrade.rb +25 -12
- data/lib/pdqtest/version.rb +1 -1
- data/res/acceptance/init.bats +2 -1
- data/res/acceptance/init__before.bats +2 -1
- data/res/acceptance/init__setup.sh +1 -0
- data/res/skeleton/.ci_custom.sh +6 -0
- data/res/skeleton/.puppet-lint.rc +1 -0
- data/res/skeleton/.travis.yml +11 -2
- data/res/skeleton/Makefile +14 -13
- data/res/skeleton/bitbucket-pipelines.yml +1 -0
- data/res/skeleton/make.ps1 +1 -0
- data/res/skeleton/spec/fixtures/hiera.yaml +1 -0
- data/res/skeleton/spec/fixtures/hieradata/test.yaml +1 -0
- data/res/templates/examples_init.pp.erb +1 -0
- metadata +4 -3
- data/res/templates/rspec.rb.erb +0 -23
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: e9833010ae1e09cfb08af4e3ce5471a07df1fcc7fd8f674b44399f6f5dc021fc
|
|
4
|
+
data.tar.gz: c5310840d59b593d0bae1d63a2cc61b84f47ccc8cfa6f72afedb5e9f10335e91
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: d2472553063f8d3b17612b7b692a6af350bb7f83090296042778cce7e0e40e0b87a680af4abb98cda3916276643e8bc409e42dc9b46edcd8397a69de538ef07c
|
|
7
|
+
data.tar.gz: bacbb3ffde09c8df33c5d5861a3b51735d830bef228b7d42ff9d00533bbd08bf30b7590b2e0092429c785e881355296a8bd648b9296db715aa3efe359712e646
|
data/doc/tips_and_tricks.md
CHANGED
data/doc/upgrade_1_2.md
ADDED
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
geoff@computer:~/tmp/ssh$ git checkout -b pdk
|
|
2
|
+
Switched to a new branch 'pdk'
|
|
3
|
+
geoff@computer:~/tmp/ssh$ pdqtest init
|
|
4
|
+
Puppet metadata not found at metadata.json - not a valid puppet module
|
|
5
|
+
geoff@computer:~/tmp/ssh$ ls
|
|
6
|
+
total 72K
|
|
7
|
+
4.0K bitbucket-pipelines.yml 4.0K Gemfile 4.0K Makefile 4.0K Rakefile
|
|
8
|
+
4.0K CHANGELOG 4.0K Gemfile.lock 4.0K manifests 4.0K README.md
|
|
9
|
+
4.0K data 4.0K hiera.yaml 4.0K metadata.json 4.0K REFERENCE.md
|
|
10
|
+
4.0K examples 12K LICENSE 4.0K Puppetfile.lock 4.0K spec
|
|
11
|
+
geoff@computer:~/tmp/ssh$ pdqtest init
|
|
12
|
+
Doing one-time upgrade to PDK - Generating fresh set of files...
|
|
13
|
+
pdk (INFO): Creating new module: x
|
|
14
|
+
pdk (INFO): Module 'x' generated at path '/tmp/d20180929-15397-q82464/x', from template 'file:///opt/puppetlabs/pdk/share/cache/pdk-templates.git'.
|
|
15
|
+
pdk (INFO): In your module directory, add classes with the 'pdk new class' command.
|
|
16
|
+
new module x --skip-interview: 😬
|
|
17
|
+
Detected PDQTest 1.x file at spec/spec_helper.rb (will upgrade to PDK)
|
|
18
|
+
Detected PDQTest 1.x file at spec/default_facts.yml (will upgrade to PDK)
|
|
19
|
+
Detected PDQTest 1.x file at .pdkignore (will upgrade to PDK)
|
|
20
|
+
Detected PDQTest 1.x file at Gemfile (will upgrade to PDK)
|
|
21
|
+
Detected PDQTest 1.x file at Rakefile (will upgrade to PDK)
|
|
22
|
+
Detected PDQTest 1.x file at .gitignore (will upgrade to PDK)
|
|
23
|
+
Updated .sync.yml with {".travis.yml"=>{:unmanaged=>true}}
|
|
24
|
+
enabling PDK in metadata.json
|
|
25
|
+
geoff@computer:~/tmp/ssh$ git status
|
|
26
|
+
On branch pdk
|
|
27
|
+
Changes not staged for commit:
|
|
28
|
+
(use "git add <file>..." to update what will be committed)
|
|
29
|
+
(use "git checkout -- <file>..." to discard changes in working directory)
|
|
30
|
+
|
|
31
|
+
modified: .gitignore
|
|
32
|
+
modified: .travis.yml
|
|
33
|
+
modified: Gemfile
|
|
34
|
+
modified: Makefile
|
|
35
|
+
modified: Rakefile
|
|
36
|
+
modified: metadata.json
|
|
37
|
+
modified: spec/spec_helper.rb
|
|
38
|
+
|
|
39
|
+
Untracked files:
|
|
40
|
+
(use "git add <file>..." to include in what will be committed)
|
|
41
|
+
|
|
42
|
+
.Puppetfile.pdqtest
|
|
43
|
+
.librarian/
|
|
44
|
+
.pdkignore
|
|
45
|
+
.pdqtest/
|
|
46
|
+
.puppet-lint.rc
|
|
47
|
+
.sync.yaml
|
|
48
|
+
Puppetfile.lock
|
|
49
|
+
make.ps1
|
|
50
|
+
spec/acceptance/init__before.bats
|
|
51
|
+
spec/acceptance/init__setup.sh
|
|
52
|
+
spec/default_facts.yml
|
|
53
|
+
spec/fixtures/
|
|
54
|
+
|
|
55
|
+
no changes added to commit (use "git add" and/or "git commit -a")
|
|
56
|
+
geoff@computer:~/tmp/ssh$ cat Makefile
|
|
57
|
+
all:
|
|
58
|
+
cd .pdqtest && pwd && bundle exec pdqtest all
|
|
59
|
+
$(MAKE) docs
|
|
60
|
+
|
|
61
|
+
fast:
|
|
62
|
+
cd .pdqtest && pwd && bundle exec pdqtest fast
|
|
63
|
+
|
|
64
|
+
shell:
|
|
65
|
+
cd .pdqtest && pwd && bundle exec pdqtest --keep-container acceptance
|
|
66
|
+
|
|
67
|
+
setup:
|
|
68
|
+
cd .pdqtest && pwd && bundle exec pdqtest setup
|
|
69
|
+
|
|
70
|
+
shellnopuppet:
|
|
71
|
+
cd .pdqtest && pwd && bundle exec pdqtest shell
|
|
72
|
+
|
|
73
|
+
logical:
|
|
74
|
+
cd .pdqtest && pwd && bundle exec pdqtest syntax
|
|
75
|
+
cd .pdqtest && pwd && bundle exec pdqtest rspec
|
|
76
|
+
$(MAKE) docs
|
|
77
|
+
|
|
78
|
+
#nastyhack:
|
|
79
|
+
# # fix for - https://tickets.puppetlabs.com/browse/PDK-1192
|
|
80
|
+
# find vendor -iname '*.pp' -exec rm {} \;
|
|
81
|
+
|
|
82
|
+
pdqtestbundle:
|
|
83
|
+
# Install all gems into _normal world_ bundle so we can use all of em
|
|
84
|
+
cd .pdqtest && pwd && bundle install
|
|
85
|
+
|
|
86
|
+
docs:
|
|
87
|
+
cd .pdqtest && pwd && bundle exec "cd ..&& puppet strings"
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
Gemfile.local:
|
|
91
|
+
echo "[🐌] Creating symlink and running pdk bundle..."
|
|
92
|
+
ln -s Gemfile.project Gemfile.local
|
|
93
|
+
$(MAKE) pdkbundle
|
|
94
|
+
|
|
95
|
+
pdkbundle:
|
|
96
|
+
pdk bundle install
|
|
97
|
+
geoff@computer:~/tmp/ssh$ make pdqtestbundle
|
|
98
|
+
# Install all gems into _normal world_ bundle so we can use all of em
|
|
99
|
+
cd .pdqtest && pwd && bundle install
|
|
100
|
+
/home/geoff/tmp/ssh/.pdqtest
|
|
101
|
+
Resolving dependencies...
|
|
102
|
+
Using rake 12.3.1
|
|
103
|
+
Using bundler 1.16.1
|
|
104
|
+
Using colored 1.2
|
|
105
|
+
Using cri 2.6.1
|
|
106
|
+
Using deep_merge 1.2.1
|
|
107
|
+
Using excon 0.62.0
|
|
108
|
+
Using multi_json 1.13.1
|
|
109
|
+
Using docker-api 1.34.2
|
|
110
|
+
Using nesty 1.0.2
|
|
111
|
+
Using escort 0.4.0
|
|
112
|
+
Using facter 2.5.1
|
|
113
|
+
Using multipart-post 2.0.0
|
|
114
|
+
Using faraday 0.13.1
|
|
115
|
+
Using faraday_middleware 0.12.2
|
|
116
|
+
Using fast_gettext 1.1.2
|
|
117
|
+
Using locale 2.1.2
|
|
118
|
+
Using text 1.3.1
|
|
119
|
+
Using gettext 3.2.9
|
|
120
|
+
Using gettext-setup 0.30
|
|
121
|
+
Using hiera 3.4.5
|
|
122
|
+
Using hocon 1.2.5
|
|
123
|
+
Using httpclient 2.8.3
|
|
124
|
+
Using little-plugger 1.1.4
|
|
125
|
+
Using log4r 1.1.10
|
|
126
|
+
Using logging 2.2.2
|
|
127
|
+
Using minitar 0.6.1
|
|
128
|
+
Using semantic_puppet 1.0.2
|
|
129
|
+
Using puppet_forge 2.2.9
|
|
130
|
+
Using r10k 2.6.4
|
|
131
|
+
Using thor 0.20.0
|
|
132
|
+
Using pdqtest 1.9.9beta6
|
|
133
|
+
Using puppet-resource_api 1.6.0
|
|
134
|
+
Using puppet 6.0.0
|
|
135
|
+
Using puppet-lint 2.3.6
|
|
136
|
+
Using rgen 0.8.2
|
|
137
|
+
Using yard 0.9.16
|
|
138
|
+
Using puppet-strings 2.1.0
|
|
139
|
+
Using puppet-syntax 2.4.1
|
|
140
|
+
Bundle complete! 5 Gemfile dependencies, 38 gems now installed.
|
|
141
|
+
Use `bundle info [gemname]` to see where a bundled gem is installed.
|
|
142
|
+
geoff@computer:~/tmp/ssh$ make
|
|
143
|
+
cd .pdqtest && pwd && bundle exec pdqtest all
|
|
144
|
+
/home/geoff/tmp/ssh/.pdqtest
|
|
145
|
+
pdk (INFO): Using Ruby 2.4.4
|
|
146
|
+
pdk (INFO): Using Puppet 5.5.6
|
|
147
|
+
[✔] Checking metadata syntax (metadata.json tasks/*.json).
|
|
148
|
+
[✖] Checking module metadata style (metadata.json).
|
|
149
|
+
[✔] Checking Puppet manifest syntax (**/**.pp).
|
|
150
|
+
[✔] Checking Puppet manifest style (**/*.pp).
|
|
151
|
+
warning: metadata-json-lint: metadata.json: Dependency puppetlabs-stdlib has an open ended dependency version requirement >= 4.15.0
|
|
152
|
+
validate 'metadata,puppet': 💣
|
|
153
|
+
Error encountered running #<Proc:0x000055595e990ce8@/home/geoff/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/pdqtest-1.9.9beta6/exe/pdqtest:91 (lambda)>
|
|
154
|
+
Overall: 💩
|
|
155
|
+
ABORTED - there are test failures! :(
|
|
156
|
+
Makefile:2: recipe for target 'all' failed
|
|
157
|
+
make: *** [all] Error 1
|
data/exe/pdqtest
CHANGED
|
@@ -23,6 +23,11 @@ require 'pdqtest/fastcheck'
|
|
|
23
23
|
# display help if nothing specified
|
|
24
24
|
ARGV.push('-h') if ARGV.empty?
|
|
25
25
|
|
|
26
|
+
# Setup logging and print out where we were started from because we have to use
|
|
27
|
+
# a separate Gemfile to PDK
|
|
28
|
+
PDQTest::Logger.logger
|
|
29
|
+
$logger.info("Entered PDQTest from #{Dir.pwd}")
|
|
30
|
+
|
|
26
31
|
|
|
27
32
|
Escort::App.create do |app|
|
|
28
33
|
app.version PDQTest::VERSION
|
|
@@ -77,7 +82,7 @@ Escort::App.create do |app|
|
|
|
77
82
|
command.summary "All"
|
|
78
83
|
command.description "Run all tests"
|
|
79
84
|
command.action do |options, arguments|
|
|
80
|
-
|
|
85
|
+
|
|
81
86
|
$logger.level = :debug if options[:global][:options][:debug]
|
|
82
87
|
|
|
83
88
|
PDQTest::Emoji.disable(options[:global][:options][:disable_emoji])
|
|
@@ -102,7 +107,6 @@ Escort::App.create do |app|
|
|
|
102
107
|
command.summary "Fast"
|
|
103
108
|
command.description "Run basic lint/syntax and acceptance tests (skips rspec)"
|
|
104
109
|
command.action do |options, arguments|
|
|
105
|
-
PDQTest::Logger.logger
|
|
106
110
|
$logger.level = :debug if options[:global][:options][:debug]
|
|
107
111
|
|
|
108
112
|
PDQTest::Emoji.disable(options[:global][:options][:disable_emoji])
|
|
@@ -112,6 +116,7 @@ Escort::App.create do |app|
|
|
|
112
116
|
PDQTest::Instance.set_keep_container(options[:global][:options][:keep_container])
|
|
113
117
|
PDQTest::Instance.set_docker_image(options[:global][:options][:image_name])
|
|
114
118
|
|
|
119
|
+
$logger.debug "before chdir #{Dir.pwd}"
|
|
115
120
|
Dir.chdir ".." do
|
|
116
121
|
PDQTest::Core.run([
|
|
117
122
|
lambda {PDQTest::Fastcheck.run},
|
|
@@ -122,21 +127,6 @@ Escort::App.create do |app|
|
|
|
122
127
|
end
|
|
123
128
|
end
|
|
124
129
|
|
|
125
|
-
app.command :rspec do |command|
|
|
126
|
-
command.summary "RSpec"
|
|
127
|
-
command.description "Run the RSpec tests (`pdk test unit` with emojis)"
|
|
128
|
-
command.action do |options, arguments|
|
|
129
|
-
PDQTest::Logger.logger
|
|
130
|
-
$logger.level = :debug if options[:global][:options][:debug]
|
|
131
|
-
|
|
132
|
-
PDQTest::Emoji.disable(options[:global][:options][:disable_emoji])
|
|
133
|
-
Dir.chdir ".." do
|
|
134
|
-
PDQTest::Core.run(lambda {PDQTest::Pdk.run("test unit")})
|
|
135
|
-
end
|
|
136
|
-
end
|
|
137
|
-
end
|
|
138
|
-
|
|
139
|
-
|
|
140
130
|
app.command :acceptance do |command|
|
|
141
131
|
command.summary "Acceptance"
|
|
142
132
|
command.description "Run the acceptance (Docker) tests"
|
|
@@ -149,7 +139,6 @@ Escort::App.create do |app|
|
|
|
149
139
|
)
|
|
150
140
|
end
|
|
151
141
|
command.action do |options, arguments|
|
|
152
|
-
PDQTest::Logger.logger
|
|
153
142
|
$logger.level = :debug if options[:global][:options][:debug]
|
|
154
143
|
|
|
155
144
|
PDQTest::Emoji.disable(options[:global][:options][:disable_emoji])
|
|
@@ -168,10 +157,11 @@ Escort::App.create do |app|
|
|
|
168
157
|
command.summary "Initialise testing"
|
|
169
158
|
command.description "Install skeleton testing configuration into this module"
|
|
170
159
|
command.action do |options, arguments|
|
|
171
|
-
PDQTest::Logger.logger
|
|
172
160
|
$logger.level = :debug if options[:global][:options][:debug]
|
|
173
161
|
|
|
174
162
|
PDQTest::Emoji.disable(options[:global][:options][:disable_emoji])
|
|
163
|
+
# Init isn't run with bundler because we're not in the bundle. because its
|
|
164
|
+
# a system command, we don't need to jump back out of 'our' Gemfile dir
|
|
175
165
|
PDQTest::Skeleton.init
|
|
176
166
|
end
|
|
177
167
|
end
|
|
@@ -188,7 +178,6 @@ Escort::App.create do |app|
|
|
|
188
178
|
)
|
|
189
179
|
end
|
|
190
180
|
command.action do |options, arguments|
|
|
191
|
-
PDQTest::Logger.logger
|
|
192
181
|
$logger.level = :debug if options[:global][:options][:debug]
|
|
193
182
|
|
|
194
183
|
PDQTest::Emoji.disable(options[:global][:options][:disable_emoji])
|
|
@@ -205,24 +194,28 @@ Escort::App.create do |app|
|
|
|
205
194
|
command.summary "Shell"
|
|
206
195
|
command.description "Open a shell inside a docker container identical to the test environment before anything has run"
|
|
207
196
|
command.action do |options, arguments|
|
|
208
|
-
PDQTest::Logger.logger
|
|
209
197
|
$logger.level = :debug if options[:global][:options][:debug]
|
|
210
198
|
|
|
211
199
|
PDQTest::Instance.set_docker_image(options[:global][:options][:image_name])
|
|
212
|
-
|
|
200
|
+
Dir.chdir ".." do
|
|
201
|
+
PDQTest::Instance.shell
|
|
202
|
+
end
|
|
213
203
|
end
|
|
214
204
|
end
|
|
215
205
|
|
|
216
|
-
app.command :
|
|
206
|
+
app.command :logical do |command|
|
|
217
207
|
command.summary "Syntax"
|
|
218
208
|
command.description "Check for syntax errors (`pdk validate metadata,puppet` with emojis)"
|
|
219
209
|
command.action do |options, arguments|
|
|
220
|
-
PDQTest::Logger.logger
|
|
221
210
|
$logger.level = :debug if options[:global][:options][:debug]
|
|
222
211
|
|
|
223
212
|
PDQTest::Emoji.disable(options[:global][:options][:disable_emoji])
|
|
224
213
|
Dir.chdir ".." do
|
|
225
|
-
PDQTest::Core.run(
|
|
214
|
+
PDQTest::Core.run([
|
|
215
|
+
lambda {PDQTest::Pdk.run("validate 'metadata,puppet'")},
|
|
216
|
+
lambda {PDQTest::Puppet.install_modules},
|
|
217
|
+
lambda {PDQTest::Pdk.run("test unit")},
|
|
218
|
+
])
|
|
226
219
|
end
|
|
227
220
|
end
|
|
228
221
|
end
|
|
@@ -232,7 +225,6 @@ Escort::App.create do |app|
|
|
|
232
225
|
command.description "Install the docker container required for testing"
|
|
233
226
|
|
|
234
227
|
command.action do |options, arguments|
|
|
235
|
-
PDQTest::Logger.logger
|
|
236
228
|
$logger.level = :debug if options[:global][:options][:debug]
|
|
237
229
|
|
|
238
230
|
Dir.chdir ".." do
|
|
@@ -249,7 +241,6 @@ Escort::App.create do |app|
|
|
|
249
241
|
command.summary "Info"
|
|
250
242
|
command.description "Print info about this module"
|
|
251
243
|
command.action do |options, arguments|
|
|
252
|
-
PDQTest::Logger.logger
|
|
253
244
|
$logger.level = :debug if options[:global][:options][:debug]
|
|
254
245
|
|
|
255
246
|
Dir.chdir ".." do
|
|
@@ -263,12 +254,11 @@ Escort::App.create do |app|
|
|
|
263
254
|
command.summary "Upgrade"
|
|
264
255
|
command.description "Upgrade the current module to use this version of PDQTest"
|
|
265
256
|
command.action do |options, arguments|
|
|
266
|
-
PDQTest::Logger.logger
|
|
267
257
|
$logger.level = :debug if options[:global][:options][:debug]
|
|
268
258
|
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
259
|
+
# also runs without bundler since we're not in the bundle yet - see notes
|
|
260
|
+
# for `init`
|
|
261
|
+
PDQTest::Upgrade.upgrade
|
|
272
262
|
end
|
|
273
263
|
end
|
|
274
264
|
end
|
data/lib/pdqtest/fastcheck.rb
CHANGED
|
@@ -5,10 +5,16 @@ module PDQTest
|
|
|
5
5
|
module Fastcheck
|
|
6
6
|
|
|
7
7
|
def self.run
|
|
8
|
-
|
|
8
|
+
$logger.debug "inside Fastcheck::run - current dir: #{Dir.pwd}"
|
|
9
|
+
|
|
10
|
+
$logger.debug "Running syntax..."
|
|
11
|
+
status = system("bundle exec 'rake syntax'")
|
|
12
|
+
$logger.debug "...done; result: #{status}"
|
|
9
13
|
|
|
10
14
|
if status
|
|
11
|
-
|
|
15
|
+
$logger.debug "Running lint..."
|
|
16
|
+
status = system("bundle exec 'puppet-lint manifests'")
|
|
17
|
+
$logger.debug "...done; result: #{status}"
|
|
12
18
|
end
|
|
13
19
|
|
|
14
20
|
PDQTest::Emoji.partial_status(status, "fastcheck (syntax+lint)")
|
data/lib/pdqtest/instance.rb
CHANGED
|
@@ -54,7 +54,22 @@ module PDQTest
|
|
|
54
54
|
# process each supported OS
|
|
55
55
|
test_platforms = @@image_name || Docker::acceptance_test_images
|
|
56
56
|
$logger.info "Acceptance test on #{test_platforms}..."
|
|
57
|
-
test_platforms.
|
|
57
|
+
test_platforms.reject { |image_name|
|
|
58
|
+
reject = false
|
|
59
|
+
if Util.is_windows
|
|
60
|
+
if image_name !~ /windows/
|
|
61
|
+
$logger.info "Skipping test image #{image_name} (requires Linux)"
|
|
62
|
+
reject = true
|
|
63
|
+
end
|
|
64
|
+
else
|
|
65
|
+
if image_name =~ /windows/
|
|
66
|
+
$logger.info "Skipping test image #{image_name} (requires Windows)"
|
|
67
|
+
reject = true
|
|
68
|
+
end
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
reject
|
|
72
|
+
}.each { |image_name|
|
|
58
73
|
$logger.info "--- start test with #{image_name} ---"
|
|
59
74
|
@@active_container = PDQTest::Docker::new_container(image_name, @@privileged)
|
|
60
75
|
$logger.info "alive, running tests"
|
data/lib/pdqtest/pdk.rb
CHANGED
|
@@ -9,7 +9,7 @@ module PDQTest
|
|
|
9
9
|
# inside `pdk bundle` to work, nor could I figure out how to load the PDK
|
|
10
10
|
# libraries from the "inside"
|
|
11
11
|
module Pdk
|
|
12
|
-
SYNC_YML = '.sync.
|
|
12
|
+
SYNC_YML = '.sync.yml'
|
|
13
13
|
|
|
14
14
|
# Copy these values from PDK generated metadata to module metadata
|
|
15
15
|
PDK_TAGS = [
|
data/lib/pdqtest/skeleton.rb
CHANGED
|
@@ -17,7 +17,7 @@ module PDQTest
|
|
|
17
17
|
ACCEPTANCE_DIR = File.join(SPEC_DIR, 'acceptance')
|
|
18
18
|
SKELETON_DIR = 'skeleton'
|
|
19
19
|
EXAMPLES_DIR = 'examples'
|
|
20
|
-
HIERA_DIR =
|
|
20
|
+
HIERA_DIR = File.join(SPEC_DIR, 'fixtures', 'hieradata')
|
|
21
21
|
HIERA_YAML = 'hiera.yaml'
|
|
22
22
|
HIERA_TEST = 'test.yaml'
|
|
23
23
|
PDK_FILES = [
|
|
@@ -36,20 +36,20 @@ module PDQTest
|
|
|
36
36
|
# Every time we `pdqtest upgrade`, update .sync.yml (merges)
|
|
37
37
|
SYNC_YML_CONTENT = {
|
|
38
38
|
".travis.yml" => {
|
|
39
|
-
"unmanaged"
|
|
39
|
+
"unmanaged" => true,
|
|
40
|
+
},
|
|
41
|
+
".gitignore" => {
|
|
42
|
+
"paths" => [
|
|
43
|
+
".Puppetfile.pdqtest",
|
|
44
|
+
],
|
|
40
45
|
}
|
|
41
|
-
}
|
|
46
|
+
}.freeze
|
|
42
47
|
|
|
43
48
|
|
|
44
49
|
def self.should_replace_file(target, skeleton)
|
|
45
50
|
target_hash = Digest::SHA256.file target
|
|
46
51
|
skeleton_hash = Digest::SHA256.file skeleton
|
|
47
|
-
|
|
48
|
-
puts target
|
|
49
|
-
puts skeleton
|
|
50
|
-
puts target_hash
|
|
51
|
-
puts skeleton_hash
|
|
52
|
-
puts Digest::SHA256.file "/nothere"
|
|
52
|
+
|
|
53
53
|
should = (target_hash != skeleton_hash)
|
|
54
54
|
$logger.debug "should replace: #{should}"
|
|
55
55
|
|
|
@@ -81,7 +81,6 @@ puts target
|
|
|
81
81
|
|
|
82
82
|
# vars is a hash of variables that can be accessed in template
|
|
83
83
|
def self.install_template(target, template_file, vars)
|
|
84
|
-
example_file = File.join(EXAMPLES_DIR, template_file)
|
|
85
84
|
if ! File.exists?(target)
|
|
86
85
|
template = File.read(Util::resource_path(File.join('templates', template_file)))
|
|
87
86
|
content = ERB.new(template, nil, '-').result(binding)
|
data/lib/pdqtest/upgrade.rb
CHANGED
|
@@ -8,19 +8,32 @@ module PDQTest
|
|
|
8
8
|
GEM_ATTRIB_REGEXP = /^\s*:\w+/
|
|
9
9
|
|
|
10
10
|
GEMS = {
|
|
11
|
-
'
|
|
12
|
-
|
|
13
|
-
|
|
11
|
+
# 'gemsource' => {
|
|
12
|
+
# 'line' => "source ENV['GEM_SOURCE'] || 'https://rubygems.org'",
|
|
13
|
+
# 'added' => false,
|
|
14
|
+
# },
|
|
15
|
+
'pdqtest' => {
|
|
16
|
+
'line' => "gem 'pdqtest', '#{PDQTest::VERSION}'",
|
|
17
|
+
'added' => false,
|
|
18
|
+
},
|
|
19
|
+
'puppet-strings' => {
|
|
20
|
+
'line' => "gem 'puppet-strings'",
|
|
21
|
+
'added' => false,
|
|
14
22
|
},
|
|
15
|
-
'puppet
|
|
16
|
-
'line'
|
|
23
|
+
'puppet' => {
|
|
24
|
+
'line' => "gem 'puppet'",
|
|
17
25
|
'added' => false,
|
|
18
26
|
},
|
|
19
|
-
'puppet'
|
|
20
|
-
'line'
|
|
27
|
+
'puppet-lint' => {
|
|
28
|
+
'line' => "gem 'puppet-lint'",
|
|
21
29
|
'added' => false,
|
|
22
30
|
},
|
|
23
|
-
|
|
31
|
+
'puppet-syntax' => {
|
|
32
|
+
'line' => "gem 'puppet-syntax'",
|
|
33
|
+
'added' => false,
|
|
34
|
+
},
|
|
35
|
+
|
|
36
|
+
}.freeze
|
|
24
37
|
|
|
25
38
|
|
|
26
39
|
# upgrade a module to the latest version of PDQTest
|
|
@@ -37,11 +50,11 @@ module PDQTest
|
|
|
37
50
|
FileUtils.touch(GEMFILE)
|
|
38
51
|
end
|
|
39
52
|
File.open(GEMFILE, 'r') do |f|
|
|
40
|
-
f.each_line{ |line|
|
|
53
|
+
f.each_line { |line|
|
|
41
54
|
if line =~ GEM_REGEXP
|
|
42
55
|
# a gem stanza
|
|
43
|
-
processing_gem =
|
|
44
|
-
if GEMS.
|
|
56
|
+
processing_gem = Regexp.last_match(2)
|
|
57
|
+
if GEMS.key?(processing_gem)
|
|
45
58
|
# fixup one of our monitored gems as needed, mark
|
|
46
59
|
# this as being a gem that is being updated so
|
|
47
60
|
# that we can kill any multi-line attributes
|
|
@@ -53,7 +66,7 @@ module PDQTest
|
|
|
53
66
|
t_file.puts line
|
|
54
67
|
updating_gem = false
|
|
55
68
|
end
|
|
56
|
-
elsif updating_gem
|
|
69
|
+
elsif updating_gem && line =~ GEM_ATTRIB_REGEXP
|
|
57
70
|
# do nothing - remove the multi-line attributes
|
|
58
71
|
else
|
|
59
72
|
# anything else... (esp comments)
|
data/lib/pdqtest/version.rb
CHANGED
data/res/acceptance/init.bats
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
# *File originally created by PDQTest*
|
|
1
2
|
# BATS test file to run after executing 'examples/init.pp' with puppet.
|
|
2
3
|
#
|
|
3
|
-
# For more info on BATS see https://github.com/
|
|
4
|
+
# For more info on BATS see https://github.com/bats-core/bats-core
|
|
4
5
|
|
|
5
6
|
# Tests are really easy! just the exit status of running a command...
|
|
6
7
|
@test "addition using bc" {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
# *File originally created by PDQTest*
|
|
1
2
|
# BATS test file to run before executing 'examples/init.pp' with puppet.
|
|
2
3
|
#
|
|
3
|
-
# For more info on BATS see https://github.com/
|
|
4
|
+
# For more info on BATS see https://github.com/bats-core/bats-core
|
|
4
5
|
|
|
5
6
|
# Tests are really easy! just the exit status of running a command...
|
|
6
7
|
@test "addition using bc" {
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
# *File originally created by PDQTest*
|
|
3
|
+
# This is your place to add custom CI actions without modifying travis.yml
|
|
4
|
+
# PDQTest will create this initial file for you but only so you know where
|
|
5
|
+
# add your stuff. We won't change this file unless you run `pdqtest init`
|
|
6
|
+
# again
|
data/res/skeleton/.travis.yml
CHANGED
|
@@ -1,9 +1,16 @@
|
|
|
1
1
|
# .travis.yml
|
|
2
2
|
#
|
|
3
|
+
# *File originally created by PDQTest*
|
|
4
|
+
#
|
|
3
5
|
# To debug travis locally:
|
|
4
6
|
# https://docs.travis-ci.com/user/common-build-problems/#Running-a-Container-Based-Docker-Image-Locally
|
|
5
7
|
---
|
|
6
8
|
sudo: false
|
|
9
|
+
|
|
10
|
+
# Don't process the PDK Gemfile - causes big problems!
|
|
11
|
+
gemfile: .pdqtest/Gemfile
|
|
12
|
+
|
|
13
|
+
bundler_args: --path .pdqtest
|
|
7
14
|
language: ruby
|
|
8
15
|
services:
|
|
9
16
|
- docker
|
|
@@ -13,9 +20,11 @@ before_install:
|
|
|
13
20
|
- sudo dpkg -i puppet5-release-trusty.deb
|
|
14
21
|
- sudo apt-get update
|
|
15
22
|
- sudo apt install -y pdk
|
|
16
|
-
|
|
17
|
-
|
|
23
|
+
|
|
24
|
+
# travis itself does the bundle install for us, so we are ready to run now
|
|
18
25
|
script:
|
|
26
|
+
- sh .ci_custom.sh
|
|
27
|
+
- make setup
|
|
19
28
|
- make
|
|
20
29
|
rvm:
|
|
21
30
|
- 2.4.1
|
data/res/skeleton/Makefile
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
# *File originally created by PDQTest*
|
|
1
2
|
all:
|
|
2
3
|
cd .pdqtest && bundle exec pdqtest all
|
|
3
4
|
$(MAKE) docs
|
|
@@ -5,6 +6,9 @@ all:
|
|
|
5
6
|
fast:
|
|
6
7
|
cd .pdqtest && bundle exec pdqtest fast
|
|
7
8
|
|
|
9
|
+
acceptance:
|
|
10
|
+
cd .pdqtest && bundle exec pdqtest acceptance
|
|
11
|
+
|
|
8
12
|
shell:
|
|
9
13
|
cd .pdqtest && bundle exec pdqtest --keep-container acceptance
|
|
10
14
|
|
|
@@ -15,24 +19,21 @@ shellnopuppet:
|
|
|
15
19
|
cd .pdqtest && bundle exec pdqtest shell
|
|
16
20
|
|
|
17
21
|
logical:
|
|
18
|
-
cd .pdqtest && bundle exec pdqtest
|
|
19
|
-
cd .pdqtest && bundle exec pdqtest rspec
|
|
22
|
+
cd .pdqtest && bundle exec pdqtest logical
|
|
20
23
|
$(MAKE) docs
|
|
21
24
|
|
|
22
|
-
|
|
23
|
-
# fix for - https://tickets.puppetlabs.com/browse/PDK-1192
|
|
24
|
-
find vendor -iname '*.pp' -exec rm {} \;
|
|
25
|
-
|
|
26
|
-
bundle:
|
|
25
|
+
pdqtestbundle:
|
|
27
26
|
# Install all gems into _normal world_ bundle so we can use all of em
|
|
28
|
-
cd .pdqtest && bundle install
|
|
29
|
-
|
|
30
|
-
Gemfile.local:
|
|
31
|
-
echo "[🐌] Creating symlink and running pdk bundle..."
|
|
32
|
-
ln -s Gemfile.project Gemfile.local
|
|
27
|
+
cd .pdqtest && pwd && bundle install
|
|
33
28
|
|
|
34
29
|
docs:
|
|
35
|
-
cd .pdqtest && bundle exec "cd ..&& puppet strings"
|
|
30
|
+
cd .pdqtest && pwd && bundle exec "cd ..&& puppet strings"
|
|
36
31
|
|
|
37
32
|
|
|
33
|
+
Gemfile.local:
|
|
34
|
+
echo "[🐌] Creating symlink and running pdk bundle..."
|
|
35
|
+
ln -s Gemfile.project Gemfile.local
|
|
36
|
+
$(MAKE) pdkbundle
|
|
38
37
|
|
|
38
|
+
pdkbundle:
|
|
39
|
+
pdk bundle install
|
data/res/skeleton/make.ps1
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: pdqtest
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.9.
|
|
4
|
+
version: 1.9.9beta6
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Geoff Williams
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2018-09-
|
|
11
|
+
date: 2018-09-29 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: bundler
|
|
@@ -197,6 +197,7 @@ files:
|
|
|
197
197
|
- doc/test_generation.md
|
|
198
198
|
- doc/tips_and_tricks.md
|
|
199
199
|
- doc/troubleshooting.md
|
|
200
|
+
- doc/upgrade_1_2.md
|
|
200
201
|
- doc/upgrading.md
|
|
201
202
|
- doc/windows.md
|
|
202
203
|
- docker_images/centos/Dockerfile
|
|
@@ -224,6 +225,7 @@ files:
|
|
|
224
225
|
- res/acceptance/init.bats
|
|
225
226
|
- res/acceptance/init__before.bats
|
|
226
227
|
- res/acceptance/init__setup.sh
|
|
228
|
+
- res/skeleton/.ci_custom.sh
|
|
227
229
|
- res/skeleton/.puppet-lint.rc
|
|
228
230
|
- res/skeleton/.travis.yml
|
|
229
231
|
- res/skeleton/Makefile
|
|
@@ -232,7 +234,6 @@ files:
|
|
|
232
234
|
- res/skeleton/spec/fixtures/hiera.yaml
|
|
233
235
|
- res/skeleton/spec/fixtures/hieradata/test.yaml
|
|
234
236
|
- res/templates/examples_init.pp.erb
|
|
235
|
-
- res/templates/rspec.rb.erb
|
|
236
237
|
homepage: https://github.com/DeclarativeSystems/pdqtest
|
|
237
238
|
licenses:
|
|
238
239
|
- Apache-2.0
|
data/res/templates/rspec.rb.erb
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
require 'spec_helper'
|
|
2
|
-
require 'puppet_factset'
|
|
3
|
-
describe '<%= vars[:classname] %>' do
|
|
4
|
-
# Uncomment only the factset you would like to use for these tests
|
|
5
|
-
<%
|
|
6
|
-
require 'puppet_factset'
|
|
7
|
-
default_factset = 'CentOS-7.0-64'
|
|
8
|
-
PuppetFactset.factsets.each { |factset|
|
|
9
|
-
-%>
|
|
10
|
-
<% if factset != default_factset -%># <% end -%>system_name = '<%= factset %>'
|
|
11
|
-
<% } -%>
|
|
12
|
-
let :facts do
|
|
13
|
-
PuppetFactset::factset_hash(system_name)
|
|
14
|
-
end
|
|
15
|
-
|
|
16
|
-
context 'compiles ok' do
|
|
17
|
-
it { should compile }
|
|
18
|
-
end
|
|
19
|
-
|
|
20
|
-
context 'with default values for all parameters' do
|
|
21
|
-
it { should contain_class('<%= vars[:classname] %>') }
|
|
22
|
-
end
|
|
23
|
-
end
|