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
@@ -75,10 +75,11 @@ module HybridPlatformsConductor
75
75
  # Register plugins by parsing gems
76
76
  def register_plugins_from_gems
77
77
  # Require all possible files that could define such a plugin, from all gems
78
- files_regexp = %r{lib/(.*hpc_plugins/#{Regexp.escape(@plugins_type.to_s)}/[^/]+)\.rb$}
79
- Gem.loaded_specs.each do |gem_name, gem_specs|
78
+ Gem.loaded_specs.clone.each do |gem_name, gem_specs|
79
+ gem_path = gem_specs.full_gem_path
80
+ files_regexp = %r{#{Regexp.escape(gem_path)}/lib/(.*hpc_plugins/#{Regexp.escape(@plugins_type.to_s)}/[^/]+)\.rb$}
80
81
  # Careful to not use gem_specs.files here as if your gem name contains "-" or other weird characters, files won't appear in the gemspec list.
81
- Dir.glob("#{gem_specs.full_gem_path}/lib/**/*.rb").each do |file|
82
+ Dir.glob("#{gem_path}/lib/**/*.rb").each do |file|
82
83
  next unless file =~ files_regexp
83
84
 
84
85
  require_name = Regexp.last_match(1)
@@ -524,14 +524,14 @@ module HybridPlatformsConductor
524
524
  nodes_to_test = selected_tests.map(&:node).uniq.sort
525
525
  @outputs =
526
526
  if @skip_run
527
- nodes_to_test.map do |node|
527
+ nodes_to_test.to_h do |node|
528
528
  run_log_file_name = "#{@config.hybrid_platforms_dir}/run_logs/#{node}.stdout"
529
529
  [
530
530
  node,
531
531
  # TODO: Find a way to also save stderr and the status code
532
532
  [0, File.exist?(run_log_file_name) ? File.read(run_log_file_name) : nil, '']
533
533
  ]
534
- end.to_h
534
+ end
535
535
  else
536
536
  # Why-run deploy on all nodes
537
537
  @deployer.concurrent_execution = !log_debug?
@@ -112,15 +112,14 @@ module HybridPlatformsConductor
112
112
  # Parse plugins
113
113
  @plugins = Dir.
114
114
  glob("#{__dir__}/topographer/plugins/*.rb").
115
- map do |file_name|
115
+ to_h do |file_name|
116
116
  plugin_name = File.basename(file_name)[0..-4].to_sym
117
117
  require file_name
118
118
  [
119
119
  plugin_name,
120
120
  Topographer::Plugins.const_get(plugin_name.to_s.split('_').collect(&:capitalize).join.to_sym)
121
121
  ]
122
- end.
123
- to_h
122
+ end
124
123
 
125
124
  @ips_to_host = known_ips.clone
126
125
 
@@ -132,11 +131,11 @@ module HybridPlatformsConductor
132
131
  ]
133
132
  @nodes_handler.prefetch_metadata_of @nodes_handler.known_nodes, metadata_properties
134
133
  @nodes_handler.known_nodes.each do |hostname|
135
- @node_metadata[hostname] = metadata_properties.map { |property| [property, @nodes_handler.metadata_of(hostname, property)] }.to_h
134
+ @node_metadata[hostname] = metadata_properties.to_h { |property| [property, @nodes_handler.metadata_of(hostname, property)] }
136
135
  end
137
136
 
138
137
  # Small cache of hostnames used a lot to parse JSON
139
- @known_nodes = @nodes_handler.known_nodes.map { |hostname| [hostname, nil] }.to_h
138
+ @known_nodes = @nodes_handler.known_nodes.to_h { |hostname| [hostname, nil] }
140
139
  # Cache of objects being used a lot in parsing for performance
141
140
  @non_word_regexp = /\W+/
142
141
  @ip_regexp = %r{(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})(/(\d{1,2})|[^\d/]|$)}
@@ -600,7 +599,7 @@ module HybridPlatformsConductor
600
599
  @ips_mask[ip_def] = {} unless @ips_mask.key?(ip_def)
601
600
  unless @ips_mask[ip_def].key?(ip_mask)
602
601
  # For performance, keep a cache of all the IPAddress::IPv4 objects
603
- @ip_v4_cache = known_ips.keys.map { |ip, _node| [ip, IPAddress::IPv4.new(ip)] }.to_h unless defined?(@ip_v4_cache)
602
+ @ip_v4_cache = known_ips.keys.to_h { |ip, _node| [ip, IPAddress::IPv4.new(ip)] } unless defined?(@ip_v4_cache)
604
603
  ip_range = IPAddress::IPv4.new("#{ip_def}/#{ip_mask}")
605
604
  @ips_mask[ip_def][ip_mask] = @ip_v4_cache.select { |_ip, ipv4| ip_range.include?(ipv4) }.keys
606
605
  end
@@ -1,5 +1,5 @@
1
1
  module HybridPlatformsConductor
2
2
 
3
- VERSION = '33.9.0'
3
+ VERSION = '33.9.4'
4
4
 
5
5
  end
@@ -54,7 +54,7 @@ describe HybridPlatformsConductor::ActionsExecutor do
54
54
  },
55
55
  log_to_dir: logs_dir
56
56
  )
57
- expect(File.exist?("#{logs_dir}/node.stdout")).to eq true
57
+ expect(File.exist?("#{logs_dir}/node.stdout")).to be true
58
58
  expect(File.read("#{logs_dir}/node.stdout")).to eq "TestStdout\nTestStderr\n"
59
59
  end
60
60
  end
@@ -18,7 +18,7 @@ describe HybridPlatformsConductor::ActionsExecutor do
18
18
  }
19
19
  )['node']
20
20
  ).to eq [0, 'TestStdout', 'TestStderr']
21
- expect(executed).to eq true
21
+ expect(executed).to be true
22
22
  end
23
23
  end
24
24
 
@@ -38,7 +38,7 @@ describe HybridPlatformsConductor::ActionsExecutor do
38
38
  timeout: 1
39
39
  )['node']
40
40
  ).to eq [:timeout, '', '']
41
- expect(executed).to eq false
41
+ expect(executed).to be false
42
42
  end
43
43
  end
44
44
 
@@ -54,7 +54,7 @@ describe HybridPlatformsConductor::ActionsExecutor do
54
54
  } },
55
55
  log_to_dir: logs_dir
56
56
  )
57
- expect(File.exist?("#{logs_dir}/node.stdout")).to eq true
57
+ expect(File.exist?("#{logs_dir}/node.stdout")).to be true
58
58
  expect(File.read("#{logs_dir}/node.stdout")).to eq "TestStdout\nTestStderr\n"
59
59
  end
60
60
  end
@@ -68,7 +68,7 @@ describe HybridPlatformsConductor::ActionsExecutor do
68
68
  {
69
69
  'node' => {
70
70
  ruby: proc do |stdout, stderr, action|
71
- expect(action.is_a?(HybridPlatformsConductor::HpcPlugins::Action::Ruby)).to eq true
71
+ expect(action.is_a?(HybridPlatformsConductor::HpcPlugins::Action::Ruby)).to be true
72
72
  stdout << 'TestStdout'
73
73
  stderr << 'TestStderr'
74
74
  executed = true
@@ -77,7 +77,7 @@ describe HybridPlatformsConductor::ActionsExecutor do
77
77
  }
78
78
  )['node']
79
79
  ).to eq [0, 'TestStdout', 'TestStderr']
80
- expect(executed).to eq true
80
+ expect(executed).to be true
81
81
  end
82
82
  end
83
83
 
@@ -90,7 +90,7 @@ describe HybridPlatformsConductor::ActionsExecutor do
90
90
  'node' => {
91
91
  ruby: {
92
92
  code: proc do |stdout, stderr, _action, connector|
93
- expect(connector.is_a?(HybridPlatformsConductorTest::TestConnector)).to eq true
93
+ expect(connector.is_a?(HybridPlatformsConductorTest::TestConnector)).to be true
94
94
  stdout << 'TestStdout'
95
95
  stderr << 'TestStderr'
96
96
  executed = true
@@ -101,7 +101,7 @@ describe HybridPlatformsConductor::ActionsExecutor do
101
101
  }
102
102
  )['node']
103
103
  ).to eq [0, 'TestStdout', 'TestStderr']
104
- expect(executed).to eq true
104
+ expect(executed).to be true
105
105
  end
106
106
  end
107
107
 
@@ -125,7 +125,7 @@ describe HybridPlatformsConductor::ActionsExecutor do
125
125
  }
126
126
  )['node']
127
127
  ).to eq [0, 'TestStdout', 'TestStderr']
128
- expect(executed).to eq true
128
+ expect(executed).to be true
129
129
  end
130
130
  end
131
131
 
@@ -60,7 +60,7 @@ describe HybridPlatformsConductor::ActionsExecutor do
60
60
  it 'does not use the SSH control master' do
61
61
  with_test_platform_for_cli do
62
62
  expect_actions_executor_runs [proc do
63
- expect(test_connector.ssh_use_control_master).to eq false
63
+ expect(test_connector.ssh_use_control_master).to be false
64
64
  {}
65
65
  end]
66
66
  exit_code, stdout, stderr = run 'run', '--node', 'node', '--command', 'echo Hello', '--ssh-no-control-master'
@@ -73,7 +73,7 @@ describe HybridPlatformsConductor::ActionsExecutor do
73
73
  it 'does not use strict host key checking' do
74
74
  with_test_platform_for_cli do
75
75
  expect_actions_executor_runs [proc do
76
- expect(test_connector.ssh_strict_host_key_checking).to eq false
76
+ expect(test_connector.ssh_strict_host_key_checking).to be false
77
77
  {}
78
78
  end]
79
79
  exit_code, stdout, stderr = run 'run', '--node', 'node', '--command', 'echo Hello', '--ssh-no-host-key-checking'
@@ -111,7 +111,7 @@ describe HybridPlatformsConductor::ActionsExecutor do
111
111
  it 'expects passwords to be input' do
112
112
  with_test_platform_for_cli do
113
113
  expect_actions_executor_runs [proc do
114
- expect(test_connector.auth_password).to eq true
114
+ expect(test_connector.auth_password).to be true
115
115
  {}
116
116
  end]
117
117
  exit_code, stdout, stderr = run 'run', '--node', 'node', '--command', 'echo Hello', '--password'
@@ -536,14 +536,14 @@ describe HybridPlatformsConductor::ActionsExecutor do
536
536
  test_connector.with_connection_to(['node']) do
537
537
  test_connector.prepare_for('node', nil, stdout, stderr)
538
538
  ssh_exec_2 = test_connector.ssh_exec
539
- expect(File.exist?(ssh_exec_1)).to eq true
540
- expect(File.exist?(ssh_exec_2)).to eq true
539
+ expect(File.exist?(ssh_exec_1)).to be true
540
+ expect(File.exist?(ssh_exec_2)).to be true
541
541
  end
542
- expect(File.exist?(ssh_exec_1)).to eq true
543
- expect(File.exist?(ssh_exec_2)).to eq false
542
+ expect(File.exist?(ssh_exec_1)).to be true
543
+ expect(File.exist?(ssh_exec_2)).to be false
544
544
  end
545
- expect(File.exist?(ssh_exec_1)).to eq false
546
- expect(File.exist?(ssh_exec_2)).to eq false
545
+ expect(File.exist?(ssh_exec_1)).to be false
546
+ expect(File.exist?(ssh_exec_2)).to be false
547
547
  end
548
548
  end
549
549
  end
@@ -590,13 +590,13 @@ describe HybridPlatformsConductor::ActionsExecutor do
590
590
  ['which env', proc { [0, "/usr/bin/env\n", ''] }],
591
591
  ['ssh -V 2>&1', proc { [0, "OpenSSH_7.4p1 Debian-10+deb9u7, OpenSSL 1.0.2u 20 Dec 2019\n", ''] }]
592
592
  ] +
593
- [[
593
+ ([[
594
594
  %r{^.+/ssh -o BatchMode=yes -o ControlMaster=yes -o ControlPersist=yes hpc\.node true$},
595
595
  proc do
596
596
  nbr_boot_messages += 1
597
597
  [255, '', "System is booting up. See pam_nologin(8)\nAuthentication failed.\n"]
598
598
  end
599
- ]] * 3 +
599
+ ]] * 3) +
600
600
  ssh_expected_commands_for({ 'node' => { connection: '192.168.42.42', user: 'test_user' } })
601
601
  ) do
602
602
  test_connector.ssh_user = 'test_user'
@@ -246,7 +246,7 @@ describe HybridPlatformsConductor::ActionsExecutor do
246
246
  Host hpc.node1
247
247
  Hostname 192.168.42.1
248
248
  EO_SSH_CONFIG
249
- expect(ssh_config_for('node2', nodes: %w[node1 node3])).to eq nil
249
+ expect(ssh_config_for('node2', nodes: %w[node1 node3])).to be_nil
250
250
  end
251
251
  end
252
252
 
@@ -11,14 +11,14 @@ describe HybridPlatformsConductor::ActionsExecutor do
11
11
  it 'returns if a user has privileged access on a node' do
12
12
  with_test_platform({ nodes: { 'node' => {} } }) do
13
13
  test_actions_executor.connector(:ssh).ssh_user = 'test_user'
14
- expect(test_actions_executor.privileged_access?('node')).to eq false
14
+ expect(test_actions_executor.privileged_access?('node')).to be false
15
15
  end
16
16
  end
17
17
 
18
18
  it 'returns if a user has privileged access on a node when connecting with root' do
19
19
  with_test_platform({ nodes: { 'node' => {} } }) do
20
20
  test_actions_executor.connector(:ssh).ssh_user = 'root'
21
- expect(test_actions_executor.privileged_access?('node')).to eq true
21
+ expect(test_actions_executor.privileged_access?('node')).to be true
22
22
  end
23
23
  end
24
24
 
@@ -28,7 +28,7 @@ describe HybridPlatformsConductor::ActionsExecutor do
28
28
  ['whoami', proc { [0, 'test_user', ''] }]
29
29
  ] do
30
30
  test_actions_executor.connector(:ssh).ssh_user = 'test_user'
31
- expect(test_actions_executor.privileged_access?('node')).to eq false
31
+ expect(test_actions_executor.privileged_access?('node')).to be false
32
32
  end
33
33
  end
34
34
  end
@@ -39,7 +39,7 @@ describe HybridPlatformsConductor::ActionsExecutor do
39
39
  ['whoami', proc { [0, 'root', ''] }]
40
40
  ] do
41
41
  test_actions_executor.connector(:ssh).ssh_user = 'test_user'
42
- expect(test_actions_executor.privileged_access?('node')).to eq true
42
+ expect(test_actions_executor.privileged_access?('node')).to be true
43
43
  end
44
44
  end
45
45
  end
@@ -15,7 +15,7 @@ describe HybridPlatformsConductor::ActionsExecutor do
15
15
  expect(test_actions_executor.execute_actions(
16
16
  {
17
17
  'node' => { test_action: { code: proc do |stdout, _stderr, action|
18
- expect(action.timeout).to eq nil
18
+ expect(action.timeout).to be_nil
19
19
  stdout << 'Hello'
20
20
  end } }
21
21
  }
@@ -168,7 +168,7 @@ describe HybridPlatformsConductor::CmdRunner do
168
168
  cmd_runner = test_cmd_runner
169
169
  cmd_runner.dry_run = true
170
170
  expect(cmd_runner.run_cmd("echo TestContent >#{repository}/test_file")).to eq [0, '', '']
171
- expect(File.exist?("#{repository}/test_file")).to eq false
171
+ expect(File.exist?("#{repository}/test_file")).to be false
172
172
  end
173
173
  end
174
174
 
@@ -177,7 +177,7 @@ describe HybridPlatformsConductor::CmdRunner do
177
177
  cmd_runner = test_cmd_runner
178
178
  cmd_runner.dry_run = true
179
179
  expect(cmd_runner.run_cmd("echo TestContent >#{repository}/test_file", expected_code: 2)).to eq [2, '', '']
180
- expect(File.exist?("#{repository}/test_file")).to eq false
180
+ expect(File.exist?("#{repository}/test_file")).to be false
181
181
  end
182
182
  end
183
183
 
@@ -190,13 +190,13 @@ describe HybridPlatformsConductor::CmdRunner do
190
190
  it 'returns non-root user when user is not root' do
191
191
  cmd_runner = test_cmd_runner
192
192
  expect(cmd_runner).to receive(:run_cmd).with('whoami', log_to_stdout: false).and_return [0, 'not_root', '']
193
- expect(cmd_runner.root?).to eq false
193
+ expect(cmd_runner.root?).to be false
194
194
  end
195
195
 
196
196
  it 'returns root user when user is root' do
197
197
  cmd_runner = test_cmd_runner
198
198
  expect(cmd_runner).to receive(:run_cmd).with('whoami', log_to_stdout: false).and_return [0, 'root', '']
199
- expect(cmd_runner.root?).to eq true
199
+ expect(cmd_runner.root?).to be true
200
200
  end
201
201
 
202
202
  it 'returns the correct executable prefix' do
@@ -196,6 +196,50 @@ describe HybridPlatformsConductor::Deployer do
196
196
  end
197
197
  end
198
198
 
199
+ it 'gets deployment info from log plugins returning UTF-8 characters' do
200
+ with_test_platform_for_deploy_tests({ nodes: { 'node' => {} } }) do
201
+ HybridPlatformsConductorTest::TestLogPlugin.mocked_logs = {
202
+ 'node' => {
203
+ deployment_info: { user: 'test_user' },
204
+ exit_status: 666,
205
+ services: %w[unknown],
206
+ stderr: 'stderrの展開テストログ',
207
+ stdout: 'stdoutの展開テストログ'
208
+ }
209
+ }
210
+ expect_actions_executor_runs [
211
+ # Expect the actions to get log files
212
+ proc do |actions_per_nodes|
213
+ expect(actions_per_nodes).to eq('node' => [{ bash: 'echo Read logs for node' }])
214
+ # Simulate the fact that data returned by the ssh system calls can contain UTF-8 chars, but is perceived as binary
215
+ { 'node' => [42, 'ログファイルはstdoutを読み取ります'.force_encoding('BINARY'), 'ログファイルはstderrを読み取ります'.force_encoding('BINARY')] }
216
+ end
217
+ ]
218
+ expect(test_deployer.deployment_info_from('node')).to eq(
219
+ 'node' => {
220
+ deployment_info: { user: 'test_user' },
221
+ exit_status: 666,
222
+ services: %w[unknown],
223
+ stderr: 'stderrの展開テストログ',
224
+ stdout: 'stdoutの展開テストログ'
225
+ }
226
+ )
227
+ expect(HybridPlatformsConductorTest::TestLogPlugin.calls).to eq [
228
+ {
229
+ method: :actions_to_read_logs,
230
+ node: 'node'
231
+ },
232
+ {
233
+ method: :logs_for,
234
+ node: 'node',
235
+ exit_status: 42,
236
+ stdout: 'ログファイルはstdoutを読み取ります',
237
+ stderr: 'ログファイルはstderrを読み取ります'
238
+ }
239
+ ]
240
+ end
241
+ end
242
+
199
243
  it 'gets deployment info from log plugins not having actions_to_read_logs' do
200
244
  with_test_platform_for_deploy_tests({ nodes: { 'node' => {} } }, additional_config: 'send_logs_to :test_log_no_read') do
201
245
  expect(test_deployer.deployment_info_from('node')).to eq(
@@ -34,7 +34,7 @@ describe HybridPlatformsConductor::Deployer do
34
34
  expect(actions_per_nodes['node'][0].keys.sort).to eq %i[ruby remote_bash].sort
35
35
  expect(actions_per_nodes['node'][0][:remote_bash]).to eq 'sudo -u root mkdir -p /var/log/deployments && sudo -u root chmod 600 /var/log/deployments'
36
36
  expect(actions_per_nodes['node'][1].keys.sort).to eq %i[scp].sort
37
- expect(actions_per_nodes['node'][1][:scp].delete(:sudo)).to eq true
37
+ expect(actions_per_nodes['node'][1][:scp].delete(:sudo)).to be true
38
38
  expect(actions_per_nodes['node'][1][:scp].delete(:owner)).to eq 'root'
39
39
  expect(actions_per_nodes['node'][1][:scp].delete(:group)).to eq 'root'
40
40
  expect(actions_per_nodes['node'][1][:scp].size).to eq 1
@@ -44,7 +44,7 @@ describe HybridPlatformsConductor::Deployer do
44
44
  expect(actions_per_nodes['node'][2][:remote_bash]).to eq "sudo -u root chmod 600 /var/log/deployments/#{File.basename(tmp_log_file)}"
45
45
  # Call the Ruby codes to be tested
46
46
  actions_per_nodes['node'][0][:ruby].call
47
- expect(File.exist?(tmp_log_file)).to eq true
47
+ expect(File.exist?(tmp_log_file)).to be true
48
48
  file_content_regexp = Regexp.new <<~EOREGEXP
49
49
  repo_name_0: platform
50
50
  commit_id_0: 123456
@@ -62,7 +62,7 @@ describe HybridPlatformsConductor::Deployer do
62
62
  expect(File.read(tmp_log_file)).to match file_content_regexp
63
63
  actions_per_nodes['node'][2][:ruby].call
64
64
  # Check temporary log file gets deleted for security reasons
65
- expect(File.exist?(tmp_log_file)).to eq false
65
+ expect(File.exist?(tmp_log_file)).to be false
66
66
  end
67
67
  ]
68
68
  expect(test_deployer.deploy_on('node')).to eq('node' => [0, 'Deploy successful stdout', 'Deploy successful stderr'])
@@ -93,7 +93,7 @@ describe HybridPlatformsConductor::Deployer do
93
93
  expect(actions_per_nodes['node'][0].keys.sort).to eq %i[ruby remote_bash].sort
94
94
  expect(actions_per_nodes['node'][0][:remote_bash]).to eq 'mkdir -p /var/log/deployments && chmod 600 /var/log/deployments'
95
95
  expect(actions_per_nodes['node'][1].keys.sort).to eq %i[scp].sort
96
- expect(actions_per_nodes['node'][1][:scp].delete(:sudo)).to eq false
96
+ expect(actions_per_nodes['node'][1][:scp].delete(:sudo)).to be false
97
97
  expect(actions_per_nodes['node'][1][:scp].delete(:owner)).to eq 'root'
98
98
  expect(actions_per_nodes['node'][1][:scp].delete(:group)).to eq 'root'
99
99
  expect(actions_per_nodes['node'][1][:scp].size).to eq 1
@@ -103,7 +103,7 @@ describe HybridPlatformsConductor::Deployer do
103
103
  expect(actions_per_nodes['node'][2][:remote_bash]).to eq "chmod 600 /var/log/deployments/#{File.basename(tmp_log_file)}"
104
104
  # Call the Ruby codes to be tested
105
105
  actions_per_nodes['node'][0][:ruby].call
106
- expect(File.exist?(tmp_log_file)).to eq true
106
+ expect(File.exist?(tmp_log_file)).to be true
107
107
  file_content_regexp = Regexp.new <<~EOREGEXP
108
108
  repo_name_0: platform
109
109
  commit_id_0: 123456
@@ -121,7 +121,7 @@ describe HybridPlatformsConductor::Deployer do
121
121
  expect(File.read(tmp_log_file)).to match file_content_regexp
122
122
  actions_per_nodes['node'][2][:ruby].call
123
123
  # Check temporary log file gets deleted for security reasons
124
- expect(File.exist?(tmp_log_file)).to eq false
124
+ expect(File.exist?(tmp_log_file)).to be false
125
125
  end
126
126
  ]
127
127
  expect(test_deployer.deploy_on('node')).to eq('node' => [0, 'Deploy successful stdout', 'Deploy successful stderr'])
@@ -150,7 +150,7 @@ describe HybridPlatformsConductor::Deployer do
150
150
  expect(actions_per_nodes['node'][0].keys.sort).to eq %i[ruby remote_bash].sort
151
151
  expect(actions_per_nodes['node'][0][:remote_bash]).to eq 'sudo -u root mkdir -p /var/log/deployments && sudo -u root chmod 600 /var/log/deployments'
152
152
  expect(actions_per_nodes['node'][1].keys.sort).to eq %i[scp].sort
153
- expect(actions_per_nodes['node'][1][:scp].delete(:sudo)).to eq true
153
+ expect(actions_per_nodes['node'][1][:scp].delete(:sudo)).to be true
154
154
  expect(actions_per_nodes['node'][1][:scp].delete(:owner)).to eq 'root'
155
155
  expect(actions_per_nodes['node'][1][:scp].delete(:group)).to eq 'root'
156
156
  expect(actions_per_nodes['node'][1][:scp].size).to eq 1
@@ -160,7 +160,7 @@ describe HybridPlatformsConductor::Deployer do
160
160
  expect(actions_per_nodes['node'][2][:remote_bash]).to eq "sudo -u root chmod 600 /var/log/deployments/#{File.basename(tmp_log_file)}"
161
161
  # Call the Ruby codes to be tested
162
162
  actions_per_nodes['node'][0][:ruby].call
163
- expect(File.exist?(tmp_log_file)).to eq true
163
+ expect(File.exist?(tmp_log_file)).to be true
164
164
  file_content_regexp = Regexp.new <<~EOREGEXP
165
165
  repo_name_0: platform
166
166
  commit_id_0: 123456
@@ -178,7 +178,7 @@ describe HybridPlatformsConductor::Deployer do
178
178
  expect(File.read(tmp_log_file)).to match file_content_regexp
179
179
  actions_per_nodes['node'][2][:ruby].call
180
180
  # Check temporary log file gets deleted for security reasons
181
- expect(File.exist?(tmp_log_file)).to eq false
181
+ expect(File.exist?(tmp_log_file)).to be false
182
182
  end
183
183
  ]
184
184
  with_cmd_runner_mocked [
@@ -211,7 +211,7 @@ describe HybridPlatformsConductor::Deployer do
211
211
  expect(actions_per_nodes['node'][0].keys.sort).to eq %i[ruby remote_bash].sort
212
212
  expect(actions_per_nodes['node'][0][:remote_bash]).to eq 'mkdir -p /var/log/deployments && chmod 600 /var/log/deployments'
213
213
  expect(actions_per_nodes['node'][1].keys.sort).to eq %i[scp].sort
214
- expect(actions_per_nodes['node'][1][:scp].delete(:sudo)).to eq false
214
+ expect(actions_per_nodes['node'][1][:scp].delete(:sudo)).to be false
215
215
  expect(actions_per_nodes['node'][1][:scp].delete(:owner)).to eq 'root'
216
216
  expect(actions_per_nodes['node'][1][:scp].delete(:group)).to eq 'root'
217
217
  expect(actions_per_nodes['node'][1][:scp].size).to eq 1
@@ -221,7 +221,7 @@ describe HybridPlatformsConductor::Deployer do
221
221
  expect(actions_per_nodes['node'][2][:remote_bash]).to eq "chmod 600 /var/log/deployments/#{File.basename(tmp_log_file)}"
222
222
  # Call the Ruby codes to be tested
223
223
  actions_per_nodes['node'][0][:ruby].call
224
- expect(File.exist?(tmp_log_file)).to eq true
224
+ expect(File.exist?(tmp_log_file)).to be true
225
225
  file_content_regexp = Regexp.new <<~EOREGEXP
226
226
  repo_name_0: platform
227
227
  commit_id_0: 123456
@@ -239,7 +239,7 @@ describe HybridPlatformsConductor::Deployer do
239
239
  expect(File.read(tmp_log_file)).to match file_content_regexp
240
240
  actions_per_nodes['node'][2][:ruby].call
241
241
  # Check temporary log file gets deleted for security reasons
242
- expect(File.exist?(tmp_log_file)).to eq false
242
+ expect(File.exist?(tmp_log_file)).to be false
243
243
  end
244
244
  ]
245
245
  with_cmd_runner_mocked [
@@ -14,7 +14,7 @@ describe HybridPlatformsConductor::Deployer do
14
14
  expect(Socket).to receive(:tcp).with('172.17.0.1', 22, { connect_timeout: 1 }).and_yield
15
15
  provisioner = nil
16
16
  test_deployer.with_test_provisioned_instance(:test_provisioner, 'node', environment: 'hpc_testing_provisioner') do |sub_test_deployer, test_instance|
17
- expect(sub_test_deployer.local_environment).to eq true
17
+ expect(sub_test_deployer.local_environment).to be true
18
18
  provisioner = test_instance
19
19
  expect(test_instance.node).to eq 'node'
20
20
  expect(test_instance.environment).to match(/^#{Regexp.escape(`whoami`.strip)}_hpc_testing_provisioner_\d+_\d+_\w+$/)
@@ -33,7 +33,7 @@ describe HybridPlatformsConductor::Deployer do
33
33
  expect(Socket).to receive(:tcp).with('172.17.0.1', 22, { connect_timeout: 666 }).and_yield
34
34
  provisioner = nil
35
35
  test_deployer.with_test_provisioned_instance(:test_provisioner, 'node', environment: 'hpc_testing_provisioner') do |sub_test_deployer, test_instance|
36
- expect(sub_test_deployer.local_environment).to eq true
36
+ expect(sub_test_deployer.local_environment).to be true
37
37
  provisioner = test_instance
38
38
  expect(test_instance.node).to eq 'node'
39
39
  expect(test_instance.environment).to match(/^#{Regexp.escape(`whoami`.strip)}_hpc_testing_provisioner_\d+_\d+_\w+$/)
@@ -65,8 +65,8 @@ describe HybridPlatformsConductor::Deployer do
65
65
  expect(Socket).to receive(:tcp).with('172.17.0.1', 22, { connect_timeout: 1 }).and_yield
66
66
  test_deployer.with_test_provisioned_instance(:test_provisioner, 'node1', environment: 'hpc_testing_provisioner') do |sub_test_deployer, test_instance|
67
67
  sub_nodes_handler = sub_test_deployer.instance_variable_get(:@nodes_handler)
68
- expect(sub_nodes_handler.get_ssh_session_exec_of('node1')).to eq true
69
- expect(sub_nodes_handler.get_ssh_session_exec_of('node2')).to eq false
68
+ expect(sub_nodes_handler.get_ssh_session_exec_of('node1')).to be true
69
+ expect(sub_nodes_handler.get_ssh_session_exec_of('node2')).to be false
70
70
  ssh_transforms = test_instance.instance_variable_get(:@config).ssh_connection_transforms
71
71
  expect(ssh_transforms.size).to eq 1
72
72
  expect(ssh_transforms[0][:nodes_selectors_stack]).to eq [%w[node2]]
@@ -90,8 +90,8 @@ describe HybridPlatformsConductor::Deployer do
90
90
  expect(Socket).to receive(:tcp).with('172.17.0.1', 22, { connect_timeout: 1 }).and_yield
91
91
  test_deployer.with_test_provisioned_instance(:test_provisioner, 'node1', environment: 'hpc_testing_provisioner') do |sub_test_deployer|
92
92
  sub_nodes_handler = sub_test_deployer.instance_variable_get(:@nodes_handler)
93
- expect(sub_nodes_handler.get_local_node_of('node1')).to eq false
94
- expect(sub_nodes_handler.get_local_node_of('node2')).to eq true
93
+ expect(sub_nodes_handler.get_local_node_of('node1')).to be false
94
+ expect(sub_nodes_handler.get_local_node_of('node2')).to be true
95
95
  end
96
96
  end
97
97
  end
@@ -132,7 +132,7 @@ describe HybridPlatformsConductor::Deployer do
132
132
  expect(Socket).to receive(:tcp).with('172.17.0.1', 22, { connect_timeout: 1 }).and_yield
133
133
  provisioner = nil
134
134
  test_deployer.with_test_provisioned_instance(:test_provisioner, 'node', environment: 'hpc_testing_provisioner', reuse_instance: true) do |sub_test_deployer, test_instance|
135
- expect(sub_test_deployer.local_environment).to eq true
135
+ expect(sub_test_deployer.local_environment).to be true
136
136
  provisioner = test_instance
137
137
  expect(test_instance.node).to eq 'node'
138
138
  expect(test_instance.environment).to eq "#{`whoami`.strip}_hpc_testing_provisioner"
@@ -150,7 +150,7 @@ describe HybridPlatformsConductor::Deployer do
150
150
  expect(Socket).to receive(:tcp).with('172.17.0.1', 22, { connect_timeout: 1 }).and_yield
151
151
  provisioner = nil
152
152
  test_deployer.with_test_provisioned_instance(:test_provisioner, 'node', environment: 'hpc_testing_provisioner', reuse_instance: true) do |sub_test_deployer, test_instance|
153
- expect(sub_test_deployer.local_environment).to eq true
153
+ expect(sub_test_deployer.local_environment).to be true
154
154
  provisioner = test_instance
155
155
  expect(test_instance.node).to eq 'node'
156
156
  expect(test_instance.environment).to eq "#{`whoami`.strip}_hpc_testing_provisioner"
@@ -48,7 +48,7 @@ describe HybridPlatformsConductor::HpcPlugins::Provisioner::Docker do
48
48
  instance.wait_for_state! :created
49
49
  begin
50
50
  # Test that the instance is created
51
- expect(::Docker::Container.all(all: true).find { |container| container.info['Names'].include? "/hpc_docker_container_node_#{environment}" }).not_to eq nil
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