hybrid_platforms_conductor 33.9.5 → 34.0.0
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/CHANGELOG.md +10 -0
- data/README.md +3 -1
- data/bin/free_veids +1 -1
- data/bin/last_deploys +1 -1
- data/bin/nodes_to_deploy +3 -3
- data/docs/gen/mermaid/README.md-0.png +0 -0
- data/docs/gen/mermaid/docs/executables/check-node.md-0.png +0 -0
- data/docs/gen/mermaid/docs/executables/deploy.md-0.png +0 -0
- data/docs/gen/mermaid/docs/executables/free_ips.md-0.png +0 -0
- data/docs/gen/mermaid/docs/executables/free_veids.md-0.png +0 -0
- data/docs/gen/mermaid/docs/executables/get_impacted_nodes.md-0.png +0 -0
- data/docs/gen/mermaid/docs/executables/last_deploys.md-0.png +0 -0
- data/docs/gen/mermaid/docs/executables/nodes_to_deploy.md-0.png +0 -0
- data/docs/gen/mermaid/docs/executables/report.md-0.png +0 -0
- data/docs/gen/mermaid/docs/executables/run.md-0.png +0 -0
- data/docs/gen/mermaid/docs/executables/setup.md-0.png +0 -0
- data/docs/gen/mermaid/docs/executables/ssh_config.md-0.png +0 -0
- data/docs/gen/mermaid/docs/executables/test.md-0.png +0 -0
- data/lib/hybrid_platforms_conductor/core_extensions/bundler/without_bundled_env.rb +1 -1
- data/lib/hybrid_platforms_conductor/core_extensions/cleanroom/fix_kwargs.rb +1 -0
- data/lib/hybrid_platforms_conductor/credentials.rb +1 -1
- data/lib/hybrid_platforms_conductor/current_dir_monitor.rb +3 -3
- data/lib/hybrid_platforms_conductor/deployer.rb +1 -1
- data/lib/hybrid_platforms_conductor/executable.rb +1 -1
- data/lib/hybrid_platforms_conductor/hpc_plugins/cmdb/host_ip.rb +2 -0
- data/lib/hybrid_platforms_conductor/hpc_plugins/cmdb/host_keys.rb +2 -0
- data/lib/hybrid_platforms_conductor/hpc_plugins/connector/ssh.rb +9 -7
- data/lib/hybrid_platforms_conductor/hpc_plugins/platform_handler/serverless_chef/recipes_tree_builder.rb +2 -1
- data/lib/hybrid_platforms_conductor/hpc_plugins/platform_handler/yaml_inventory.rb +1 -1
- data/lib/hybrid_platforms_conductor/hpc_plugins/provisioner/proxmox/proxmox_waiter.rb +1 -0
- data/lib/hybrid_platforms_conductor/hpc_plugins/provisioner/proxmox/reserve_proxmox_container +2 -2
- data/lib/hybrid_platforms_conductor/hpc_plugins/provisioner/proxmox.rb +1 -0
- data/lib/hybrid_platforms_conductor/hpc_plugins/report/confluence.rb +1 -0
- data/lib/hybrid_platforms_conductor/hpc_plugins/secrets_reader/keepass.rb +3 -2
- data/lib/hybrid_platforms_conductor/hpc_plugins/test/executables.rb +5 -5
- data/lib/hybrid_platforms_conductor/hpc_plugins/test/linear_strategy.rb +2 -2
- data/lib/hybrid_platforms_conductor/hpc_plugins/test/veids.rb +1 -1
- data/lib/hybrid_platforms_conductor/hpc_plugins/test_report/confluence.rb +1 -0
- data/lib/hybrid_platforms_conductor/json_dumper.rb +1 -1
- data/lib/hybrid_platforms_conductor/logger_helpers.rb +6 -6
- data/lib/hybrid_platforms_conductor/nodes_handler.rb +4 -6
- data/lib/hybrid_platforms_conductor/parallel_threads.rb +1 -1
- data/lib/hybrid_platforms_conductor/platform_handler.rb +1 -1
- data/lib/hybrid_platforms_conductor/platforms_handler.rb +1 -1
- data/lib/hybrid_platforms_conductor/services_handler.rb +6 -6
- data/lib/hybrid_platforms_conductor/test_report.rb +4 -4
- data/lib/hybrid_platforms_conductor/tests_runner.rb +3 -0
- data/lib/hybrid_platforms_conductor/thycotic.rb +2 -2
- data/lib/hybrid_platforms_conductor/topographer.rb +2 -2
- data/lib/hybrid_platforms_conductor/version.rb +1 -1
- data/spec/hybrid_platforms_conductor_test/api/actions_executor/connectors/ssh/connections_spec.rb +3 -10
- data/spec/hybrid_platforms_conductor_test/api/actions_executor/connectors/ssh/global_helpers_spec.rb +1 -6
- data/spec/hybrid_platforms_conductor_test/api/credentials_spec.rb +13 -13
- data/spec/hybrid_platforms_conductor_test/api/deployer/provisioners/docker/Dockerfile +1 -1
- data/spec/hybrid_platforms_conductor_test/api/deployer/provisioners/docker_spec.rb +3 -3
- data/spec/hybrid_platforms_conductor_test/api/deployer/secrets_reader_plugins/keepass_spec.rb +1 -1
- data/spec/hybrid_platforms_conductor_test/api/nodes_handler/cmdbs/config_spec.rb +1 -1
- data/spec/hybrid_platforms_conductor_test/api/nodes_handler/cmdbs_plugins_api_spec.rb +3 -3
- data/spec/hybrid_platforms_conductor_test/api/nodes_handler/config_dsl_spec.rb +1 -1
- data/spec/hybrid_platforms_conductor_test/api/nodes_handler/git_diff_impacts_spec.rb +2 -2
- data/spec/hybrid_platforms_conductor_test/api/platform_handlers/serverless_chef/packaging_spec.rb +2 -2
- data/spec/hybrid_platforms_conductor_test/api/platforms_handler_spec.rb +3 -3
- data/spec/hybrid_platforms_conductor_test/api/plugins_spec.rb +1 -3
- data/spec/hybrid_platforms_conductor_test/api/services_handler/deploy_allowed_spec.rb +9 -9
- data/spec/hybrid_platforms_conductor_test/api/tests_runner/common_spec.rb +5 -5
- data/spec/hybrid_platforms_conductor_test/api/tests_runner/node_check_spec.rb +2 -2
- data/spec/hybrid_platforms_conductor_test/api/tests_runner/reports_spec.rb +1 -1
- data/spec/hybrid_platforms_conductor_test/executables/options/common_spec.rb +1 -1
- data/spec/hybrid_platforms_conductor_test/helpers/connector_ssh_helpers.rb +4 -6
- data/spec/hybrid_platforms_conductor_test/helpers/deployer_helpers.rb +3 -3
- data/spec/hybrid_platforms_conductor_test/helpers/executables_helpers.rb +1 -1
- data/spec/hybrid_platforms_conductor_test/helpers/provisioner_proxmox_helpers.rb +4 -4
- data/spec/hybrid_platforms_conductor_test/serverless_chef_repositories/recipes/cookbooks/test_cookbook_3/recipes/35_unparsable_include.rb +2 -2
- data/spec/hybrid_platforms_conductor_test/test_log_no_read_plugin.rb +1 -1
- data/spec/hybrid_platforms_conductor_test/test_log_plugin.rb +1 -1
- data/spec/hybrid_platforms_conductor_test.rb +3 -2
- metadata +170 -244
@@ -17,7 +17,7 @@ module HybridPlatformsConductor
|
|
17
17
|
# * *domain* (String): Domain to use for authentication to Thycotic [default: ENV['hpc_domain_for_thycotic']]
|
18
18
|
# * Proc: Code called with the Thyctotic instance.
|
19
19
|
# * *thycotic* (ThyctoticApi): The Thycotic instance to use.
|
20
|
-
def with_thycotic(thycotic_url, domain: ENV
|
20
|
+
def with_thycotic(thycotic_url, domain: ENV.fetch('hpc_domain_for_thycotic', nil))
|
21
21
|
with_credentials_for(:thycotic, resource: thycotic_url) do |thycotic_user, thycotic_password|
|
22
22
|
yield ThycoticApi.new(thycotic_url, thycotic_user, thycotic_password, domain: domain, logger: @logger, logger_stderr: @logger_stderr)
|
23
23
|
end
|
@@ -41,7 +41,7 @@ module HybridPlatformsConductor
|
|
41
41
|
url,
|
42
42
|
user,
|
43
43
|
password,
|
44
|
-
domain: ENV
|
44
|
+
domain: ENV.fetch('hpc_domain_for_thycotic', nil),
|
45
45
|
logger: Logger.new($stdout),
|
46
46
|
logger_stderr: Logger.new($stderr)
|
47
47
|
)
|
@@ -381,7 +381,7 @@ module HybridPlatformsConductor
|
|
381
381
|
next unless nodes_list.include?(node_name)
|
382
382
|
|
383
383
|
new_nodes_graph[node_name] = node_info.merge(
|
384
|
-
connections: node_info[:connections].
|
384
|
+
connections: node_info[:connections].slice(*nodes_list),
|
385
385
|
includes: node_info[:includes] & nodes_list
|
386
386
|
)
|
387
387
|
end
|
@@ -398,7 +398,7 @@ module HybridPlatformsConductor
|
|
398
398
|
next if nodes_list.include?(node_name)
|
399
399
|
|
400
400
|
new_nodes_graph[node_name] = node_info.merge(
|
401
|
-
connections: node_info[:connections].
|
401
|
+
connections: node_info[:connections].except(*nodes_list),
|
402
402
|
includes: node_info[:includes] - nodes_list
|
403
403
|
)
|
404
404
|
end
|
data/spec/hybrid_platforms_conductor_test/api/actions_executor/connectors/ssh/connections_spec.rb
CHANGED
@@ -601,17 +601,10 @@ describe HybridPlatformsConductor::ActionsExecutor do
|
|
601
601
|
) do
|
602
602
|
test_connector.ssh_user = 'test_user'
|
603
603
|
# To speed up the test, alter the wait time between retries.
|
604
|
-
|
605
|
-
|
606
|
-
HybridPlatformsConductor::HpcPlugins::Connector::Ssh.send(:remove_const, :WAIT_TIME_FOR_BOOT)
|
607
|
-
HybridPlatformsConductor::HpcPlugins::Connector::Ssh.const_set(:WAIT_TIME_FOR_BOOT, 1)
|
608
|
-
test_connector.with_connection_to(['node']) do
|
609
|
-
end
|
610
|
-
expect(nbr_boot_messages).to eq 3
|
611
|
-
ensure
|
612
|
-
HybridPlatformsConductor::HpcPlugins::Connector::Ssh.send(:remove_const, :WAIT_TIME_FOR_BOOT)
|
613
|
-
HybridPlatformsConductor::HpcPlugins::Connector::Ssh.const_set(:WAIT_TIME_FOR_BOOT, old_wait)
|
604
|
+
stub_const('HybridPlatformsConductor::HpcPlugins::Connector::Ssh::WAIT_TIME_FOR_BOOT', 1)
|
605
|
+
test_connector.with_connection_to(['node']) do
|
614
606
|
end
|
607
|
+
expect(nbr_boot_messages).to eq 3
|
615
608
|
end
|
616
609
|
end
|
617
610
|
end
|
data/spec/hybrid_platforms_conductor_test/api/actions_executor/connectors/ssh/global_helpers_spec.rb
CHANGED
@@ -57,7 +57,6 @@ describe HybridPlatformsConductor::ActionsExecutor do
|
|
57
57
|
Host *
|
58
58
|
User test_user
|
59
59
|
ControlPath #{Dir.tmpdir}/hpc_ssh/hpc_ssh_mux_%h_%p_%r
|
60
|
-
PubkeyAcceptedKeyTypes +ssh-dss
|
61
60
|
EO_SSH_CONFIG
|
62
61
|
end
|
63
62
|
end
|
@@ -69,14 +68,13 @@ describe HybridPlatformsConductor::ActionsExecutor do
|
|
69
68
|
Host *
|
70
69
|
User test_user
|
71
70
|
ControlPath #{Dir.tmpdir}/hpc_ssh/hpc_ssh_mux_%h_%p_%r
|
72
|
-
PubkeyAcceptedKeyTypes +ssh-dss
|
73
71
|
EO_SSH_CONFIG
|
74
72
|
end
|
75
73
|
end
|
76
74
|
|
77
75
|
it 'generates a global configuration with user taken from whoami when no env variable is set' do
|
78
76
|
with_test_platform({}) do
|
79
|
-
original_user = ENV
|
77
|
+
original_user = ENV.fetch('USER', nil)
|
80
78
|
begin
|
81
79
|
ENV.delete 'USER'
|
82
80
|
ENV.delete 'hpc_ssh_user'
|
@@ -106,7 +104,6 @@ describe HybridPlatformsConductor::ActionsExecutor do
|
|
106
104
|
Host *
|
107
105
|
User test_user
|
108
106
|
ControlPath #{Dir.tmpdir}/hpc_ssh/hpc_ssh_mux_%h_%p_%r
|
109
|
-
PubkeyAcceptedKeyTypes +ssh-dss
|
110
107
|
EO_SSH_CONFIG
|
111
108
|
end
|
112
109
|
end
|
@@ -118,7 +115,6 @@ describe HybridPlatformsConductor::ActionsExecutor do
|
|
118
115
|
Host *
|
119
116
|
User test_user
|
120
117
|
ControlPath #{Dir.tmpdir}/hpc_ssh/hpc_ssh_mux_%h_%p_%r
|
121
|
-
PubkeyAcceptedKeyTypes +ssh-dss
|
122
118
|
UserKnownHostsFile /path/to/known_hosts
|
123
119
|
EO_SSH_CONFIG
|
124
120
|
end
|
@@ -132,7 +128,6 @@ describe HybridPlatformsConductor::ActionsExecutor do
|
|
132
128
|
Host *
|
133
129
|
User test_user
|
134
130
|
ControlPath #{Dir.tmpdir}/hpc_ssh/hpc_ssh_mux_%h_%p_%r
|
135
|
-
PubkeyAcceptedKeyTypes +ssh-dss
|
136
131
|
StrictHostKeyChecking no
|
137
132
|
EO_SSH_CONFIG
|
138
133
|
end
|
@@ -37,7 +37,7 @@ describe HybridPlatformsConductor::Credentials do
|
|
37
37
|
it 'returns no credentials when they are not set' do
|
38
38
|
with_platforms '' do
|
39
39
|
# Check that .netrc won't be read
|
40
|
-
expect(
|
40
|
+
expect(Netrc).not_to receive(:read)
|
41
41
|
expect_credentials_to_be nil, nil
|
42
42
|
end
|
43
43
|
end
|
@@ -48,7 +48,7 @@ describe HybridPlatformsConductor::Credentials do
|
|
48
48
|
ENV['hpc_password_for_test_credential'] = 'env_test_password'
|
49
49
|
begin
|
50
50
|
# Check that .netrc won't be read
|
51
|
-
expect(
|
51
|
+
expect(Netrc).not_to receive(:read)
|
52
52
|
expect_credentials_to_be 'env_test_user', 'env_test_password'
|
53
53
|
ensure
|
54
54
|
ENV.delete('hpc_user_for_test_credential')
|
@@ -78,8 +78,8 @@ describe HybridPlatformsConductor::Credentials do
|
|
78
78
|
|
79
79
|
it 'returns credentials taken from .netrc when a resource is specified' do
|
80
80
|
with_platforms '' do
|
81
|
-
expect(
|
82
|
-
mocked_netrc = instance_double(
|
81
|
+
expect(Netrc).to receive(:read) do
|
82
|
+
mocked_netrc = instance_double(Netrc)
|
83
83
|
expect(mocked_netrc).to receive(:[]).with('my_domain.com').and_return %w[test_user test_password]
|
84
84
|
expect(mocked_netrc).to receive(:instance_variable_get).with(:@data).and_return []
|
85
85
|
mocked_netrc
|
@@ -90,8 +90,8 @@ describe HybridPlatformsConductor::Credentials do
|
|
90
90
|
|
91
91
|
it 'returns credentials taken from .netrc when a non-URL resource is specified' do
|
92
92
|
with_platforms '' do
|
93
|
-
expect(
|
94
|
-
mocked_netrc = instance_double(
|
93
|
+
expect(Netrc).to receive(:read) do
|
94
|
+
mocked_netrc = instance_double(Netrc)
|
95
95
|
expect(mocked_netrc).to receive(:[]).with('This is:not/ a URL!').and_return %w[test_user test_password]
|
96
96
|
expect(mocked_netrc).to receive(:instance_variable_get).with(:@data).and_return []
|
97
97
|
mocked_netrc
|
@@ -103,8 +103,8 @@ describe HybridPlatformsConductor::Credentials do
|
|
103
103
|
it 'erases the value of the password taken from netrc after usage' do
|
104
104
|
with_platforms '' do
|
105
105
|
netrc_data = [['mocked_data']]
|
106
|
-
expect(
|
107
|
-
mocked_netrc = instance_double(
|
106
|
+
expect(Netrc).to receive(:read) do
|
107
|
+
mocked_netrc = instance_double(Netrc)
|
108
108
|
expect(mocked_netrc).to receive(:[]).with('my_domain.com').and_return %w[test_user test_password]
|
109
109
|
expect(mocked_netrc).to receive(:instance_variable_get).with(:@data).and_return netrc_data
|
110
110
|
mocked_netrc
|
@@ -133,7 +133,7 @@ describe HybridPlatformsConductor::Credentials do
|
|
133
133
|
ENV['hpc_password_for_test_credential'] = 'env_test_password'
|
134
134
|
begin
|
135
135
|
# Check that .netrc won't be read
|
136
|
-
expect(
|
136
|
+
expect(Netrc).not_to receive(:read)
|
137
137
|
expect_credentials_to_be 'user_for_', 'password_for_'
|
138
138
|
ensure
|
139
139
|
ENV.delete('hpc_user_for_test_credential')
|
@@ -155,7 +155,7 @@ describe HybridPlatformsConductor::Credentials do
|
|
155
155
|
ENV['hpc_password_for_test_credential'] = 'env_test_password'
|
156
156
|
begin
|
157
157
|
# Check that .netrc won't be read
|
158
|
-
expect(
|
158
|
+
expect(Netrc).not_to receive(:read)
|
159
159
|
expect_credentials_to_be 'user_for_test_resource', 'password_for_test_resource', resource: 'test_resource'
|
160
160
|
ensure
|
161
161
|
ENV.delete('hpc_user_for_test_credential')
|
@@ -166,7 +166,7 @@ describe HybridPlatformsConductor::Credentials do
|
|
166
166
|
|
167
167
|
it 'returns credentials taken from config for a given resource even when they are nil' do
|
168
168
|
with_platforms(
|
169
|
-
<<~
|
169
|
+
<<~EO_CONFIG
|
170
170
|
credentials_for(:test_credential) do |resource, requester|
|
171
171
|
requester.call nil, nil
|
172
172
|
end
|
@@ -177,7 +177,7 @@ describe HybridPlatformsConductor::Credentials do
|
|
177
177
|
ENV['hpc_password_for_test_credential'] = 'env_test_password'
|
178
178
|
begin
|
179
179
|
# Check that .netrc won't be read
|
180
|
-
expect(
|
180
|
+
expect(Netrc).not_to receive(:read)
|
181
181
|
expect_credentials_to_be nil, nil, resource: 'test_resource'
|
182
182
|
ensure
|
183
183
|
ENV.delete('hpc_user_for_test_credential')
|
@@ -233,7 +233,7 @@ describe HybridPlatformsConductor::Credentials do
|
|
233
233
|
|
234
234
|
it 'fails if the requester is not called from config' do
|
235
235
|
with_platforms(
|
236
|
-
<<~
|
236
|
+
<<~EO_CONFIG
|
237
237
|
credentials_for(:test_credential) do |resource, requester|
|
238
238
|
end
|
239
239
|
EO_CONFIG
|
@@ -43,12 +43,12 @@ describe HybridPlatformsConductor::HpcPlugins::Provisioner::Docker do
|
|
43
43
|
# Make sure we use a unique environment for this test
|
44
44
|
environment = "test_#{Process.pid}_#{(Time.now - Process.clock_gettime(Process::CLOCK_BOOTTIME)).strftime('%Y%m%d%H%M%S')}"
|
45
45
|
with_test_docker_platform(environment) do |instance|
|
46
|
-
expect(
|
46
|
+
expect(Docker::Container).to receive(:create).and_call_original
|
47
47
|
instance.create
|
48
48
|
instance.wait_for_state! :created
|
49
49
|
begin
|
50
50
|
# Test that the instance is created
|
51
|
-
expect(
|
51
|
+
expect(Docker::Container.all(all: true).find { |container| container.info['Names'].include? "/hpc_docker_container_node_#{environment}" }).not_to be_nil
|
52
52
|
expect(instance.state).to eq :created
|
53
53
|
ensure
|
54
54
|
# Clean the Docker containers if needed
|
@@ -62,7 +62,7 @@ describe HybridPlatformsConductor::HpcPlugins::Provisioner::Docker do
|
|
62
62
|
instance.create
|
63
63
|
instance.wait_for_state! :created
|
64
64
|
begin
|
65
|
-
expect(
|
65
|
+
expect(Docker::Container).not_to receive(:create)
|
66
66
|
instance.create
|
67
67
|
expect(instance.state).to eq :created
|
68
68
|
ensure
|
data/spec/hybrid_platforms_conductor_test/api/deployer/secrets_reader_plugins/keepass_spec.rb
CHANGED
@@ -76,7 +76,7 @@ describe HybridPlatformsConductor::Deployer do
|
|
76
76
|
platform_info,
|
77
77
|
additional_config: "read_secrets_from :keepass\n#{additional_config}"
|
78
78
|
) do
|
79
|
-
mock_databases.
|
79
|
+
mock_databases.each_key do |database|
|
80
80
|
expect(test_deployer.instance_variable_get(:@secrets_readers)[:keepass]).to receive(:with_credentials_for).with(:keepass, resource: database) do |_id, resource: nil, &client_code|
|
81
81
|
client_code.call nil, mock_keepass_password
|
82
82
|
end
|
@@ -14,7 +14,7 @@ describe HybridPlatformsConductor::NodesHandler do
|
|
14
14
|
it 'sets different metadata for different nodes' do
|
15
15
|
with_test_platform(
|
16
16
|
{ nodes: { 'node1' => {}, 'node2' => {} } },
|
17
|
-
additional_config: <<~
|
17
|
+
additional_config: <<~EO_CONFIG
|
18
18
|
for_nodes('node1') { set_metadata(my_property_1: 'my_value1', my_property_2: 'my_value2') }
|
19
19
|
for_nodes('node2') { set_metadata(my_property_2: 'my_value3', my_property_3: 'my_value4') }
|
20
20
|
EO_CONFIG
|
@@ -276,7 +276,7 @@ describe HybridPlatformsConductor::NodesHandler do
|
|
276
276
|
it 'can configure different priority rules for different properties on different nodes' do
|
277
277
|
with_cmdb_test_platform(
|
278
278
|
cmdbs: %i[test_cmdb test_cmdb_2],
|
279
|
-
additional_config: <<~
|
279
|
+
additional_config: <<~EO_CONFIG
|
280
280
|
for_nodes('node1') do
|
281
281
|
master_cmdbs(
|
282
282
|
test_cmdb: :different_comment_2,
|
@@ -309,7 +309,7 @@ describe HybridPlatformsConductor::NodesHandler do
|
|
309
309
|
it 'fails when there are conflicts in the definition of master CMDBs' do
|
310
310
|
with_cmdb_test_platform(
|
311
311
|
cmdbs: %i[test_cmdb test_cmdb_2],
|
312
|
-
additional_config: <<~
|
312
|
+
additional_config: <<~EO_CONFIG
|
313
313
|
master_cmdbs(
|
314
314
|
test_cmdb: %i[different_comment different_comment_2]
|
315
315
|
)
|
@@ -326,7 +326,7 @@ describe HybridPlatformsConductor::NodesHandler do
|
|
326
326
|
it 'fails when the CMDB marked as master does not implement the property' do
|
327
327
|
with_cmdb_test_platform(
|
328
328
|
cmdbs: %i[test_cmdb test_cmdb_2],
|
329
|
-
additional_config: <<~
|
329
|
+
additional_config: <<~EO_CONFIG
|
330
330
|
master_cmdbs(
|
331
331
|
test_cmdb_2: :upcase
|
332
332
|
)
|
@@ -70,7 +70,7 @@ describe HybridPlatformsConductor::NodesHandler do
|
|
70
70
|
gemspec
|
71
71
|
+
|
72
72
|
+gem 'byebug'
|
73
|
-
|
73
|
+
No newline at end of file
|
74
74
|
diff --git a/lib/hybrid_platforms_conductor/nodes_handler.rb b/lib/stale/hybrid_platforms_conductor/nodes_handler.rb
|
75
75
|
index e8e1778..69a84bd 100644
|
76
76
|
--- a/lib/hybrid_platforms_conductor/nodes_handler.rb
|
@@ -101,7 +101,7 @@ describe HybridPlatformsConductor::NodesHandler do
|
|
101
101
|
gemspec
|
102
102
|
+
|
103
103
|
+gem 'byebug'
|
104
|
-
|
104
|
+
No newline at end of file
|
105
105
|
EO_STDOUT
|
106
106
|
},
|
107
107
|
'lib/hybrid_platforms_conductor/nodes_handler.rb' => {
|
data/spec/hybrid_platforms_conductor_test/api/platform_handlers/serverless_chef/packaging_spec.rb
CHANGED
@@ -332,7 +332,7 @@ describe HybridPlatformsConductor::HpcPlugins::PlatformHandler::ServerlessChef d
|
|
332
332
|
|
333
333
|
it 'packages the repository with a testadmin public key in local mode' do
|
334
334
|
with_serverless_chef_platforms('hpc_test') do |platform, repository|
|
335
|
-
File.write("#{ENV
|
335
|
+
File.write("#{ENV.fetch('hpc_platforms', nil)}/testadmin.key.pub", 'ssh-rsa 12345 testadmin@test.com')
|
336
336
|
with_packaging_mocked(
|
337
337
|
repository,
|
338
338
|
policy_file: 'policyfiles/test_policy.local.rb',
|
@@ -351,7 +351,7 @@ describe HybridPlatformsConductor::HpcPlugins::PlatformHandler::ServerlessChef d
|
|
351
351
|
|
352
352
|
it 'does not package the repository with a testadmin public key in prod mode' do
|
353
353
|
with_serverless_chef_platforms('hpc_test') do |platform, repository|
|
354
|
-
File.write("#{ENV
|
354
|
+
File.write("#{ENV.fetch('hpc_platforms', nil)}/testadmin.key.pub", 'ssh-rsa 12345 testadmin@test.com')
|
355
355
|
with_packaging_mocked(
|
356
356
|
repository,
|
357
357
|
cookbook_metadata: {
|
@@ -70,7 +70,7 @@ describe HybridPlatformsConductor::PlatformsHandler do
|
|
70
70
|
'platform1' => { platform_type: :test },
|
71
71
|
'platform2' => { platform_type: :test_2 }
|
72
72
|
},
|
73
|
-
additional_config: "test_2_platform path:
|
73
|
+
additional_config: "test_2_platform path: '#{repository}/platform1'"
|
74
74
|
) do
|
75
75
|
expect { test_platforms_handler.known_platforms }.to raise_error 'Platform name platform1 is declared several times.'
|
76
76
|
end
|
@@ -84,7 +84,7 @@ describe HybridPlatformsConductor::PlatformsHandler do
|
|
84
84
|
'platform1' => { platform_type: :test },
|
85
85
|
'platform2' => { platform_type: :test_2 }
|
86
86
|
},
|
87
|
-
additional_config: "test_2_platform path:
|
87
|
+
additional_config: "test_2_platform path: '#{repository}', name: 'other_platform'"
|
88
88
|
) do
|
89
89
|
expect { test_platforms_handler.known_platforms }.to raise_error "Platform repository path #{repository} is declared several times."
|
90
90
|
end
|
@@ -99,7 +99,7 @@ describe HybridPlatformsConductor::PlatformsHandler do
|
|
99
99
|
'platform1' => { platform_type: :test },
|
100
100
|
'platform2' => { platform_type: :test_2 }
|
101
101
|
},
|
102
|
-
additional_config: "test_platform path:
|
102
|
+
additional_config: "test_platform path: '#{repository}/platform1', name: 'other_platform'"
|
103
103
|
) do
|
104
104
|
expect(test_platforms_handler.known_platforms.map(&:name).sort).to eq %w[platform1 platform2 other_platform].sort
|
105
105
|
end
|
@@ -105,9 +105,7 @@ describe HybridPlatformsConductor::Plugins do
|
|
105
105
|
with_test_platform({}) do
|
106
106
|
plugins = described_class.new(
|
107
107
|
:test_plugin_type,
|
108
|
-
init_plugin: proc
|
109
|
-
plugin_class.name
|
110
|
-
end,
|
108
|
+
init_plugin: proc(&:name),
|
111
109
|
logger: logger,
|
112
110
|
logger_stderr: logger
|
113
111
|
)
|
@@ -34,14 +34,14 @@ describe HybridPlatformsConductor::ServicesHandler do
|
|
34
34
|
it 'allows deployment in local environment' do
|
35
35
|
with_test_platform_for_services_test do
|
36
36
|
with_cmd_runner_mocked([]) do
|
37
|
-
expect(test_services_handler.
|
37
|
+
expect(test_services_handler.barrier_to_deploy(services: { 'node1' => %w[service1] }, local_environment: true)).to be_nil
|
38
38
|
end
|
39
39
|
end
|
40
40
|
end
|
41
41
|
|
42
42
|
it 'allows deployment if branch is on master' do
|
43
43
|
with_test_platform_for_services_test do
|
44
|
-
expect(test_services_handler.
|
44
|
+
expect(test_services_handler.barrier_to_deploy(services: { 'node1' => %w[service1] }, local_environment: false)).to be_nil
|
45
45
|
end
|
46
46
|
end
|
47
47
|
|
@@ -52,7 +52,7 @@ describe HybridPlatformsConductor::ServicesHandler do
|
|
52
52
|
deployable_services: %w[service1]
|
53
53
|
}
|
54
54
|
) do
|
55
|
-
expect(test_services_handler.
|
55
|
+
expect(test_services_handler.barrier_to_deploy(services: { 'node1' => %w[service1] }, local_environment: false)).to be_nil
|
56
56
|
end
|
57
57
|
end
|
58
58
|
|
@@ -62,7 +62,7 @@ describe HybridPlatformsConductor::ServicesHandler do
|
|
62
62
|
git = Git.open(repository)
|
63
63
|
git.add_remote('another_remote', remote_repo).fetch
|
64
64
|
git.checkout('remotes/another_remote/master')
|
65
|
-
expect(test_services_handler.
|
65
|
+
expect(test_services_handler.barrier_to_deploy(services: { 'node1' => %w[service1] }, local_environment: false)).to be_nil
|
66
66
|
end
|
67
67
|
end
|
68
68
|
end
|
@@ -70,14 +70,14 @@ describe HybridPlatformsConductor::ServicesHandler do
|
|
70
70
|
it 'allows deployment if branch is on master even if not checked-out' do
|
71
71
|
with_test_platform_for_services_test do |repository|
|
72
72
|
Git.open(repository).branch('other_branch').checkout
|
73
|
-
expect(test_services_handler.
|
73
|
+
expect(test_services_handler.barrier_to_deploy(services: { 'node1' => %w[service1] }, local_environment: false)).to be_nil
|
74
74
|
end
|
75
75
|
end
|
76
76
|
|
77
77
|
it 'refuses deployment if branch is not master' do
|
78
78
|
with_test_platform_for_services_test do |repository|
|
79
79
|
checkout_non_master_on(repository)
|
80
|
-
expect(test_services_handler.
|
80
|
+
expect(test_services_handler.barrier_to_deploy(services: { 'node1' => %w[service1] }, local_environment: false)).to eq "The following platforms have not checked out master: #{repository}. Only master should be deployed in production."
|
81
81
|
end
|
82
82
|
end
|
83
83
|
|
@@ -91,7 +91,7 @@ describe HybridPlatformsConductor::ServicesHandler do
|
|
91
91
|
as_git: true
|
92
92
|
) do
|
93
93
|
expect(
|
94
|
-
test_services_handler.
|
94
|
+
test_services_handler.barrier_to_deploy(
|
95
95
|
services: { 'node1' => %w[service1], 'node2' => %w[service2], 'node3' => %w[service3] },
|
96
96
|
local_environment: false
|
97
97
|
)
|
@@ -112,7 +112,7 @@ describe HybridPlatformsConductor::ServicesHandler do
|
|
112
112
|
checkout_non_master_on(repositories['platform2'])
|
113
113
|
checkout_non_master_on(repositories['platform4'])
|
114
114
|
expect(
|
115
|
-
test_services_handler.
|
115
|
+
test_services_handler.barrier_to_deploy(
|
116
116
|
services: { 'node1' => %w[service1], 'node2' => %w[service2], 'node3' => %w[service3], 'node4' => %w[service4] },
|
117
117
|
local_environment: false
|
118
118
|
)
|
@@ -133,7 +133,7 @@ describe HybridPlatformsConductor::ServicesHandler do
|
|
133
133
|
checkout_non_master_on(repositories['platform2'])
|
134
134
|
checkout_non_master_on(repositories['platform4'])
|
135
135
|
expect(
|
136
|
-
test_services_handler.
|
136
|
+
test_services_handler.barrier_to_deploy(
|
137
137
|
services: { 'node1' => %w[service1 service3] },
|
138
138
|
local_environment: false
|
139
139
|
)
|
@@ -53,7 +53,7 @@ describe HybridPlatformsConductor::TestsRunner do
|
|
53
53
|
it 'returns 0 when tests are failing as expected' do
|
54
54
|
with_test_platform(
|
55
55
|
{},
|
56
|
-
additional_config: <<~
|
56
|
+
additional_config: <<~EO_CONFIG
|
57
57
|
expect_tests_to_fail(:platform_test, 'Expected failure')
|
58
58
|
EO_CONFIG
|
59
59
|
) do
|
@@ -67,7 +67,7 @@ describe HybridPlatformsConductor::TestsRunner do
|
|
67
67
|
it 'returns 0 when tests are failing as expected on a given node' do
|
68
68
|
with_test_platform(
|
69
69
|
{ nodes: { 'node1' => {}, 'node2' => {}, 'node3' => {} } },
|
70
|
-
additional_config: <<~
|
70
|
+
additional_config: <<~EO_CONFIG
|
71
71
|
for_nodes('node2') do
|
72
72
|
expect_tests_to_fail(:node_test, 'Expected failure')
|
73
73
|
end
|
@@ -83,7 +83,7 @@ describe HybridPlatformsConductor::TestsRunner do
|
|
83
83
|
it 'returns 1 when tests are succeeding but were expected to fail' do
|
84
84
|
with_test_platform(
|
85
85
|
{},
|
86
|
-
additional_config: <<~
|
86
|
+
additional_config: <<~EO_CONFIG
|
87
87
|
expect_tests_to_fail(:platform_test, 'Expected failure')
|
88
88
|
EO_CONFIG
|
89
89
|
) do
|
@@ -96,7 +96,7 @@ describe HybridPlatformsConductor::TestsRunner do
|
|
96
96
|
it 'returns 1 when extra expected failures have not been tested when running all tests' do
|
97
97
|
with_test_platform(
|
98
98
|
{ nodes: { 'another_node' => {} } },
|
99
|
-
additional_config: <<~
|
99
|
+
additional_config: <<~EO_CONFIG
|
100
100
|
for_nodes('another_node') do
|
101
101
|
expect_tests_to_fail(:platform_test, 'Expected failure')
|
102
102
|
end
|
@@ -111,7 +111,7 @@ describe HybridPlatformsConductor::TestsRunner do
|
|
111
111
|
it 'fails when expected failures reference missing nodes' do
|
112
112
|
with_test_platform(
|
113
113
|
{ nodes: { 'node' => {} } },
|
114
|
-
additional_config: <<~
|
114
|
+
additional_config: <<~EO_CONFIG
|
115
115
|
for_nodes('missing_node') do
|
116
116
|
expect_tests_to_fail(:node_test, 'Expected failure')
|
117
117
|
end
|
@@ -134,7 +134,7 @@ describe HybridPlatformsConductor::TestsRunner do
|
|
134
134
|
|
135
135
|
it 'reuses run_logs logs instead of running check-node when we ask for it' do
|
136
136
|
with_test_platform_for_node_check_tests do
|
137
|
-
run_logs_dir = "#{ENV
|
137
|
+
run_logs_dir = "#{ENV.fetch('hpc_platforms', nil)}/run_logs"
|
138
138
|
FileUtils.mkdir_p run_logs_dir
|
139
139
|
File.write("#{run_logs_dir}/node11.stdout", 'node11 check ok from logs')
|
140
140
|
File.write("#{run_logs_dir}/node12.stdout", 'node12 check ok from logs')
|
@@ -155,7 +155,7 @@ describe HybridPlatformsConductor::TestsRunner do
|
|
155
155
|
|
156
156
|
it 'fails when some run_logs are missing' do
|
157
157
|
with_test_platform_for_node_check_tests do
|
158
|
-
run_logs_dir = "#{ENV
|
158
|
+
run_logs_dir = "#{ENV.fetch('hpc_platforms', nil)}/run_logs"
|
159
159
|
FileUtils.mkdir_p run_logs_dir
|
160
160
|
File.write("#{run_logs_dir}/node11.stdout", 'node11 check ok from logs')
|
161
161
|
File.write("#{run_logs_dir}/node12.stdout", 'node12 check ok from logs')
|
@@ -309,7 +309,7 @@ describe HybridPlatformsConductor::TestsRunner do
|
|
309
309
|
'nodes_list2' => %w[node2 node3 node4]
|
310
310
|
}
|
311
311
|
},
|
312
|
-
additional_config: <<~
|
312
|
+
additional_config: <<~EO_CONFIG
|
313
313
|
for_nodes('node1') do
|
314
314
|
expect_tests_to_fail(:node_test, 'Expected failure')
|
315
315
|
end
|
@@ -35,7 +35,7 @@ describe 'executables\' common options' do
|
|
35
35
|
# 'topograph' => ['--from', '--node node1', '--to', '--node node1', '--skip-run', '--output', 'graphviz:graph.gv'],
|
36
36
|
}.each do |executable, default_options|
|
37
37
|
|
38
|
-
context "checking common options for #{executable}" do
|
38
|
+
context "when checking common options for #{executable}" do
|
39
39
|
|
40
40
|
it 'displays its help' do
|
41
41
|
with_test_platform_for_common_options do
|
@@ -43,12 +43,10 @@ module HybridPlatformsConductorTest
|
|
43
43
|
ssh_commands_per_connection = []
|
44
44
|
if with_strict_host_key_checking
|
45
45
|
ip = node_connection_info[:ip] || node_connection_info[:connection]
|
46
|
-
ssh_commands_once.
|
46
|
+
ssh_commands_once.push(
|
47
47
|
[
|
48
|
-
[
|
49
|
-
|
50
|
-
proc { [0, "#{ip} ssh-rsa fake_host_key_for_#{ip}", ''] }
|
51
|
-
]
|
48
|
+
"ssh-keyscan -p #{node_connection_info[:port]} #{ip}",
|
49
|
+
proc { [0, "#{ip} ssh-rsa fake_host_key_for_#{ip}", ''] }
|
52
50
|
]
|
53
51
|
)
|
54
52
|
end
|
@@ -144,7 +142,7 @@ module HybridPlatformsConductorTest
|
|
144
142
|
with_cmd_runner_mocked(
|
145
143
|
[
|
146
144
|
['which env', proc { [0, "/usr/bin/env\n", ''] }],
|
147
|
-
['ssh -V 2>&1', proc { [0, "
|
145
|
+
['ssh -V 2>&1', proc { [0, "OpenSSH_9.8p1 Debian-10+deb9u7, OpenSSL 1.0.2u 20 Dec 2019\n", ''] }]
|
148
146
|
] +
|
149
147
|
(password ? [['sshpass -V', proc { [0, "sshpass 1.06\n", ''] }]] : []) +
|
150
148
|
ssh_expected_commands_for(
|
@@ -97,7 +97,7 @@ module HybridPlatformsConductorTest
|
|
97
97
|
# Parameters::
|
98
98
|
# * *services* (Hash<String, Array<String> >): List of services to be expected, per node name
|
99
99
|
def expect_services_handler_to_deploy(services)
|
100
|
-
expect(test_services_handler).to receive(:
|
100
|
+
expect(test_services_handler).to receive(:barrier_to_deploy).with(
|
101
101
|
services: services,
|
102
102
|
local_environment: false
|
103
103
|
).and_return(nil)
|
@@ -187,7 +187,7 @@ module HybridPlatformsConductorTest
|
|
187
187
|
# Parameters::
|
188
188
|
# * *nodes_info* (Hash): Node info to give the platform [default: 1 node having 1 service]
|
189
189
|
# * *expect_services_to_deploy* (Hash<String,Array<String>>): Expected services to be deployed [default: all services from nodes_info]
|
190
|
-
# * *expect_deploy_allowed* (Boolean): Should we expect the call to
|
190
|
+
# * *expect_deploy_allowed* (Boolean): Should we expect the call to barrier_to_deploy [default: true]
|
191
191
|
# * *expect_package* (Boolean): Should we expect packaging? [default: true]
|
192
192
|
# * *expect_prepare_for_deploy* (Boolean): Should we expect calls to prepare for deploy? [default: true]
|
193
193
|
# * *expect_connections_to_nodes* (Boolean): Should we expect connections to nodes? [default: true]
|
@@ -223,7 +223,7 @@ module HybridPlatformsConductorTest
|
|
223
223
|
with_test_platform(nodes_info, as_git: !check_mode, additional_config: "#{additional_config}\nsend_logs_to :test_log") do |repository|
|
224
224
|
# Mock the ServicesHandler accesses
|
225
225
|
if !check_mode && expect_deploy_allowed
|
226
|
-
expect(test_services_handler).to receive(:
|
226
|
+
expect(test_services_handler).to receive(:barrier_to_deploy).with(
|
227
227
|
services: expect_services_to_deploy,
|
228
228
|
local_environment: expect_local_environment
|
229
229
|
).and_return(nil)
|
@@ -62,7 +62,7 @@ module HybridPlatformsConductorTest
|
|
62
62
|
allow(component_class).to(receive(:new).once { component })
|
63
63
|
end
|
64
64
|
# Run the executable
|
65
|
-
args.
|
65
|
+
args.push('--debug') if ENV['TEST_DEBUG'] == '1'
|
66
66
|
ARGV.replace(args)
|
67
67
|
old_program_name = $PROGRAM_NAME
|
68
68
|
$0 = executable
|
@@ -359,7 +359,7 @@ module HybridPlatformsConductorTest
|
|
359
359
|
end
|
360
360
|
]
|
361
361
|
if destroy_vm
|
362
|
-
runs.
|
362
|
+
runs.push(
|
363
363
|
proc do |actions|
|
364
364
|
expect(actions.keys).to eq ['node']
|
365
365
|
expect(actions['node'].size).to eq 4
|
@@ -409,7 +409,7 @@ module HybridPlatformsConductorTest
|
|
409
409
|
#{JSON.pretty_generate(result)}
|
410
410
|
EO_STDOUT
|
411
411
|
end
|
412
|
-
|
412
|
+
)
|
413
413
|
end
|
414
414
|
expect_actions_executor_runs runs
|
415
415
|
end
|
@@ -722,12 +722,12 @@ module HybridPlatformsConductorTest
|
|
722
722
|
unless create.nil?
|
723
723
|
create_file = "#{@repository}/proxmox/create_vm.json"
|
724
724
|
File.write(create_file, create.to_json)
|
725
|
-
script_args.
|
725
|
+
script_args.push('--create', create_file)
|
726
726
|
end
|
727
727
|
unless destroy.nil?
|
728
728
|
destroy_file = "#{@repository}/proxmox/destroy_vm.json"
|
729
729
|
File.write(destroy_file, destroy.to_json)
|
730
|
-
script_args.
|
730
|
+
script_args.push('--destroy', destroy_file)
|
731
731
|
end
|
732
732
|
# Call the script by loading the Ruby file mocking the ARGV and ENV variables
|
733
733
|
old_argv = ARGV.dup
|