pdqtest 1.9.9beta8 → 1.9.9beta9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -0
- data/exe/pdqtest +22 -0
- data/lib/pdqtest/docker.rb +12 -72
- data/lib/pdqtest/execution.rb +82 -0
- data/lib/pdqtest/inplace.rb +58 -0
- data/lib/pdqtest/instance.rb +51 -25
- data/lib/pdqtest/puppet.rb +30 -29
- data/lib/pdqtest/upgrade.rb +1 -1
- data/lib/pdqtest/version.rb +1 -1
- data/res/skeleton/bitbucket-pipelines.yml +1 -1
- metadata +3 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 438426faf365d5ee59ac7b075dec4bef83048a08e4d231bf9e069f8b70374194
|
4
|
+
data.tar.gz: b8d07f4d78e6e4f4721fcbe6a9e34e7e5ca51bd59e11c4f55fd1765b548b571f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 66d94c1d45b76ab56e30dc7ab1aa26b0f32727f12232b04b83b308d65cc25328bae044ca1e4941c927b08d9680b6d91a335bed6e8213306aff073ff7ba66e811
|
7
|
+
data.tar.gz: cd0acb639f47015da1c6d23e1431ac512a07585c429fbf8ad5a9336d23f90f72a45808921337c584b938f924f917b46523f6438f4129624b1822f08c906afc98
|
data/README.md
CHANGED
@@ -32,6 +32,7 @@ PDQTest 2.0 new features:
|
|
32
32
|
* [PDK Support](doc/pdk.md)
|
33
33
|
* [Windows support](doc/windows.md)
|
34
34
|
* [PDQTest 1.x -> 2.x Upgrade guide](doc/upgrade_1_2.md)
|
35
|
+
* [Inplace execution](https://github.com/declarativesystems/pdqtest/issues/34)
|
35
36
|
|
36
37
|
## PDQTest Manual
|
37
38
|
1. [Installation](doc/installation.md)
|
data/exe/pdqtest
CHANGED
@@ -76,6 +76,20 @@ Escort::App.create do |app|
|
|
76
76
|
:type => :boolean,
|
77
77
|
:default => false,
|
78
78
|
)
|
79
|
+
|
80
|
+
opts.opt(:inplace,
|
81
|
+
'Run puppet in place on *THIS* system -- WARNING! this is likely to destroy your computer',
|
82
|
+
:long => '--inplace',
|
83
|
+
:type => :boolean,
|
84
|
+
:default => false,
|
85
|
+
)
|
86
|
+
|
87
|
+
opts.opt(:inplace_enable,
|
88
|
+
'Enable inplace mode to make changes (safety/debugging switch)',
|
89
|
+
:long => '--inplace-enable',
|
90
|
+
:type => :boolean,
|
91
|
+
:default => false,
|
92
|
+
)
|
79
93
|
end
|
80
94
|
|
81
95
|
app.command :all do |command|
|
@@ -85,9 +99,12 @@ Escort::App.create do |app|
|
|
85
99
|
|
86
100
|
$logger.level = :debug if options[:global][:options][:debug]
|
87
101
|
|
102
|
+
|
88
103
|
PDQTest::Emoji.disable(options[:global][:options][:disable_emoji])
|
89
104
|
PDQTest::Puppet.skip_second_run(options[:global][:options][:skip_idempotency])
|
90
105
|
|
106
|
+
PDQTest::Inplace.set_enable options[:global][:options][:inplace_enable]
|
107
|
+
PDQTest::Instance.set_inplace options[:global][:options][:inplace]
|
91
108
|
PDQTest::Instance.set_privileged(options[:global][:options][:privileged])
|
92
109
|
PDQTest::Instance.set_keep_container(options[:global][:options][:keep_container])
|
93
110
|
PDQTest::Instance.set_docker_image(options[:global][:options][:image_name])
|
@@ -112,6 +129,8 @@ Escort::App.create do |app|
|
|
112
129
|
PDQTest::Emoji.disable(options[:global][:options][:disable_emoji])
|
113
130
|
PDQTest::Puppet.skip_second_run(options[:global][:options][:skip_idempotency])
|
114
131
|
|
132
|
+
PDQTest::Inplace.set_enable options[:global][:options][:inplace_enable]
|
133
|
+
PDQTest::Instance.set_inplace options[:global][:options][:inplace]
|
115
134
|
PDQTest::Instance.set_privileged(options[:global][:options][:privileged])
|
116
135
|
PDQTest::Instance.set_keep_container(options[:global][:options][:keep_container])
|
117
136
|
PDQTest::Instance.set_docker_image(options[:global][:options][:image_name])
|
@@ -143,6 +162,9 @@ Escort::App.create do |app|
|
|
143
162
|
|
144
163
|
PDQTest::Emoji.disable(options[:global][:options][:disable_emoji])
|
145
164
|
PDQTest::Puppet.skip_second_run(options[:global][:options][:skip_idempotency])
|
165
|
+
|
166
|
+
PDQTest::Inplace.set_enable options[:global][:options][:inplace_enable]
|
167
|
+
PDQTest::Instance.set_inplace options[:global][:options][:inplace]
|
146
168
|
PDQTest::Instance.set_privileged(options[:global][:options][:privileged])
|
147
169
|
PDQTest::Instance.set_docker_image(options[:global][:options][:image_name])
|
148
170
|
PDQTest::Instance.set_keep_container(options[:global][:options][:keep_container])
|
data/lib/pdqtest/docker.rb
CHANGED
@@ -1,12 +1,13 @@
|
|
1
1
|
require 'pdqtest/util'
|
2
2
|
require 'pdqtest/puppet'
|
3
|
+
require 'pdqtest/execution'
|
3
4
|
|
4
5
|
module PDQTest
|
5
6
|
module Docker
|
6
7
|
OUT = 0
|
7
8
|
ERR = 1
|
8
9
|
STATUS = 2
|
9
|
-
|
10
|
+
|
10
11
|
IMAGES = {
|
11
12
|
:DEFAULT => 'declarativesystems/pdqtest-centos:2018-09-15-0',
|
12
13
|
:UBUNTU => 'declarativesystems/pdqtest-ubuntu:2018-09-15-0',
|
@@ -43,6 +44,7 @@ module PDQTest
|
|
43
44
|
|
44
45
|
# convenience lookup for container testcase dir since its used all over the
|
45
46
|
# place
|
47
|
+
# fixme! - belongs somewhere else now...
|
46
48
|
def self.test_dir
|
47
49
|
CONTAINER_PATHS[Util.host_platform][:testcase]
|
48
50
|
end
|
@@ -67,38 +69,16 @@ module PDQTest
|
|
67
69
|
volumes
|
68
70
|
end
|
69
71
|
|
72
|
+
def self._exec_real(container, real_c)
|
73
|
+
$logger.debug("exec_real: running docker command: #{real_c}")
|
74
|
+
_res = container.exec(real_c, tty: true)
|
70
75
|
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
res[STATUS]=0
|
78
|
-
res[REAL_CMD]=[]
|
79
|
-
|
80
|
-
Array(cmd).each do |c|
|
81
|
-
real_c = Util.wrap_cmd(c)
|
82
|
-
res[REAL_CMD] << real_c
|
83
|
-
$logger.debug "Executing: #{real_c}"
|
84
|
-
_res = container.exec(real_c, tty: true)
|
85
|
-
|
86
|
-
if c =~ /robocopy/
|
87
|
-
# robocopy exit codes break the status check we do later on - we have
|
88
|
-
# to manually 'fix' them here
|
89
|
-
if _res[STATUS] < 4
|
90
|
-
_res[STATUS] = 0
|
91
|
-
end
|
92
|
-
end
|
93
|
-
res[STATUS] += _res[STATUS]
|
94
|
-
res[OUT] += _res[OUT]
|
95
|
-
res[ERR] += _res[ERR]
|
96
|
-
|
97
|
-
# non zero status from something thats not puppet apply is probably an error
|
98
|
-
if _res[STATUS] != 0 && !(c =~ /pupet apply|bats/)
|
99
|
-
$logger.warn "non-zero exit status: #{_res[STATUS]} from #{real_c}: #{_res[OUT]} #{_res[ERR]}"
|
100
|
-
end
|
101
|
-
end
|
76
|
+
# docker returns an array of stuff - convert to hash with labels
|
77
|
+
res = {
|
78
|
+
:OUT => _res[OUT],
|
79
|
+
:ERR => _res[ERR],
|
80
|
+
:STATUS => _res[STATUS],
|
81
|
+
}
|
102
82
|
|
103
83
|
res
|
104
84
|
end
|
@@ -218,45 +198,5 @@ module PDQTest
|
|
218
198
|
container.delete(:force => true)
|
219
199
|
end
|
220
200
|
|
221
|
-
def self.exec_status(res, puppet=false)
|
222
|
-
if puppet
|
223
|
-
# 0 == ok, no changes
|
224
|
-
# 2 == ok, changes made
|
225
|
-
allowable_values = [0,2]
|
226
|
-
else
|
227
|
-
allowable_values = [0]
|
228
|
-
end
|
229
|
-
status = allowable_values.include?(res[STATUS])
|
230
|
-
end
|
231
|
-
|
232
|
-
def self.exec_out(res)
|
233
|
-
res[OUT]
|
234
|
-
end
|
235
|
-
|
236
|
-
def self.exec_err(res)
|
237
|
-
res[ERR]
|
238
|
-
end
|
239
|
-
|
240
|
-
def self.log_out(res)
|
241
|
-
exec_out(res).each { |l|
|
242
|
-
# Output comes back as an array and needs to be iterated or we lose our
|
243
|
-
# ansi formatting
|
244
|
-
$logger.info l.chomp
|
245
|
-
}
|
246
|
-
end
|
247
|
-
|
248
|
-
def self.log_all(res)
|
249
|
-
log_err(res)
|
250
|
-
log_out(res)
|
251
|
-
end
|
252
|
-
|
253
|
-
def self.log_err(res)
|
254
|
-
exec_err(res).each { |l|
|
255
|
-
# Output comes back as an array and needs to be iterated or we lose our
|
256
|
-
# ansi formatting
|
257
|
-
$logger.error l.chomp
|
258
|
-
}
|
259
|
-
end
|
260
|
-
|
261
201
|
end
|
262
202
|
end
|
@@ -0,0 +1,82 @@
|
|
1
|
+
require 'pdqtest/puppet'
|
2
|
+
module PDQTest
|
3
|
+
module Execution
|
4
|
+
|
5
|
+
def self.exec_out(res)
|
6
|
+
res[:OUT]
|
7
|
+
end
|
8
|
+
|
9
|
+
def self.exec_err(res)
|
10
|
+
res[:ERR]
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.log_out(res)
|
14
|
+
exec_out(res).each { |l|
|
15
|
+
# Output comes back as an array and needs to be iterated or we lose our
|
16
|
+
# ansi formatting
|
17
|
+
$logger.info l.chomp
|
18
|
+
}
|
19
|
+
end
|
20
|
+
|
21
|
+
def self.log_all(res)
|
22
|
+
log_err(res)
|
23
|
+
log_out(res)
|
24
|
+
end
|
25
|
+
|
26
|
+
def self.log_err(res)
|
27
|
+
exec_err(res).each { |l|
|
28
|
+
# Output comes back as an array and needs to be iterated or we lose our
|
29
|
+
# ansi formatting
|
30
|
+
$logger.error l.chomp
|
31
|
+
}
|
32
|
+
end
|
33
|
+
|
34
|
+
def self.exec(cc, container, cmd)
|
35
|
+
status = 0
|
36
|
+
res = {}
|
37
|
+
|
38
|
+
res[:OUT]=[]
|
39
|
+
res[:ERR]=[]
|
40
|
+
res[:STATUS]=0
|
41
|
+
res[:REAL_CMD]=[]
|
42
|
+
|
43
|
+
Array(cmd).each do |c|
|
44
|
+
real_c = Util.wrap_cmd(c)
|
45
|
+
res[:REAL_CMD] << real_c
|
46
|
+
$logger.debug "Executing: #{real_c}"
|
47
|
+
_res = cc._exec_real(container, real_c)
|
48
|
+
|
49
|
+
if c =~ /robocopy/
|
50
|
+
# robocopy exit codes break the status check we do later on - we have
|
51
|
+
# to manually 'fix' them here
|
52
|
+
if _res[:STATUS] < 4
|
53
|
+
_res[:STATUS] = 0
|
54
|
+
end
|
55
|
+
end
|
56
|
+
res[:STATUS] += _res[:STATUS]
|
57
|
+
res[:OUT] += _res[:OUT]
|
58
|
+
res[:ERR] += _res[:ERR]
|
59
|
+
|
60
|
+
# non zero status from something thats not puppet apply is probably an error
|
61
|
+
if _res[:STATUS] != 0 && !(c =~ /pupet apply|bats/)
|
62
|
+
$logger.warn "non-zero exit status: #{_res[:STATUS]} from #{real_c}: #{_res[:OUT]} #{_res[:ERR]}"
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
res
|
67
|
+
end
|
68
|
+
|
69
|
+
# convert exit code (integer) to boolean: true == good; false == bad
|
70
|
+
def self.exec_status(res, puppet=false)
|
71
|
+
if puppet
|
72
|
+
# 0 == ok, no changes
|
73
|
+
# 2 == ok, changes made
|
74
|
+
allowable_values = [0,2]
|
75
|
+
else
|
76
|
+
allowable_values = [0]
|
77
|
+
end
|
78
|
+
status = allowable_values.include?(res[:STATUS])
|
79
|
+
end
|
80
|
+
|
81
|
+
end
|
82
|
+
end
|
@@ -0,0 +1,58 @@
|
|
1
|
+
require 'pdqtest/puppet'
|
2
|
+
require 'open3'
|
3
|
+
module PDQTest
|
4
|
+
module Inplace
|
5
|
+
INPLACE_IMAGE = "__INPLACE__"
|
6
|
+
@@enable = false
|
7
|
+
|
8
|
+
def self.set_enable(enable)
|
9
|
+
if enable
|
10
|
+
$logger.warn <<~END
|
11
|
+
PDQTest run with --inplace --inplace-enable will run Puppet on
|
12
|
+
*this* computer!
|
13
|
+
|
14
|
+
You have 5 seconds to abort, press ctrl+c now
|
15
|
+
END
|
16
|
+
sleep(5)
|
17
|
+
end
|
18
|
+
@@enable = enable
|
19
|
+
end
|
20
|
+
|
21
|
+
def self._exec_real(container, real_c)
|
22
|
+
res = {}
|
23
|
+
|
24
|
+
res[:OUT] = []
|
25
|
+
res[:ERR] = []
|
26
|
+
res[:STATUS] = 0
|
27
|
+
$logger.debug("exec_real: running inplace command: #{real_c}")
|
28
|
+
if @@enable
|
29
|
+
# must splat to avoid "wrong first argument"
|
30
|
+
Open3.popen3(*real_c) do |stdin, stdout, stderr, wait_thr|
|
31
|
+
res[:OUT] = stdout.read.split("\n")
|
32
|
+
res[:ERR] = stderr.read.split("\n")
|
33
|
+
# Process::Status object returned from `.value`
|
34
|
+
res[:STATUS] = wait_thr.value.exitstatus
|
35
|
+
end
|
36
|
+
else
|
37
|
+
$logger.info "didn't run command, reason: DISABLED"
|
38
|
+
end
|
39
|
+
$logger.debug("...result: #{res[:STATUS]}")
|
40
|
+
|
41
|
+
res
|
42
|
+
end
|
43
|
+
|
44
|
+
def self.id
|
45
|
+
INPLACE_IMAGE
|
46
|
+
end
|
47
|
+
|
48
|
+
def self.new_container(image_name, privileged)
|
49
|
+
FileUtils.rm_f Docker.test_dir if Dir.exist? Docker.test_dir
|
50
|
+
|
51
|
+
FileUtils.cp_r(File.join(Dir.pwd, "."), Docker.test_dir)
|
52
|
+
end
|
53
|
+
|
54
|
+
def self.cleanup_container(container)
|
55
|
+
FileUtils.rm_f Docker.test_dir
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
data/lib/pdqtest/instance.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
require 'docker-api'
|
2
2
|
require 'pdqtest/puppet'
|
3
3
|
require 'pdqtest/docker'
|
4
|
+
require 'pdqtest/inplace'
|
4
5
|
require 'escort'
|
5
6
|
|
6
7
|
module PDQTest
|
@@ -9,6 +10,7 @@ module PDQTest
|
|
9
10
|
@@active_container = nil
|
10
11
|
@@image_name = false
|
11
12
|
@@privileged = false
|
13
|
+
@@inplace = false
|
12
14
|
|
13
15
|
def self.get_active_container
|
14
16
|
@@active_container
|
@@ -39,6 +41,37 @@ module PDQTest
|
|
39
41
|
@@privileged
|
40
42
|
end
|
41
43
|
|
44
|
+
def self.set_inplace(inplace)
|
45
|
+
@@inplace = inplace
|
46
|
+
end
|
47
|
+
|
48
|
+
def self.get_inplace()
|
49
|
+
@@inplace
|
50
|
+
end
|
51
|
+
|
52
|
+
|
53
|
+
def self.get_acceptance_test_images
|
54
|
+
test_platforms = @@image_name || PDQTest::Docker.acceptance_test_images
|
55
|
+
filtered_test_platforms = test_platforms.reject do |image_name|
|
56
|
+
reject = false
|
57
|
+
if Util.is_windows
|
58
|
+
if image_name !~ /windows/
|
59
|
+
$logger.info "Skipping test image #{image_name} (requires Linux)"
|
60
|
+
reject = true
|
61
|
+
end
|
62
|
+
else
|
63
|
+
if image_name =~ /windows/
|
64
|
+
$logger.info "Skipping test image #{image_name} (requires Windows)"
|
65
|
+
reject = true
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
reject
|
70
|
+
end
|
71
|
+
|
72
|
+
filtered_test_platforms
|
73
|
+
end
|
74
|
+
|
42
75
|
def self.run(example=nil)
|
43
76
|
# needed to prevent timeouts from container.exec()
|
44
77
|
Excon.defaults[:write_timeout] = 10000
|
@@ -48,38 +81,29 @@ module PDQTest
|
|
48
81
|
# remove reference to any previous test container
|
49
82
|
@@active_container = nil
|
50
83
|
|
51
|
-
if PDQTest::Puppet
|
84
|
+
if PDQTest::Puppet.find_examples.empty?
|
52
85
|
$logger.info "No acceptance tests found, annotate examples with #{PDQTest::Puppet.setting(:magic_marker)} to make some"
|
53
86
|
else
|
54
|
-
# process each supported OS
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
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|
|
87
|
+
# process each supported OS and figure out what controller container to use
|
88
|
+
if @@inplace
|
89
|
+
test_platforms = [PDQTest::Inplace::INPLACE_IMAGE]
|
90
|
+
cc = PDQTest::Inplace
|
91
|
+
else
|
92
|
+
test_platforms = get_acceptance_test_images
|
93
|
+
cc = PDQTest::Docker
|
94
|
+
end
|
95
|
+
|
96
|
+
test_platforms.each { |image_name|
|
73
97
|
$logger.info "--- start test with #{image_name} ---"
|
74
|
-
@@active_container =
|
98
|
+
@@active_container = cc.new_container(image_name, @@privileged)
|
75
99
|
$logger.info "alive, running tests"
|
76
|
-
status &= PDQTest::Puppet.run(@@active_container, example)
|
100
|
+
status &= PDQTest::Puppet.run(cc, @@active_container, example)
|
77
101
|
|
78
|
-
if @@keep_container
|
102
|
+
if @@keep_container && ! @@inplace
|
79
103
|
$logger.info "finished build, container #{@@active_container.id} left on system"
|
80
104
|
$logger.info " docker exec -ti #{@@active_container.id} #{Util.shell} "
|
81
105
|
else
|
82
|
-
|
106
|
+
cc.cleanup_container(@@active_container)
|
83
107
|
@@active_container = nil
|
84
108
|
end
|
85
109
|
|
@@ -97,7 +121,9 @@ module PDQTest
|
|
97
121
|
$logger.info "Opening a shell in #{image_name}"
|
98
122
|
@@active_container = PDQTest::Docker::new_container(image_name, @@privileged)
|
99
123
|
|
100
|
-
|
124
|
+
# Shell is always executed with docker - if you want a new shell for
|
125
|
+
# in-place, your already in it ;-)
|
126
|
+
PDQTest::Execution.exec(PDQTest::Docker, @@active_container, PDQTest::Puppet.setup)
|
101
127
|
|
102
128
|
# In theory I should be able to get something like the code below to
|
103
129
|
# redirect all input streams and give a makeshift interactive shell, howeve
|
data/lib/pdqtest/puppet.rb
CHANGED
@@ -260,13 +260,13 @@ module PDQTest
|
|
260
260
|
t.gsub(EXAMPLES_DIR + '/','').gsub('.pp','')
|
261
261
|
end
|
262
262
|
|
263
|
-
def self.xats_test(container, example, suffix)
|
263
|
+
def self.xats_test(cc, container, example, suffix)
|
264
264
|
testcase = Util.joinp(XATS_TESTS, test_basename(example) + suffix)
|
265
265
|
if File.exists?(testcase)
|
266
266
|
$logger.info "*** #{setting(:name)} test **** #{setting(:test_cmd)} #{testcase}"
|
267
|
-
res = PDQTest::
|
268
|
-
status = PDQTest::
|
269
|
-
PDQTest::
|
267
|
+
res = PDQTest::Execution.exec(cc, container, "cd #{Docker.test_dir} ; #{setting(:test_cmd)} #{testcase}")
|
268
|
+
status = PDQTest::Execution.exec_status(res)
|
269
|
+
PDQTest::Execution.log_all(res)
|
270
270
|
@@bats_executed << testcase
|
271
271
|
else
|
272
272
|
$logger.info "no #{suffix} tests for #{example} (should be at #{testcase})"
|
@@ -276,19 +276,20 @@ module PDQTest
|
|
276
276
|
status
|
277
277
|
end
|
278
278
|
|
279
|
-
def self.setup_test(container, example)
|
279
|
+
def self.setup_test(cc, container, example)
|
280
280
|
setup_script = Util.joinp(XATS_TESTS, test_basename(example)) + setting(:setup_suffix)
|
281
281
|
if File.exists?(setup_script)
|
282
282
|
script = File.read(setup_script)
|
283
283
|
$logger.debug "setup script: \n #{script}"
|
284
284
|
if script.strip.empty?
|
285
285
|
$logger.info "skipping empty setup script at #{setup_script}"
|
286
|
+
status = true
|
286
287
|
else
|
287
288
|
$logger.info "Setting up test for #{example}"
|
288
289
|
|
289
|
-
res = PDQTest::
|
290
|
-
status = PDQTest::
|
291
|
-
PDQTest::
|
290
|
+
res = PDQTest::Execution.exec(cc, container, script)
|
291
|
+
status = PDQTest::Execution.exec_status(res)
|
292
|
+
PDQTest::Execution.log_all(res)
|
292
293
|
end
|
293
294
|
@@setup_executed << setup_script
|
294
295
|
else
|
@@ -299,42 +300,42 @@ module PDQTest
|
|
299
300
|
status
|
300
301
|
end
|
301
302
|
|
302
|
-
def self.run_example(container, example)
|
303
|
+
def self.run_example(cc, container, example)
|
303
304
|
$logger.info "testing #{example}"
|
304
305
|
status = false
|
305
306
|
|
306
|
-
if setup_test(container, example)
|
307
|
+
if setup_test(cc, container, example)
|
307
308
|
|
308
309
|
# see if we should run a bats test before running puppet
|
309
|
-
if xats_test(container, example, setting(:before_suffix))
|
310
|
+
if xats_test(cc, container, example, setting(:before_suffix))
|
310
311
|
|
311
312
|
# run puppet apply - 1st run
|
312
|
-
res = PDQTest::
|
313
|
-
PDQTest::
|
314
|
-
if PDQTest::
|
313
|
+
res = PDQTest::Execution.exec(cc, container, puppet_apply(example))
|
314
|
+
PDQTest::Execution.log_out(res)
|
315
|
+
if PDQTest::Execution.exec_status(res, true) # allow 2 as exit status
|
315
316
|
|
316
317
|
if @@skip_second_run
|
317
318
|
$logger.info "Skipping idempotency check as you requested..."
|
318
319
|
|
319
320
|
# check the system right now since puppet ran OK once
|
320
|
-
status = xats_test(container, example, setting(:after_suffix))
|
321
|
+
status = xats_test(cc, container, example, setting(:after_suffix))
|
321
322
|
else
|
322
323
|
# run puppet apply - 2nd run (check for idempotencey/no more changes)
|
323
|
-
res = PDQTest::
|
324
|
-
PDQTest::
|
324
|
+
res = PDQTest::Execution.exec(cc, container, puppet_apply(example))
|
325
|
+
PDQTest::Execution.log_out(res)
|
325
326
|
|
326
327
|
# run the bats test if nothing failed yet
|
327
|
-
if PDQTest::
|
328
|
-
status = xats_test(container, example, setting(:after_suffix))
|
328
|
+
if PDQTest::Execution.exec_status(res) # only allow 0 as exit status
|
329
|
+
status = xats_test(cc, container, example, setting(:after_suffix))
|
329
330
|
else
|
330
331
|
$logger.error "Not idempotent: #{example}"
|
331
332
|
end
|
332
333
|
end
|
333
334
|
else
|
334
|
-
$logger.error "First puppet run of #{example} failed (status: #{res[
|
335
|
+
$logger.error "First puppet run of #{example} failed (status: #{res[:STATUS]})"
|
335
336
|
end
|
336
337
|
else
|
337
|
-
$logger.error "#{setting(:name)} tests to run before #{example} failed
|
338
|
+
$logger.error "#{setting(:name)} tests to run before #{example} failed"
|
338
339
|
end
|
339
340
|
else
|
340
341
|
$logger.error "Setup script for #{example} failed (see previous error)"
|
@@ -343,7 +344,7 @@ module PDQTest
|
|
343
344
|
status
|
344
345
|
end
|
345
346
|
|
346
|
-
def self.run(container, example=nil)
|
347
|
+
def self.run(cc, container, example=nil)
|
347
348
|
# we must always have ./spec/fixtures/modules because we need to create a
|
348
349
|
# symlink back to the main module inside here...
|
349
350
|
# (spec/fixtures/modules/foo -> /testcase)
|
@@ -357,14 +358,14 @@ module PDQTest
|
|
357
358
|
status = true
|
358
359
|
$logger.info "...running container setup"
|
359
360
|
setup_start = Time.now
|
360
|
-
res = PDQTest::
|
361
|
+
res = PDQTest::Execution.exec(cc, container, setup)
|
361
362
|
setup_end = Time.now
|
362
|
-
status &= PDQTest::
|
363
|
+
status &= PDQTest::Execution.exec_status(res)
|
363
364
|
if Util.is_windows
|
364
365
|
# write a script to allow user to update modules
|
365
366
|
$logger.info "wasted #{((setup_end - setup_start))} seconds of your life on windows tax"
|
366
367
|
File.open("refresh.ps1", 'w') do |file|
|
367
|
-
res[
|
368
|
+
res[:REAL_CMD].each do |c|
|
368
369
|
file.puts("#{c[0]} #{c[1]} \"#{c[2]}\"")
|
369
370
|
end
|
370
371
|
end
|
@@ -376,14 +377,14 @@ module PDQTest
|
|
376
377
|
if status
|
377
378
|
$logger.info "...run tests"
|
378
379
|
if example
|
379
|
-
status &= run_example(container, example)
|
380
|
+
status &= run_example(cc, container, example)
|
380
381
|
if ! status
|
381
382
|
$logger.error "Example #{example} failed!"
|
382
383
|
end
|
383
384
|
else
|
384
385
|
find_examples.each { |e|
|
385
386
|
if status
|
386
|
-
status &= run_example(container, e)
|
387
|
+
status &= run_example(cc, container, e)
|
387
388
|
if ! status
|
388
389
|
$logger.error "Example #{e} failed! - skipping rest of tests"
|
389
390
|
end
|
@@ -391,8 +392,8 @@ module PDQTest
|
|
391
392
|
}
|
392
393
|
end
|
393
394
|
else
|
394
|
-
PDQTest::
|
395
|
-
$logger.error "Error running puppet setup, see previous error, command was: #{res[
|
395
|
+
PDQTest::Execution.log_all(res)
|
396
|
+
$logger.error "Error running puppet setup, see previous error, command was: #{res[:REAL_CMD]}"
|
396
397
|
end
|
397
398
|
|
398
399
|
PDQTest::Emoji.partial_status(status, 'Puppet')
|
data/lib/pdqtest/upgrade.rb
CHANGED
data/lib/pdqtest/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
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.9beta9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Geoff Williams
|
@@ -211,7 +211,9 @@ files:
|
|
211
211
|
- lib/pdqtest/core.rb
|
212
212
|
- lib/pdqtest/docker.rb
|
213
213
|
- lib/pdqtest/emoji.rb
|
214
|
+
- lib/pdqtest/execution.rb
|
214
215
|
- lib/pdqtest/fastcheck.rb
|
216
|
+
- lib/pdqtest/inplace.rb
|
215
217
|
- lib/pdqtest/instance.rb
|
216
218
|
- lib/pdqtest/logger.rb
|
217
219
|
- lib/pdqtest/pdk.rb
|