hybrid_platforms_conductor 33.9.4 → 34.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (79) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +16 -0
  3. data/README.md +3 -1
  4. data/bin/free_veids +1 -1
  5. data/bin/last_deploys +1 -1
  6. data/bin/nodes_to_deploy +3 -3
  7. data/docs/gen/mermaid/README.md-0.png +0 -0
  8. data/docs/gen/mermaid/docs/executables/check-node.md-0.png +0 -0
  9. data/docs/gen/mermaid/docs/executables/deploy.md-0.png +0 -0
  10. data/docs/gen/mermaid/docs/executables/free_ips.md-0.png +0 -0
  11. data/docs/gen/mermaid/docs/executables/free_veids.md-0.png +0 -0
  12. data/docs/gen/mermaid/docs/executables/get_impacted_nodes.md-0.png +0 -0
  13. data/docs/gen/mermaid/docs/executables/last_deploys.md-0.png +0 -0
  14. data/docs/gen/mermaid/docs/executables/nodes_to_deploy.md-0.png +0 -0
  15. data/docs/gen/mermaid/docs/executables/report.md-0.png +0 -0
  16. data/docs/gen/mermaid/docs/executables/run.md-0.png +0 -0
  17. data/docs/gen/mermaid/docs/executables/setup.md-0.png +0 -0
  18. data/docs/gen/mermaid/docs/executables/ssh_config.md-0.png +0 -0
  19. data/docs/gen/mermaid/docs/executables/test.md-0.png +0 -0
  20. data/lib/hybrid_platforms_conductor/core_extensions/bundler/without_bundled_env.rb +1 -1
  21. data/lib/hybrid_platforms_conductor/core_extensions/cleanroom/fix_kwargs.rb +1 -0
  22. data/lib/hybrid_platforms_conductor/credentials.rb +1 -1
  23. data/lib/hybrid_platforms_conductor/current_dir_monitor.rb +3 -3
  24. data/lib/hybrid_platforms_conductor/deployer.rb +1 -1
  25. data/lib/hybrid_platforms_conductor/executable.rb +1 -1
  26. data/lib/hybrid_platforms_conductor/hpc_plugins/cmdb/host_ip.rb +2 -0
  27. data/lib/hybrid_platforms_conductor/hpc_plugins/cmdb/host_keys.rb +2 -0
  28. data/lib/hybrid_platforms_conductor/hpc_plugins/connector/ssh.rb +9 -7
  29. data/lib/hybrid_platforms_conductor/hpc_plugins/platform_handler/serverless_chef/recipes_tree_builder.rb +2 -1
  30. data/lib/hybrid_platforms_conductor/hpc_plugins/platform_handler/yaml_inventory.rb +1 -1
  31. data/lib/hybrid_platforms_conductor/hpc_plugins/provisioner/proxmox/proxmox_waiter.rb +1 -0
  32. data/lib/hybrid_platforms_conductor/hpc_plugins/provisioner/proxmox/reserve_proxmox_container +2 -2
  33. data/lib/hybrid_platforms_conductor/hpc_plugins/provisioner/proxmox.rb +1 -0
  34. data/lib/hybrid_platforms_conductor/hpc_plugins/report/confluence.rb +1 -0
  35. data/lib/hybrid_platforms_conductor/hpc_plugins/secrets_reader/keepass.rb +3 -2
  36. data/lib/hybrid_platforms_conductor/hpc_plugins/test/executables.rb +5 -5
  37. data/lib/hybrid_platforms_conductor/hpc_plugins/test/linear_strategy.rb +5 -5
  38. data/lib/hybrid_platforms_conductor/hpc_plugins/test/veids.rb +1 -1
  39. data/lib/hybrid_platforms_conductor/hpc_plugins/test_report/confluence.rb +1 -0
  40. data/lib/hybrid_platforms_conductor/json_dumper.rb +1 -1
  41. data/lib/hybrid_platforms_conductor/logger_helpers.rb +6 -6
  42. data/lib/hybrid_platforms_conductor/nodes_handler.rb +4 -6
  43. data/lib/hybrid_platforms_conductor/parallel_threads.rb +1 -1
  44. data/lib/hybrid_platforms_conductor/platform_handler.rb +1 -1
  45. data/lib/hybrid_platforms_conductor/platforms_handler.rb +1 -1
  46. data/lib/hybrid_platforms_conductor/services_handler.rb +6 -6
  47. data/lib/hybrid_platforms_conductor/test_report.rb +4 -4
  48. data/lib/hybrid_platforms_conductor/tests_runner.rb +3 -0
  49. data/lib/hybrid_platforms_conductor/thycotic.rb +2 -2
  50. data/lib/hybrid_platforms_conductor/topographer.rb +2 -2
  51. data/lib/hybrid_platforms_conductor/version.rb +1 -1
  52. data/spec/hybrid_platforms_conductor_test/api/actions_executor/connectors/ssh/connections_spec.rb +3 -10
  53. data/spec/hybrid_platforms_conductor_test/api/actions_executor/connectors/ssh/global_helpers_spec.rb +1 -6
  54. data/spec/hybrid_platforms_conductor_test/api/credentials_spec.rb +13 -13
  55. data/spec/hybrid_platforms_conductor_test/api/deployer/provisioners/docker/Dockerfile +1 -1
  56. data/spec/hybrid_platforms_conductor_test/api/deployer/provisioners/docker_spec.rb +3 -3
  57. data/spec/hybrid_platforms_conductor_test/api/deployer/secrets_reader_plugins/keepass_spec.rb +1 -1
  58. data/spec/hybrid_platforms_conductor_test/api/nodes_handler/cmdbs/config_spec.rb +1 -1
  59. data/spec/hybrid_platforms_conductor_test/api/nodes_handler/cmdbs_plugins_api_spec.rb +3 -3
  60. data/spec/hybrid_platforms_conductor_test/api/nodes_handler/config_dsl_spec.rb +1 -1
  61. data/spec/hybrid_platforms_conductor_test/api/nodes_handler/git_diff_impacts_spec.rb +2 -2
  62. data/spec/hybrid_platforms_conductor_test/api/platform_handlers/serverless_chef/packaging_spec.rb +2 -2
  63. data/spec/hybrid_platforms_conductor_test/api/platforms_handler_spec.rb +3 -3
  64. data/spec/hybrid_platforms_conductor_test/api/plugins_spec.rb +1 -3
  65. data/spec/hybrid_platforms_conductor_test/api/services_handler/deploy_allowed_spec.rb +9 -9
  66. data/spec/hybrid_platforms_conductor_test/api/tests_runner/common_spec.rb +5 -5
  67. data/spec/hybrid_platforms_conductor_test/api/tests_runner/node_check_spec.rb +2 -2
  68. data/spec/hybrid_platforms_conductor_test/api/tests_runner/reports_spec.rb +1 -1
  69. data/spec/hybrid_platforms_conductor_test/api/tests_runner/test_plugins/linear_strategy_spec.rb +69 -0
  70. data/spec/hybrid_platforms_conductor_test/executables/options/common_spec.rb +1 -1
  71. data/spec/hybrid_platforms_conductor_test/helpers/connector_ssh_helpers.rb +4 -6
  72. data/spec/hybrid_platforms_conductor_test/helpers/deployer_helpers.rb +3 -3
  73. data/spec/hybrid_platforms_conductor_test/helpers/executables_helpers.rb +1 -1
  74. data/spec/hybrid_platforms_conductor_test/helpers/provisioner_proxmox_helpers.rb +4 -4
  75. data/spec/hybrid_platforms_conductor_test/serverless_chef_repositories/recipes/cookbooks/test_cookbook_3/recipes/35_unparsable_include.rb +2 -2
  76. data/spec/hybrid_platforms_conductor_test/test_log_no_read_plugin.rb +1 -1
  77. data/spec/hybrid_platforms_conductor_test/test_log_plugin.rb +1 -1
  78. data/spec/hybrid_platforms_conductor_test.rb +3 -2
  79. metadata +171 -244
@@ -404,6 +404,8 @@ module HybridPlatformsConductor
404
404
  # String
405
405
  CMD_SEPARATOR = '===== TEST COMMAND EXECUTION ===== Separator generated by Hybrid Platforms Conductor test framework ====='
406
406
 
407
+ private_constant :CONNECTION_TIMEOUT, :DEFAULT_CMD_TIMEOUT, :CMD_SEPARATOR
408
+
407
409
  # Run tests that are node specific and require a connection to the node
408
410
  def run_tests_connection_on_nodes
409
411
  run_tests_on_subjects(
@@ -513,6 +515,7 @@ module HybridPlatformsConductor
513
515
  # Timeout in seconds given to a check-node run
514
516
  # Integer
515
517
  CHECK_NODE_TIMEOUT = 30 * 60 # 30 minutes
518
+ private_constant :CHECK_NODE_TIMEOUT
516
519
 
517
520
  # Run tests that use check-node results
518
521
  def run_tests_on_check_nodes
@@ -17,7 +17,7 @@ module HybridPlatformsConductor
17
17
  # * *domain* (String): Domain to use for authentication to Thycotic [default: ENV['hpc_domain_for_thycotic']]
18
18
  # * Proc: Code called with the Thyctotic instance.
19
19
  # * *thycotic* (ThyctoticApi): The Thycotic instance to use.
20
- def with_thycotic(thycotic_url, domain: ENV['hpc_domain_for_thycotic'])
20
+ def with_thycotic(thycotic_url, domain: ENV.fetch('hpc_domain_for_thycotic', nil))
21
21
  with_credentials_for(:thycotic, resource: thycotic_url) do |thycotic_user, thycotic_password|
22
22
  yield ThycoticApi.new(thycotic_url, thycotic_user, thycotic_password, domain: domain, logger: @logger, logger_stderr: @logger_stderr)
23
23
  end
@@ -41,7 +41,7 @@ module HybridPlatformsConductor
41
41
  url,
42
42
  user,
43
43
  password,
44
- domain: ENV['hpc_domain_for_thycotic'],
44
+ domain: ENV.fetch('hpc_domain_for_thycotic', nil),
45
45
  logger: Logger.new($stdout),
46
46
  logger_stderr: Logger.new($stderr)
47
47
  )
@@ -381,7 +381,7 @@ module HybridPlatformsConductor
381
381
  next unless nodes_list.include?(node_name)
382
382
 
383
383
  new_nodes_graph[node_name] = node_info.merge(
384
- connections: node_info[:connections].select { |connected_hostname, _labels| nodes_list.include?(connected_hostname) },
384
+ connections: node_info[:connections].slice(*nodes_list),
385
385
  includes: node_info[:includes] & nodes_list
386
386
  )
387
387
  end
@@ -398,7 +398,7 @@ module HybridPlatformsConductor
398
398
  next if nodes_list.include?(node_name)
399
399
 
400
400
  new_nodes_graph[node_name] = node_info.merge(
401
- connections: node_info[:connections].reject { |connected_hostname, _labels| nodes_list.include?(connected_hostname) },
401
+ connections: node_info[:connections].except(*nodes_list),
402
402
  includes: node_info[:includes] - nodes_list
403
403
  )
404
404
  end
@@ -1,5 +1,5 @@
1
1
  module HybridPlatformsConductor
2
2
 
3
- VERSION = '33.9.4'
3
+ VERSION = '34.0.0'
4
4
 
5
5
  end
@@ -601,17 +601,10 @@ describe HybridPlatformsConductor::ActionsExecutor do
601
601
  ) do
602
602
  test_connector.ssh_user = 'test_user'
603
603
  # To speed up the test, alter the wait time between retries.
604
- old_wait = HybridPlatformsConductor::HpcPlugins::Connector::Ssh.const_get(:WAIT_TIME_FOR_BOOT)
605
- begin
606
- HybridPlatformsConductor::HpcPlugins::Connector::Ssh.send(:remove_const, :WAIT_TIME_FOR_BOOT)
607
- HybridPlatformsConductor::HpcPlugins::Connector::Ssh.const_set(:WAIT_TIME_FOR_BOOT, 1)
608
- test_connector.with_connection_to(['node']) do
609
- end
610
- expect(nbr_boot_messages).to eq 3
611
- ensure
612
- HybridPlatformsConductor::HpcPlugins::Connector::Ssh.send(:remove_const, :WAIT_TIME_FOR_BOOT)
613
- HybridPlatformsConductor::HpcPlugins::Connector::Ssh.const_set(:WAIT_TIME_FOR_BOOT, old_wait)
604
+ stub_const('HybridPlatformsConductor::HpcPlugins::Connector::Ssh::WAIT_TIME_FOR_BOOT', 1)
605
+ test_connector.with_connection_to(['node']) do
614
606
  end
607
+ expect(nbr_boot_messages).to eq 3
615
608
  end
616
609
  end
617
610
  end
@@ -57,7 +57,6 @@ describe HybridPlatformsConductor::ActionsExecutor do
57
57
  Host *
58
58
  User test_user
59
59
  ControlPath #{Dir.tmpdir}/hpc_ssh/hpc_ssh_mux_%h_%p_%r
60
- PubkeyAcceptedKeyTypes +ssh-dss
61
60
  EO_SSH_CONFIG
62
61
  end
63
62
  end
@@ -69,14 +68,13 @@ describe HybridPlatformsConductor::ActionsExecutor do
69
68
  Host *
70
69
  User test_user
71
70
  ControlPath #{Dir.tmpdir}/hpc_ssh/hpc_ssh_mux_%h_%p_%r
72
- PubkeyAcceptedKeyTypes +ssh-dss
73
71
  EO_SSH_CONFIG
74
72
  end
75
73
  end
76
74
 
77
75
  it 'generates a global configuration with user taken from whoami when no env variable is set' do
78
76
  with_test_platform({}) do
79
- original_user = ENV['USER']
77
+ original_user = ENV.fetch('USER', nil)
80
78
  begin
81
79
  ENV.delete 'USER'
82
80
  ENV.delete 'hpc_ssh_user'
@@ -106,7 +104,6 @@ describe HybridPlatformsConductor::ActionsExecutor do
106
104
  Host *
107
105
  User test_user
108
106
  ControlPath #{Dir.tmpdir}/hpc_ssh/hpc_ssh_mux_%h_%p_%r
109
- PubkeyAcceptedKeyTypes +ssh-dss
110
107
  EO_SSH_CONFIG
111
108
  end
112
109
  end
@@ -118,7 +115,6 @@ describe HybridPlatformsConductor::ActionsExecutor do
118
115
  Host *
119
116
  User test_user
120
117
  ControlPath #{Dir.tmpdir}/hpc_ssh/hpc_ssh_mux_%h_%p_%r
121
- PubkeyAcceptedKeyTypes +ssh-dss
122
118
  UserKnownHostsFile /path/to/known_hosts
123
119
  EO_SSH_CONFIG
124
120
  end
@@ -132,7 +128,6 @@ describe HybridPlatformsConductor::ActionsExecutor do
132
128
  Host *
133
129
  User test_user
134
130
  ControlPath #{Dir.tmpdir}/hpc_ssh/hpc_ssh_mux_%h_%p_%r
135
- PubkeyAcceptedKeyTypes +ssh-dss
136
131
  StrictHostKeyChecking no
137
132
  EO_SSH_CONFIG
138
133
  end
@@ -37,7 +37,7 @@ describe HybridPlatformsConductor::Credentials do
37
37
  it 'returns no credentials when they are not set' do
38
38
  with_platforms '' do
39
39
  # Check that .netrc won't be read
40
- expect(::Netrc).not_to receive(:read)
40
+ expect(Netrc).not_to receive(:read)
41
41
  expect_credentials_to_be nil, nil
42
42
  end
43
43
  end
@@ -48,7 +48,7 @@ describe HybridPlatformsConductor::Credentials do
48
48
  ENV['hpc_password_for_test_credential'] = 'env_test_password'
49
49
  begin
50
50
  # Check that .netrc won't be read
51
- expect(::Netrc).not_to receive(:read)
51
+ expect(Netrc).not_to receive(:read)
52
52
  expect_credentials_to_be 'env_test_user', 'env_test_password'
53
53
  ensure
54
54
  ENV.delete('hpc_user_for_test_credential')
@@ -78,8 +78,8 @@ describe HybridPlatformsConductor::Credentials do
78
78
 
79
79
  it 'returns credentials taken from .netrc when a resource is specified' do
80
80
  with_platforms '' do
81
- expect(::Netrc).to receive(:read) do
82
- mocked_netrc = instance_double(::Netrc)
81
+ expect(Netrc).to receive(:read) do
82
+ mocked_netrc = instance_double(Netrc)
83
83
  expect(mocked_netrc).to receive(:[]).with('my_domain.com').and_return %w[test_user test_password]
84
84
  expect(mocked_netrc).to receive(:instance_variable_get).with(:@data).and_return []
85
85
  mocked_netrc
@@ -90,8 +90,8 @@ describe HybridPlatformsConductor::Credentials do
90
90
 
91
91
  it 'returns credentials taken from .netrc when a non-URL resource is specified' do
92
92
  with_platforms '' do
93
- expect(::Netrc).to receive(:read) do
94
- mocked_netrc = instance_double(::Netrc)
93
+ expect(Netrc).to receive(:read) do
94
+ mocked_netrc = instance_double(Netrc)
95
95
  expect(mocked_netrc).to receive(:[]).with('This is:not/ a URL!').and_return %w[test_user test_password]
96
96
  expect(mocked_netrc).to receive(:instance_variable_get).with(:@data).and_return []
97
97
  mocked_netrc
@@ -103,8 +103,8 @@ describe HybridPlatformsConductor::Credentials do
103
103
  it 'erases the value of the password taken from netrc after usage' do
104
104
  with_platforms '' do
105
105
  netrc_data = [['mocked_data']]
106
- expect(::Netrc).to receive(:read) do
107
- mocked_netrc = instance_double(::Netrc)
106
+ expect(Netrc).to receive(:read) do
107
+ mocked_netrc = instance_double(Netrc)
108
108
  expect(mocked_netrc).to receive(:[]).with('my_domain.com').and_return %w[test_user test_password]
109
109
  expect(mocked_netrc).to receive(:instance_variable_get).with(:@data).and_return netrc_data
110
110
  mocked_netrc
@@ -133,7 +133,7 @@ describe HybridPlatformsConductor::Credentials do
133
133
  ENV['hpc_password_for_test_credential'] = 'env_test_password'
134
134
  begin
135
135
  # Check that .netrc won't be read
136
- expect(::Netrc).not_to receive(:read)
136
+ expect(Netrc).not_to receive(:read)
137
137
  expect_credentials_to_be 'user_for_', 'password_for_'
138
138
  ensure
139
139
  ENV.delete('hpc_user_for_test_credential')
@@ -155,7 +155,7 @@ describe HybridPlatformsConductor::Credentials do
155
155
  ENV['hpc_password_for_test_credential'] = 'env_test_password'
156
156
  begin
157
157
  # Check that .netrc won't be read
158
- expect(::Netrc).not_to receive(:read)
158
+ expect(Netrc).not_to receive(:read)
159
159
  expect_credentials_to_be 'user_for_test_resource', 'password_for_test_resource', resource: 'test_resource'
160
160
  ensure
161
161
  ENV.delete('hpc_user_for_test_credential')
@@ -166,7 +166,7 @@ describe HybridPlatformsConductor::Credentials do
166
166
 
167
167
  it 'returns credentials taken from config for a given resource even when they are nil' do
168
168
  with_platforms(
169
- <<~'EO_CONFIG'
169
+ <<~EO_CONFIG
170
170
  credentials_for(:test_credential) do |resource, requester|
171
171
  requester.call nil, nil
172
172
  end
@@ -177,7 +177,7 @@ describe HybridPlatformsConductor::Credentials do
177
177
  ENV['hpc_password_for_test_credential'] = 'env_test_password'
178
178
  begin
179
179
  # Check that .netrc won't be read
180
- expect(::Netrc).not_to receive(:read)
180
+ expect(Netrc).not_to receive(:read)
181
181
  expect_credentials_to_be nil, nil, resource: 'test_resource'
182
182
  ensure
183
183
  ENV.delete('hpc_user_for_test_credential')
@@ -233,7 +233,7 @@ describe HybridPlatformsConductor::Credentials do
233
233
 
234
234
  it 'fails if the requester is not called from config' do
235
235
  with_platforms(
236
- <<~'EO_CONFIG'
236
+ <<~EO_CONFIG
237
237
  credentials_for(:test_credential) do |resource, requester|
238
238
  end
239
239
  EO_CONFIG
@@ -1,5 +1,5 @@
1
1
  # This is an example of Dockerfile that can serve as an image for testing Docker handling in the Deployer
2
- FROM debian:stretch
2
+ FROM debian:bookworm
3
3
 
4
4
  RUN apt-get update && apt-get install -y openssh-server
5
5
  RUN mkdir /var/run/sshd
@@ -43,12 +43,12 @@ describe HybridPlatformsConductor::HpcPlugins::Provisioner::Docker do
43
43
  # Make sure we use a unique environment for this test
44
44
  environment = "test_#{Process.pid}_#{(Time.now - Process.clock_gettime(Process::CLOCK_BOOTTIME)).strftime('%Y%m%d%H%M%S')}"
45
45
  with_test_docker_platform(environment) do |instance|
46
- expect(::Docker::Container).to receive(:create).and_call_original
46
+ expect(Docker::Container).to receive(:create).and_call_original
47
47
  instance.create
48
48
  instance.wait_for_state! :created
49
49
  begin
50
50
  # Test that the instance is created
51
- expect(::Docker::Container.all(all: true).find { |container| container.info['Names'].include? "/hpc_docker_container_node_#{environment}" }).not_to be_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
@@ -62,7 +62,7 @@ describe HybridPlatformsConductor::HpcPlugins::Provisioner::Docker do
62
62
  instance.create
63
63
  instance.wait_for_state! :created
64
64
  begin
65
- expect(::Docker::Container).not_to receive(:create)
65
+ expect(Docker::Container).not_to receive(:create)
66
66
  instance.create
67
67
  expect(instance.state).to eq :created
68
68
  ensure
@@ -76,7 +76,7 @@ describe HybridPlatformsConductor::Deployer do
76
76
  platform_info,
77
77
  additional_config: "read_secrets_from :keepass\n#{additional_config}"
78
78
  ) do
79
- mock_databases.each do |database, _xml|
79
+ mock_databases.each_key do |database|
80
80
  expect(test_deployer.instance_variable_get(:@secrets_readers)[:keepass]).to receive(:with_credentials_for).with(:keepass, resource: database) do |_id, resource: nil, &client_code|
81
81
  client_code.call nil, mock_keepass_password
82
82
  end
@@ -14,7 +14,7 @@ describe HybridPlatformsConductor::NodesHandler do
14
14
  it 'sets different metadata for different nodes' do
15
15
  with_test_platform(
16
16
  { nodes: { 'node1' => {}, 'node2' => {} } },
17
- additional_config: <<~'EO_CONFIG'
17
+ additional_config: <<~EO_CONFIG
18
18
  for_nodes('node1') { set_metadata(my_property_1: 'my_value1', my_property_2: 'my_value2') }
19
19
  for_nodes('node2') { set_metadata(my_property_2: 'my_value3', my_property_3: 'my_value4') }
20
20
  EO_CONFIG
@@ -276,7 +276,7 @@ describe HybridPlatformsConductor::NodesHandler do
276
276
  it 'can configure different priority rules for different properties on different nodes' do
277
277
  with_cmdb_test_platform(
278
278
  cmdbs: %i[test_cmdb test_cmdb_2],
279
- additional_config: <<~'EO_CONFIG'
279
+ additional_config: <<~EO_CONFIG
280
280
  for_nodes('node1') do
281
281
  master_cmdbs(
282
282
  test_cmdb: :different_comment_2,
@@ -309,7 +309,7 @@ describe HybridPlatformsConductor::NodesHandler do
309
309
  it 'fails when there are conflicts in the definition of master CMDBs' do
310
310
  with_cmdb_test_platform(
311
311
  cmdbs: %i[test_cmdb test_cmdb_2],
312
- additional_config: <<~'EO_CONFIG'
312
+ additional_config: <<~EO_CONFIG
313
313
  master_cmdbs(
314
314
  test_cmdb: %i[different_comment different_comment_2]
315
315
  )
@@ -326,7 +326,7 @@ describe HybridPlatformsConductor::NodesHandler do
326
326
  it 'fails when the CMDB marked as master does not implement the property' do
327
327
  with_cmdb_test_platform(
328
328
  cmdbs: %i[test_cmdb test_cmdb_2],
329
- additional_config: <<~'EO_CONFIG'
329
+ additional_config: <<~EO_CONFIG
330
330
  master_cmdbs(
331
331
  test_cmdb_2: :upcase
332
332
  )
@@ -11,7 +11,7 @@ describe HybridPlatformsConductor::NodesHandler do
11
11
  'node3' => {}
12
12
  }
13
13
  },
14
- additional_config: <<~'EO_CONFIG'
14
+ additional_config: <<~EO_CONFIG
15
15
  master_cmdbs(
16
16
  test_cmdb: :property_1,
17
17
  test_cmdb_2: :property_2
@@ -70,7 +70,7 @@ describe HybridPlatformsConductor::NodesHandler do
70
70
  gemspec
71
71
  +
72
72
  +gem 'byebug'
73
-
73
+ No newline at end of file
74
74
  diff --git a/lib/hybrid_platforms_conductor/nodes_handler.rb b/lib/stale/hybrid_platforms_conductor/nodes_handler.rb
75
75
  index e8e1778..69a84bd 100644
76
76
  --- a/lib/hybrid_platforms_conductor/nodes_handler.rb
@@ -101,7 +101,7 @@ describe HybridPlatformsConductor::NodesHandler do
101
101
  gemspec
102
102
  +
103
103
  +gem 'byebug'
104
-
104
+ No newline at end of file
105
105
  EO_STDOUT
106
106
  },
107
107
  'lib/hybrid_platforms_conductor/nodes_handler.rb' => {
@@ -332,7 +332,7 @@ describe HybridPlatformsConductor::HpcPlugins::PlatformHandler::ServerlessChef d
332
332
 
333
333
  it 'packages the repository with a testadmin public key in local mode' do
334
334
  with_serverless_chef_platforms('hpc_test') do |platform, repository|
335
- File.write("#{ENV['hpc_platforms']}/testadmin.key.pub", 'ssh-rsa 12345 testadmin@test.com')
335
+ File.write("#{ENV.fetch('hpc_platforms', nil)}/testadmin.key.pub", 'ssh-rsa 12345 testadmin@test.com')
336
336
  with_packaging_mocked(
337
337
  repository,
338
338
  policy_file: 'policyfiles/test_policy.local.rb',
@@ -351,7 +351,7 @@ describe HybridPlatformsConductor::HpcPlugins::PlatformHandler::ServerlessChef d
351
351
 
352
352
  it 'does not package the repository with a testadmin public key in prod mode' do
353
353
  with_serverless_chef_platforms('hpc_test') do |platform, repository|
354
- File.write("#{ENV['hpc_platforms']}/testadmin.key.pub", 'ssh-rsa 12345 testadmin@test.com')
354
+ File.write("#{ENV.fetch('hpc_platforms', nil)}/testadmin.key.pub", 'ssh-rsa 12345 testadmin@test.com')
355
355
  with_packaging_mocked(
356
356
  repository,
357
357
  cookbook_metadata: {
@@ -70,7 +70,7 @@ describe HybridPlatformsConductor::PlatformsHandler do
70
70
  'platform1' => { platform_type: :test },
71
71
  'platform2' => { platform_type: :test_2 }
72
72
  },
73
- additional_config: "test_2_platform path: \'#{repository}/platform1\'"
73
+ additional_config: "test_2_platform path: '#{repository}/platform1'"
74
74
  ) do
75
75
  expect { test_platforms_handler.known_platforms }.to raise_error 'Platform name platform1 is declared several times.'
76
76
  end
@@ -84,7 +84,7 @@ describe HybridPlatformsConductor::PlatformsHandler do
84
84
  'platform1' => { platform_type: :test },
85
85
  'platform2' => { platform_type: :test_2 }
86
86
  },
87
- additional_config: "test_2_platform path: \'#{repository}\', name: 'other_platform'"
87
+ additional_config: "test_2_platform path: '#{repository}', name: 'other_platform'"
88
88
  ) do
89
89
  expect { test_platforms_handler.known_platforms }.to raise_error "Platform repository path #{repository} is declared several times."
90
90
  end
@@ -99,7 +99,7 @@ describe HybridPlatformsConductor::PlatformsHandler do
99
99
  'platform1' => { platform_type: :test },
100
100
  'platform2' => { platform_type: :test_2 }
101
101
  },
102
- additional_config: "test_platform path: \'#{repository}/platform1\', name: 'other_platform'"
102
+ additional_config: "test_platform path: '#{repository}/platform1', name: 'other_platform'"
103
103
  ) do
104
104
  expect(test_platforms_handler.known_platforms.map(&:name).sort).to eq %w[platform1 platform2 other_platform].sort
105
105
  end
@@ -105,9 +105,7 @@ describe HybridPlatformsConductor::Plugins do
105
105
  with_test_platform({}) do
106
106
  plugins = described_class.new(
107
107
  :test_plugin_type,
108
- init_plugin: proc do |plugin_class|
109
- plugin_class.name
110
- end,
108
+ init_plugin: proc(&:name),
111
109
  logger: logger,
112
110
  logger_stderr: logger
113
111
  )
@@ -34,14 +34,14 @@ describe HybridPlatformsConductor::ServicesHandler do
34
34
  it 'allows deployment in local environment' do
35
35
  with_test_platform_for_services_test do
36
36
  with_cmd_runner_mocked([]) do
37
- expect(test_services_handler.deploy_allowed?(services: { 'node1' => %w[service1] }, local_environment: true)).to be_nil
37
+ expect(test_services_handler.barrier_to_deploy(services: { 'node1' => %w[service1] }, local_environment: true)).to be_nil
38
38
  end
39
39
  end
40
40
  end
41
41
 
42
42
  it 'allows deployment if branch is on master' do
43
43
  with_test_platform_for_services_test do
44
- expect(test_services_handler.deploy_allowed?(services: { 'node1' => %w[service1] }, local_environment: false)).to be_nil
44
+ expect(test_services_handler.barrier_to_deploy(services: { 'node1' => %w[service1] }, local_environment: false)).to be_nil
45
45
  end
46
46
  end
47
47
 
@@ -52,7 +52,7 @@ describe HybridPlatformsConductor::ServicesHandler do
52
52
  deployable_services: %w[service1]
53
53
  }
54
54
  ) do
55
- expect(test_services_handler.deploy_allowed?(services: { 'node1' => %w[service1] }, local_environment: false)).to be_nil
55
+ expect(test_services_handler.barrier_to_deploy(services: { 'node1' => %w[service1] }, local_environment: false)).to be_nil
56
56
  end
57
57
  end
58
58
 
@@ -62,7 +62,7 @@ describe HybridPlatformsConductor::ServicesHandler do
62
62
  git = Git.open(repository)
63
63
  git.add_remote('another_remote', remote_repo).fetch
64
64
  git.checkout('remotes/another_remote/master')
65
- expect(test_services_handler.deploy_allowed?(services: { 'node1' => %w[service1] }, local_environment: false)).to be_nil
65
+ expect(test_services_handler.barrier_to_deploy(services: { 'node1' => %w[service1] }, local_environment: false)).to be_nil
66
66
  end
67
67
  end
68
68
  end
@@ -70,14 +70,14 @@ describe HybridPlatformsConductor::ServicesHandler do
70
70
  it 'allows deployment if branch is on master even if not checked-out' do
71
71
  with_test_platform_for_services_test do |repository|
72
72
  Git.open(repository).branch('other_branch').checkout
73
- expect(test_services_handler.deploy_allowed?(services: { 'node1' => %w[service1] }, local_environment: false)).to be_nil
73
+ expect(test_services_handler.barrier_to_deploy(services: { 'node1' => %w[service1] }, local_environment: false)).to be_nil
74
74
  end
75
75
  end
76
76
 
77
77
  it 'refuses deployment if branch is not master' do
78
78
  with_test_platform_for_services_test do |repository|
79
79
  checkout_non_master_on(repository)
80
- expect(test_services_handler.deploy_allowed?(services: { 'node1' => %w[service1] }, local_environment: false)).to eq "The following platforms have not checked out master: #{repository}. Only master should be deployed in production."
80
+ expect(test_services_handler.barrier_to_deploy(services: { 'node1' => %w[service1] }, local_environment: false)).to eq "The following platforms have not checked out master: #{repository}. Only master should be deployed in production."
81
81
  end
82
82
  end
83
83
 
@@ -91,7 +91,7 @@ describe HybridPlatformsConductor::ServicesHandler do
91
91
  as_git: true
92
92
  ) do
93
93
  expect(
94
- test_services_handler.deploy_allowed?(
94
+ test_services_handler.barrier_to_deploy(
95
95
  services: { 'node1' => %w[service1], 'node2' => %w[service2], 'node3' => %w[service3] },
96
96
  local_environment: false
97
97
  )
@@ -112,7 +112,7 @@ describe HybridPlatformsConductor::ServicesHandler do
112
112
  checkout_non_master_on(repositories['platform2'])
113
113
  checkout_non_master_on(repositories['platform4'])
114
114
  expect(
115
- test_services_handler.deploy_allowed?(
115
+ test_services_handler.barrier_to_deploy(
116
116
  services: { 'node1' => %w[service1], 'node2' => %w[service2], 'node3' => %w[service3], 'node4' => %w[service4] },
117
117
  local_environment: false
118
118
  )
@@ -133,7 +133,7 @@ describe HybridPlatformsConductor::ServicesHandler do
133
133
  checkout_non_master_on(repositories['platform2'])
134
134
  checkout_non_master_on(repositories['platform4'])
135
135
  expect(
136
- test_services_handler.deploy_allowed?(
136
+ test_services_handler.barrier_to_deploy(
137
137
  services: { 'node1' => %w[service1 service3] },
138
138
  local_environment: false
139
139
  )
@@ -53,7 +53,7 @@ describe HybridPlatformsConductor::TestsRunner do
53
53
  it 'returns 0 when tests are failing as expected' do
54
54
  with_test_platform(
55
55
  {},
56
- additional_config: <<~'EO_CONFIG'
56
+ additional_config: <<~EO_CONFIG
57
57
  expect_tests_to_fail(:platform_test, 'Expected failure')
58
58
  EO_CONFIG
59
59
  ) do
@@ -67,7 +67,7 @@ describe HybridPlatformsConductor::TestsRunner do
67
67
  it 'returns 0 when tests are failing as expected on a given node' do
68
68
  with_test_platform(
69
69
  { nodes: { 'node1' => {}, 'node2' => {}, 'node3' => {} } },
70
- additional_config: <<~'EO_CONFIG'
70
+ additional_config: <<~EO_CONFIG
71
71
  for_nodes('node2') do
72
72
  expect_tests_to_fail(:node_test, 'Expected failure')
73
73
  end
@@ -83,7 +83,7 @@ describe HybridPlatformsConductor::TestsRunner do
83
83
  it 'returns 1 when tests are succeeding but were expected to fail' do
84
84
  with_test_platform(
85
85
  {},
86
- additional_config: <<~'EO_CONFIG'
86
+ additional_config: <<~EO_CONFIG
87
87
  expect_tests_to_fail(:platform_test, 'Expected failure')
88
88
  EO_CONFIG
89
89
  ) do
@@ -96,7 +96,7 @@ describe HybridPlatformsConductor::TestsRunner do
96
96
  it 'returns 1 when extra expected failures have not been tested when running all tests' do
97
97
  with_test_platform(
98
98
  { nodes: { 'another_node' => {} } },
99
- additional_config: <<~'EO_CONFIG'
99
+ additional_config: <<~EO_CONFIG
100
100
  for_nodes('another_node') do
101
101
  expect_tests_to_fail(:platform_test, 'Expected failure')
102
102
  end
@@ -111,7 +111,7 @@ describe HybridPlatformsConductor::TestsRunner do
111
111
  it 'fails when expected failures reference missing nodes' do
112
112
  with_test_platform(
113
113
  { nodes: { 'node' => {} } },
114
- additional_config: <<~'EO_CONFIG'
114
+ additional_config: <<~EO_CONFIG
115
115
  for_nodes('missing_node') do
116
116
  expect_tests_to_fail(:node_test, 'Expected failure')
117
117
  end
@@ -134,7 +134,7 @@ describe HybridPlatformsConductor::TestsRunner do
134
134
 
135
135
  it 'reuses run_logs logs instead of running check-node when we ask for it' do
136
136
  with_test_platform_for_node_check_tests do
137
- run_logs_dir = "#{ENV['hpc_platforms']}/run_logs"
137
+ run_logs_dir = "#{ENV.fetch('hpc_platforms', nil)}/run_logs"
138
138
  FileUtils.mkdir_p run_logs_dir
139
139
  File.write("#{run_logs_dir}/node11.stdout", 'node11 check ok from logs')
140
140
  File.write("#{run_logs_dir}/node12.stdout", 'node12 check ok from logs')
@@ -155,7 +155,7 @@ describe HybridPlatformsConductor::TestsRunner do
155
155
 
156
156
  it 'fails when some run_logs are missing' do
157
157
  with_test_platform_for_node_check_tests do
158
- run_logs_dir = "#{ENV['hpc_platforms']}/run_logs"
158
+ run_logs_dir = "#{ENV.fetch('hpc_platforms', nil)}/run_logs"
159
159
  FileUtils.mkdir_p run_logs_dir
160
160
  File.write("#{run_logs_dir}/node11.stdout", 'node11 check ok from logs')
161
161
  File.write("#{run_logs_dir}/node12.stdout", 'node12 check ok from logs')
@@ -309,7 +309,7 @@ describe HybridPlatformsConductor::TestsRunner do
309
309
  'nodes_list2' => %w[node2 node3 node4]
310
310
  }
311
311
  },
312
- additional_config: <<~'EO_CONFIG'
312
+ additional_config: <<~EO_CONFIG
313
313
  for_nodes('node1') do
314
314
  expect_tests_to_fail(:node_test, 'Expected failure')
315
315
  end
@@ -0,0 +1,69 @@
1
+ describe HybridPlatformsConductor::TestsRunner do
2
+
3
+ context 'when checking test plugins' do
4
+
5
+ context 'with linear_strategy' do
6
+
7
+ it 'succeeds when git history is linear' do
8
+ with_test_platform({}) do |repository_path|
9
+ test_tests_runner.tests = [:linear_strategy]
10
+ with_cmd_runner_mocked [
11
+ ["cd #{repository_path} && git --no-pager log --merges --pretty=format:\"%H\"", proc { [0, '', ''] }]
12
+ ] do
13
+ expect(test_tests_runner.run_tests([])).to eq 0
14
+ end
15
+ end
16
+ end
17
+
18
+ it 'succeeds when git history is semi-linear' do
19
+ with_test_platform({}) do |repository_path|
20
+ test_tests_runner.tests = [:linear_strategy]
21
+ with_cmd_runner_mocked [
22
+ ["cd #{repository_path} && git --no-pager log --merges --pretty=format:\"%H\"", proc { [0, "11111111\n22222222\n", ''] }],
23
+ [/^cd #{Regexp.escape(repository_path)} && git --no-pager log\s+--pretty=format:"%H"\s+--graph\s+\$\(git merge-base\s+--octopus\s+\$\(git --no-pager log 11111111 --max-count 1 --pretty=format:"%P"\)\s*\)\.\.11111111\s+\| grep '\|'$/, proc { [1, '', ''] }],
24
+ [/^cd #{Regexp.escape(repository_path)} && git --no-pager log\s+--pretty=format:"%H"\s+--graph\s+\$\(git merge-base\s+--octopus\s+\$\(git --no-pager log 22222222 --max-count 1 --pretty=format:"%P"\)\s*\)\.\.22222222\s+\| grep '\|'$/, proc { [1, '', ''] }]
25
+ ] do
26
+ expect(test_tests_runner.run_tests([])).to eq 0
27
+ end
28
+ end
29
+ end
30
+
31
+ it 'fails when git history is not semi-linear' do
32
+ with_test_platform({}) do |repository_path|
33
+ test_tests_runner.tests = [:linear_strategy]
34
+ register_tests_report_plugins(test_tests_runner, report: HybridPlatformsConductorTest::TestsReportPlugin)
35
+ test_tests_runner.reports = [:report]
36
+ with_cmd_runner_mocked [
37
+ ["cd #{repository_path} && git --no-pager log --merges --pretty=format:\"%H\"", proc { [0, "11111111\n22222222\n", ''] }],
38
+ [/^cd #{Regexp.escape(repository_path)} && git --no-pager log\s+--pretty=format:"%H"\s+--graph\s+\$\(git merge-base\s+--octopus\s+\$\(git --no-pager log 11111111 --max-count 1 --pretty=format:"%P"\)\s*\)\.\.11111111\s+\| grep '\|'$/, proc { [1, '', ''] }],
39
+ [/^cd #{Regexp.escape(repository_path)} && git --no-pager log\s+--pretty=format:"%H"\s+--graph\s+\$\(git merge-base\s+--octopus\s+\$\(git --no-pager log 22222222 --max-count 1 --pretty=format:"%P"\)\s*\)\.\.22222222\s+\| grep '\|'$/, proc { [0, '* | 33333333', ''] }],
40
+ ["cd #{repository_path} && git show --no-patch --format=%ci 22222222", proc { [0, "#{(Time.now - (24 * 60 * 60)).strftime('%F %T')}\n", ''] }]
41
+ ] do
42
+ expect(test_tests_runner.run_tests([])).to eq 1
43
+ expect(HybridPlatformsConductorTest::TestsReportPlugin.reports.size).to eq 1
44
+ expect(HybridPlatformsConductorTest::TestsReportPlugin.reports.first[:platform_tests].sort).to eq [
45
+ [:linear_strategy, true, 'platform', ['Git history is not linear because of Merge commit 22222222']]
46
+ ]
47
+ end
48
+ end
49
+ end
50
+
51
+ it 'succeeds when git history is not semi-linear before 6 months' do
52
+ with_test_platform({}) do |repository_path|
53
+ test_tests_runner.tests = [:linear_strategy]
54
+ with_cmd_runner_mocked [
55
+ ["cd #{repository_path} && git --no-pager log --merges --pretty=format:\"%H\"", proc { [0, "11111111\n22222222\n", ''] }],
56
+ [/^cd #{Regexp.escape(repository_path)} && git --no-pager log\s+--pretty=format:"%H"\s+--graph\s+\$\(git merge-base\s+--octopus\s+\$\(git --no-pager log 11111111 --max-count 1 --pretty=format:"%P"\)\s*\)\.\.11111111\s+\| grep '\|'$/, proc { [1, '', ''] }],
57
+ [/^cd #{Regexp.escape(repository_path)} && git --no-pager log\s+--pretty=format:"%H"\s+--graph\s+\$\(git merge-base\s+--octopus\s+\$\(git --no-pager log 22222222 --max-count 1 --pretty=format:"%P"\)\s*\)\.\.22222222\s+\| grep '\|'$/, proc { [0, '* | 33333333', ''] }],
58
+ ["cd #{repository_path} && git show --no-patch --format=%ci 22222222", proc { [0, "#{(Time.now - (6 * 31 * 24 * 60 * 60)).strftime('%F %T')}\n", ''] }]
59
+ ] do
60
+ expect(test_tests_runner.run_tests([])).to eq 0
61
+ end
62
+ end
63
+ end
64
+
65
+ end
66
+
67
+ end
68
+
69
+ end
@@ -35,7 +35,7 @@ describe 'executables\' common options' do
35
35
  # 'topograph' => ['--from', '--node node1', '--to', '--node node1', '--skip-run', '--output', 'graphviz:graph.gv'],
36
36
  }.each do |executable, default_options|
37
37
 
38
- context "checking common options for #{executable}" do
38
+ context "when checking common options for #{executable}" do
39
39
 
40
40
  it 'displays its help' do
41
41
  with_test_platform_for_common_options do