cem_acpt 0.8.1 → 0.8.2
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/provision/terraform.rb +13 -7
- data/lib/cem_acpt/test_runner.rb +20 -1
- data/lib/cem_acpt/utils/shell.rb +1 -25
- data/lib/cem_acpt/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e7eb7faf465af2f2ea5ab7649db1cf7e05c55573b869966c7e99c49aff498bf7
|
4
|
+
data.tar.gz: d79aadcc053957630a339b49a5ea456c5d67cc0dab24b036184cfec3e6c67609
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cee1f24c8c38d68b01078f56e41963a02f5c3c5e2df8a35907b86e19b20600fe5ba612d7382be02da41b0a38f662a09019f629cf4decae30f35dad14f878fd38
|
7
|
+
data.tar.gz: 968a449a29d6f487e802954ca9af7d1d64bd2dd85c7f95cbaf95cecf7357a261a113293e712b8be8b01a593564de885d25c80ab5b01632215b98e8bd43310012
|
data/Gemfile.lock
CHANGED
@@ -25,6 +25,7 @@ module CemAcpt
|
|
25
25
|
@module_package_path = nil
|
26
26
|
@private_key = nil
|
27
27
|
@public_key = nil
|
28
|
+
@applied = false
|
28
29
|
end
|
29
30
|
|
30
31
|
# @return [Hash] A hash of instance names and IPs
|
@@ -36,13 +37,18 @@ module CemAcpt
|
|
36
37
|
terraform_init
|
37
38
|
terraform_plan(formatted_vars, DEFAULT_PLAN_NAME)
|
38
39
|
terraform_apply(DEFAULT_PLAN_NAME)
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
40
|
+
@applied = true
|
41
|
+
end
|
42
|
+
|
43
|
+
def output
|
44
|
+
raise 'Terraform has not been applied yet' unless @applied
|
45
|
+
|
46
|
+
output = terraform_output('instance_name_ip', json: true)
|
47
|
+
logger.debug('CemAcpt::Provision::Terraform') { "Terraform output:\n#{output}" }
|
48
|
+
JSON.parse(output)
|
49
|
+
rescue JSON::ParserError => e
|
50
|
+
logger.error('CemAcpt::Provision::Terraform') { "Error parsing Terraform output: #{output}" }
|
51
|
+
raise e
|
46
52
|
end
|
47
53
|
|
48
54
|
def destroy
|
data/lib/cem_acpt/test_runner.rb
CHANGED
@@ -59,7 +59,8 @@ module CemAcpt
|
|
59
59
|
@run_data[:nodes] = new_node_data
|
60
60
|
logger.info('CemAcpt::TestRunner') { 'Created node data...' }
|
61
61
|
logger.verbose('CemAcpt::TestRunner') { "Node data: #{@run_data[:nodes]}" }
|
62
|
-
|
62
|
+
provision_test_nodes
|
63
|
+
@instance_names_ips = provisioner_output
|
63
64
|
logger.info('CemAcpt::TestRunner') { "Instance names and IPs class: #{@instance_names_ips.class}" }
|
64
65
|
@provisioned = true
|
65
66
|
logger.info('CemAcpt::TestRunner') { 'Provisioned test nodes...' }
|
@@ -156,6 +157,24 @@ module CemAcpt
|
|
156
157
|
@provisioner.provision
|
157
158
|
end
|
158
159
|
|
160
|
+
def provisioner_output
|
161
|
+
logger.info('CemAcpt::TestRunner') { 'Getting provisioner output...' }
|
162
|
+
@attempts = 0
|
163
|
+
@max_attempts = 3
|
164
|
+
output = nil
|
165
|
+
while @attempts < @max_attempts
|
166
|
+
@attempts += 1
|
167
|
+
output = @provisioner.output
|
168
|
+
break unless (output.nil? || output.empty?) && @attempts < @max_attempts # Don't sleep if this is last attempt
|
169
|
+
|
170
|
+
logger.info('CemAcpt::TestRunner') { "Provisioner output is nil or empty, retrying (#{@attempts}/#{@max_attempts})" }
|
171
|
+
sleep 3
|
172
|
+
end
|
173
|
+
raise 'Provisioner output is nil or empty' if output.nil? || output.empty?
|
174
|
+
|
175
|
+
output
|
176
|
+
end
|
177
|
+
|
159
178
|
def destroy_test_nodes
|
160
179
|
logger.info('CemAcpt::TestRunner') { 'Destroying test nodes if necessary...' }
|
161
180
|
if !@provisioned
|
data/lib/cem_acpt/utils/shell.rb
CHANGED
@@ -30,19 +30,10 @@ module CemAcpt
|
|
30
30
|
stdin.close
|
31
31
|
outerr.sync = true
|
32
32
|
output_thread = Thread.new do
|
33
|
-
while (line = outerr.
|
33
|
+
while (line = outerr.gets("\n"))
|
34
34
|
output << line if output
|
35
35
|
io_outerr.write(line) unless line.chomp.empty?
|
36
36
|
end
|
37
|
-
rescue IO::WaitReadable
|
38
|
-
begin
|
39
|
-
IO.select([outerr])
|
40
|
-
retry
|
41
|
-
rescue IOError
|
42
|
-
# outerr closed, won't retry
|
43
|
-
end
|
44
|
-
rescue EOFError
|
45
|
-
# outerr closed, won't retry
|
46
37
|
end
|
47
38
|
wait_thr.join
|
48
39
|
output_thread.exit
|
@@ -70,21 +61,6 @@ module CemAcpt
|
|
70
61
|
end
|
71
62
|
nil
|
72
63
|
end
|
73
|
-
|
74
|
-
# IO monkey patch for non-blocking readline
|
75
|
-
class ::IO
|
76
|
-
def readline_nonblock
|
77
|
-
rlnb = []
|
78
|
-
rnlb << read_nonblock(1) while rlnb[-1] != "\n"
|
79
|
-
rlnb.join
|
80
|
-
rescue IO::WaitReadable => blocking
|
81
|
-
raise blocking if rlnb.empty?
|
82
|
-
|
83
|
-
rlnb.join
|
84
|
-
rescue EOFError
|
85
|
-
rlnb.join
|
86
|
-
end
|
87
|
-
end
|
88
64
|
end
|
89
65
|
end
|
90
66
|
end
|
data/lib/cem_acpt/version.rb
CHANGED