cem_acpt 0.6.4 → 0.6.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/cem_acpt/config.rb +1 -0
- data/lib/cem_acpt/logging.rb +5 -3
- data/lib/cem_acpt/provision/terraform.rb +23 -6
- data/lib/cem_acpt/test_runner.rb +29 -25
- data/lib/cem_acpt/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 98336b152de85be1f1d7bfd20cd901da25d728d9ea120fb713becff384986560
|
4
|
+
data.tar.gz: ab6e2579bb7df9e58a0c4ed290e40a64a4b1a0c6a6f00894b924694de915e65e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3c353057f6cda43e7b2e2a6eacfba36cdd41c2c78e459f7548b3e3ddd789a1c732e143b008b62f7c4e8fbb11e823a3e69f16a9a810c3c81db86be77e45b4b89e
|
7
|
+
data.tar.gz: c2cb83e57613ec0bed0292411e83a99705af80f0d205b699b52dd07ae49814d4adc8d235a9233c65b658d9652686b3dd302f5a1f45d0c19551f8c2811ef62ade
|
data/Gemfile.lock
CHANGED
data/lib/cem_acpt/config.rb
CHANGED
@@ -359,6 +359,7 @@ module CemAcpt
|
|
359
359
|
checksum = File.read(module_terraform_checksum_file).strip
|
360
360
|
return if checksum == module_terraform_checksum
|
361
361
|
end
|
362
|
+
FileUtils.rm_rf(File.join(user_config_dir, 'terraform'))
|
362
363
|
FileUtils.cp_r(File.expand_path(File.join(__dir__, '..', 'terraform')), user_config_dir)
|
363
364
|
@module_terraform_checksum = new_module_terraform_checksum
|
364
365
|
File.write(module_terraform_checksum_file, module_terraform_checksum)
|
data/lib/cem_acpt/logging.rb
CHANGED
@@ -126,9 +126,11 @@ module CemAcpt
|
|
126
126
|
# Wraps the given block in a Github Actions group if in CI mode
|
127
127
|
# @param name [String] the name of the group
|
128
128
|
def with_ci_group(name)
|
129
|
-
|
130
|
-
|
131
|
-
|
129
|
+
if @ci_mode
|
130
|
+
self.<< "::group::#{name}\n"
|
131
|
+
else
|
132
|
+
info(name)
|
133
|
+
end
|
132
134
|
yield
|
133
135
|
ensure
|
134
136
|
self.<< "::endgroup::\n" if @ci_mode
|
@@ -14,7 +14,7 @@ module CemAcpt
|
|
14
14
|
DEFAULT_VARS_FILE = 'testvars.json'
|
15
15
|
include CemAcpt::Logging
|
16
16
|
|
17
|
-
attr_reader :environment, :working_dir
|
17
|
+
attr_reader :environment, :working_dir, :module_package_path, :private_key, :public_key
|
18
18
|
|
19
19
|
def initialize(config, provision_data)
|
20
20
|
@config = config
|
@@ -22,11 +22,14 @@ module CemAcpt
|
|
22
22
|
@backend = new_backend(@provision_data[:test_data].first[:test_name])
|
23
23
|
@environment = new_environment(@config)
|
24
24
|
@working_dir = nil
|
25
|
+
@module_package_path = nil
|
26
|
+
@private_key = nil
|
27
|
+
@public_key = nil
|
25
28
|
end
|
26
29
|
|
27
|
-
def provision
|
30
|
+
def provision(reuse_working_dir: false)
|
28
31
|
logger.info('Terraform') { 'Provisioning nodes...' }
|
29
|
-
@working_dir = new_working_dir
|
32
|
+
@working_dir = new_working_dir unless reuse_working_dir
|
30
33
|
validate_working_dir!
|
31
34
|
save_vars_to_file!(formatted_vars) # Easier to reuse nodes this way
|
32
35
|
|
@@ -42,6 +45,9 @@ module CemAcpt
|
|
42
45
|
logger.verbose('Terraform') { "Deleting old working directory #{working_dir}" }
|
43
46
|
FileUtils.rm_rf(working_dir)
|
44
47
|
@working_dir = nil
|
48
|
+
@module_package_path = nil
|
49
|
+
@private_key = nil
|
50
|
+
@public_key = nil
|
45
51
|
end
|
46
52
|
|
47
53
|
def show
|
@@ -156,7 +162,18 @@ module CemAcpt
|
|
156
162
|
FileUtils.cp_r(@backend.provision_directory, work_dir)
|
157
163
|
logger.verbose('Terraform') { "Copied provision directory #{@backend.provision_directory} to #{work_dir}" }
|
158
164
|
FileUtils.cp(@provision_data[:module_package_path], work_dir)
|
165
|
+
@module_package_path = File.join(work_dir, File.basename(@provision_data[:module_package_path]))
|
159
166
|
logger.verbose('Terraform') { "Copied module package #{@provision_data[:module_package_path]} to #{work_dir}" }
|
167
|
+
if File.exist?(@provision_data[:private_key])
|
168
|
+
FileUtils.cp(@provision_data[:private_key], work_dir)
|
169
|
+
@private_key = File.join(work_dir, File.basename(@provision_data[:private_key]))
|
170
|
+
logger.verbose('Terraform') { "Copied private key #{@provision_data[:private_key]} to #{work_dir}" }
|
171
|
+
end
|
172
|
+
if File.exist?(@provision_data[:public_key])
|
173
|
+
FileUtils.cp(@provision_data[:public_key], work_dir)
|
174
|
+
@public_key = File.join(work_dir, File.basename(@provision_data[:public_key]))
|
175
|
+
logger.verbose('Terraform') { "Copied public key #{@provision_data[:public_key]} to #{work_dir}" }
|
176
|
+
end
|
160
177
|
work_dir
|
161
178
|
rescue StandardError => e
|
162
179
|
logger.error('Terraform') { 'Error creating working directory' }
|
@@ -204,9 +221,9 @@ module CemAcpt
|
|
204
221
|
def formatted_vars
|
205
222
|
@provision_data[:nodes].first.platform_data.merge(
|
206
223
|
{
|
207
|
-
puppet_module_package: @
|
208
|
-
private_key: @
|
209
|
-
public_key: @
|
224
|
+
puppet_module_package: @module_package_path,
|
225
|
+
private_key: @private_key,
|
226
|
+
public_key: @public_key,
|
210
227
|
node_data: provision_node_data,
|
211
228
|
}
|
212
229
|
)
|
data/lib/cem_acpt/test_runner.rb
CHANGED
@@ -39,27 +39,27 @@ module CemAcpt
|
|
39
39
|
def run
|
40
40
|
@run_data = {}
|
41
41
|
@start_time = Time.now
|
42
|
-
logger.
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
42
|
+
logger.with_ci_group("CemAcpt v#{CemAcpt::VERSION} run started at #{@start_time}") do
|
43
|
+
logger.info('CemAcpt') { "Using module directory: #{config.get('module_dir')}..." }
|
44
|
+
Dir.chdir(config.get('module_dir')) do
|
45
|
+
keep_terminal_alive
|
46
|
+
@run_data[:private_key], @run_data[:public_key], @run_data[:known_hosts] = new_ephemeral_ssh_keys
|
47
|
+
logger.info('CemAcpt') { 'Created ephemeral SSH key pair...' }
|
48
|
+
@run_data[:module_package_path] = build_module_package
|
49
|
+
logger.info('CemAcpt') { "Created module package: #{@run_data[:module_package_path]}..." }
|
50
|
+
@run_data[:test_data] = new_test_data
|
51
|
+
logger.info('CemAcpt') { 'Created test data...' }
|
52
|
+
logger.verbose('CemAcpt') { "Test data: #{@run_data[:test_data]}" }
|
53
|
+
@run_data[:nodes] = new_node_data
|
54
|
+
logger.info('CemAcpt') { 'Created node data...' }
|
55
|
+
logger.verbose('CemAcpt') { "Node data: #{@run_data[:nodes]}" }
|
56
|
+
@instance_names_ips = provision_test_nodes
|
57
|
+
logger.info('CemAcpt') { 'Provisioned test nodes...' }
|
58
|
+
logger.debug('CemAcpt') { "Instance names and IPs: #{@instance_names_ips}" }
|
59
|
+
@results = run_tests(@instance_names_ips.map { |_, v| v['ip'] },
|
60
|
+
config.get('actions.only'),
|
61
|
+
config.get('actions.except'))
|
62
|
+
end
|
63
63
|
end
|
64
64
|
ensure
|
65
65
|
clean_up
|
@@ -105,7 +105,7 @@ module CemAcpt
|
|
105
105
|
end
|
106
106
|
|
107
107
|
def clean_ephemeral_ssh_keys
|
108
|
-
return if config.get('no_ephemeral_ssh_key')
|
108
|
+
return if config.get('no_ephemeral_ssh_key') || config.get('no_destroy_nodes')
|
109
109
|
|
110
110
|
CemAcpt::Utils::SSH::Ephemeral.clean
|
111
111
|
end
|
@@ -124,13 +124,17 @@ module CemAcpt
|
|
124
124
|
end
|
125
125
|
|
126
126
|
def destroy_test_nodes
|
127
|
-
|
127
|
+
return no_destroy if config.get('no_destroy_nodes')
|
128
|
+
|
129
|
+
logger.with_ci_group("CemAcpt v#{CemAcpt::VERSION} run finished at #{Time.now}") { @provisioner&.destroy }
|
128
130
|
end
|
129
131
|
|
130
132
|
def no_destroy
|
131
133
|
logger.warn('CemAcpt') { 'Not destroying test nodes...' }
|
132
|
-
|
133
|
-
|
134
|
+
logger.with_ci_group("CemAcpt v#{CemAcpt::VERSION} run finished at #{Time.now}") do
|
135
|
+
@provisioner&.show
|
136
|
+
logger.info('CemAcpt') { "Test SSH Keys:\n Private Key: #{@run_data[:private_key]}\n Public Key:#{@run_data[:public_key]}" }
|
137
|
+
end
|
134
138
|
end
|
135
139
|
|
136
140
|
def run_tests(hosts, only_actions, except_actions)
|
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.6.
|
4
|
+
version: 0.6.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- puppetlabs
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-04-
|
11
|
+
date: 2023-04-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: async-http
|