cem_acpt 0.2.0 → 0.2.3
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/Gemfile.lock +1 -1
- data/cem_acpt.gemspec +3 -3
- data/lib/cem_acpt/platform/gcp/cmd.rb +0 -43
- data/lib/cem_acpt/test_runner/runner.rb +0 -18
- data/lib/cem_acpt/utils.rb +16 -14
- data/lib/cem_acpt/version.rb +1 -1
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a727f17ebb1ca0b67caa2380338d4e0f4c51b97f30833d0ff2def0b0d6679688
|
4
|
+
data.tar.gz: 6395e670075384a22f2935882ba999ad950065933d94d30f6b9cf5095f9a07dd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3ad2d225b4d57f3d0e8b60c4539c8f3a0680fb390a4a56d04ce4f4f694a1f377832782c2e20ddf7d99e8814a029eb61713c6c64d6dd35f9628ac21cde3c1efb8
|
7
|
+
data.tar.gz: 704d7fac67463d27db15e9d32999de5166e9c4769e8b8c28f3fb26a28e61a8e7e94aca5ba0ef42b1e9095766bd5b39f4edc4ec96786ff508038f51d03f0f20ff
|
data/Gemfile.lock
CHANGED
data/cem_acpt.gemspec
CHANGED
@@ -5,14 +5,14 @@ require_relative 'lib/cem_acpt/version'
|
|
5
5
|
Gem::Specification.new do |spec|
|
6
6
|
spec.name = 'cem_acpt'
|
7
7
|
spec.version = CemAcpt::VERSION
|
8
|
-
spec.authors = ['
|
9
|
-
spec.email = ['
|
8
|
+
spec.authors = ['puppetlabs']
|
9
|
+
spec.email = ['abide-team@puppet.com']
|
10
10
|
|
11
11
|
spec.summary = 'CEM Acceptance Tests'
|
12
12
|
spec.description = 'Litmus-like library focusing on CEM Acceptance Tests'
|
13
13
|
spec.homepage = 'https://github.com/puppetlabs/cem_acpt'
|
14
14
|
spec.license = 'proprietary'
|
15
|
-
spec.required_ruby_version = Gem::Requirement.new('>= 2.
|
15
|
+
spec.required_ruby_version = Gem::Requirement.new('>= 2.6.0')
|
16
16
|
|
17
17
|
spec.metadata['homepage_uri'] = spec.homepage
|
18
18
|
spec.metadata['source_code_uri'] = 'https://github.com/puppetlabs/cem_acpt'
|
@@ -94,17 +94,10 @@ module CemAcpt::Platform::Gcp
|
|
94
94
|
begin
|
95
95
|
::JSON.parse(stdout)
|
96
96
|
rescue ::JSON::ParserError
|
97
|
-
<<<<<<< HEAD
|
98
|
-
stdout
|
99
|
-
end
|
100
|
-
else
|
101
|
-
stdout
|
102
|
-
=======
|
103
97
|
stdout.chomp
|
104
98
|
end
|
105
99
|
else
|
106
100
|
stdout.chomp
|
107
|
-
>>>>>>> 489757f (Fixes for race conditions)
|
108
101
|
end
|
109
102
|
end
|
110
103
|
|
@@ -239,20 +232,12 @@ module CemAcpt::Platform::Gcp
|
|
239
232
|
end
|
240
233
|
|
241
234
|
def apply_manifest(instance_name, manifest, opts = {})
|
242
|
-
<<<<<<< HEAD
|
243
|
-
keep_manifest_file = opts[:apply][:keep_manifest_file] || false
|
244
|
-
with_temp_manifest_file(manifest, keep_manifest_file: keep_manifest_file) do |tf|
|
245
|
-
upload_temp_manifest(instance_name, tf.path, opts: opts)
|
246
|
-
end
|
247
|
-
apply_cmd = ["#{opts[:puppet_path]} apply /tmp/acpt_manifest.pp"]
|
248
|
-
=======
|
249
235
|
unless opts[:apply][:no_upload]
|
250
236
|
with_temp_manifest_file(manifest) do |tf|
|
251
237
|
upload_temp_manifest(instance_name, tf.path, remote_path: '/tmp/acpt_manifest.pp', opts: opts)
|
252
238
|
end
|
253
239
|
end
|
254
240
|
apply_cmd = [opts[:puppet_path], 'apply', '/tmp/acpt_manifest.pp']
|
255
|
-
>>>>>>> 489757f (Fixes for race conditions)
|
256
241
|
apply_cmd << '--trace' if opts[:apply][:trace]
|
257
242
|
apply_cmd << "--hiera_config=#{opts[:apply][:hiera_config]}" if opts[:apply][:hiera_config]
|
258
243
|
apply_cmd << '--debug' if opts[:apply][:debug]
|
@@ -276,11 +261,7 @@ module CemAcpt::Platform::Gcp
|
|
276
261
|
cmd_parts.join(' ')
|
277
262
|
end
|
278
263
|
|
279
|
-
<<<<<<< HEAD
|
280
|
-
def with_temp_manifest_file(manifest, file_name: 'acpt_manifest', keep_manifest_file: false)
|
281
|
-
=======
|
282
264
|
def with_temp_manifest_file(manifest, file_name: 'acpt_manifest')
|
283
|
-
>>>>>>> 489757f (Fixes for race conditions)
|
284
265
|
require 'tempfile'
|
285
266
|
tf = Tempfile.new(file_name)
|
286
267
|
tf.write(manifest)
|
@@ -288,25 +269,12 @@ module CemAcpt::Platform::Gcp
|
|
288
269
|
begin
|
289
270
|
yield tf
|
290
271
|
ensure
|
291
|
-
<<<<<<< HEAD
|
292
|
-
if keep_manifest_file
|
293
|
-
@manifest_file_exists = true
|
294
|
-
else
|
295
|
-
tf.unlink
|
296
|
-
@manifest_file_exists = false
|
297
|
-
end
|
298
|
-
=======
|
299
272
|
tf.unlink
|
300
|
-
>>>>>>> 489757f (Fixes for race conditions)
|
301
273
|
end
|
302
274
|
end
|
303
275
|
|
304
276
|
def upload_temp_manifest(instance_name, local_path, remote_path: '/tmp/acpt_manifest.pp', opts: {})
|
305
|
-
<<<<<<< HEAD
|
306
|
-
scp_upload(instance_name, local_path, remote_path, opts: opts[:ssh_opts]) unless @manifest_file_exists
|
307
|
-
=======
|
308
277
|
scp_upload(instance_name, local_path, remote_path, opts: opts[:ssh_opts]) unless opts[:apply][:no_upload]
|
309
|
-
>>>>>>> 489757f (Fixes for race conditions)
|
310
278
|
end
|
311
279
|
|
312
280
|
def gcloud_ssh(instance_name, command, ignore_command_errors: false)
|
@@ -322,15 +290,7 @@ module CemAcpt::Platform::Gcp
|
|
322
290
|
# Default options for Net::SSH
|
323
291
|
def default_ssh_opts
|
324
292
|
{
|
325
|
-
<<<<<<< HEAD
|
326
|
-
verify_host_key: :never,
|
327
|
-
keys: [ssh_key],
|
328
|
-
kex: ['diffie-hellman-group-exchange-sha256'], # ecdh algos cause jruby to shit the bed
|
329
|
-
keys_only: true,
|
330
|
-
config: false,
|
331
|
-
=======
|
332
293
|
auth_methods: ['publickey'],
|
333
|
-
>>>>>>> 489757f (Fixes for race conditions)
|
334
294
|
check_host_ip: false,
|
335
295
|
compression: true,
|
336
296
|
config: false,
|
@@ -341,10 +301,7 @@ module CemAcpt::Platform::Gcp
|
|
341
301
|
port: 22,
|
342
302
|
user: user_name,
|
343
303
|
user_known_hosts_file: File.join(ENV['HOME'], '.ssh', 'acpt_test_known_hosts'),
|
344
|
-
<<<<<<< HEAD
|
345
|
-
=======
|
346
304
|
verify_host_key: :never,
|
347
|
-
>>>>>>> 489757f (Fixes for race conditions)
|
348
305
|
}
|
349
306
|
end
|
350
307
|
|
@@ -42,11 +42,6 @@ module CemAcpt
|
|
42
42
|
@module_pkg_path = @context.module_package_path
|
43
43
|
@node_exists = false
|
44
44
|
@run_result = CemAcpt::TestRunner::RunnerResult.new(@node, debug: @debug_mode)
|
45
|
-
<<<<<<< HEAD
|
46
|
-
validate!
|
47
|
-
end
|
48
|
-
|
49
|
-
=======
|
50
45
|
@completed_steps = []
|
51
46
|
validate!
|
52
47
|
end
|
@@ -61,7 +56,6 @@ module CemAcpt
|
|
61
56
|
destroy unless step_sym == :destroy
|
62
57
|
end
|
63
58
|
|
64
|
-
>>>>>>> 489757f (Fixes for race conditions)
|
65
59
|
# Executes test suite steps
|
66
60
|
def start
|
67
61
|
async_info("Starting test suite for #{@node.node_name}", log_prefix('RUNNER'))
|
@@ -85,23 +79,11 @@ module CemAcpt
|
|
85
79
|
|
86
80
|
private
|
87
81
|
|
88
|
-
<<<<<<< HEAD
|
89
|
-
def run_step(step_sym)
|
90
|
-
send(step_sym)
|
91
|
-
rescue StandardError => e
|
92
|
-
raise CemAcpt::TestRunner::RunnerStepError.new(step_sym, e)
|
93
|
-
end
|
94
|
-
|
95
|
-
=======
|
96
|
-
>>>>>>> 489757f (Fixes for race conditions)
|
97
82
|
def step_error_logging(err)
|
98
83
|
prefix = err.respond_to?(:step) ? log_prefix(err.step.capitalize) : log_prefix('RUNNER')
|
99
84
|
fatal_msg = ["runner failed: #{err.message}"]
|
100
85
|
async_fatal(fatal_msg, prefix)
|
101
|
-
<<<<<<< HEAD
|
102
|
-
=======
|
103
86
|
async_debug("Completed steps: #{@completed_steps}", prefix)
|
104
|
-
>>>>>>> 489757f (Fixes for race conditions)
|
105
87
|
async_debug("Failed runner backtrace:\n#{err.backtrace.join("\n")}", prefix)
|
106
88
|
async_debug("Failed runner test data: #{@node.test_data}", prefix)
|
107
89
|
end
|
data/lib/cem_acpt/utils.rb
CHANGED
@@ -18,7 +18,7 @@ module CemAcpt
|
|
18
18
|
# File-related utilities
|
19
19
|
module File
|
20
20
|
def self.set_permissions(permission, *file_paths)
|
21
|
-
file_paths.map { |p| File.chmod(permission, p) }
|
21
|
+
file_paths.map { |p| ::File.chmod(permission, p) }
|
22
22
|
end
|
23
23
|
end
|
24
24
|
|
@@ -32,7 +32,7 @@ module CemAcpt
|
|
32
32
|
# Finds and returns the Puppet executable
|
33
33
|
def self.puppet_executable
|
34
34
|
this_os = CemAcpt::Utils.os
|
35
|
-
if File.file?(DEFAULT_PUPPET_PATH[this_os]) && File.executable?(DEFAULT_PUPPET_PATH[this_os])
|
35
|
+
if ::File.file?(DEFAULT_PUPPET_PATH[this_os]) && ::File.executable?(DEFAULT_PUPPET_PATH[this_os])
|
36
36
|
return DEFAULT_PUPPET_PATH[this_os]
|
37
37
|
end
|
38
38
|
|
@@ -41,9 +41,9 @@ module CemAcpt
|
|
41
41
|
exts = ENV['PATHEXT'] ? ".{#{ENV['PATHEXT'].tr(';', ',').tr('.', '').downcase}}" : '.{exe,com,bat}'
|
42
42
|
file_name = "#{file_name}#{exts}"
|
43
43
|
end
|
44
|
-
ENV['PATH'].split(File::PATH_SEPARATOR).each do |path|
|
45
|
-
if File.file?(File.join(path, file_name)) && File.executable?(File.join(path, file_name))
|
46
|
-
return File.join(path, file_name)
|
44
|
+
ENV['PATH'].split(::File::PATH_SEPARATOR).each do |path|
|
45
|
+
if ::File.file?(::File.join(path, file_name)) && ::File.executable?(::File.join(path, file_name))
|
46
|
+
return ::File.join(path, file_name)
|
47
47
|
end
|
48
48
|
end
|
49
49
|
raise 'Could not find Puppet executable! Is Puppet installed?'
|
@@ -75,30 +75,32 @@ module CemAcpt
|
|
75
75
|
module Node
|
76
76
|
def self.random_instance_name(prefix: 'cem-acpt-', length: 24)
|
77
77
|
rand_length = length - prefix.length
|
78
|
-
"#{prefix}#{SecureRandom.hex(rand_length)}"
|
78
|
+
"#{prefix}#{::SecureRandom.hex(rand_length)}"
|
79
79
|
end
|
80
80
|
end
|
81
81
|
|
82
82
|
# SSH-related utilities
|
83
83
|
module SSH
|
84
|
-
def self.
|
85
|
-
bin_path =
|
84
|
+
def self.ssh_keygen
|
85
|
+
bin_path = `#{ENV['SHELL']} -c 'command -v ssh-keygen'`.chomp
|
86
86
|
raise 'Cannot find ssh-keygen! Install it and verify PATH' unless bin_path
|
87
87
|
|
88
88
|
bin_path
|
89
|
+
rescue StandardError => e
|
90
|
+
raise "Cannot find ssh-keygen! Install it and verify PATH. Orignal error: #{e}"
|
89
91
|
end
|
90
92
|
|
91
93
|
def self.default_keydir
|
92
|
-
ssh_dir = File.join(ENV['HOME'], '.ssh')
|
93
|
-
raise "SSH directory at #{ssh_dir} does not exist" unless File.directory?(ssh_dir)
|
94
|
+
ssh_dir = ::File.join(ENV['HOME'], '.ssh')
|
95
|
+
raise "SSH directory at #{ssh_dir} does not exist" unless ::File.directory?(ssh_dir)
|
94
96
|
|
95
97
|
ssh_dir
|
96
98
|
end
|
97
99
|
|
98
100
|
def self.ephemeral_ssh_key(type: 'rsa', bits: '4096', comment: nil, keydir: default_keydir)
|
99
|
-
raise ArgumentError, 'keydir does not exist' unless File.directory?(keydir)
|
101
|
+
raise ArgumentError, 'keydir does not exist' unless ::File.directory?(keydir)
|
100
102
|
|
101
|
-
keyfile = File.join(keydir, SecureRandom.hex(16))
|
103
|
+
keyfile = ::File.join(keydir, SecureRandom.hex(16))
|
102
104
|
keygen_cmd = [ssh_keygen, "-t #{type}", "-b #{bits}", "-f #{keyfile}", '-N ""']
|
103
105
|
keygen_cmd << "-C \"#{comment}\"" if comment
|
104
106
|
_, stderr, status = Open3.capture3(keygen_cmd.join(' '))
|
@@ -108,8 +110,8 @@ module CemAcpt
|
|
108
110
|
end
|
109
111
|
|
110
112
|
def self.acpt_known_hosts(keydir: default_keydir, file_name: 'acpt_known_hosts', overwrite: true)
|
111
|
-
kh_file = File.join(keydir, file_name)
|
112
|
-
File.open(kh_file, 'w') { |f| f.write("\n") } unless File.exist?(kh_file) && !overwrite
|
113
|
+
kh_file = ::File.join(keydir, file_name)
|
114
|
+
::File.open(kh_file, 'w') { |f| f.write("\n") } unless ::File.exist?(kh_file) && !overwrite
|
113
115
|
kh_file
|
114
116
|
end
|
115
117
|
|
data/lib/cem_acpt/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cem_acpt
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
|
-
-
|
7
|
+
- puppetlabs
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-06-
|
11
|
+
date: 2022-06-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
requirement: !ruby/object:Gem::Requirement
|
@@ -124,7 +124,7 @@ dependencies:
|
|
124
124
|
version: '0'
|
125
125
|
description: Litmus-like library focusing on CEM Acceptance Tests
|
126
126
|
email:
|
127
|
-
-
|
127
|
+
- abide-team@puppet.com
|
128
128
|
executables:
|
129
129
|
- cem_acpt
|
130
130
|
extensions: []
|
@@ -184,7 +184,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
184
184
|
requirements:
|
185
185
|
- - ">="
|
186
186
|
- !ruby/object:Gem::Version
|
187
|
-
version: 2.
|
187
|
+
version: 2.6.0
|
188
188
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
189
189
|
requirements:
|
190
190
|
- - ">="
|