hybrid_platforms_conductor 33.0.0 → 33.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (242) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +6 -0
  3. data/bin/check-node +0 -1
  4. data/bin/deploy +0 -1
  5. data/bin/get_impacted_nodes +0 -1
  6. data/bin/last_deploys +8 -7
  7. data/bin/nodes_to_deploy +2 -2
  8. data/bin/setup +6 -6
  9. data/bin/topograph +1 -1
  10. data/lib/hybrid_platforms_conductor/action.rb +4 -4
  11. data/lib/hybrid_platforms_conductor/actions_executor.rb +37 -42
  12. data/lib/hybrid_platforms_conductor/bitbucket.rb +5 -4
  13. data/lib/hybrid_platforms_conductor/cmd_runner.rb +13 -12
  14. data/lib/hybrid_platforms_conductor/cmdb.rb +2 -2
  15. data/lib/hybrid_platforms_conductor/common_config_dsl/bitbucket.rb +2 -1
  16. data/lib/hybrid_platforms_conductor/common_config_dsl/confluence.rb +2 -1
  17. data/lib/hybrid_platforms_conductor/common_config_dsl/file_system_tests.rb +5 -4
  18. data/lib/hybrid_platforms_conductor/common_config_dsl/github.rb +4 -3
  19. data/lib/hybrid_platforms_conductor/common_config_dsl/idempotence_tests.rb +2 -2
  20. data/lib/hybrid_platforms_conductor/config.rb +7 -4
  21. data/lib/hybrid_platforms_conductor/confluence.rb +1 -1
  22. data/lib/hybrid_platforms_conductor/connector.rb +5 -2
  23. data/lib/hybrid_platforms_conductor/core_extensions/symbol/zero.rb +24 -0
  24. data/lib/hybrid_platforms_conductor/credentials.rb +39 -36
  25. data/lib/hybrid_platforms_conductor/current_dir_monitor.rb +4 -1
  26. data/lib/hybrid_platforms_conductor/deployer.rb +95 -96
  27. data/lib/hybrid_platforms_conductor/executable.rb +20 -15
  28. data/lib/hybrid_platforms_conductor/hpc_plugins/cmdb/config.rb +10 -7
  29. data/lib/hybrid_platforms_conductor/hpc_plugins/cmdb/host_ip.rb +1 -1
  30. data/lib/hybrid_platforms_conductor/hpc_plugins/cmdb/host_keys.rb +2 -2
  31. data/lib/hybrid_platforms_conductor/hpc_plugins/cmdb/platform_handlers.rb +4 -4
  32. data/lib/hybrid_platforms_conductor/hpc_plugins/connector/local.rb +2 -0
  33. data/lib/hybrid_platforms_conductor/hpc_plugins/connector/ssh.rb +45 -49
  34. data/lib/hybrid_platforms_conductor/hpc_plugins/log/remote_fs.rb +6 -5
  35. data/lib/hybrid_platforms_conductor/hpc_plugins/platform_handler/serverless_chef.rb +68 -66
  36. data/lib/hybrid_platforms_conductor/hpc_plugins/platform_handler/serverless_chef/dsl_parser.rb +13 -0
  37. data/lib/hybrid_platforms_conductor/hpc_plugins/platform_handler/serverless_chef/recipes_tree_builder.rb +39 -38
  38. data/lib/hybrid_platforms_conductor/hpc_plugins/platform_handler/yaml_inventory.rb +5 -4
  39. data/lib/hybrid_platforms_conductor/hpc_plugins/provisioner/docker.rb +43 -45
  40. data/lib/hybrid_platforms_conductor/hpc_plugins/provisioner/podman.rb +18 -20
  41. data/lib/hybrid_platforms_conductor/hpc_plugins/provisioner/proxmox.rb +118 -117
  42. data/lib/hybrid_platforms_conductor/hpc_plugins/provisioner/proxmox/proxmox_waiter.rb +39 -43
  43. data/lib/hybrid_platforms_conductor/hpc_plugins/provisioner/proxmox/reserve_proxmox_container +9 -13
  44. data/lib/hybrid_platforms_conductor/hpc_plugins/report/confluence.rb +2 -2
  45. data/lib/hybrid_platforms_conductor/hpc_plugins/report/mediawiki.rb +28 -21
  46. data/lib/hybrid_platforms_conductor/hpc_plugins/report/stdout.rb +26 -22
  47. data/lib/hybrid_platforms_conductor/hpc_plugins/secrets_reader/cli.rb +8 -6
  48. data/lib/hybrid_platforms_conductor/hpc_plugins/secrets_reader/thycotic.rb +7 -4
  49. data/lib/hybrid_platforms_conductor/hpc_plugins/test/bitbucket_conf.rb +3 -3
  50. data/lib/hybrid_platforms_conductor/hpc_plugins/test/check_deploy_and_idempotence.rb +4 -2
  51. data/lib/hybrid_platforms_conductor/hpc_plugins/test/deploy_freshness.rb +0 -1
  52. data/lib/hybrid_platforms_conductor/hpc_plugins/test/deploy_removes_root_access.rb +21 -19
  53. data/lib/hybrid_platforms_conductor/hpc_plugins/test/divergence.rb +2 -2
  54. data/lib/hybrid_platforms_conductor/hpc_plugins/test/executables.rb +2 -2
  55. data/lib/hybrid_platforms_conductor/hpc_plugins/test/file_system.rb +19 -21
  56. data/lib/hybrid_platforms_conductor/hpc_plugins/test/file_system_hdfs.rb +19 -21
  57. data/lib/hybrid_platforms_conductor/hpc_plugins/test/github_ci.rb +2 -3
  58. data/lib/hybrid_platforms_conductor/hpc_plugins/test/idempotence.rb +2 -2
  59. data/lib/hybrid_platforms_conductor/hpc_plugins/test/ip.rb +1 -1
  60. data/lib/hybrid_platforms_conductor/hpc_plugins/test/jenkins_ci_conf.rb +21 -22
  61. data/lib/hybrid_platforms_conductor/hpc_plugins/test/jenkins_ci_masters_ok.rb +10 -12
  62. data/lib/hybrid_platforms_conductor/hpc_plugins/test/linear_strategy.rb +9 -9
  63. data/lib/hybrid_platforms_conductor/hpc_plugins/test/local_users.rb +2 -2
  64. data/lib/hybrid_platforms_conductor/hpc_plugins/test/mounts.rb +2 -2
  65. data/lib/hybrid_platforms_conductor/hpc_plugins/test/orphan_files.rb +10 -9
  66. data/lib/hybrid_platforms_conductor/hpc_plugins/test/ports.rb +2 -2
  67. data/lib/hybrid_platforms_conductor/hpc_plugins/test/private_ips.rb +5 -5
  68. data/lib/hybrid_platforms_conductor/hpc_plugins/test/public_ips.rb +5 -5
  69. data/lib/hybrid_platforms_conductor/hpc_plugins/test/spectre.rb +4 -6
  70. data/lib/hybrid_platforms_conductor/hpc_plugins/test/veids.rb +3 -3
  71. data/lib/hybrid_platforms_conductor/hpc_plugins/test/vulnerabilities.rb +25 -24
  72. data/lib/hybrid_platforms_conductor/hpc_plugins/test_report/confluence.rb +2 -2
  73. data/lib/hybrid_platforms_conductor/hpc_plugins/test_report/stdout.rb +8 -6
  74. data/lib/hybrid_platforms_conductor/io_router.rb +14 -13
  75. data/lib/hybrid_platforms_conductor/json_dumper.rb +2 -2
  76. data/lib/hybrid_platforms_conductor/log.rb +2 -2
  77. data/lib/hybrid_platforms_conductor/logger_helpers.rb +19 -16
  78. data/lib/hybrid_platforms_conductor/nodes_handler.rb +89 -71
  79. data/lib/hybrid_platforms_conductor/parallel_threads.rb +7 -11
  80. data/lib/hybrid_platforms_conductor/platform_handler.rb +7 -7
  81. data/lib/hybrid_platforms_conductor/platforms_handler.rb +5 -3
  82. data/lib/hybrid_platforms_conductor/plugin.rb +2 -2
  83. data/lib/hybrid_platforms_conductor/plugins.rb +13 -8
  84. data/lib/hybrid_platforms_conductor/provisioner.rb +4 -4
  85. data/lib/hybrid_platforms_conductor/report.rb +2 -2
  86. data/lib/hybrid_platforms_conductor/reports_handler.rb +3 -2
  87. data/lib/hybrid_platforms_conductor/secrets_reader.rb +2 -2
  88. data/lib/hybrid_platforms_conductor/services_handler.rb +32 -29
  89. data/lib/hybrid_platforms_conductor/test_only_remote_node.rb +1 -1
  90. data/lib/hybrid_platforms_conductor/test_report.rb +15 -18
  91. data/lib/hybrid_platforms_conductor/tests_runner.rb +116 -118
  92. data/lib/hybrid_platforms_conductor/thycotic.rb +28 -19
  93. data/lib/hybrid_platforms_conductor/topographer.rb +200 -190
  94. data/lib/hybrid_platforms_conductor/topographer/plugins/graphviz.rb +8 -8
  95. data/lib/hybrid_platforms_conductor/topographer/plugins/json.rb +4 -4
  96. data/lib/hybrid_platforms_conductor/version.rb +1 -1
  97. data/spec/hybrid_platforms_conductor_test.rb +6 -6
  98. data/spec/hybrid_platforms_conductor_test/api/actions_executor/actions/bash_spec.rb +16 -11
  99. data/spec/hybrid_platforms_conductor_test/api/actions_executor/actions/interactive_spec.rb +1 -1
  100. data/spec/hybrid_platforms_conductor_test/api/actions_executor/actions/remote_bash_spec.rb +23 -18
  101. data/spec/hybrid_platforms_conductor_test/api/actions_executor/actions/ruby_spec.rb +67 -49
  102. data/spec/hybrid_platforms_conductor_test/api/actions_executor/actions/scp_spec.rb +20 -14
  103. data/spec/hybrid_platforms_conductor_test/api/actions_executor/actions_spec.rb +63 -50
  104. data/spec/hybrid_platforms_conductor_test/api/actions_executor/connection_spec.rb +35 -35
  105. data/spec/hybrid_platforms_conductor_test/api/actions_executor/connectors/local/connectable_nodes_spec.rb +12 -8
  106. data/spec/hybrid_platforms_conductor_test/api/actions_executor/connectors/local/remote_actions_spec.rb +4 -7
  107. data/spec/hybrid_platforms_conductor_test/api/actions_executor/connectors/ssh/cli_options_spec.rb +21 -22
  108. data/spec/hybrid_platforms_conductor_test/api/actions_executor/connectors/ssh/config_dsl_spec.rb +23 -24
  109. data/spec/hybrid_platforms_conductor_test/api/actions_executor/connectors/ssh/connectable_nodes_spec.rb +10 -6
  110. data/spec/hybrid_platforms_conductor_test/api/actions_executor/connectors/ssh/connections_spec.rb +73 -54
  111. data/spec/hybrid_platforms_conductor_test/api/actions_executor/connectors/ssh/global_helpers_spec.rb +145 -126
  112. data/spec/hybrid_platforms_conductor_test/api/actions_executor/connectors/ssh/node_helpers_spec.rb +3 -3
  113. data/spec/hybrid_platforms_conductor_test/api/actions_executor/connectors/ssh/remote_actions_spec.rb +29 -25
  114. data/spec/hybrid_platforms_conductor_test/api/actions_executor/logging_spec.rb +106 -91
  115. data/spec/hybrid_platforms_conductor_test/api/actions_executor/parallel_spec.rb +272 -244
  116. data/spec/hybrid_platforms_conductor_test/api/actions_executor/timeout_spec.rb +10 -12
  117. data/spec/hybrid_platforms_conductor_test/api/cmd_runner_spec.rb +36 -36
  118. data/spec/hybrid_platforms_conductor_test/api/config_spec.rb +24 -22
  119. data/spec/hybrid_platforms_conductor_test/api/deployer/check_spec.rb +4 -2
  120. data/spec/hybrid_platforms_conductor_test/api/deployer/config_dsl_spec.rb +7 -11
  121. data/spec/hybrid_platforms_conductor_test/api/deployer/deploy_spec.rb +34 -26
  122. data/spec/hybrid_platforms_conductor_test/api/deployer/log_plugins/remote_fs_spec.rb +21 -21
  123. data/spec/hybrid_platforms_conductor_test/api/deployer/parse_deploy_output_spec.rb +55 -59
  124. data/spec/hybrid_platforms_conductor_test/api/deployer/provisioner_spec.rb +36 -62
  125. data/spec/hybrid_platforms_conductor_test/api/deployer/provisioners/podman_spec.rb +17 -17
  126. data/spec/hybrid_platforms_conductor_test/api/deployer/provisioners/proxmox/config_dsl_spec.rb +4 -4
  127. data/spec/hybrid_platforms_conductor_test/api/deployer/provisioners/proxmox/create_spec.rb +44 -51
  128. data/spec/hybrid_platforms_conductor_test/api/deployer/provisioners/proxmox/destroy_spec.rb +3 -3
  129. data/spec/hybrid_platforms_conductor_test/api/deployer/provisioners/proxmox/ip_spec.rb +12 -16
  130. data/spec/hybrid_platforms_conductor_test/api/deployer/provisioners/proxmox/reserve_proxmox_container/destroy_vm_spec.rb +31 -19
  131. data/spec/hybrid_platforms_conductor_test/api/deployer/provisioners/proxmox/reserve_proxmox_container/expired_containers_spec.rb +324 -266
  132. data/spec/hybrid_platforms_conductor_test/api/deployer/provisioners/proxmox/reserve_proxmox_container/ips_assignment_spec.rb +89 -61
  133. data/spec/hybrid_platforms_conductor_test/api/deployer/provisioners/proxmox/reserve_proxmox_container/other_lxc_containers_resources_spec.rb +117 -93
  134. data/spec/hybrid_platforms_conductor_test/api/deployer/provisioners/proxmox/reserve_proxmox_container/pve_node_resources_spec.rb +71 -54
  135. data/spec/hybrid_platforms_conductor_test/api/deployer/provisioners/proxmox/reserve_proxmox_container/retries_spec.rb +10 -8
  136. data/spec/hybrid_platforms_conductor_test/api/deployer/provisioners/proxmox/reserve_proxmox_container/vm_ids_assignment_spec.rb +80 -60
  137. data/spec/hybrid_platforms_conductor_test/api/deployer/provisioners/proxmox/start_spec.rb +1 -1
  138. data/spec/hybrid_platforms_conductor_test/api/deployer/provisioners/proxmox/state_spec.rb +1 -1
  139. data/spec/hybrid_platforms_conductor_test/api/deployer/provisioners/proxmox/stop_spec.rb +1 -1
  140. data/spec/hybrid_platforms_conductor_test/api/deployer/secrets_reader_plugins/cli_spec.rb +21 -20
  141. data/spec/hybrid_platforms_conductor_test/api/deployer/secrets_reader_plugins/thycotic_spec.rb +70 -55
  142. data/spec/hybrid_platforms_conductor_test/api/nodes_handler/cmdbs/config_spec.rb +8 -10
  143. data/spec/hybrid_platforms_conductor_test/api/nodes_handler/cmdbs/host_ip_spec.rb +33 -24
  144. data/spec/hybrid_platforms_conductor_test/api/nodes_handler/cmdbs/host_keys_spec.rb +64 -51
  145. data/spec/hybrid_platforms_conductor_test/api/nodes_handler/cmdbs/platform_handlers_spec.rb +3 -3
  146. data/spec/hybrid_platforms_conductor_test/api/nodes_handler/cmdbs_plugins_api_spec.rb +50 -51
  147. data/spec/hybrid_platforms_conductor_test/api/nodes_handler/common_spec.rb +91 -81
  148. data/spec/hybrid_platforms_conductor_test/api/nodes_handler/config_dsl_spec.rb +14 -16
  149. data/spec/hybrid_platforms_conductor_test/api/nodes_handler/git_diff_impacts_spec.rb +51 -75
  150. data/spec/hybrid_platforms_conductor_test/api/nodes_handler/nodes_selectors_spec.rb +35 -26
  151. data/spec/hybrid_platforms_conductor_test/api/nodes_handler/platform_handlers_plugins_api_spec.rb +24 -16
  152. data/spec/hybrid_platforms_conductor_test/api/nodes_handler/several_platforms_spec.rb +29 -19
  153. data/spec/hybrid_platforms_conductor_test/api/platform_handler_spec.rb +4 -4
  154. data/spec/hybrid_platforms_conductor_test/api/platform_handlers/serverless_chef/config_dsl_spec.rb +2 -2
  155. data/spec/hybrid_platforms_conductor_test/api/platform_handlers/serverless_chef/deploy_output_parsing_spec.rb +6 -6
  156. data/spec/hybrid_platforms_conductor_test/api/platform_handlers/serverless_chef/diff_impacts_spec.rb +57 -99
  157. data/spec/hybrid_platforms_conductor_test/api/platform_handlers/serverless_chef/inventory_spec.rb +4 -4
  158. data/spec/hybrid_platforms_conductor_test/api/platform_handlers/serverless_chef/packaging_spec.rb +32 -35
  159. data/spec/hybrid_platforms_conductor_test/api/platform_handlers/serverless_chef/services_deployment_spec.rb +10 -10
  160. data/spec/hybrid_platforms_conductor_test/api/platforms_handler_spec.rb +38 -27
  161. data/spec/hybrid_platforms_conductor_test/api/plugins_spec.rb +46 -52
  162. data/spec/hybrid_platforms_conductor_test/api/reports_handler_spec.rb +2 -2
  163. data/spec/hybrid_platforms_conductor_test/api/services_handler/actions_to_deploy_spec.rb +90 -58
  164. data/spec/hybrid_platforms_conductor_test/api/services_handler/deploy_allowed_spec.rb +38 -34
  165. data/spec/hybrid_platforms_conductor_test/api/services_handler/log_info_spec.rb +11 -9
  166. data/spec/hybrid_platforms_conductor_test/api/services_handler/package_spec.rb +193 -171
  167. data/spec/hybrid_platforms_conductor_test/api/services_handler/parse_deploy_output_spec.rb +66 -54
  168. data/spec/hybrid_platforms_conductor_test/api/services_handler/prepare_for_deploy_spec.rb +147 -133
  169. data/spec/hybrid_platforms_conductor_test/api/tests_runner/common_spec.rb +69 -49
  170. data/spec/hybrid_platforms_conductor_test/api/tests_runner/global_spec.rb +4 -3
  171. data/spec/hybrid_platforms_conductor_test/api/tests_runner/node_check_spec.rb +8 -5
  172. data/spec/hybrid_platforms_conductor_test/api/tests_runner/node_spec.rb +8 -5
  173. data/spec/hybrid_platforms_conductor_test/api/tests_runner/node_ssh_spec.rb +30 -27
  174. data/spec/hybrid_platforms_conductor_test/api/tests_runner/platform_spec.rb +12 -9
  175. data/spec/hybrid_platforms_conductor_test/api/tests_runner/reports_spec.rb +48 -47
  176. data/spec/hybrid_platforms_conductor_test/api/tests_runner/test_plugins/bitbucket_conf_spec.rb +5 -5
  177. data/spec/hybrid_platforms_conductor_test/api/tests_runner/test_plugins/github_ci_spec.rb +5 -5
  178. data/spec/hybrid_platforms_conductor_test/api/tests_runner/test_reports_plugins/confluence_spec.rb +5 -5
  179. data/spec/hybrid_platforms_conductor_test/cmdb_plugins/test_cmdb.rb +9 -9
  180. data/spec/hybrid_platforms_conductor_test/cmdb_plugins/{test_cmdb2.rb → test_cmdb_2.rb} +6 -6
  181. data/spec/hybrid_platforms_conductor_test/cmdb_plugins/test_cmdb_others.rb +3 -3
  182. data/spec/hybrid_platforms_conductor_test/cmdb_plugins/{test_cmdb_others2.rb → test_cmdb_others_2.rb} +2 -2
  183. data/spec/hybrid_platforms_conductor_test/docs_spec.rb +1 -1
  184. data/spec/hybrid_platforms_conductor_test/executables/{check-node_spec.rb → check_node_spec.rb} +4 -6
  185. data/spec/hybrid_platforms_conductor_test/executables/deploy_spec.rb +4 -6
  186. data/spec/hybrid_platforms_conductor_test/executables/get_impacted_nodes_spec.rb +76 -77
  187. data/spec/hybrid_platforms_conductor_test/executables/last_deploys_spec.rb +13 -15
  188. data/spec/hybrid_platforms_conductor_test/executables/nodes_to_deploy_spec.rb +289 -307
  189. data/spec/hybrid_platforms_conductor_test/executables/options/actions_executor_spec.rb +4 -6
  190. data/spec/hybrid_platforms_conductor_test/executables/options/cmd_runner_spec.rb +3 -5
  191. data/spec/hybrid_platforms_conductor_test/executables/options/common_spec.rb +8 -9
  192. data/spec/hybrid_platforms_conductor_test/executables/options/deployer_spec.rb +12 -14
  193. data/spec/hybrid_platforms_conductor_test/executables/options/nodes_handler_spec.rb +9 -10
  194. data/spec/hybrid_platforms_conductor_test/executables/options/nodes_selectors_spec.rb +9 -10
  195. data/spec/hybrid_platforms_conductor_test/executables/options/reports_handler_spec.rb +1 -1
  196. data/spec/hybrid_platforms_conductor_test/executables/options/tests_runner_spec.rb +22 -22
  197. data/spec/hybrid_platforms_conductor_test/executables/report_spec.rb +22 -16
  198. data/spec/hybrid_platforms_conductor_test/executables/run_spec.rb +32 -32
  199. data/spec/hybrid_platforms_conductor_test/executables/ssh_config_spec.rb +7 -9
  200. data/spec/hybrid_platforms_conductor_test/executables/test_spec.rb +3 -5
  201. data/spec/hybrid_platforms_conductor_test/helpers/actions_executor_helpers.rb +2 -2
  202. data/spec/hybrid_platforms_conductor_test/helpers/cmd_runner_helpers.rb +4 -3
  203. data/spec/hybrid_platforms_conductor_test/helpers/cmdb_helpers.rb +2 -2
  204. data/spec/hybrid_platforms_conductor_test/helpers/config_helpers.rb +1 -1
  205. data/spec/hybrid_platforms_conductor_test/helpers/connector_ssh_helpers.rb +12 -13
  206. data/spec/hybrid_platforms_conductor_test/helpers/deployer_helpers.rb +216 -14
  207. data/spec/hybrid_platforms_conductor_test/helpers/executables_helpers.rb +11 -11
  208. data/spec/hybrid_platforms_conductor_test/helpers/nodes_handler_helpers.rb +1 -1
  209. data/spec/hybrid_platforms_conductor_test/helpers/platforms_handler_helpers.rb +39 -28
  210. data/spec/hybrid_platforms_conductor_test/helpers/plugins_helpers.rb +1 -1
  211. data/spec/hybrid_platforms_conductor_test/helpers/provisioner_proxmox_helpers.rb +86 -111
  212. data/spec/hybrid_platforms_conductor_test/helpers/reports_handler_helpers.rb +1 -1
  213. data/spec/hybrid_platforms_conductor_test/helpers/serverless_chef_helpers.rb +3 -3
  214. data/spec/hybrid_platforms_conductor_test/helpers/services_handler_helpers.rb +1 -1
  215. data/spec/hybrid_platforms_conductor_test/helpers/tests_runner_helpers.rb +1 -1
  216. data/spec/hybrid_platforms_conductor_test/mocked_lib/my_test_gem/hpc_plugins/test_plugin_type/{test_plugin_id1.rb → test_plugin_id_1.rb} +0 -0
  217. data/spec/hybrid_platforms_conductor_test/mocked_lib/my_test_gem/hpc_plugins/test_plugin_type/{test_plugin_id2.rb → test_plugin_id_2.rb} +0 -0
  218. data/spec/hybrid_platforms_conductor_test/mocked_lib/my_test_gem2/sub_dir/hpc_plugins/test_plugin_type/{test_plugin_id3.rb → test_plugin_id_3.rb} +0 -0
  219. data/spec/hybrid_platforms_conductor_test/mocked_lib/my_test_gem2/sub_dir/hpc_plugins/{test_plugin_type2/test_plugin_id4.rb → test_plugin_type_2/test_plugin_id_4.rb} +0 -0
  220. data/spec/hybrid_platforms_conductor_test/platform_handler_plugins/test.rb +1 -1
  221. data/spec/hybrid_platforms_conductor_test/platform_handler_plugins/{test2.rb → test_2.rb} +0 -0
  222. data/spec/hybrid_platforms_conductor_test/rubocop_spec.rb +31 -0
  223. data/spec/hybrid_platforms_conductor_test/serverless_chef_repositories/1_node/nodes/node.json +3 -3
  224. data/spec/hybrid_platforms_conductor_test/serverless_chef_repositories/data_bags/nodes/node.json +3 -3
  225. data/spec/hybrid_platforms_conductor_test/serverless_chef_repositories/recipes/cookbooks/test_cookbook_2/libraries/default.rb +1 -0
  226. data/spec/hybrid_platforms_conductor_test/serverless_chef_repositories/several_cookbooks/other_cookbooks/test_cookbook_2/libraries/default.rb +1 -0
  227. data/spec/hybrid_platforms_conductor_test/shared_examples/deployer.rb +952 -0
  228. data/spec/hybrid_platforms_conductor_test/test_connector.rb +3 -3
  229. data/spec/hybrid_platforms_conductor_test/test_log_no_read_plugin.rb +3 -1
  230. data/spec/hybrid_platforms_conductor_test/test_log_plugin.rb +3 -1
  231. data/spec/hybrid_platforms_conductor_test/test_plugins/global.rb +1 -0
  232. data/spec/hybrid_platforms_conductor_test/test_plugins/node.rb +1 -0
  233. data/spec/hybrid_platforms_conductor_test/test_plugins/node_check.rb +1 -0
  234. data/spec/hybrid_platforms_conductor_test/test_plugins/platform.rb +1 -0
  235. data/spec/hybrid_platforms_conductor_test/test_plugins/several_checks.rb +2 -2
  236. data/spec/hybrid_platforms_conductor_test/test_secrets_reader_plugin.rb +4 -4
  237. data/spec/hybrid_platforms_conductor_test/tests_report_plugin.rb +5 -6
  238. data/spec/spec_helper.rb +17 -18
  239. data/tools/check_md +16 -20
  240. data/tools/generate_mermaid +1 -1
  241. metadata +43 -13
  242. data/spec/hybrid_platforms_conductor_test/helpers/deployer_test_helpers.rb +0 -1152
@@ -2,21 +2,23 @@ require 'hybrid_platforms_conductor/hpc_plugins/provisioner/proxmox'
2
2
 
3
3
  describe HybridPlatformsConductor::HpcPlugins::Provisioner::Proxmox do
4
4
 
5
- context 'checking the reserve_proxmox_container sync tool' do
5
+ context 'when checking the reserve_proxmox_container sync tool' do
6
6
 
7
- context 'checking expiration strategy for containers' do
7
+ context 'when checking expiration strategy for containers' do
8
8
 
9
9
  it 'does not expire a VM when there are enough free resources on a PVE node' do
10
10
  with_sync_node do
11
- mock_proxmox(mocked_pve_nodes: {
12
- 'pve_node_name' => {
13
- memory_total: 4 * 1024 * 1024 * 1024,
14
- lxc_containers: {
15
- # Make sure it is expired
16
- 1000 => { ip: '192.168.0.100', maxmem: 1024 * 1024 * 1024, creation_date: (Time.now - 31 * 24 * 60 * 60).utc }
11
+ mock_proxmox(
12
+ mocked_pve_nodes: {
13
+ 'pve_node_name' => {
14
+ memory_total: 4 * 1024 * 1024 * 1024,
15
+ lxc_containers: {
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 }
18
+ }
17
19
  }
18
20
  }
19
- })
21
+ )
20
22
  expect(call_reserve_proxmox_container(2, 1024, 1)).to eq(
21
23
  pve_node: 'pve_node_name',
22
24
  vm_id: 1001,
@@ -28,15 +30,17 @@ describe HybridPlatformsConductor::HpcPlugins::Provisioner::Proxmox do
28
30
  it 'expires a VM when there are not enough free resources on a PVE node' do
29
31
  with_sync_node do
30
32
  creation_date = (Time.now - 31 * 24 * 60 * 60).utc
31
- mock_proxmox(mocked_pve_nodes: {
32
- 'pve_node_name' => {
33
- memory_total: 4 * 1024 * 1024 * 1024,
34
- lxc_containers: {
35
- # Make sure it is expired
36
- 1000 => { ip: '192.168.0.100', maxmem: 4 * 1024 * 1024 * 1024, creation_date: creation_date }
33
+ mock_proxmox(
34
+ mocked_pve_nodes: {
35
+ 'pve_node_name' => {
36
+ memory_total: 4 * 1024 * 1024 * 1024,
37
+ lxc_containers: {
38
+ # Make sure it is expired
39
+ 1000 => { ip: '192.168.0.100', maxmem: 4 * 1024 * 1024 * 1024, creation_date: creation_date }
40
+ }
37
41
  }
38
42
  }
39
- })
43
+ )
40
44
  expect(call_reserve_proxmox_container(2, 1024, 1)).to eq(
41
45
  pve_node: 'pve_node_name',
42
46
  vm_id: 1000,
@@ -61,26 +65,28 @@ describe HybridPlatformsConductor::HpcPlugins::Provisioner::Proxmox do
61
65
  }
62
66
  ]
63
67
  ]
64
- expect(Time.parse(@proxmox_actions[2][2]['description'].match(/^===== HPC info =====\nnode: test_node\nenvironment: test_env\ncreation_date: (.+)\n/)[1])).to be > creation_date
68
+ expect(Time.parse(proxmox_actions[2][2]['description'].match(/^===== HPC info =====\nnode: test_node\nenvironment: test_env\ncreation_date: (.+)\n/)[1])).to be > creation_date
65
69
  end
66
70
  end
67
71
 
68
72
  it 'expires a VM without stopping it when there are not enough free resources on a PVE node and the VM is not running' do
69
73
  with_sync_node do
70
- mock_proxmox(mocked_pve_nodes: {
71
- 'pve_node_name' => {
72
- memory_total: 4 * 1024 * 1024 * 1024,
73
- lxc_containers: {
74
- 1000 => {
75
- ip: '192.168.0.100',
76
- maxmem: 4 * 1024 * 1024 * 1024,
77
- status: 'stopped',
78
- # Make sure it is expired
79
- creation_date: (Time.now - 31 * 24 * 60 * 60).utc
74
+ mock_proxmox(
75
+ mocked_pve_nodes: {
76
+ 'pve_node_name' => {
77
+ memory_total: 4 * 1024 * 1024 * 1024,
78
+ lxc_containers: {
79
+ 1000 => {
80
+ ip: '192.168.0.100',
81
+ maxmem: 4 * 1024 * 1024 * 1024,
82
+ status: 'stopped',
83
+ # Make sure it is expired
84
+ creation_date: (Time.now - 31 * 24 * 60 * 60).utc
85
+ }
80
86
  }
81
87
  }
82
88
  }
83
- })
89
+ )
84
90
  expect(call_reserve_proxmox_container(2, 1024, 1)).to eq(
85
91
  pve_node: 'pve_node_name',
86
92
  vm_id: 1000,
@@ -105,16 +111,18 @@ describe HybridPlatformsConductor::HpcPlugins::Provisioner::Proxmox do
105
111
 
106
112
  it 'reuses the IP address and VM IDs of an expired VM when there are not enough free resources on a PVE node' do
107
113
  with_sync_node do
108
- mock_proxmox(mocked_pve_nodes: {
109
- 'pve_node_name' => {
110
- memory_total: 8 * 1024 * 1024 * 1024,
111
- lxc_containers: {
112
- 1000 => { ip: '192.168.0.100', maxmem: 2 * 1024 * 1024 * 1024, creation_date: Time.now.utc },
113
- 1001 => { ip: '192.168.0.101', maxmem: 4 * 1024 * 1024 * 1024, creation_date: (Time.now - 31 * 24 * 60 * 60).utc },
114
- 1002 => { ip: '192.168.0.102', maxmem: 2 * 1024 * 1024 * 1024, creation_date: Time.now.utc }
114
+ mock_proxmox(
115
+ mocked_pve_nodes: {
116
+ 'pve_node_name' => {
117
+ memory_total: 8 * 1024 * 1024 * 1024,
118
+ lxc_containers: {
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 },
121
+ 1002 => { ip: '192.168.0.102', maxmem: 2 * 1024 * 1024 * 1024, creation_date: Time.now.utc }
122
+ }
115
123
  }
116
124
  }
117
- })
125
+ )
118
126
  expect(call_reserve_proxmox_container(2, 1024, 1)).to eq(
119
127
  pve_node: 'pve_node_name',
120
128
  vm_id: 1001,
@@ -140,42 +148,49 @@ describe HybridPlatformsConductor::HpcPlugins::Provisioner::Proxmox do
140
148
 
141
149
  it 'does not try to expire expired VMs when the freed resources would not be enough anyway for the new container' do
142
150
  with_sync_node do
143
- mock_proxmox(mocked_pve_nodes: {
144
- 'pve_node_name' => {
145
- memory_total: 6 * 1024 * 1024 * 1024,
146
- lxc_containers: {
147
- 1000 => { ip: '192.168.0.100', maxmem: 2 * 1024 * 1024 * 1024, creation_date: Time.now.utc },
148
- 1001 => { ip: '192.168.0.101', maxmem: 2 * 1024 * 1024 * 1024, creation_date: (Time.now - 31 * 24 * 60 * 60).utc },
149
- 1002 => { ip: '192.168.0.102', maxmem: 2 * 1024 * 1024 * 1024, creation_date: Time.now.utc }
151
+ mock_proxmox(
152
+ mocked_pve_nodes: {
153
+ 'pve_node_name' => {
154
+ memory_total: 6 * 1024 * 1024 * 1024,
155
+ lxc_containers: {
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 },
158
+ 1002 => { ip: '192.168.0.102', maxmem: 2 * 1024 * 1024 * 1024, creation_date: Time.now.utc }
159
+ }
150
160
  }
151
161
  }
152
- })
153
- expect(call_reserve_proxmox_container(2, 1024, 1,
154
- config: {
155
- vm_ips_list: %w[
156
- 192.168.0.100
157
- 192.168.0.101
158
- 192.168.0.102
159
- 192.168.0.103
160
- ]
161
- }
162
- )).to eq(error: 'not_enough_resources')
162
+ )
163
+ expect(
164
+ call_reserve_proxmox_container(
165
+ 2, 1024, 1,
166
+ config: {
167
+ vm_ips_list: %w[
168
+ 192.168.0.100
169
+ 192.168.0.101
170
+ 192.168.0.102
171
+ 192.168.0.103
172
+ ]
173
+ }
174
+ )
175
+ ).to eq(error: 'not_enough_resources')
163
176
  expect_proxmox_actions_to_be []
164
177
  end
165
178
  end
166
179
 
167
180
  it 'expires all expired containers of a PVE node if needed' do
168
181
  with_sync_node do
169
- mock_proxmox(mocked_pve_nodes: {
170
- 'pve_node_name' => {
171
- memory_total: 8 * 1024 * 1024 * 1024,
172
- lxc_containers: {
173
- 1000 => { ip: '192.168.0.100', maxmem: 2 * 1024 * 1024 * 1024, creation_date: Time.now.utc },
174
- 1001 => { ip: '192.168.0.101', maxmem: 4 * 1024 * 1024 * 1024, creation_date: (Time.now - 31 * 24 * 60 * 60).utc },
175
- 1002 => { ip: '192.168.0.102', maxmem: 2 * 1024 * 1024 * 1024, creation_date: (Time.now - 31 * 24 * 60 * 60).utc }
182
+ mock_proxmox(
183
+ mocked_pve_nodes: {
184
+ 'pve_node_name' => {
185
+ memory_total: 8 * 1024 * 1024 * 1024,
186
+ lxc_containers: {
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 }
190
+ }
176
191
  }
177
192
  }
178
- })
193
+ )
179
194
  expect(call_reserve_proxmox_container(2, 1024, 1)).to eq(
180
195
  pve_node: 'pve_node_name',
181
196
  vm_id: 1001,
@@ -203,16 +218,18 @@ describe HybridPlatformsConductor::HpcPlugins::Provisioner::Proxmox do
203
218
 
204
219
  it 'does not expire containers that don\'t belong to the VM IDs range' do
205
220
  with_sync_node do
206
- mock_proxmox(mocked_pve_nodes: {
207
- 'pve_node_name' => {
208
- memory_total: 8 * 1024 * 1024 * 1024,
209
- lxc_containers: {
210
- 1000 => { ip: '192.168.0.100', maxmem: 2 * 1024 * 1024 * 1024, creation_date: Time.now.utc },
211
- 1001 => { ip: '192.168.0.101', maxmem: 4 * 1024 * 1024 * 1024, creation_date: (Time.now - 31 * 24 * 60 * 60).utc },
212
- 2002 => { ip: '192.168.0.102', maxmem: 2 * 1024 * 1024 * 1024, creation_date: (Time.now - 31 * 24 * 60 * 60).utc }
221
+ mock_proxmox(
222
+ mocked_pve_nodes: {
223
+ 'pve_node_name' => {
224
+ memory_total: 8 * 1024 * 1024 * 1024,
225
+ lxc_containers: {
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 }
229
+ }
213
230
  }
214
231
  }
215
- })
232
+ )
216
233
  expect(call_reserve_proxmox_container(2, 1024, 1)).to eq(
217
234
  pve_node: 'pve_node_name',
218
235
  vm_id: 1001,
@@ -238,22 +255,24 @@ describe HybridPlatformsConductor::HpcPlugins::Provisioner::Proxmox do
238
255
 
239
256
  it 'selects a PVE node that still has free resources without expiring VMs even if it would have freed more resources' do
240
257
  with_sync_node do
241
- mock_proxmox(mocked_pve_nodes: {
242
- # Expiring VMs from this node would free a lot of resources
243
- 'pve_node_1' => {
244
- memory_total: 16 * 1024 * 1024 * 1024,
245
- lxc_containers: {
246
- 1000 => { ip: '192.168.0.100', maxmem: 14 * 1024 * 1024 * 1024, creation_date: (Time.now - 31 * 24 * 60 * 60).utc }
247
- }
248
- },
249
- # But this node has still a bit of resources left without expiring VMs
250
- 'pve_node_2' => {
251
- memory_total: 16 * 1024 * 1024 * 1024,
252
- lxc_containers: {
253
- 1001 => { ip: '192.168.0.101', maxmem: 10 * 1024 * 1024 * 1024, creation_date: (Time.now - 31 * 24 * 60 * 60).utc }
258
+ mock_proxmox(
259
+ mocked_pve_nodes: {
260
+ # Expiring VMs from this node would free a lot of resources
261
+ 'pve_node_1' => {
262
+ memory_total: 16 * 1024 * 1024 * 1024,
263
+ lxc_containers: {
264
+ 1000 => { ip: '192.168.0.100', maxmem: 14 * 1024 * 1024 * 1024, creation_date: (Time.now - 31 * 24 * 60 * 60).utc }
265
+ }
266
+ },
267
+ # But this node has still a bit of resources left without expiring VMs
268
+ 'pve_node_2' => {
269
+ memory_total: 16 * 1024 * 1024 * 1024,
270
+ lxc_containers: {
271
+ 1001 => { ip: '192.168.0.101', maxmem: 10 * 1024 * 1024 * 1024, creation_date: (Time.now - 31 * 24 * 60 * 60).utc }
272
+ }
254
273
  }
255
274
  }
256
- })
275
+ )
257
276
  expect(call_reserve_proxmox_container(2, 1024, 1, config: { pve_nodes: nil })).to eq(
258
277
  pve_node: 'pve_node_2',
259
278
  vm_id: 1002,
@@ -277,34 +296,39 @@ describe HybridPlatformsConductor::HpcPlugins::Provisioner::Proxmox do
277
296
 
278
297
  it 'selects the PVE node that would have the more resources free after expiration when no other PVE node has free resources' do
279
298
  with_sync_node do
280
- mock_proxmox(mocked_pve_nodes: {
281
- 'pve_node_1' => {
282
- memory_total: 16 * 1024 * 1024 * 1024,
283
- lxc_containers: {
284
- 1000 => { ip: '192.168.0.100', maxmem: 8 * 1024 * 1024 * 1024, creation_date: Time.now.utc },
285
- 1001 => { ip: '192.168.0.101', maxmem: 6 * 1024 * 1024 * 1024, creation_date: (Time.now - 31 * 24 * 60 * 60).utc }
286
- }
287
- },
288
- 'pve_node_2' => {
289
- memory_total: 16 * 1024 * 1024 * 1024,
290
- lxc_containers: {
291
- 1002 => { ip: '192.168.0.102', maxmem: 10 * 1024 * 1024 * 1024, creation_date: Time.now.utc },
292
- 1003 => { ip: '192.168.0.103', maxmem: 4 * 1024 * 1024 * 1024, creation_date: (Time.now - 31 * 24 * 60 * 60).utc }
299
+ mock_proxmox(
300
+ mocked_pve_nodes: {
301
+ 'pve_node_1' => {
302
+ memory_total: 16 * 1024 * 1024 * 1024,
303
+ lxc_containers: {
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 }
306
+ }
307
+ },
308
+ 'pve_node_2' => {
309
+ memory_total: 16 * 1024 * 1024 * 1024,
310
+ lxc_containers: {
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 }
313
+ }
293
314
  }
294
315
  }
295
- })
296
- expect(call_reserve_proxmox_container(2, 1024, 1,
297
- config: {
298
- pve_nodes: nil,
299
- vm_ips_list: %w[
300
- 192.168.0.100
301
- 192.168.0.101
302
- 192.168.0.102
303
- 192.168.0.103
304
- 192.168.0.104
305
- ]
306
- }
307
- )).to eq(
316
+ )
317
+ expect(
318
+ call_reserve_proxmox_container(
319
+ 2, 1024, 1,
320
+ config: {
321
+ pve_nodes: nil,
322
+ vm_ips_list: %w[
323
+ 192.168.0.100
324
+ 192.168.0.101
325
+ 192.168.0.102
326
+ 192.168.0.103
327
+ 192.168.0.104
328
+ ]
329
+ }
330
+ )
331
+ ).to eq(
308
332
  pve_node: 'pve_node_1',
309
333
  vm_id: 1001,
310
334
  vm_ip: '192.168.0.101'
@@ -329,25 +353,30 @@ describe HybridPlatformsConductor::HpcPlugins::Provisioner::Proxmox do
329
353
 
330
354
  it 'expires VMs even if free resources are available when IPs are all used' do
331
355
  with_sync_node do
332
- mock_proxmox(mocked_pve_nodes: {
333
- 'pve_node_name' => {
334
- memory_total: 16 * 1024 * 1024 * 1024,
335
- lxc_containers: {
336
- 1000 => { ip: '192.168.0.100', maxmem: 1 * 1024 * 1024 * 1024, creation_date: Time.now.utc },
337
- 1001 => { ip: '192.168.0.101', maxmem: 1 * 1024 * 1024 * 1024, creation_date: (Time.now - 31 * 24 * 60 * 60).utc },
338
- 1002 => { ip: '192.168.0.102', maxmem: 1 * 1024 * 1024 * 1024, creation_date: Time.now.utc }
356
+ mock_proxmox(
357
+ mocked_pve_nodes: {
358
+ 'pve_node_name' => {
359
+ memory_total: 16 * 1024 * 1024 * 1024,
360
+ lxc_containers: {
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 },
363
+ 1002 => { ip: '192.168.0.102', maxmem: 1 * 1024 * 1024 * 1024, creation_date: Time.now.utc }
364
+ }
339
365
  }
340
366
  }
341
- })
342
- expect(call_reserve_proxmox_container(2, 1024, 1,
343
- config: {
344
- vm_ips_list: %w[
345
- 192.168.0.100
346
- 192.168.0.101
347
- 192.168.0.102
348
- ]
349
- }
350
- )).to eq(
367
+ )
368
+ expect(
369
+ call_reserve_proxmox_container(
370
+ 2, 1024, 1,
371
+ config: {
372
+ vm_ips_list: %w[
373
+ 192.168.0.100
374
+ 192.168.0.101
375
+ 192.168.0.102
376
+ ]
377
+ }
378
+ )
379
+ ).to eq(
351
380
  pve_node: 'pve_node_name',
352
381
  vm_id: 1001,
353
382
  vm_ip: '192.168.0.101'
@@ -372,33 +401,38 @@ describe HybridPlatformsConductor::HpcPlugins::Provisioner::Proxmox do
372
401
 
373
402
  it 'expires VMs from non-selected PVE nodes even if free resources are available when IPs are all used' do
374
403
  with_sync_node do
375
- mock_proxmox(mocked_pve_nodes: {
376
- # Make sure this node should be selected
377
- 'pve_node_1' => {
378
- memory_total: 16 * 1024 * 1024 * 1024,
379
- lxc_containers: {
380
- 1000 => { ip: '192.168.0.100', maxmem: 1 * 1024 * 1024 * 1024, creation_date: Time.now.utc },
381
- 1002 => { ip: '192.168.0.102', maxmem: 1 * 1024 * 1024 * 1024, creation_date: Time.now.utc }
382
- }
383
- },
384
- # But this node is the only one having expired VMs
385
- 'pve_node_2' => {
386
- memory_total: 2 * 1024 * 1024 * 1024,
387
- lxc_containers: {
388
- 1001 => { ip: '192.168.0.101', maxmem: 1 * 1024 * 1024 * 1024, creation_date: (Time.now - 31 * 24 * 60 * 60).utc }
404
+ mock_proxmox(
405
+ mocked_pve_nodes: {
406
+ # Make sure this node should be selected
407
+ 'pve_node_1' => {
408
+ memory_total: 16 * 1024 * 1024 * 1024,
409
+ lxc_containers: {
410
+ 1000 => { ip: '192.168.0.100', maxmem: 1 * 1024 * 1024 * 1024, creation_date: Time.now.utc },
411
+ 1002 => { ip: '192.168.0.102', maxmem: 1 * 1024 * 1024 * 1024, creation_date: Time.now.utc }
412
+ }
413
+ },
414
+ # But this node is the only one having expired VMs
415
+ 'pve_node_2' => {
416
+ memory_total: 2 * 1024 * 1024 * 1024,
417
+ lxc_containers: {
418
+ 1001 => { ip: '192.168.0.101', maxmem: 1 * 1024 * 1024 * 1024, creation_date: (Time.now - 31 * 24 * 60 * 60).utc }
419
+ }
389
420
  }
390
421
  }
391
- })
392
- expect(call_reserve_proxmox_container(2, 1024, 1,
393
- config: {
394
- pve_nodes: nil,
395
- vm_ips_list: %w[
396
- 192.168.0.100
397
- 192.168.0.101
398
- 192.168.0.102
399
- ]
400
- }
401
- )).to eq(
422
+ )
423
+ expect(
424
+ call_reserve_proxmox_container(
425
+ 2, 1024, 1,
426
+ config: {
427
+ pve_nodes: nil,
428
+ vm_ips_list: %w[
429
+ 192.168.0.100
430
+ 192.168.0.101
431
+ 192.168.0.102
432
+ ]
433
+ }
434
+ )
435
+ ).to eq(
402
436
  pve_node: 'pve_node_1',
403
437
  vm_id: 1001,
404
438
  vm_ip: '192.168.0.101'
@@ -423,27 +457,32 @@ describe HybridPlatformsConductor::HpcPlugins::Provisioner::Proxmox do
423
457
 
424
458
  it 'expires VMs even if free resources are available when VM IDs are all used' do
425
459
  with_sync_node do
426
- mock_proxmox(mocked_pve_nodes: {
427
- 'pve_node_name' => {
428
- memory_total: 16 * 1024 * 1024 * 1024,
429
- lxc_containers: {
430
- 1000 => { ip: '192.168.0.100', maxmem: 1 * 1024 * 1024 * 1024, creation_date: Time.now.utc },
431
- 1001 => { ip: '192.168.0.101', maxmem: 1 * 1024 * 1024 * 1024, creation_date: (Time.now - 31 * 24 * 60 * 60).utc },
432
- 1002 => { ip: '192.168.0.102', maxmem: 1 * 1024 * 1024 * 1024, creation_date: Time.now.utc }
460
+ mock_proxmox(
461
+ mocked_pve_nodes: {
462
+ 'pve_node_name' => {
463
+ memory_total: 16 * 1024 * 1024 * 1024,
464
+ lxc_containers: {
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 },
467
+ 1002 => { ip: '192.168.0.102', maxmem: 1 * 1024 * 1024 * 1024, creation_date: Time.now.utc }
468
+ }
433
469
  }
434
470
  }
435
- })
436
- expect(call_reserve_proxmox_container(2, 1024, 1,
437
- config: {
438
- vm_ips_list: %w[
439
- 192.168.0.100
440
- 192.168.0.101
441
- 192.168.0.102
442
- 192.168.0.103
443
- ],
444
- vm_ids_range: [1000, 1002]
445
- }
446
- )).to eq(
471
+ )
472
+ expect(
473
+ call_reserve_proxmox_container(
474
+ 2, 1024, 1,
475
+ config: {
476
+ vm_ips_list: %w[
477
+ 192.168.0.100
478
+ 192.168.0.101
479
+ 192.168.0.102
480
+ 192.168.0.103
481
+ ],
482
+ vm_ids_range: [1000, 1002]
483
+ }
484
+ )
485
+ ).to eq(
447
486
  pve_node: 'pve_node_name',
448
487
  vm_id: 1001,
449
488
  vm_ip: '192.168.0.101'
@@ -468,35 +507,40 @@ describe HybridPlatformsConductor::HpcPlugins::Provisioner::Proxmox do
468
507
 
469
508
  it 'expires VMs from non-selected PVE nodes even if free resources are available when VM IDs are all used' do
470
509
  with_sync_node do
471
- mock_proxmox(mocked_pve_nodes: {
472
- # Make sure this node should be selected
473
- 'pve_node_1' => {
474
- memory_total: 16 * 1024 * 1024 * 1024,
475
- lxc_containers: {
476
- 1000 => { ip: '192.168.0.100', maxmem: 1 * 1024 * 1024 * 1024, creation_date: Time.now.utc },
477
- 1002 => { ip: '192.168.0.102', maxmem: 1 * 1024 * 1024 * 1024, creation_date: Time.now.utc }
478
- }
479
- },
480
- # But this node is the only one having expired VMs
481
- 'pve_node_2' => {
482
- memory_total: 2 * 1024 * 1024 * 1024,
483
- lxc_containers: {
484
- 1001 => { ip: '192.168.0.101', maxmem: 1 * 1024 * 1024 * 1024, creation_date: (Time.now - 31 * 24 * 60 * 60).utc }
510
+ mock_proxmox(
511
+ mocked_pve_nodes: {
512
+ # Make sure this node should be selected
513
+ 'pve_node_1' => {
514
+ memory_total: 16 * 1024 * 1024 * 1024,
515
+ lxc_containers: {
516
+ 1000 => { ip: '192.168.0.100', maxmem: 1 * 1024 * 1024 * 1024, creation_date: Time.now.utc },
517
+ 1002 => { ip: '192.168.0.102', maxmem: 1 * 1024 * 1024 * 1024, creation_date: Time.now.utc }
518
+ }
519
+ },
520
+ # But this node is the only one having expired VMs
521
+ 'pve_node_2' => {
522
+ memory_total: 2 * 1024 * 1024 * 1024,
523
+ lxc_containers: {
524
+ 1001 => { ip: '192.168.0.101', maxmem: 1 * 1024 * 1024 * 1024, creation_date: (Time.now - 31 * 24 * 60 * 60).utc }
525
+ }
485
526
  }
486
527
  }
487
- })
488
- expect(call_reserve_proxmox_container(2, 1024, 1,
489
- config: {
490
- pve_nodes: nil,
491
- vm_ips_list: %w[
492
- 192.168.0.100
493
- 192.168.0.101
494
- 192.168.0.102
495
- 192.168.0.103
496
- ],
497
- vm_ids_range: [1000, 1002]
498
- }
499
- )).to eq(
528
+ )
529
+ expect(
530
+ call_reserve_proxmox_container(
531
+ 2, 1024, 1,
532
+ config: {
533
+ pve_nodes: nil,
534
+ vm_ips_list: %w[
535
+ 192.168.0.100
536
+ 192.168.0.101
537
+ 192.168.0.102
538
+ 192.168.0.103
539
+ ],
540
+ vm_ids_range: [1000, 1002]
541
+ }
542
+ )
543
+ ).to eq(
500
544
  pve_node: 'pve_node_1',
501
545
  vm_id: 1001,
502
546
  vm_ip: '192.168.0.101'
@@ -521,32 +565,37 @@ describe HybridPlatformsConductor::HpcPlugins::Provisioner::Proxmox do
521
565
 
522
566
  it 'expires VMs even if free resources are available when the maximum number of VMs has been reached' do
523
567
  with_sync_node do
524
- mock_proxmox(mocked_pve_nodes: {
525
- 'pve_node_name' => {
526
- memory_total: 16 * 1024 * 1024 * 1024,
527
- lxc_containers: {
528
- 1000 => { ip: '192.168.0.100', maxmem: 1 * 1024 * 1024 * 1024, creation_date: Time.now.utc },
529
- 1001 => { ip: '192.168.0.101', maxmem: 1 * 1024 * 1024 * 1024, creation_date: (Time.now - 31 * 24 * 60 * 60).utc },
530
- 1002 => { ip: '192.168.0.102', maxmem: 1 * 1024 * 1024 * 1024, creation_date: Time.now.utc }
568
+ mock_proxmox(
569
+ mocked_pve_nodes: {
570
+ 'pve_node_name' => {
571
+ memory_total: 16 * 1024 * 1024 * 1024,
572
+ lxc_containers: {
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 },
575
+ 1002 => { ip: '192.168.0.102', maxmem: 1 * 1024 * 1024 * 1024, creation_date: Time.now.utc }
576
+ }
531
577
  }
532
578
  }
533
- })
534
- expect(call_reserve_proxmox_container(2, 1024, 1,
535
- config: {
536
- vm_ips_list: %w[
537
- 192.168.0.100
538
- 192.168.0.101
539
- 192.168.0.102
540
- 192.168.0.103
541
- ],
542
- limits: {
543
- nbr_vms_max: 3,
544
- cpu_loads_thresholds: [10, 10, 10],
545
- ram_percent_used_max: 0.75,
546
- disk_percent_used_max: 0.75
579
+ )
580
+ expect(
581
+ call_reserve_proxmox_container(
582
+ 2, 1024, 1,
583
+ config: {
584
+ vm_ips_list: %w[
585
+ 192.168.0.100
586
+ 192.168.0.101
587
+ 192.168.0.102
588
+ 192.168.0.103
589
+ ],
590
+ limits: {
591
+ nbr_vms_max: 3,
592
+ cpu_loads_thresholds: [10, 10, 10],
593
+ ram_percent_used_max: 0.75,
594
+ disk_percent_used_max: 0.75
595
+ }
547
596
  }
548
- }
549
- )).to eq(
597
+ )
598
+ ).to eq(
550
599
  pve_node: 'pve_node_name',
551
600
  vm_id: 1001,
552
601
  vm_ip: '192.168.0.101'
@@ -571,40 +620,45 @@ describe HybridPlatformsConductor::HpcPlugins::Provisioner::Proxmox do
571
620
 
572
621
  it 'expires VMs from non-selected PVE nodes even if free resources are available when the maximum number of VMs has been reached' do
573
622
  with_sync_node do
574
- mock_proxmox(mocked_pve_nodes: {
575
- # Make sure this node should be selected
576
- 'pve_node_1' => {
577
- memory_total: 16 * 1024 * 1024 * 1024,
578
- lxc_containers: {
579
- 1000 => { ip: '192.168.0.100', maxmem: 1 * 1024 * 1024 * 1024, creation_date: Time.now.utc },
580
- 1002 => { ip: '192.168.0.102', maxmem: 1 * 1024 * 1024 * 1024, creation_date: Time.now.utc }
581
- }
582
- },
583
- # But this node is the only one having expired VMs
584
- 'pve_node_2' => {
585
- memory_total: 2 * 1024 * 1024 * 1024,
586
- lxc_containers: {
587
- 1001 => { ip: '192.168.0.101', maxmem: 1 * 1024 * 1024 * 1024, creation_date: (Time.now - 31 * 24 * 60 * 60).utc }
623
+ mock_proxmox(
624
+ mocked_pve_nodes: {
625
+ # Make sure this node should be selected
626
+ 'pve_node_1' => {
627
+ memory_total: 16 * 1024 * 1024 * 1024,
628
+ lxc_containers: {
629
+ 1000 => { ip: '192.168.0.100', maxmem: 1 * 1024 * 1024 * 1024, creation_date: Time.now.utc },
630
+ 1002 => { ip: '192.168.0.102', maxmem: 1 * 1024 * 1024 * 1024, creation_date: Time.now.utc }
631
+ }
632
+ },
633
+ # But this node is the only one having expired VMs
634
+ 'pve_node_2' => {
635
+ memory_total: 2 * 1024 * 1024 * 1024,
636
+ lxc_containers: {
637
+ 1001 => { ip: '192.168.0.101', maxmem: 1 * 1024 * 1024 * 1024, creation_date: (Time.now - 31 * 24 * 60 * 60).utc }
638
+ }
588
639
  }
589
640
  }
590
- })
591
- expect(call_reserve_proxmox_container(2, 1024, 1,
592
- config: {
593
- pve_nodes: nil,
594
- vm_ips_list: %w[
595
- 192.168.0.100
596
- 192.168.0.101
597
- 192.168.0.102
598
- 192.168.0.103
599
- ],
600
- limits: {
601
- nbr_vms_max: 3,
602
- cpu_loads_thresholds: [10, 10, 10],
603
- ram_percent_used_max: 0.75,
604
- disk_percent_used_max: 0.75
641
+ )
642
+ expect(
643
+ call_reserve_proxmox_container(
644
+ 2, 1024, 1,
645
+ config: {
646
+ pve_nodes: nil,
647
+ vm_ips_list: %w[
648
+ 192.168.0.100
649
+ 192.168.0.101
650
+ 192.168.0.102
651
+ 192.168.0.103
652
+ ],
653
+ limits: {
654
+ nbr_vms_max: 3,
655
+ cpu_loads_thresholds: [10, 10, 10],
656
+ ram_percent_used_max: 0.75,
657
+ disk_percent_used_max: 0.75
658
+ }
605
659
  }
606
- }
607
- )).to eq(
660
+ )
661
+ ).to eq(
608
662
  pve_node: 'pve_node_1',
609
663
  vm_id: 1001,
610
664
  vm_ip: '192.168.0.101'
@@ -629,21 +683,23 @@ describe HybridPlatformsConductor::HpcPlugins::Provisioner::Proxmox do
629
683
 
630
684
  it 'does not expire a VM that is stopped for long time but still used for debug purposes' do
631
685
  with_sync_node do
632
- mock_proxmox(mocked_pve_nodes: {
633
- 'pve_node_name' => {
634
- memory_total: 4 * 1024 * 1024 * 1024,
635
- lxc_containers: {
636
- # Make sure it is not expired
637
- 1000 => {
638
- ip: '192.168.0.100',
639
- maxmem: 4 * 1024 * 1024 * 1024,
640
- creation_date: Time.now.utc,
641
- status: 'stopped',
642
- debug: true
686
+ mock_proxmox(
687
+ mocked_pve_nodes: {
688
+ 'pve_node_name' => {
689
+ memory_total: 4 * 1024 * 1024 * 1024,
690
+ lxc_containers: {
691
+ # Make sure it is not expired
692
+ 1000 => {
693
+ ip: '192.168.0.100',
694
+ maxmem: 4 * 1024 * 1024 * 1024,
695
+ creation_date: Time.now.utc,
696
+ status: 'stopped',
697
+ debug: true
698
+ }
643
699
  }
644
700
  }
645
701
  }
646
- })
702
+ )
647
703
  expect(call_reserve_proxmox_container(2, 1024, 1)).to eq(error: 'not_enough_resources')
648
704
  expect_proxmox_actions_to_be []
649
705
  end
@@ -691,7 +747,8 @@ describe HybridPlatformsConductor::HpcPlugins::Provisioner::Proxmox do
691
747
 
692
748
  it 'does not expire a VM that is stopped for some time even when it is not used for debug purposes' do
693
749
  with_sync_node do
694
- mock_proxmox(mocked_pve_nodes: [{
750
+ mock_proxmox(
751
+ mocked_pve_nodes: [{
695
752
  # 2 seconds separate each run.
696
753
  # Make sure the third and later runs mock the container as running instead of stopped
697
754
  'pve_node_name' => {
@@ -738,7 +795,8 @@ describe HybridPlatformsConductor::HpcPlugins::Provisioner::Proxmox do
738
795
  with_sync_node do
739
796
  creation_date_1 = (Time.now - 20).utc
740
797
  creation_date_2 = (Time.now - 10).utc
741
- mock_proxmox(mocked_pve_nodes: [{
798
+ mock_proxmox(
799
+ mocked_pve_nodes: [{
742
800
  # 2 seconds separate each run.
743
801
  # Make sure the third and later runs mock the container as another one, still stopped
744
802
  'pve_node_name' => {