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
@@ -14,7 +14,7 @@ describe HybridPlatformsConductor::HpcPlugins::Provisioner::Proxmox do
14
14
  memory_total: 4 * 1024 * 1024 * 1024,
15
15
  lxc_containers: {
16
16
  # Make sure it is expired
17
- 1000 => { ip: '192.168.0.100', maxmem: 1024 * 1024 * 1024, creation_date: (Time.now - 31 * 24 * 60 * 60).utc }
17
+ 1000 => { ip: '192.168.0.100', maxmem: 1024 * 1024 * 1024, creation_date: (Time.now - (31 * 24 * 60 * 60)).utc }
18
18
  }
19
19
  }
20
20
  }
@@ -29,7 +29,7 @@ describe HybridPlatformsConductor::HpcPlugins::Provisioner::Proxmox do
29
29
 
30
30
  it 'expires a VM when there are not enough free resources on a PVE node' do
31
31
  with_sync_node do
32
- creation_date = (Time.now - 31 * 24 * 60 * 60).utc
32
+ creation_date = (Time.now - (31 * 24 * 60 * 60)).utc
33
33
  mock_proxmox(
34
34
  mocked_pve_nodes: {
35
35
  'pve_node_name' => {
@@ -81,7 +81,7 @@ describe HybridPlatformsConductor::HpcPlugins::Provisioner::Proxmox do
81
81
  maxmem: 4 * 1024 * 1024 * 1024,
82
82
  status: 'stopped',
83
83
  # Make sure it is expired
84
- creation_date: (Time.now - 31 * 24 * 60 * 60).utc
84
+ creation_date: (Time.now - (31 * 24 * 60 * 60)).utc
85
85
  }
86
86
  }
87
87
  }
@@ -117,7 +117,7 @@ describe HybridPlatformsConductor::HpcPlugins::Provisioner::Proxmox do
117
117
  memory_total: 8 * 1024 * 1024 * 1024,
118
118
  lxc_containers: {
119
119
  1000 => { ip: '192.168.0.100', maxmem: 2 * 1024 * 1024 * 1024, creation_date: Time.now.utc },
120
- 1001 => { ip: '192.168.0.101', maxmem: 4 * 1024 * 1024 * 1024, creation_date: (Time.now - 31 * 24 * 60 * 60).utc },
120
+ 1001 => { ip: '192.168.0.101', maxmem: 4 * 1024 * 1024 * 1024, creation_date: (Time.now - (31 * 24 * 60 * 60)).utc },
121
121
  1002 => { ip: '192.168.0.102', maxmem: 2 * 1024 * 1024 * 1024, creation_date: Time.now.utc }
122
122
  }
123
123
  }
@@ -154,7 +154,7 @@ describe HybridPlatformsConductor::HpcPlugins::Provisioner::Proxmox do
154
154
  memory_total: 6 * 1024 * 1024 * 1024,
155
155
  lxc_containers: {
156
156
  1000 => { ip: '192.168.0.100', maxmem: 2 * 1024 * 1024 * 1024, creation_date: Time.now.utc },
157
- 1001 => { ip: '192.168.0.101', maxmem: 2 * 1024 * 1024 * 1024, creation_date: (Time.now - 31 * 24 * 60 * 60).utc },
157
+ 1001 => { ip: '192.168.0.101', maxmem: 2 * 1024 * 1024 * 1024, creation_date: (Time.now - (31 * 24 * 60 * 60)).utc },
158
158
  1002 => { ip: '192.168.0.102', maxmem: 2 * 1024 * 1024 * 1024, creation_date: Time.now.utc }
159
159
  }
160
160
  }
@@ -185,8 +185,8 @@ describe HybridPlatformsConductor::HpcPlugins::Provisioner::Proxmox do
185
185
  memory_total: 8 * 1024 * 1024 * 1024,
186
186
  lxc_containers: {
187
187
  1000 => { ip: '192.168.0.100', maxmem: 2 * 1024 * 1024 * 1024, creation_date: Time.now.utc },
188
- 1001 => { ip: '192.168.0.101', maxmem: 4 * 1024 * 1024 * 1024, creation_date: (Time.now - 31 * 24 * 60 * 60).utc },
189
- 1002 => { ip: '192.168.0.102', maxmem: 2 * 1024 * 1024 * 1024, creation_date: (Time.now - 31 * 24 * 60 * 60).utc }
188
+ 1001 => { ip: '192.168.0.101', maxmem: 4 * 1024 * 1024 * 1024, creation_date: (Time.now - (31 * 24 * 60 * 60)).utc },
189
+ 1002 => { ip: '192.168.0.102', maxmem: 2 * 1024 * 1024 * 1024, creation_date: (Time.now - (31 * 24 * 60 * 60)).utc }
190
190
  }
191
191
  }
192
192
  }
@@ -224,8 +224,8 @@ describe HybridPlatformsConductor::HpcPlugins::Provisioner::Proxmox do
224
224
  memory_total: 8 * 1024 * 1024 * 1024,
225
225
  lxc_containers: {
226
226
  1000 => { ip: '192.168.0.100', maxmem: 2 * 1024 * 1024 * 1024, creation_date: Time.now.utc },
227
- 1001 => { ip: '192.168.0.101', maxmem: 4 * 1024 * 1024 * 1024, creation_date: (Time.now - 31 * 24 * 60 * 60).utc },
228
- 2002 => { ip: '192.168.0.102', maxmem: 2 * 1024 * 1024 * 1024, creation_date: (Time.now - 31 * 24 * 60 * 60).utc }
227
+ 1001 => { ip: '192.168.0.101', maxmem: 4 * 1024 * 1024 * 1024, creation_date: (Time.now - (31 * 24 * 60 * 60)).utc },
228
+ 2002 => { ip: '192.168.0.102', maxmem: 2 * 1024 * 1024 * 1024, creation_date: (Time.now - (31 * 24 * 60 * 60)).utc }
229
229
  }
230
230
  }
231
231
  }
@@ -261,14 +261,14 @@ describe HybridPlatformsConductor::HpcPlugins::Provisioner::Proxmox do
261
261
  'pve_node_1' => {
262
262
  memory_total: 16 * 1024 * 1024 * 1024,
263
263
  lxc_containers: {
264
- 1000 => { ip: '192.168.0.100', maxmem: 14 * 1024 * 1024 * 1024, creation_date: (Time.now - 31 * 24 * 60 * 60).utc }
264
+ 1000 => { ip: '192.168.0.100', maxmem: 14 * 1024 * 1024 * 1024, creation_date: (Time.now - (31 * 24 * 60 * 60)).utc }
265
265
  }
266
266
  },
267
267
  # But this node has still a bit of resources left without expiring VMs
268
268
  'pve_node_2' => {
269
269
  memory_total: 16 * 1024 * 1024 * 1024,
270
270
  lxc_containers: {
271
- 1001 => { ip: '192.168.0.101', maxmem: 10 * 1024 * 1024 * 1024, creation_date: (Time.now - 31 * 24 * 60 * 60).utc }
271
+ 1001 => { ip: '192.168.0.101', maxmem: 10 * 1024 * 1024 * 1024, creation_date: (Time.now - (31 * 24 * 60 * 60)).utc }
272
272
  }
273
273
  }
274
274
  }
@@ -302,14 +302,14 @@ describe HybridPlatformsConductor::HpcPlugins::Provisioner::Proxmox do
302
302
  memory_total: 16 * 1024 * 1024 * 1024,
303
303
  lxc_containers: {
304
304
  1000 => { ip: '192.168.0.100', maxmem: 8 * 1024 * 1024 * 1024, creation_date: Time.now.utc },
305
- 1001 => { ip: '192.168.0.101', maxmem: 6 * 1024 * 1024 * 1024, creation_date: (Time.now - 31 * 24 * 60 * 60).utc }
305
+ 1001 => { ip: '192.168.0.101', maxmem: 6 * 1024 * 1024 * 1024, creation_date: (Time.now - (31 * 24 * 60 * 60)).utc }
306
306
  }
307
307
  },
308
308
  'pve_node_2' => {
309
309
  memory_total: 16 * 1024 * 1024 * 1024,
310
310
  lxc_containers: {
311
311
  1002 => { ip: '192.168.0.102', maxmem: 10 * 1024 * 1024 * 1024, creation_date: Time.now.utc },
312
- 1003 => { ip: '192.168.0.103', maxmem: 4 * 1024 * 1024 * 1024, creation_date: (Time.now - 31 * 24 * 60 * 60).utc }
312
+ 1003 => { ip: '192.168.0.103', maxmem: 4 * 1024 * 1024 * 1024, creation_date: (Time.now - (31 * 24 * 60 * 60)).utc }
313
313
  }
314
314
  }
315
315
  }
@@ -359,7 +359,7 @@ describe HybridPlatformsConductor::HpcPlugins::Provisioner::Proxmox do
359
359
  memory_total: 16 * 1024 * 1024 * 1024,
360
360
  lxc_containers: {
361
361
  1000 => { ip: '192.168.0.100', maxmem: 1 * 1024 * 1024 * 1024, creation_date: Time.now.utc },
362
- 1001 => { ip: '192.168.0.101', maxmem: 1 * 1024 * 1024 * 1024, creation_date: (Time.now - 31 * 24 * 60 * 60).utc },
362
+ 1001 => { ip: '192.168.0.101', maxmem: 1 * 1024 * 1024 * 1024, creation_date: (Time.now - (31 * 24 * 60 * 60)).utc },
363
363
  1002 => { ip: '192.168.0.102', maxmem: 1 * 1024 * 1024 * 1024, creation_date: Time.now.utc }
364
364
  }
365
365
  }
@@ -415,7 +415,7 @@ describe HybridPlatformsConductor::HpcPlugins::Provisioner::Proxmox do
415
415
  'pve_node_2' => {
416
416
  memory_total: 2 * 1024 * 1024 * 1024,
417
417
  lxc_containers: {
418
- 1001 => { ip: '192.168.0.101', maxmem: 1 * 1024 * 1024 * 1024, creation_date: (Time.now - 31 * 24 * 60 * 60).utc }
418
+ 1001 => { ip: '192.168.0.101', maxmem: 1 * 1024 * 1024 * 1024, creation_date: (Time.now - (31 * 24 * 60 * 60)).utc }
419
419
  }
420
420
  }
421
421
  }
@@ -463,7 +463,7 @@ describe HybridPlatformsConductor::HpcPlugins::Provisioner::Proxmox do
463
463
  memory_total: 16 * 1024 * 1024 * 1024,
464
464
  lxc_containers: {
465
465
  1000 => { ip: '192.168.0.100', maxmem: 1 * 1024 * 1024 * 1024, creation_date: Time.now.utc },
466
- 1001 => { ip: '192.168.0.101', maxmem: 1 * 1024 * 1024 * 1024, creation_date: (Time.now - 31 * 24 * 60 * 60).utc },
466
+ 1001 => { ip: '192.168.0.101', maxmem: 1 * 1024 * 1024 * 1024, creation_date: (Time.now - (31 * 24 * 60 * 60)).utc },
467
467
  1002 => { ip: '192.168.0.102', maxmem: 1 * 1024 * 1024 * 1024, creation_date: Time.now.utc }
468
468
  }
469
469
  }
@@ -521,7 +521,7 @@ describe HybridPlatformsConductor::HpcPlugins::Provisioner::Proxmox do
521
521
  'pve_node_2' => {
522
522
  memory_total: 2 * 1024 * 1024 * 1024,
523
523
  lxc_containers: {
524
- 1001 => { ip: '192.168.0.101', maxmem: 1 * 1024 * 1024 * 1024, creation_date: (Time.now - 31 * 24 * 60 * 60).utc }
524
+ 1001 => { ip: '192.168.0.101', maxmem: 1 * 1024 * 1024 * 1024, creation_date: (Time.now - (31 * 24 * 60 * 60)).utc }
525
525
  }
526
526
  }
527
527
  }
@@ -571,7 +571,7 @@ describe HybridPlatformsConductor::HpcPlugins::Provisioner::Proxmox do
571
571
  memory_total: 16 * 1024 * 1024 * 1024,
572
572
  lxc_containers: {
573
573
  1000 => { ip: '192.168.0.100', maxmem: 1 * 1024 * 1024 * 1024, creation_date: Time.now.utc },
574
- 1001 => { ip: '192.168.0.101', maxmem: 1 * 1024 * 1024 * 1024, creation_date: (Time.now - 31 * 24 * 60 * 60).utc },
574
+ 1001 => { ip: '192.168.0.101', maxmem: 1 * 1024 * 1024 * 1024, creation_date: (Time.now - (31 * 24 * 60 * 60)).utc },
575
575
  1002 => { ip: '192.168.0.102', maxmem: 1 * 1024 * 1024 * 1024, creation_date: Time.now.utc }
576
576
  }
577
577
  }
@@ -634,7 +634,7 @@ describe HybridPlatformsConductor::HpcPlugins::Provisioner::Proxmox do
634
634
  'pve_node_2' => {
635
635
  memory_total: 2 * 1024 * 1024 * 1024,
636
636
  lxc_containers: {
637
- 1001 => { ip: '192.168.0.101', maxmem: 1 * 1024 * 1024 * 1024, creation_date: (Time.now - 31 * 24 * 60 * 60).utc }
637
+ 1001 => { ip: '192.168.0.101', maxmem: 1 * 1024 * 1024 * 1024, creation_date: (Time.now - (31 * 24 * 60 * 60)).utc }
638
638
  }
639
639
  }
640
640
  }
@@ -748,7 +748,7 @@ describe HybridPlatformsConductor::HpcPlugins::Provisioner::Proxmox do
748
748
  it 'does not expire a VM that is stopped for some time even when it is not used for debug purposes' do
749
749
  with_sync_node do
750
750
  mock_proxmox(
751
- mocked_pve_nodes: [{
751
+ mocked_pve_nodes: ([{
752
752
  # 2 seconds separate each run.
753
753
  # Make sure the third and later runs mock the container as running instead of stopped
754
754
  'pve_node_name' => {
@@ -765,8 +765,8 @@ describe HybridPlatformsConductor::HpcPlugins::Provisioner::Proxmox do
765
765
  }
766
766
  }
767
767
  }
768
- }] * 2 +
769
- [{
768
+ }] * 2) +
769
+ ([{
770
770
  # 2 seconds separate each run.
771
771
  # Make sure the third and later runs mock the container as running instead of stopped
772
772
  'pve_node_name' => {
@@ -783,7 +783,7 @@ describe HybridPlatformsConductor::HpcPlugins::Provisioner::Proxmox do
783
783
  }
784
784
  }
785
785
  }
786
- }] * 2
786
+ }] * 2)
787
787
  )
788
788
  # Timeout for a non-debug stopped container to be considered expired is 3 seconds in tests
789
789
  expect(call_reserve_proxmox_container(2, 1024, 1, max_retries: 4, wait_before_retry: 2)).to eq(error: 'not_enough_resources')
@@ -796,7 +796,7 @@ describe HybridPlatformsConductor::HpcPlugins::Provisioner::Proxmox do
796
796
  creation_date_1 = (Time.now - 20).utc
797
797
  creation_date_2 = (Time.now - 10).utc
798
798
  mock_proxmox(
799
- mocked_pve_nodes: [{
799
+ mocked_pve_nodes: ([{
800
800
  # 2 seconds separate each run.
801
801
  # Make sure the third and later runs mock the container as another one, still stopped
802
802
  'pve_node_name' => {
@@ -812,8 +812,8 @@ describe HybridPlatformsConductor::HpcPlugins::Provisioner::Proxmox do
812
812
  }
813
813
  }
814
814
  }
815
- }] * 2 +
816
- [{
815
+ }] * 2) +
816
+ ([{
817
817
  # 2 seconds separate each run.
818
818
  # Make sure the third and later runs mock the container as another one, still stopped
819
819
  'pve_node_name' => {
@@ -829,7 +829,7 @@ describe HybridPlatformsConductor::HpcPlugins::Provisioner::Proxmox do
829
829
  }
830
830
  }
831
831
  }
832
- }] * 2
832
+ }] * 2)
833
833
  )
834
834
  # Timeout for a non-debug stopped container to be considered expired is 3 seconds in tests
835
835
  expect(call_reserve_proxmox_container(2, 1024, 1, max_retries: 4, wait_before_retry: 2)).to eq(error: 'not_enough_resources')
@@ -52,7 +52,7 @@ describe HybridPlatformsConductor::HpcPlugins::Provisioner::Proxmox do
52
52
  with_sync_node do
53
53
  mock_proxmox(mocked_pve_nodes: [{ 'pve_node_name' => { error_strings: ['NOK: error code = 500'] * 5 } }])
54
54
  result = call_reserve_proxmox_container(2, 1024, 4, config: { api_max_retries: 4 })
55
- expect(result[:error]).not_to eq nil
55
+ expect(result[:error]).not_to be_nil
56
56
  expect(result[:error]).to match(%r{Unhandled exception from reserve_proxmox_container: Proxmox API get nodes/pve_node_name/lxc returns NOK: error code = 500 continuously \(tried 5 times\)})
57
57
  expect_proxmox_actions_to_be [
58
58
  [:create_ticket],
@@ -17,6 +17,7 @@ describe HybridPlatformsConductor::NodesHandler do
17
17
  it 'returns a host IP when hostname is set' do
18
18
  with_test_platform({ nodes: { 'test_node' => {} } }) do
19
19
  with_cmd_runner_mocked [
20
+ ['command -v getent', proc { [0, '', ''] }],
20
21
  ['getent hosts my_domain.my_host', proc { [0, '192.168.42.42 my_domain.my_host', ''] }]
21
22
  ] do
22
23
  expect(cmdb(:host_ip).get_host_ip(['test_node'], { 'test_node' => { hostname: 'my_domain.my_host' } })).to eq('test_node' => '192.168.42.42')
@@ -24,9 +25,21 @@ describe HybridPlatformsConductor::NodesHandler do
24
25
  end
25
26
  end
26
27
 
28
+ it 'returns a host IP when hostname is set without getenv' do
29
+ with_test_platform({ nodes: { 'test_node' => {} } }) do
30
+ with_cmd_runner_mocked [
31
+ ['command -v getent', proc { [1, '', ''] }],
32
+ ['host my_domain.my_host | grep \'has address\'', proc { [0, 'my_domain.my_host has address 192.168.42.42', ''] }]
33
+ ] do
34
+ expect(cmdb(:host_ip).get_host_ip(['test_node'], { 'test_node' => { hostname: 'my_domain.my_host' } })).to eq('test_node' => '192.168.42.42')
35
+ end
36
+ end
37
+ end
38
+
27
39
  it 'does not return a host IP when getent can\'t retrieve it' do
28
40
  with_test_platform({ nodes: { 'test_node' => {} } }) do
29
41
  with_cmd_runner_mocked [
42
+ ['command -v getent', proc { [0, '', ''] }],
30
43
  ['getent hosts my_domain.my_host', proc { [0, '', ''] }]
31
44
  ] do
32
45
  expect(cmdb(:host_ip).get_host_ip(['test_node'], { 'test_node' => { hostname: 'my_domain.my_host' } })).to eq({})
@@ -34,6 +47,17 @@ describe HybridPlatformsConductor::NodesHandler do
34
47
  end
35
48
  end
36
49
 
50
+ it 'does not return a host IP when getent can\'t retrieve it without getenv' do
51
+ with_test_platform({ nodes: { 'test_node' => {} } }) do
52
+ with_cmd_runner_mocked [
53
+ ['command -v getent', proc { [1, '', ''] }],
54
+ ['host my_domain.my_host | grep \'has address\'', proc { [1, '', ''] }]
55
+ ] do
56
+ expect(cmdb(:host_ip).get_host_ip(['test_node'], { 'test_node' => { hostname: 'my_domain.my_host' } })).to eq({})
57
+ end
58
+ end
59
+ end
60
+
37
61
  it 'returns a host IPs for the maximum hosts it can from the list' do
38
62
  with_test_platform(
39
63
  {
@@ -46,6 +70,7 @@ describe HybridPlatformsConductor::NodesHandler do
46
70
  }
47
71
  ) do
48
72
  with_cmd_runner_mocked [
73
+ ['command -v getent', proc { [0, '', ''] }],
49
74
  ['getent hosts my_domain.my_host1', proc { [0, '192.168.42.1 my_domain.my_host1', ''] }],
50
75
  ['getent hosts my_domain.my_host2', proc { [0, '', ''] }],
51
76
  ['getent hosts my_domain.my_host4', proc { [0, '192.168.42.4 my_domain.my_host4', ''] }]
@@ -56,7 +56,7 @@ describe HybridPlatformsConductor::NodesHandler do
56
56
 
57
57
  it 'returns nodes metadata using dynamic method even on non-existant properties' do
58
58
  with_cmdb_test_platform do
59
- expect(test_nodes_handler.get_downcase_of('node1')).to eq nil
59
+ expect(test_nodes_handler.get_downcase_of('node1')).to be_nil
60
60
  end
61
61
  end
62
62
 
@@ -245,7 +245,7 @@ describe HybridPlatformsConductor::NodesHandler do
245
245
  additional_config: 'master_cmdbs(test_cmdb_2: :different_comment)'
246
246
  ) do
247
247
  expect(test_nodes_handler.get_different_comment_of('node1')).to eq 'Comment from test_cmdb_2'
248
- expect(cmdb(:test_cmdb).calls).to eq nil
248
+ expect(cmdb(:test_cmdb).calls).to be_nil
249
249
  expect(cmdb(:test_cmdb_2).calls).to eq [
250
250
  [:get_different_comment, ['node1'], {}]
251
251
  ]
@@ -385,7 +385,7 @@ describe HybridPlatformsConductor::NodesHandler do
385
385
 
386
386
  it 'does not cache metadata from others method when they are not the required property' do
387
387
  with_cmdb_test_platform(cmdbs: %i[test_cmdb test_cmdb_others]) do
388
- expect(test_nodes_handler.get_unknown_of('node1')).to eq nil
388
+ expect(test_nodes_handler.get_unknown_of('node1')).to be_nil
389
389
  expect(cmdb(:test_cmdb_others).calls).to eq [
390
390
  [:get_others, ['node1'], {}]
391
391
  ]
@@ -400,7 +400,7 @@ describe HybridPlatformsConductor::NodesHandler do
400
400
  it 'does not refuse conflicts between CMDBs and overriden values' do
401
401
  with_cmdb_test_platform(cmdbs: %i[test_cmdb_others]) do
402
402
  test_nodes_handler.override_metadata_of 'node1', :downcase, 'OVERIDDEN'
403
- expect(test_nodes_handler.get_unknown_of('node1')).to eq nil
403
+ expect(test_nodes_handler.get_unknown_of('node1')).to be_nil
404
404
  expect(test_nodes_handler.get_downcase_of('node1')).to eq 'OVERIDDEN'
405
405
  end
406
406
  end
@@ -409,7 +409,7 @@ describe HybridPlatformsConductor::NodesHandler do
409
409
  with_cmdb_test_platform do
410
410
  test_nodes_handler.override_metadata_of 'node1', :upcase, 'OVERIDDEN'
411
411
  expect(test_nodes_handler.metadata_of('node1', :upcase)).to eq 'OVERIDDEN'
412
- expect(cmdb(:test_cmdb).calls).to eq nil
412
+ expect(cmdb(:test_cmdb).calls).to be_nil
413
413
  end
414
414
  end
415
415
 
@@ -12,7 +12,7 @@ describe HybridPlatformsConductor::HpcPlugins::PlatformHandler::ServerlessChef d
12
12
 
13
13
  it 'returns no nodes list' do
14
14
  with_serverless_chef_platforms('empty') do |platform|
15
- expect(platform.respond_to?(:known_nodes_lists)).to eq false
15
+ expect(platform.respond_to?(:known_nodes_lists)).to be false
16
16
  end
17
17
  end
18
18
 
@@ -90,7 +90,7 @@ describe HybridPlatformsConductor::HpcPlugins::PlatformHandler::ServerlessChef d
90
90
  with_packaging_mocked(repository) do
91
91
  platform.package(services: { 'node' => %w[test_policy] }, secrets: {}, local_environment: false)
92
92
  gems_file = "#{repository}/dist/prod/test_policy/gems.json"
93
- expect(File.exist?(gems_file)).to eq true
93
+ expect(File.exist?(gems_file)).to be true
94
94
  expect(JSON.parse(File.read(gems_file))).to eq []
95
95
  end
96
96
  end
@@ -110,7 +110,7 @@ describe HybridPlatformsConductor::HpcPlugins::PlatformHandler::ServerlessChef d
110
110
  with_packaging_mocked(repository) do
111
111
  platform.package(services: { 'node' => %w[test_policy] }, secrets: { secret: 'value' }, local_environment: false)
112
112
  secret_file = "#{repository}/dist/prod/test_policy/data_bags/hpc_secrets/hpc_secrets.json"
113
- expect(File.exist?(secret_file)).to eq true
113
+ expect(File.exist?(secret_file)).to be true
114
114
  expect(JSON.parse(File.read(secret_file))).to eq(
115
115
  'id' => 'hpc_secrets',
116
116
  'secret' => 'value'
@@ -124,7 +124,7 @@ describe HybridPlatformsConductor::HpcPlugins::PlatformHandler::ServerlessChef d
124
124
  with_packaging_mocked(repository, policy_file: 'policyfiles/test_policy.local.rb', env: 'local') do
125
125
  platform.package(services: { 'node' => %w[test_policy] }, secrets: {}, local_environment: true)
126
126
  local_policy_file = "#{repository}/policyfiles/test_policy.local.lock.json"
127
- expect(File.exist?(local_policy_file)).to eq true
127
+ expect(File.exist?(local_policy_file)).to be true
128
128
  expect(JSON.parse(File.read(local_policy_file))).to eq('run_list' => ['recipe[test_cookbook]'])
129
129
  end
130
130
  end
@@ -247,7 +247,7 @@ describe HybridPlatformsConductor::HpcPlugins::PlatformHandler::ServerlessChef d
247
247
  ) do
248
248
  platform.package(services: { 'node1' => %w[test_policy_1] }, secrets: {}, local_environment: false)
249
249
  gems_file = "#{repository}/dist/prod/test_policy_1/gems.json"
250
- expect(File.exist?(gems_file)).to eq true
250
+ expect(File.exist?(gems_file)).to be true
251
251
  expect(JSON.parse(File.read(gems_file)).sort).to eq [
252
252
  ['my_gem_1', '0.0.1'],
253
253
  ['my_gem_2', '0.0.2'],
@@ -266,7 +266,7 @@ describe HybridPlatformsConductor::HpcPlugins::PlatformHandler::ServerlessChef d
266
266
  with_packaging_mocked(repository, data_bags: true) do
267
267
  platform.package(services: { 'node' => %w[test_policy] }, secrets: {}, local_environment: false)
268
268
  data_bag_file = "#{repository}/dist/prod/test_policy/data_bags/my_bag/my_item.json"
269
- expect(File.exist?(data_bag_file)).to eq true
269
+ expect(File.exist?(data_bag_file)).to be true
270
270
  expect(JSON.parse(File.read(data_bag_file))).to eq(
271
271
  'id' => 'my_item',
272
272
  'content' => 'Bag content'
@@ -284,7 +284,7 @@ describe HybridPlatformsConductor::HpcPlugins::PlatformHandler::ServerlessChef d
284
284
  with_packaging_mocked(repository, policy_file: 'policyfiles/test_policy.local.rb', env: 'local') do
285
285
  platform.package(services: { 'node' => %w[test_policy] }, secrets: {}, local_environment: true)
286
286
  local_policy_file = "#{repository}/policyfiles/test_policy.local.lock.json"
287
- expect(File.exist?(local_policy_file)).to eq true
287
+ expect(File.exist?(local_policy_file)).to be true
288
288
  expect(JSON.parse(File.read(local_policy_file))).to eq(
289
289
  'run_list' => [
290
290
  'hpc_test::before_run',
@@ -302,7 +302,7 @@ describe HybridPlatformsConductor::HpcPlugins::PlatformHandler::ServerlessChef d
302
302
  with_packaging_mocked(repository, policy_file: 'policyfiles/test_policy.local.rb', env: 'local') do
303
303
  platform.package(services: { 'node' => %w[test_policy] }, secrets: {}, local_environment: true)
304
304
  local_policy_file = "#{repository}/policyfiles/test_policy.local.lock.json"
305
- expect(File.exist?(local_policy_file)).to eq true
305
+ expect(File.exist?(local_policy_file)).to be true
306
306
  expect(JSON.parse(File.read(local_policy_file))).to eq(
307
307
  'run_list' => [
308
308
  'hpc_test::before_run',
@@ -319,7 +319,7 @@ describe HybridPlatformsConductor::HpcPlugins::PlatformHandler::ServerlessChef d
319
319
  with_packaging_mocked(repository, policy_file: 'policyfiles/test_policy.local.rb', env: 'local') do
320
320
  platform.package(services: { 'node' => %w[test_policy] }, secrets: {}, local_environment: true)
321
321
  local_policy_file = "#{repository}/policyfiles/test_policy.local.lock.json"
322
- expect(File.exist?(local_policy_file)).to eq true
322
+ expect(File.exist?(local_policy_file)).to be true
323
323
  expect(JSON.parse(File.read(local_policy_file))).to eq(
324
324
  'run_list' => [
325
325
  'recipe[test_cookbook]',
@@ -343,7 +343,7 @@ describe HybridPlatformsConductor::HpcPlugins::PlatformHandler::ServerlessChef d
343
343
  ) do
344
344
  platform.package(services: { 'node' => %w[test_policy] }, secrets: {}, local_environment: true)
345
345
  testadmin_key_pub = Dir.glob("#{repository}/dist/local/test_policy/cookbook_artifacts/hpc_test-*/files/default/testadmin.key.pub").first
346
- expect(testadmin_key_pub).not_to eq nil
346
+ expect(testadmin_key_pub).not_to be_nil
347
347
  expect(File.read(testadmin_key_pub)).to eq 'ssh-rsa 12345 testadmin@test.com'
348
348
  end
349
349
  end
@@ -168,7 +168,7 @@ describe HybridPlatformsConductor::HpcPlugins::PlatformHandler::ServerlessChef d
168
168
  )
169
169
  expect(platform.actions_to_deploy_on('node', 'test_policy', use_why_run: false)).to eq expected_actions_to_deploy_chef(repository)
170
170
  attributes_file = "#{repository}/dist/prod/test_policy/nodes/node.json"
171
- expect(File.exist?(attributes_file)).to eq true
171
+ expect(File.exist?(attributes_file)).to be true
172
172
  expect(JSON.parse(File.read(attributes_file))).to eq(
173
173
  'description' => 'Single test node',
174
174
  'image' => 'debian_9',
@@ -138,7 +138,7 @@ describe HybridPlatformsConductor::PlatformsHandler do
138
138
  'platform3' => { platform_type: :test }
139
139
  }
140
140
  ) do
141
- expect(test_platforms_handler.platform('platform4')).to eq nil
141
+ expect(test_platforms_handler.platform('platform4')).to be_nil
142
142
  end
143
143
  end
144
144
 
@@ -7,6 +7,9 @@ module HybridPlatformsConductor
7
7
  class TestPluginType2 < Plugin
8
8
  end
9
9
 
10
+ class TestPluginType3 < Plugin
11
+ end
12
+
10
13
  end
11
14
 
12
15
  module HybridPlatformsConductorTest
@@ -122,7 +125,7 @@ describe HybridPlatformsConductor::Plugins do
122
125
  plugins[:new_plugin] = HybridPlatformsConductorTest::RandomClassWithValidation
123
126
  expect(plugins.keys).to eq [:new_plugin]
124
127
  expect(plugins[:new_plugin]).to eq HybridPlatformsConductorTest::RandomClassWithValidation
125
- expect(HybridPlatformsConductorTest::RandomClassWithValidation.validation_done).to eq true
128
+ expect(HybridPlatformsConductorTest::RandomClassWithValidation.validation_done).to be true
126
129
  end
127
130
  end
128
131
 
@@ -133,7 +136,7 @@ describe HybridPlatformsConductor::Plugins do
133
136
  HybridPlatformsConductorTest::RandomClassWithValidation.validation_result = false
134
137
  plugins[:new_plugin] = HybridPlatformsConductorTest::RandomClassWithValidation
135
138
  expect(plugins.keys).to eq []
136
- expect(HybridPlatformsConductorTest::RandomClassWithValidation.validation_done).to eq true
139
+ expect(HybridPlatformsConductorTest::RandomClassWithValidation.validation_done).to be true
137
140
  end
138
141
  end
139
142
 
@@ -162,6 +165,31 @@ describe HybridPlatformsConductor::Plugins do
162
165
  end
163
166
  end
164
167
 
168
+ it 'discovers automatically plugins of a given type in the hpc_plugins directory of a gem even if lib is used in the gem\'s installation path' do
169
+ with_test_platform({}) do
170
+ # Mock the discovery of Ruby gems
171
+ expect(Gem).to receive(:loaded_specs) do
172
+ my_test_gem_spec = instance_double Gem::Specification
173
+ expect(my_test_gem_spec).to receive(:full_gem_path).and_return('path/to/__gem_full_path__/in/lib/sub')
174
+ expect(Dir).to receive(:glob).with('path/to/__gem_full_path__/in/lib/sub/lib/**/*.rb').and_return [
175
+ 'path/to/__gem_full_path__/in/lib/sub/lib/my_test_gem_with_lib/sub1/lib/sub2/hpc_plugins/test_plugin_type_3/test_plugin_id_5.rb'
176
+ ]
177
+ {
178
+ 'my_test_gem_with_lib' => my_test_gem_spec
179
+ }
180
+ end
181
+ # Alter the load path to mock an extra Rubygem
182
+ $LOAD_PATH.unshift "#{__dir__}/../mocked_lib"
183
+ begin
184
+ plugins = described_class.new(:test_plugin_type_3, logger: logger, logger_stderr: logger)
185
+ expect(plugins.keys).to eq [:test_plugin_id_5]
186
+ expect(plugins[:test_plugin_id_5]).to eq HybridPlatformsConductorTest::MockedLib::MyTestGemWithLib::Sub1::Lib::Sub2::HpcPlugins::TestPluginType3::TestPluginId5
187
+ ensure
188
+ $LOAD_PATH.shift
189
+ end
190
+ end
191
+ end
192
+
165
193
  it 'discovers automatically several plugins of different types in the hpc_plugins directories of several gems' do
166
194
  with_test_platform({}) do
167
195
  # Mock the discovery of Ruby gems
@@ -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 eq nil
37
+ expect(test_services_handler.deploy_allowed?(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 eq nil
44
+ expect(test_services_handler.deploy_allowed?(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 eq nil
55
+ expect(test_services_handler.deploy_allowed?(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 eq nil
65
+ expect(test_services_handler.deploy_allowed?(services: { 'node1' => %w[service1] }, local_environment: false)).to be_nil
66
66
  end
67
67
  end
68
68
  end
@@ -70,7 +70,7 @@ 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 eq nil
73
+ expect(test_services_handler.deploy_allowed?(services: { 'node1' => %w[service1] }, local_environment: false)).to be_nil
74
74
  end
75
75
  end
76
76
 
@@ -95,7 +95,7 @@ describe HybridPlatformsConductor::ServicesHandler do
95
95
  services: { 'node1' => %w[service1], 'node2' => %w[service2], 'node3' => %w[service3] },
96
96
  local_environment: false
97
97
  )
98
- ).to eq nil
98
+ ).to be_nil
99
99
  end
100
100
  end
101
101
 
@@ -137,7 +137,7 @@ describe HybridPlatformsConductor::ServicesHandler do
137
137
  services: { 'node1' => %w[service1 service3] },
138
138
  local_environment: false
139
139
  )
140
- ).to eq nil
140
+ ).to be_nil
141
141
  end
142
142
  end
143
143