hybrid_platforms_conductor 33.9.1 → 33.9.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +33 -0
- data/bin/last_deploys +3 -4
- 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/actions_executor.rb +2 -2
- data/lib/hybrid_platforms_conductor/common_config_dsl/file_system_tests.rb +2 -2
- data/lib/hybrid_platforms_conductor/config.rb +1 -0
- data/lib/hybrid_platforms_conductor/deployer.rb +19 -13
- data/lib/hybrid_platforms_conductor/executable.rb +1 -1
- data/lib/hybrid_platforms_conductor/hpc_plugins/cmdb/host_ip.rb +21 -7
- data/lib/hybrid_platforms_conductor/hpc_plugins/cmdb/platform_handlers.rb +2 -2
- data/lib/hybrid_platforms_conductor/hpc_plugins/connector/ssh.rb +1 -1
- data/lib/hybrid_platforms_conductor/hpc_plugins/platform_handler/serverless_chef.rb +1 -2
- data/lib/hybrid_platforms_conductor/hpc_plugins/provisioner/proxmox/proxmox_waiter.rb +6 -6
- data/lib/hybrid_platforms_conductor/hpc_plugins/provisioner/proxmox.rb +2 -2
- data/lib/hybrid_platforms_conductor/hpc_plugins/report/mediawiki.rb +1 -1
- data/lib/hybrid_platforms_conductor/hpc_plugins/secrets_reader/keepass.rb +6 -6
- data/lib/hybrid_platforms_conductor/hpc_plugins/test/file_system.rb +2 -2
- data/lib/hybrid_platforms_conductor/hpc_plugins/test/file_system_hdfs.rb +2 -2
- data/lib/hybrid_platforms_conductor/hpc_plugins/test/ip.rb +1 -1
- data/lib/hybrid_platforms_conductor/hpc_plugins/test/linear_strategy.rb +4 -4
- data/lib/hybrid_platforms_conductor/hpc_plugins/test/private_ips.rb +1 -2
- data/lib/hybrid_platforms_conductor/hpc_plugins/test/public_ips.rb +1 -2
- data/lib/hybrid_platforms_conductor/hpc_plugins/test/veids.rb +1 -2
- data/lib/hybrid_platforms_conductor/hpc_plugins/test/vulnerabilities.rb +2 -2
- data/lib/hybrid_platforms_conductor/plugins.rb +4 -3
- data/lib/hybrid_platforms_conductor/tests_runner.rb +2 -2
- data/lib/hybrid_platforms_conductor/topographer.rb +5 -6
- data/lib/hybrid_platforms_conductor/version.rb +1 -1
- data/spec/hybrid_platforms_conductor_test/api/actions_executor/actions/bash_spec.rb +1 -1
- data/spec/hybrid_platforms_conductor_test/api/actions_executor/actions/ruby_spec.rb +8 -8
- data/spec/hybrid_platforms_conductor_test/api/actions_executor/connectors/ssh/cli_options_spec.rb +3 -3
- data/spec/hybrid_platforms_conductor_test/api/actions_executor/connectors/ssh/connections_spec.rb +8 -8
- data/spec/hybrid_platforms_conductor_test/api/actions_executor/connectors/ssh/global_helpers_spec.rb +1 -1
- data/spec/hybrid_platforms_conductor_test/api/actions_executor/helpers_spec.rb +4 -4
- data/spec/hybrid_platforms_conductor_test/api/actions_executor/timeout_spec.rb +1 -1
- data/spec/hybrid_platforms_conductor_test/api/cmd_runner_spec.rb +4 -4
- data/spec/hybrid_platforms_conductor_test/api/deployer/deploy_spec.rb +44 -0
- data/spec/hybrid_platforms_conductor_test/api/deployer/log_plugins/remote_fs_spec.rb +12 -12
- data/spec/hybrid_platforms_conductor_test/api/deployer/provisioner_spec.rb +8 -8
- data/spec/hybrid_platforms_conductor_test/api/deployer/provisioners/docker_spec.rb +1 -1
- data/spec/hybrid_platforms_conductor_test/api/deployer/provisioners/proxmox/reserve_proxmox_container/expired_containers_spec.rb +27 -27
- data/spec/hybrid_platforms_conductor_test/api/deployer/provisioners/proxmox/reserve_proxmox_container/retries_spec.rb +1 -1
- data/spec/hybrid_platforms_conductor_test/api/nodes_handler/cmdbs/host_ip_spec.rb +25 -0
- data/spec/hybrid_platforms_conductor_test/api/nodes_handler/cmdbs_plugins_api_spec.rb +5 -5
- data/spec/hybrid_platforms_conductor_test/api/platform_handlers/serverless_chef/inventory_spec.rb +1 -1
- data/spec/hybrid_platforms_conductor_test/api/platform_handlers/serverless_chef/packaging_spec.rb +9 -9
- data/spec/hybrid_platforms_conductor_test/api/platform_handlers/serverless_chef/services_deployment_spec.rb +1 -1
- data/spec/hybrid_platforms_conductor_test/api/platforms_handler_spec.rb +1 -1
- data/spec/hybrid_platforms_conductor_test/api/plugins_spec.rb +30 -2
- data/spec/hybrid_platforms_conductor_test/api/services_handler/deploy_allowed_spec.rb +7 -7
- data/spec/hybrid_platforms_conductor_test/api/services_handler/package_spec.rb +18 -18
- data/spec/hybrid_platforms_conductor_test/api/services_handler/prepare_for_deploy_spec.rb +30 -30
- 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 +6 -6
- data/spec/hybrid_platforms_conductor_test/api/tests_runner/node_ssh_spec.rb +6 -6
- data/spec/hybrid_platforms_conductor_test/api/tests_runner/reports_spec.rb +4 -4
- data/spec/hybrid_platforms_conductor_test/api/tests_runner/test_plugins/linear_strategy_spec.rb +69 -0
- data/spec/hybrid_platforms_conductor_test/cmdb_plugins/test_cmdb.rb +8 -8
- data/spec/hybrid_platforms_conductor_test/cmdb_plugins/test_cmdb_2.rb +5 -5
- data/spec/hybrid_platforms_conductor_test/cmdb_plugins/test_cmdb_others.rb +3 -3
- data/spec/hybrid_platforms_conductor_test/cmdb_plugins/test_cmdb_others_2.rb +3 -3
- data/spec/hybrid_platforms_conductor_test/docs_spec.rb +1 -1
- data/spec/hybrid_platforms_conductor_test/executables/check_node_spec.rb +1 -1
- data/spec/hybrid_platforms_conductor_test/executables/deploy_spec.rb +1 -1
- data/spec/hybrid_platforms_conductor_test/executables/options/cmd_runner_spec.rb +1 -1
- data/spec/hybrid_platforms_conductor_test/executables/options/deployer_spec.rb +2 -2
- data/spec/hybrid_platforms_conductor_test/executables/options/nodes_handler_spec.rb +1 -0
- data/spec/hybrid_platforms_conductor_test/executables/options/tests_runner_spec.rb +1 -1
- data/spec/hybrid_platforms_conductor_test/executables/report_spec.rb +1 -0
- data/spec/hybrid_platforms_conductor_test/executables/run_spec.rb +2 -2
- data/spec/hybrid_platforms_conductor_test/helpers/actions_executor_helpers.rb +1 -1
- data/spec/hybrid_platforms_conductor_test/helpers/cmdb_helpers.rb +2 -2
- data/spec/hybrid_platforms_conductor_test/helpers/connector_ssh_helpers.rb +1 -1
- data/spec/hybrid_platforms_conductor_test/helpers/deployer_helpers.rb +7 -7
- data/spec/hybrid_platforms_conductor_test/helpers/platforms_handler_helpers.rb +3 -3
- data/spec/hybrid_platforms_conductor_test/helpers/provisioner_proxmox_helpers.rb +11 -12
- data/spec/hybrid_platforms_conductor_test/helpers/serverless_chef_helpers.rb +2 -2
- data/spec/hybrid_platforms_conductor_test/mocked_lib/my_test_gem_with_lib/sub1/lib/sub2/hpc_plugins/test_plugin_type_3/test_plugin_id_5.rb +34 -0
- data/spec/hybrid_platforms_conductor_test/shared_examples/deployer.rb +1 -1
- data/spec/hybrid_platforms_conductor_test/test_connector.rb +1 -1
- data/spec/hybrid_platforms_conductor_test/test_log_plugin.rb +2 -2
- data/spec/hybrid_platforms_conductor_test.rb +2 -0
- metadata +153 -136
@@ -27,7 +27,7 @@ module HybridPlatformsConductorTest
|
|
27
27
|
def get_nothing(nodes, metadata)
|
28
28
|
record_call(:get_nothing, nodes, metadata)
|
29
29
|
# Here we return something to test that if the first one fails we have the second CMDB
|
30
|
-
nodes.
|
30
|
+
nodes.to_h { |node| [node, "#{node} has nothing"] }
|
31
31
|
end
|
32
32
|
|
33
33
|
# Get a specific property for a given set of nodes.
|
@@ -42,7 +42,7 @@ module HybridPlatformsConductorTest
|
|
42
42
|
# Nodes for which the property can't be fetched can be ommitted.
|
43
43
|
def get_same_comment(nodes, metadata)
|
44
44
|
record_call(:get_same_comment, nodes, metadata)
|
45
|
-
nodes.
|
45
|
+
nodes.to_h { |node| [node, "Comment for #{node}"] }
|
46
46
|
end
|
47
47
|
|
48
48
|
# Get a specific property for a given set of nodes.
|
@@ -57,7 +57,7 @@ module HybridPlatformsConductorTest
|
|
57
57
|
# Nodes for which the property can't be fetched can be ommitted.
|
58
58
|
def get_different_comment(nodes, metadata)
|
59
59
|
record_call(:get_different_comment, nodes, metadata)
|
60
|
-
nodes.
|
60
|
+
nodes.to_h { |node| [node, 'Comment from test_cmdb_2'] }
|
61
61
|
end
|
62
62
|
|
63
63
|
# Get a specific property for a given set of nodes.
|
@@ -72,7 +72,7 @@ module HybridPlatformsConductorTest
|
|
72
72
|
# Nodes for which the property can't be fetched can be ommitted.
|
73
73
|
def get_different_comment_2(nodes, metadata)
|
74
74
|
record_call(:get_different_comment_2, nodes, metadata)
|
75
|
-
nodes.
|
75
|
+
nodes.to_h { |node| [node, 'Comment2 from test_cmdb_2'] }
|
76
76
|
end
|
77
77
|
|
78
78
|
# Register a call to be checked by the tests later
|
@@ -83,7 +83,7 @@ module HybridPlatformsConductorTest
|
|
83
83
|
def record_call(method, *args)
|
84
84
|
@calls = [] unless defined?(@calls)
|
85
85
|
# Create a shallow copy of the args, just to make sure they won't get changed by later code
|
86
|
-
@calls << [method] + Marshal.load(Marshal.dump(args))
|
86
|
+
@calls << ([method] + Marshal.load(Marshal.dump(args)))
|
87
87
|
end
|
88
88
|
|
89
89
|
end
|
@@ -30,7 +30,7 @@ module HybridPlatformsConductorTest
|
|
30
30
|
# Nodes for which the property can't be fetched can be ommitted.
|
31
31
|
def get_others(nodes, metadata)
|
32
32
|
record_call(:get_others, nodes, metadata)
|
33
|
-
nodes.
|
33
|
+
nodes.to_h do |node|
|
34
34
|
[
|
35
35
|
node,
|
36
36
|
{
|
@@ -39,7 +39,7 @@ module HybridPlatformsConductorTest
|
|
39
39
|
nothing: "#{node} has another nothing"
|
40
40
|
}
|
41
41
|
]
|
42
|
-
end
|
42
|
+
end
|
43
43
|
end
|
44
44
|
|
45
45
|
# Register a call to be checked by the tests later
|
@@ -50,7 +50,7 @@ module HybridPlatformsConductorTest
|
|
50
50
|
def record_call(method, *args)
|
51
51
|
@calls = [] unless defined?(@calls)
|
52
52
|
# Create a shallow copy of the args, just to make sure they won't get changed by later code
|
53
|
-
@calls << [method] + Marshal.load(Marshal.dump(args))
|
53
|
+
@calls << ([method] + Marshal.load(Marshal.dump(args)))
|
54
54
|
end
|
55
55
|
|
56
56
|
end
|
@@ -30,14 +30,14 @@ module HybridPlatformsConductorTest
|
|
30
30
|
# Nodes for which the property can't be fetched can be ommitted.
|
31
31
|
def get_others(nodes, metadata)
|
32
32
|
record_call(:get_others, nodes, metadata)
|
33
|
-
nodes.
|
33
|
+
nodes.to_h do |node|
|
34
34
|
[
|
35
35
|
node,
|
36
36
|
{
|
37
37
|
downcase: "__#{node}__"
|
38
38
|
}
|
39
39
|
]
|
40
|
-
end
|
40
|
+
end
|
41
41
|
end
|
42
42
|
|
43
43
|
# Register a call to be checked by the tests later
|
@@ -48,7 +48,7 @@ module HybridPlatformsConductorTest
|
|
48
48
|
def record_call(method, *args)
|
49
49
|
@calls = [] unless defined?(@calls)
|
50
50
|
# Create a shallow copy of the args, just to make sure they won't get changed by later code
|
51
|
-
@calls << [method] + Marshal.load(Marshal.dump(args))
|
51
|
+
@calls << ([method] + Marshal.load(Marshal.dump(args)))
|
52
52
|
end
|
53
53
|
|
54
54
|
end
|
@@ -3,7 +3,7 @@ describe 'Documentation' do
|
|
3
3
|
it 'makes sure all Markdown links are valid' do
|
4
4
|
check_stdout = `bundle exec tools/check_md README.md #{Dir.glob('docs/**/*.md').join(' ')}`.split("\n")
|
5
5
|
summary_idx = check_stdout.index { |line| line =~ /^\d+ errors:$/ }
|
6
|
-
expect(summary_idx).not_to
|
6
|
+
expect(summary_idx).not_to be_nil, "Could not parse check output: #{check_stdout.join("\n")}"
|
7
7
|
expect(check_stdout[summary_idx]).to eq('0 errors:'), "Invalid links found: #{check_stdout[summary_idx..].join("\n")}"
|
8
8
|
end
|
9
9
|
|
@@ -13,7 +13,7 @@ describe 'check-node executable' do
|
|
13
13
|
it 'checks a given node' do
|
14
14
|
with_test_platform_for_check_node do
|
15
15
|
expect(test_deployer).to receive(:deploy_on).with('node') do
|
16
|
-
expect(test_deployer.use_why_run).to
|
16
|
+
expect(test_deployer.use_why_run).to be true
|
17
17
|
test_deployer.stdout_device << "Check ok\n"
|
18
18
|
{ 'node' => [0, "Check ok\n", ''] }
|
19
19
|
end
|
@@ -13,7 +13,7 @@ describe 'deploy executable' do
|
|
13
13
|
it 'deploys a given node' do
|
14
14
|
with_test_platform_for_deploy do
|
15
15
|
expect(test_deployer).to receive(:deploy_on).with(['node']) do
|
16
|
-
expect(test_deployer.use_why_run).to
|
16
|
+
expect(test_deployer.use_why_run).to be false
|
17
17
|
test_deployer.stdout_device << "Deploy ok\n"
|
18
18
|
{ 'node' => [0, "Deploy ok\n", ''] }
|
19
19
|
end
|
@@ -13,7 +13,7 @@ describe 'executables\' Cmd Runner options' do
|
|
13
13
|
it 'displays commands instead of running them' do
|
14
14
|
with_test_platform_for_cmd_runner_options do
|
15
15
|
expect_actions_executor_runs([proc do
|
16
|
-
expect(test_cmd_runner.dry_run).to
|
16
|
+
expect(test_cmd_runner.dry_run).to be true
|
17
17
|
{}
|
18
18
|
end])
|
19
19
|
exit_code, stdout, stderr = run 'run', '--node', 'node', '--command', 'echo Hello', '--show-commands'
|
@@ -13,7 +13,7 @@ describe 'executables\' Deployer options' do
|
|
13
13
|
it 'uses parallel mode' do
|
14
14
|
with_test_platform_for_deployer_options do
|
15
15
|
expect(test_deployer).to receive(:deploy_on).with(['node']) do
|
16
|
-
expect(test_deployer.concurrent_execution).to
|
16
|
+
expect(test_deployer.concurrent_execution).to be true
|
17
17
|
{}
|
18
18
|
end
|
19
19
|
exit_code, _stdout, stderr = run 'deploy', '--node', 'node', '--parallel'
|
@@ -25,7 +25,7 @@ describe 'executables\' Deployer options' do
|
|
25
25
|
it 'uses why-run' do
|
26
26
|
with_test_platform_for_deployer_options do
|
27
27
|
expect(test_deployer).to receive(:deploy_on).with(['node']) do
|
28
|
-
expect(test_deployer.use_why_run).to
|
28
|
+
expect(test_deployer.use_why_run).to be true
|
29
29
|
{}
|
30
30
|
end
|
31
31
|
exit_code, _stdout, stderr = run 'deploy', '--node', 'node', '--why-run'
|
@@ -63,6 +63,7 @@ describe 'executables\' Nodes Handler options' do
|
|
63
63
|
it 'displays info about nodes' do
|
64
64
|
with_test_platform_for_nodes_handler_options do
|
65
65
|
with_cmd_runner_mocked [
|
66
|
+
['command -v getent', proc { [0, '', ''] }],
|
66
67
|
['getent hosts my_host15.my_domain', proc { [0, '192.168.42.15 my_host16.my_domain', ''] }],
|
67
68
|
['getent hosts my_host16.my_domain', proc { [0, '192.168.42.16 my_host16.my_domain', ''] }]
|
68
69
|
] do
|
@@ -61,7 +61,7 @@ describe 'executables\' Tests Runner options' do
|
|
61
61
|
it 'uses current run_logs instead of executing new check-nodes' do
|
62
62
|
with_test_platform({}) do
|
63
63
|
expect(test_tests_runner).to receive(:run_tests).with([]) do
|
64
|
-
expect(test_tests_runner.skip_run).to
|
64
|
+
expect(test_tests_runner.skip_run).to be true
|
65
65
|
0
|
66
66
|
end
|
67
67
|
exit_code, stdout, stderr = run 'test', '--test', 'my_test', '--skip-run'
|
@@ -47,6 +47,7 @@ describe 'report executable' do
|
|
47
47
|
}
|
48
48
|
) do
|
49
49
|
with_cmd_runner_mocked [
|
50
|
+
['command -v getent', proc { [0, '', ''] }],
|
50
51
|
['getent hosts node.domain.com', proc { [0, '192.168.0.1 node.domain.com', ''] }]
|
51
52
|
] do
|
52
53
|
exit_code, stdout, stderr = run 'report', '--node', 'node'
|
@@ -73,7 +73,7 @@ describe 'run executable' do
|
|
73
73
|
it 'executes a single command on several nodes' do
|
74
74
|
with_test_platform_for_run do
|
75
75
|
expect_actions_executor_runs([proc do |actions, timeout: nil, concurrent: false, log_to_dir: 'run_logs', log_to_stdout: true|
|
76
|
-
expect(concurrent).to
|
76
|
+
expect(concurrent).to be false
|
77
77
|
expect(actions).to eq(%w[node1 node2] => [{ remote_bash: ['echo Hello'] }])
|
78
78
|
test_actions_executor.stdout_device << "Hello\nHello\n"
|
79
79
|
{ 'node1' => [0, "Hello\nHello\n", ''] }
|
@@ -133,7 +133,7 @@ describe 'run executable' do
|
|
133
133
|
it 'executes in parallel' do
|
134
134
|
with_test_platform_for_run do
|
135
135
|
expect_actions_executor_runs([proc do |actions, timeout: nil, concurrent: false, log_to_dir: 'run_logs', log_to_stdout: true|
|
136
|
-
expect(concurrent).to
|
136
|
+
expect(concurrent).to be true
|
137
137
|
expect(actions).to eq(%w[node1 node2] => [{ remote_bash: ['echo Hello'] }])
|
138
138
|
test_actions_executor.stdout_device << "Hello\nHello\n"
|
139
139
|
{ 'node1' => [0, "Hello\nHello\n", ''] }
|
@@ -58,7 +58,7 @@ module HybridPlatformsConductorTest
|
|
58
58
|
def with_connections_mocked_on(expected_nodes)
|
59
59
|
expect(test_actions_executor).to receive(:with_connections_prepared_to) do |nodes, no_exception: false, &client_code|
|
60
60
|
expect(nodes.sort).to eq expected_nodes.sort
|
61
|
-
client_code.call
|
61
|
+
client_code.call(nodes.to_h { |node| [node, test_actions_executor.connector(:test_connector)] })
|
62
62
|
end
|
63
63
|
yield
|
64
64
|
end
|
@@ -21,12 +21,12 @@ module HybridPlatformsConductorTest
|
|
21
21
|
def register_test_cmdb(cmdb_names = [:test_cmdb])
|
22
22
|
register_plugins(
|
23
23
|
:cmdb,
|
24
|
-
cmdb_names.
|
24
|
+
cmdb_names.to_h do |plugin_id|
|
25
25
|
[
|
26
26
|
plugin_id,
|
27
27
|
HybridPlatformsConductorTest::CmdbPlugins.const_get(plugin_id.to_s.split('_').collect(&:capitalize).join.to_sym)
|
28
28
|
]
|
29
|
-
end
|
29
|
+
end
|
30
30
|
)
|
31
31
|
end
|
32
32
|
|
@@ -105,7 +105,7 @@ module HybridPlatformsConductorTest
|
|
105
105
|
{ optional: with_control_master_destroy_optional }
|
106
106
|
]
|
107
107
|
end
|
108
|
-
ssh_commands_once + ssh_commands_per_connection * node_connection_info[:times]
|
108
|
+
ssh_commands_once + (ssh_commands_per_connection * node_connection_info[:times])
|
109
109
|
end.flatten(1)
|
110
110
|
end
|
111
111
|
|
@@ -40,10 +40,10 @@ module HybridPlatformsConductorTest
|
|
40
40
|
# * Hash<String, [Integer or Symbol, String, String] >: Expected result of those expected actions
|
41
41
|
def expect_actions_to_deploy_on(actions, nodes, check: false, sudo: 'sudo -u root', expected_actions: [], mocked_result: nil)
|
42
42
|
nodes = [nodes] if nodes.is_a?(String)
|
43
|
-
mocked_result = nodes.
|
43
|
+
mocked_result = nodes.to_h { |node| [node, [0, "#{check ? 'Check' : 'Deploy'} successful", '']] } if mocked_result.nil?
|
44
44
|
expect(actions.size).to eq nodes.size
|
45
45
|
nodes.each do |node|
|
46
|
-
expect(actions.key?(node)).to
|
46
|
+
expect(actions.key?(node)).to be true
|
47
47
|
expect(actions[node].size).to eq(2 + expected_actions.size)
|
48
48
|
expect_action_to_lock_node(actions[node][0], node, sudo: sudo)
|
49
49
|
expect(actions[node][1..-2]).to eq expected_actions
|
@@ -62,10 +62,10 @@ module HybridPlatformsConductorTest
|
|
62
62
|
nodes = [nodes] if nodes.is_a?(String)
|
63
63
|
expect(actions.size).to eq nodes.size
|
64
64
|
nodes.each do |node|
|
65
|
-
expect(actions.key?(node)).to
|
65
|
+
expect(actions.key?(node)).to be true
|
66
66
|
expect_action_to_unlock_node(actions[node], node, sudo: sudo)
|
67
67
|
end
|
68
|
-
nodes.
|
68
|
+
nodes.to_h { |node| [node, [0, 'Release mutex successful', '']] }
|
69
69
|
end
|
70
70
|
|
71
71
|
# Expect a given set of actions to upload log files on a list of nodes (using the test_log log plugin)
|
@@ -77,10 +77,10 @@ module HybridPlatformsConductorTest
|
|
77
77
|
nodes = [nodes] if nodes.is_a?(String)
|
78
78
|
expect(actions.size).to eq nodes.size
|
79
79
|
nodes.each do |node|
|
80
|
-
expect(actions.key?(node)).to
|
80
|
+
expect(actions.key?(node)).to be true
|
81
81
|
expect(actions[node]).to eq [{ bash: "echo Save test logs to #{node}" }]
|
82
82
|
end
|
83
|
-
nodes.
|
83
|
+
nodes.to_h { |node| [node, [0, 'Logs uploaded', '']] }
|
84
84
|
end
|
85
85
|
|
86
86
|
# Get a test Deployer
|
@@ -325,7 +325,7 @@ module HybridPlatformsConductorTest
|
|
325
325
|
expect_actions_executor_runs(statuses.map do |status|
|
326
326
|
status = { 'node' => status } if status.is_a?(Array)
|
327
327
|
expected_actions_for_deploy_on(
|
328
|
-
services: status.keys.
|
328
|
+
services: status.keys.to_h { |node| [node, %w[service]] },
|
329
329
|
mocked_deploy_result: status
|
330
330
|
)
|
331
331
|
end.flatten)
|
@@ -14,7 +14,7 @@ module HybridPlatformsConductorTest
|
|
14
14
|
# * Parameters::
|
15
15
|
# * *repositories* (Hash<String,String>): Path to the repositories, per repository name
|
16
16
|
def with_repositories(names = [], as_git: false)
|
17
|
-
repositories = names.
|
17
|
+
repositories = names.to_h { |name| [name, "#{Dir.tmpdir}/hpc_test/#{name}"] }
|
18
18
|
repositories.each_value do |dir|
|
19
19
|
FileUtils.rm_rf dir
|
20
20
|
FileUtils.mkdir_p dir
|
@@ -91,12 +91,12 @@ module HybridPlatformsConductorTest
|
|
91
91
|
"#{platform_type}_platform path: '#{dir}'#{platforms_info[platform].key?(:name) ? ", name: '#{platforms_info[platform][:name]}'" : ''}"
|
92
92
|
end.join("\n") + "\n#{additional_config}"
|
93
93
|
) do
|
94
|
-
register_platform_handlers(platform_types.
|
94
|
+
register_platform_handlers(platform_types.to_h do |platform_type|
|
95
95
|
[
|
96
96
|
platform_type,
|
97
97
|
HybridPlatformsConductorTest::PlatformHandlerPlugins.const_get(platform_type.to_s.split('_').collect(&:capitalize).join.to_sym)
|
98
98
|
]
|
99
|
-
end
|
99
|
+
end)
|
100
100
|
self.test_platforms_info = platforms_info
|
101
101
|
yield repositories
|
102
102
|
end
|
@@ -97,7 +97,7 @@ module HybridPlatformsConductorTest
|
|
97
97
|
expect(user).to eq proxmox_user
|
98
98
|
expect(password).to eq proxmox_password
|
99
99
|
expect(realm).to eq proxmox_realm
|
100
|
-
expect(options[:verify_ssl]).to
|
100
|
+
expect(options[:verify_ssl]).to be false
|
101
101
|
proxmox = instance_double ::Proxmox::Proxmox
|
102
102
|
# Mock initialization
|
103
103
|
expect(proxmox).to receive(:logger=).and_return(nil)
|
@@ -137,7 +137,7 @@ module HybridPlatformsConductorTest
|
|
137
137
|
expect(user).to eq proxmox_user
|
138
138
|
expect(password).to eq proxmox_password
|
139
139
|
expect(realm).to eq 'pam'
|
140
|
-
expect(options[:verify_ssl]).to
|
140
|
+
expect(options[:verify_ssl]).to be false
|
141
141
|
proxmox = instance_double ::Proxmox::Proxmox
|
142
142
|
# Mock initialization
|
143
143
|
expect(proxmox).to receive(:logger=).and_return(nil)
|
@@ -180,7 +180,7 @@ module HybridPlatformsConductorTest
|
|
180
180
|
expect(user).to eq proxmox_user
|
181
181
|
expect(password).to eq proxmox_password
|
182
182
|
expect(realm).to eq 'pam'
|
183
|
-
expect(options[:verify_ssl]).to
|
183
|
+
expect(options[:verify_ssl]).to be false
|
184
184
|
proxmox = instance_double ::Proxmox::Proxmox
|
185
185
|
# Mock initialization
|
186
186
|
expect(proxmox).to receive(:logger=).and_return(nil)
|
@@ -215,7 +215,7 @@ module HybridPlatformsConductorTest
|
|
215
215
|
expect(user).to eq proxmox_user
|
216
216
|
expect(password).to eq proxmox_password
|
217
217
|
expect(realm).to eq 'pam'
|
218
|
-
expect(options[:verify_ssl]).to
|
218
|
+
expect(options[:verify_ssl]).to be false
|
219
219
|
proxmox = instance_double ::Proxmox::Proxmox
|
220
220
|
# Mock initialization
|
221
221
|
expect(proxmox).to receive(:logger=).and_return(nil)
|
@@ -252,7 +252,7 @@ module HybridPlatformsConductorTest
|
|
252
252
|
expect(user).to eq proxmox_user
|
253
253
|
expect(password).to eq proxmox_password
|
254
254
|
expect(realm).to eq 'pam'
|
255
|
-
expect(options[:verify_ssl]).to
|
255
|
+
expect(options[:verify_ssl]).to be false
|
256
256
|
proxmox = instance_double ::Proxmox::Proxmox
|
257
257
|
# Mock initialization
|
258
258
|
expect(proxmox).to receive(:logger=).and_return(nil)
|
@@ -494,8 +494,8 @@ module HybridPlatformsConductorTest
|
|
494
494
|
mock_proxmox_calls_with(
|
495
495
|
mocked_pve_nodes.map do |pve_nodes|
|
496
496
|
# Complete pve_nodes with default values
|
497
|
-
pve_nodes = pve_nodes.
|
498
|
-
pve_node_info[:lxc_containers] = (pve_node_info.key?(:lxc_containers) ? pve_node_info[:lxc_containers] : {}).
|
497
|
+
pve_nodes = pve_nodes.to_h do |pve_node_name, pve_node_info|
|
498
|
+
pve_node_info[:lxc_containers] = (pve_node_info.key?(:lxc_containers) ? pve_node_info[:lxc_containers] : {}).to_h do |vm_id, vm_info|
|
499
499
|
[
|
500
500
|
vm_id,
|
501
501
|
{
|
@@ -510,7 +510,7 @@ module HybridPlatformsConductorTest
|
|
510
510
|
environment: 'test_env'
|
511
511
|
}.merge(vm_info)
|
512
512
|
]
|
513
|
-
end
|
513
|
+
end
|
514
514
|
[
|
515
515
|
pve_node_name,
|
516
516
|
{
|
@@ -519,14 +519,14 @@ module HybridPlatformsConductorTest
|
|
519
519
|
storage_total: 100 * 1024 * 1024 * 1024
|
520
520
|
}.merge(pve_node_info)
|
521
521
|
]
|
522
|
-
end
|
522
|
+
end
|
523
523
|
proc do |url, pve_node, user, password, realm, options|
|
524
524
|
expect(url).to eq 'https://my-proxmox.my-domain.com:8006/api2/json/'
|
525
525
|
expect(pve_node).to eq 'my-proxmox'
|
526
526
|
expect(user).to eq proxmox_user
|
527
527
|
expect(password).to eq proxmox_password
|
528
528
|
expect(realm).to eq proxmox_realm
|
529
|
-
expect(options[:verify_ssl]).to
|
529
|
+
expect(options[:verify_ssl]).to be false
|
530
530
|
proxmox = instance_double ::Proxmox::Proxmox
|
531
531
|
# Mock getting status of a container
|
532
532
|
allow(proxmox).to receive(:get) do |path|
|
@@ -647,8 +647,7 @@ module HybridPlatformsConductorTest
|
|
647
647
|
block.nil? ? remaining_leftovers : remaining_leftovers.each(&block)
|
648
648
|
when %r{^/sys/fs/cgroup/\*/lxc/(.+)$}
|
649
649
|
vm_id_str = Regexp.last_match(1)
|
650
|
-
|
651
|
-
matched_files = remaining_leftovers.select { |file| file =~ file_pattern }
|
650
|
+
matched_files = remaining_leftovers.grep(%r{^/sys/fs/cgroup/.+/lxc/#{Regexp.escape(vm_id_str)}$})
|
652
651
|
block.nil? ? matched_files : matched_files.each(&block)
|
653
652
|
else
|
654
653
|
original_glob.call(dir, &block)
|
@@ -27,12 +27,12 @@ module HybridPlatformsConductorTest
|
|
27
27
|
FileUtils.cp_r "#{__dir__}/../serverless_chef_repositories/#{names[name]}/.", repository
|
28
28
|
end
|
29
29
|
with_platforms(repositories.values.map { |repository| "serverless_chef_platform path: '#{repository}'\n" }.join + additional_config) do
|
30
|
-
repositories = names.keys.
|
30
|
+
repositories = names.keys.to_h do |name|
|
31
31
|
[
|
32
32
|
test_platforms_handler.platform(name),
|
33
33
|
repositories[name]
|
34
34
|
]
|
35
|
-
end
|
35
|
+
end
|
36
36
|
test_platforms_handler.inject_dependencies(
|
37
37
|
nodes_handler: test_nodes_handler,
|
38
38
|
actions_executor: test_actions_executor
|
@@ -0,0 +1,34 @@
|
|
1
|
+
module HybridPlatformsConductorTest
|
2
|
+
|
3
|
+
module MockedLib
|
4
|
+
|
5
|
+
module MyTestGemWithLib
|
6
|
+
|
7
|
+
module Sub1
|
8
|
+
|
9
|
+
module Lib
|
10
|
+
|
11
|
+
module Sub2
|
12
|
+
|
13
|
+
module HpcPlugins
|
14
|
+
|
15
|
+
module TestPluginType3
|
16
|
+
|
17
|
+
class TestPluginId5 < HybridPlatformsConductor::TestPluginType3
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|
@@ -24,7 +24,7 @@ shared_examples 'a deployer' do
|
|
24
24
|
with_platform_to_deploy(expect_local_environment: true) do
|
25
25
|
test_deployer.local_environment = true
|
26
26
|
expect(test_deployer.deploy_on('node')).to eq('node' => expected_deploy_result)
|
27
|
-
expect(test_deployer.local_environment).to
|
27
|
+
expect(test_deployer.local_environment).to be true
|
28
28
|
end
|
29
29
|
end
|
30
30
|
|
@@ -140,7 +140,7 @@ module HybridPlatformsConductorTest
|
|
140
140
|
extra_opts[:sudo] = sudo if sudo
|
141
141
|
extra_opts[:owner] = owner if owner
|
142
142
|
extra_opts[:group] = group if group
|
143
|
-
@calls << [:remote_copy, from, to] + (extra_opts.empty? ? [] : [extra_opts])
|
143
|
+
@calls << ([:remote_copy, from, to] + (extra_opts.empty? ? [] : [extra_opts]))
|
144
144
|
@remote_copy_code&.call(@stdout_io, @stderr_io, self)
|
145
145
|
end
|
146
146
|
|
@@ -5,7 +5,7 @@ module HybridPlatformsConductorTest
|
|
5
5
|
|
6
6
|
class << self
|
7
7
|
|
8
|
-
attr_accessor
|
8
|
+
attr_accessor(*%i[calls mocked_logs])
|
9
9
|
|
10
10
|
end
|
11
11
|
|
@@ -89,7 +89,7 @@ module HybridPlatformsConductorTest
|
|
89
89
|
stdout: stdout,
|
90
90
|
stderr: stderr
|
91
91
|
}
|
92
|
-
{
|
92
|
+
TestLogPlugin.mocked_logs[node] || {
|
93
93
|
services: %w[unknown],
|
94
94
|
deployment_info: {
|
95
95
|
user: 'test_user'
|
@@ -58,6 +58,7 @@ require 'hybrid_platforms_conductor_test/test_plugins/several_checks'
|
|
58
58
|
require 'hybrid_platforms_conductor_test/test_provisioner'
|
59
59
|
require 'hybrid_platforms_conductor_test/test_secrets_reader_plugin'
|
60
60
|
require 'hybrid_platforms_conductor_test/tests_report_plugin'
|
61
|
+
require 'active_support/core_ext/module'
|
61
62
|
|
62
63
|
module HybridPlatformsConductorTest
|
63
64
|
|
@@ -145,6 +146,7 @@ module HybridPlatformsConductorTest
|
|
145
146
|
HybridPlatformsConductorTest::TestPlugins::NodeCheck.only_on_nodes = nil
|
146
147
|
HybridPlatformsConductorTest::TestPlugins::SeveralChecks.runs = []
|
147
148
|
HybridPlatformsConductorTest::TestLogPlugin.calls = []
|
149
|
+
HybridPlatformsConductorTest::TestLogPlugin.mocked_logs = {}
|
148
150
|
HybridPlatformsConductorTest::TestLogNoReadPlugin.calls = []
|
149
151
|
HybridPlatformsConductorTest::TestSecretsReaderPlugin.calls = []
|
150
152
|
HybridPlatformsConductorTest::TestSecretsReaderPlugin.deployer = nil
|