hybrid_platforms_conductor 33.9.0 → 33.9.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (97) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +39 -0
  3. data/bin/last_deploys +3 -4
  4. data/bin/nodes_to_deploy +19 -9
  5. data/docs/gen/mermaid/README.md-0.png +0 -0
  6. data/docs/gen/mermaid/docs/executables/check-node.md-0.png +0 -0
  7. data/docs/gen/mermaid/docs/executables/deploy.md-0.png +0 -0
  8. data/docs/gen/mermaid/docs/executables/free_ips.md-0.png +0 -0
  9. data/docs/gen/mermaid/docs/executables/free_veids.md-0.png +0 -0
  10. data/docs/gen/mermaid/docs/executables/get_impacted_nodes.md-0.png +0 -0
  11. data/docs/gen/mermaid/docs/executables/last_deploys.md-0.png +0 -0
  12. data/docs/gen/mermaid/docs/executables/nodes_to_deploy.md-0.png +0 -0
  13. data/docs/gen/mermaid/docs/executables/report.md-0.png +0 -0
  14. data/docs/gen/mermaid/docs/executables/run.md-0.png +0 -0
  15. data/docs/gen/mermaid/docs/executables/setup.md-0.png +0 -0
  16. data/docs/gen/mermaid/docs/executables/ssh_config.md-0.png +0 -0
  17. data/docs/gen/mermaid/docs/executables/test.md-0.png +0 -0
  18. data/lib/hybrid_platforms_conductor/actions_executor.rb +2 -2
  19. data/lib/hybrid_platforms_conductor/common_config_dsl/file_system_tests.rb +2 -2
  20. data/lib/hybrid_platforms_conductor/config.rb +1 -0
  21. data/lib/hybrid_platforms_conductor/deployer.rb +19 -13
  22. data/lib/hybrid_platforms_conductor/executable.rb +1 -1
  23. data/lib/hybrid_platforms_conductor/hpc_plugins/cmdb/host_ip.rb +21 -7
  24. data/lib/hybrid_platforms_conductor/hpc_plugins/cmdb/platform_handlers.rb +2 -2
  25. data/lib/hybrid_platforms_conductor/hpc_plugins/connector/ssh.rb +1 -1
  26. data/lib/hybrid_platforms_conductor/hpc_plugins/platform_handler/serverless_chef.rb +1 -2
  27. data/lib/hybrid_platforms_conductor/hpc_plugins/provisioner/proxmox/proxmox_waiter.rb +6 -6
  28. data/lib/hybrid_platforms_conductor/hpc_plugins/provisioner/proxmox.rb +2 -2
  29. data/lib/hybrid_platforms_conductor/hpc_plugins/report/mediawiki.rb +1 -1
  30. data/lib/hybrid_platforms_conductor/hpc_plugins/secrets_reader/keepass.rb +6 -6
  31. data/lib/hybrid_platforms_conductor/hpc_plugins/test/file_system.rb +2 -2
  32. data/lib/hybrid_platforms_conductor/hpc_plugins/test/file_system_hdfs.rb +2 -2
  33. data/lib/hybrid_platforms_conductor/hpc_plugins/test/ip.rb +1 -1
  34. data/lib/hybrid_platforms_conductor/hpc_plugins/test/linear_strategy.rb +1 -1
  35. data/lib/hybrid_platforms_conductor/hpc_plugins/test/private_ips.rb +1 -2
  36. data/lib/hybrid_platforms_conductor/hpc_plugins/test/public_ips.rb +1 -2
  37. data/lib/hybrid_platforms_conductor/hpc_plugins/test/veids.rb +1 -2
  38. data/lib/hybrid_platforms_conductor/hpc_plugins/test/vulnerabilities.rb +2 -2
  39. data/lib/hybrid_platforms_conductor/plugins.rb +4 -3
  40. data/lib/hybrid_platforms_conductor/tests_runner.rb +2 -2
  41. data/lib/hybrid_platforms_conductor/topographer.rb +5 -6
  42. data/lib/hybrid_platforms_conductor/version.rb +1 -1
  43. data/spec/hybrid_platforms_conductor_test/api/actions_executor/actions/bash_spec.rb +1 -1
  44. data/spec/hybrid_platforms_conductor_test/api/actions_executor/actions/ruby_spec.rb +8 -8
  45. data/spec/hybrid_platforms_conductor_test/api/actions_executor/connectors/ssh/cli_options_spec.rb +3 -3
  46. data/spec/hybrid_platforms_conductor_test/api/actions_executor/connectors/ssh/connections_spec.rb +8 -8
  47. data/spec/hybrid_platforms_conductor_test/api/actions_executor/connectors/ssh/global_helpers_spec.rb +1 -1
  48. data/spec/hybrid_platforms_conductor_test/api/actions_executor/helpers_spec.rb +4 -4
  49. data/spec/hybrid_platforms_conductor_test/api/actions_executor/timeout_spec.rb +1 -1
  50. data/spec/hybrid_platforms_conductor_test/api/cmd_runner_spec.rb +4 -4
  51. data/spec/hybrid_platforms_conductor_test/api/deployer/deploy_spec.rb +44 -0
  52. data/spec/hybrid_platforms_conductor_test/api/deployer/log_plugins/remote_fs_spec.rb +12 -12
  53. data/spec/hybrid_platforms_conductor_test/api/deployer/provisioner_spec.rb +8 -8
  54. data/spec/hybrid_platforms_conductor_test/api/deployer/provisioners/docker_spec.rb +1 -1
  55. data/spec/hybrid_platforms_conductor_test/api/deployer/provisioners/proxmox/reserve_proxmox_container/expired_containers_spec.rb +27 -27
  56. data/spec/hybrid_platforms_conductor_test/api/deployer/provisioners/proxmox/reserve_proxmox_container/retries_spec.rb +1 -1
  57. data/spec/hybrid_platforms_conductor_test/api/nodes_handler/cmdbs/host_ip_spec.rb +25 -0
  58. data/spec/hybrid_platforms_conductor_test/api/nodes_handler/cmdbs_plugins_api_spec.rb +5 -5
  59. data/spec/hybrid_platforms_conductor_test/api/platform_handlers/serverless_chef/inventory_spec.rb +1 -1
  60. data/spec/hybrid_platforms_conductor_test/api/platform_handlers/serverless_chef/packaging_spec.rb +9 -9
  61. data/spec/hybrid_platforms_conductor_test/api/platform_handlers/serverless_chef/services_deployment_spec.rb +1 -1
  62. data/spec/hybrid_platforms_conductor_test/api/platforms_handler_spec.rb +1 -1
  63. data/spec/hybrid_platforms_conductor_test/api/plugins_spec.rb +30 -2
  64. data/spec/hybrid_platforms_conductor_test/api/services_handler/deploy_allowed_spec.rb +7 -7
  65. data/spec/hybrid_platforms_conductor_test/api/services_handler/package_spec.rb +18 -18
  66. data/spec/hybrid_platforms_conductor_test/api/services_handler/prepare_for_deploy_spec.rb +30 -30
  67. data/spec/hybrid_platforms_conductor_test/api/tests_runner/common_spec.rb +5 -5
  68. data/spec/hybrid_platforms_conductor_test/api/tests_runner/node_check_spec.rb +6 -6
  69. data/spec/hybrid_platforms_conductor_test/api/tests_runner/node_ssh_spec.rb +6 -6
  70. data/spec/hybrid_platforms_conductor_test/api/tests_runner/reports_spec.rb +4 -4
  71. data/spec/hybrid_platforms_conductor_test/cmdb_plugins/test_cmdb.rb +8 -8
  72. data/spec/hybrid_platforms_conductor_test/cmdb_plugins/test_cmdb_2.rb +5 -5
  73. data/spec/hybrid_platforms_conductor_test/cmdb_plugins/test_cmdb_others.rb +3 -3
  74. data/spec/hybrid_platforms_conductor_test/cmdb_plugins/test_cmdb_others_2.rb +3 -3
  75. data/spec/hybrid_platforms_conductor_test/docs_spec.rb +1 -1
  76. data/spec/hybrid_platforms_conductor_test/executables/check_node_spec.rb +1 -1
  77. data/spec/hybrid_platforms_conductor_test/executables/deploy_spec.rb +1 -1
  78. data/spec/hybrid_platforms_conductor_test/executables/nodes_to_deploy_spec.rb +75 -0
  79. data/spec/hybrid_platforms_conductor_test/executables/options/cmd_runner_spec.rb +1 -1
  80. data/spec/hybrid_platforms_conductor_test/executables/options/deployer_spec.rb +2 -2
  81. data/spec/hybrid_platforms_conductor_test/executables/options/nodes_handler_spec.rb +1 -0
  82. data/spec/hybrid_platforms_conductor_test/executables/options/tests_runner_spec.rb +1 -1
  83. data/spec/hybrid_platforms_conductor_test/executables/report_spec.rb +1 -0
  84. data/spec/hybrid_platforms_conductor_test/executables/run_spec.rb +2 -2
  85. data/spec/hybrid_platforms_conductor_test/helpers/actions_executor_helpers.rb +1 -1
  86. data/spec/hybrid_platforms_conductor_test/helpers/cmdb_helpers.rb +2 -2
  87. data/spec/hybrid_platforms_conductor_test/helpers/connector_ssh_helpers.rb +1 -1
  88. data/spec/hybrid_platforms_conductor_test/helpers/deployer_helpers.rb +7 -7
  89. data/spec/hybrid_platforms_conductor_test/helpers/platforms_handler_helpers.rb +3 -3
  90. data/spec/hybrid_platforms_conductor_test/helpers/provisioner_proxmox_helpers.rb +11 -12
  91. data/spec/hybrid_platforms_conductor_test/helpers/serverless_chef_helpers.rb +2 -2
  92. 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
  93. data/spec/hybrid_platforms_conductor_test/shared_examples/deployer.rb +1 -1
  94. data/spec/hybrid_platforms_conductor_test/test_connector.rb +1 -1
  95. data/spec/hybrid_platforms_conductor_test/test_log_plugin.rb +2 -2
  96. data/spec/hybrid_platforms_conductor_test.rb +2 -0
  97. metadata +152 -136
@@ -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.map do |node|
33
+ nodes.to_h do |node|
34
34
  [
35
35
  node,
36
36
  {
37
37
  downcase: "__#{node}__"
38
38
  }
39
39
  ]
40
- end.to_h
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 eq(nil), "Could not parse check output: #{check_stdout.join("\n")}"
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 eq true
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 eq false
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
@@ -190,6 +190,81 @@ describe 'nodes_to_deploy executable' do
190
190
  end
191
191
  end
192
192
 
193
+ it 'considers nodes having the same invalid commit ids in their logs to be deployed' do
194
+ with_test_platform_for_nodes_to_deploy do
195
+ expect(test_deployer).to receive(:deployment_info_from).with(%w[node1 node2]).and_return(
196
+ 'node1' => {
197
+ services: %w[service1],
198
+ deployment_info: {
199
+ repo_name_0: 'platform',
200
+ commit_id_0: 'abcdef1',
201
+ exit_status: 0
202
+ },
203
+ exit_status: 0,
204
+ stdout: '',
205
+ stderr: ''
206
+ },
207
+ 'node2' => {
208
+ services: %w[service2],
209
+ deployment_info: {
210
+ repo_name_0: 'platform',
211
+ commit_id_0: 'abcdef1',
212
+ exit_status: 0
213
+ },
214
+ exit_status: 0,
215
+ stdout: '',
216
+ stderr: ''
217
+ }
218
+ )
219
+ expect(test_nodes_handler).to receive(:impacted_nodes_from_git_diff).with('platform', from_commit: 'abcdef1', to_commit: 'master') do
220
+ raise HybridPlatformsConductor::NodesHandler::GitError, 'Mocked git error due to an invalid commit id'
221
+ end
222
+ exit_code, stdout = run 'nodes_to_deploy'
223
+ expect(exit_code).to eq 0
224
+ expect(stdout).to eq <<~EO_STDOUT
225
+ ===== Nodes to deploy =====
226
+ node1
227
+ node2
228
+ EO_STDOUT
229
+ end
230
+ end
231
+
232
+ it 'considers nodes having unknown platforms in their logs to be deployed' do
233
+ with_test_platform_for_nodes_to_deploy do
234
+ expect(test_deployer).to receive(:deployment_info_from).with(%w[node1 node2]).and_return(
235
+ 'node1' => {
236
+ services: %w[service1],
237
+ deployment_info: {
238
+ repo_name_0: 'unknown_platform',
239
+ commit_id_0: 'abcdef1',
240
+ exit_status: 0
241
+ },
242
+ exit_status: 0,
243
+ stdout: '',
244
+ stderr: ''
245
+ },
246
+ 'node2' => {
247
+ services: %w[service2],
248
+ deployment_info: {
249
+ repo_name_0: 'platform',
250
+ commit_id_0: 'abcdef2',
251
+ exit_status: 0
252
+ },
253
+ exit_status: 0,
254
+ stdout: '',
255
+ stderr: ''
256
+ }
257
+ )
258
+ expect(test_nodes_handler).to receive(:impacted_nodes_from_git_diff).with('platform', from_commit: 'abcdef2', to_commit: 'master').and_return [%w[], [], [], false]
259
+ exit_code, stdout = run 'nodes_to_deploy'
260
+ expect(exit_code).to eq 0
261
+ expect(stdout).to eq <<~EO_STDOUT
262
+ ===== Nodes to deploy =====
263
+ node1
264
+ EO_STDOUT
265
+ end
266
+ end
267
+
193
268
  it 'ignores impacts if asked' do
194
269
  with_test_platform_for_nodes_to_deploy do
195
270
  exit_code, stdout = run 'nodes_to_deploy', '--ignore-deployed-info'
@@ -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 eq true
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 eq true
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 eq true
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 eq true
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 eq false
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 eq true
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 nodes.map { |node| [node, test_actions_executor.connector(:test_connector)] }.to_h
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.map do |plugin_id|
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.to_h
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.map { |node| [node, [0, "#{check ? 'Check' : 'Deploy'} successful", '']] }.to_h if mocked_result.nil?
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 eq true
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 eq true
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.map { |node| [node, [0, 'Release mutex successful', '']] }.to_h
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 eq true
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.map { |node| [node, [0, 'Logs uploaded', '']] }.to_h
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.map { |node| [node, %w[service]] }.to_h,
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.map { |name| [name, "#{Dir.tmpdir}/hpc_test/#{name}"] }.to_h
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.map do |platform_type|
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.to_h)
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 eq false
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 eq false
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 eq false
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 eq false
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 eq false
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.map do |pve_node_name, pve_node_info|
498
- pve_node_info[:lxc_containers] = (pve_node_info.key?(:lxc_containers) ? pve_node_info[:lxc_containers] : {}).map do |vm_id, vm_info|
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.to_h
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.to_h
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 eq false
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
- file_pattern = %r{^/sys/fs/cgroup/.+/lxc/#{Regexp.escape(vm_id_str)}$}
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.map do |name|
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.to_h
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 eq true
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 :calls
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