hybrid_platforms_conductor 32.3.6

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 (244) hide show
  1. checksums.yaml +7 -0
  2. data/bin/check-node +24 -0
  3. data/bin/deploy +12 -0
  4. data/bin/dump_nodes_json +12 -0
  5. data/bin/free_ips +23 -0
  6. data/bin/free_veids +17 -0
  7. data/bin/get_impacted_nodes +43 -0
  8. data/bin/last_deploys +56 -0
  9. data/bin/nodes_to_deploy +104 -0
  10. data/bin/report +10 -0
  11. data/bin/run +39 -0
  12. data/bin/setup +11 -0
  13. data/bin/ssh_config +14 -0
  14. data/bin/test +13 -0
  15. data/bin/topograph +54 -0
  16. data/lib/hybrid_platforms_conductor/action.rb +82 -0
  17. data/lib/hybrid_platforms_conductor/actions_executor.rb +307 -0
  18. data/lib/hybrid_platforms_conductor/bitbucket.rb +123 -0
  19. data/lib/hybrid_platforms_conductor/cmd_runner.rb +188 -0
  20. data/lib/hybrid_platforms_conductor/cmdb.rb +34 -0
  21. data/lib/hybrid_platforms_conductor/common_config_dsl/bitbucket.rb +78 -0
  22. data/lib/hybrid_platforms_conductor/common_config_dsl/confluence.rb +43 -0
  23. data/lib/hybrid_platforms_conductor/common_config_dsl/file_system_tests.rb +110 -0
  24. data/lib/hybrid_platforms_conductor/common_config_dsl/idempotence_tests.rb +38 -0
  25. data/lib/hybrid_platforms_conductor/config.rb +263 -0
  26. data/lib/hybrid_platforms_conductor/confluence.rb +119 -0
  27. data/lib/hybrid_platforms_conductor/connector.rb +84 -0
  28. data/lib/hybrid_platforms_conductor/credentials.rb +127 -0
  29. data/lib/hybrid_platforms_conductor/current_dir_monitor.rb +42 -0
  30. data/lib/hybrid_platforms_conductor/deployer.rb +598 -0
  31. data/lib/hybrid_platforms_conductor/executable.rb +145 -0
  32. data/lib/hybrid_platforms_conductor/hpc_plugins/action/bash.rb +44 -0
  33. data/lib/hybrid_platforms_conductor/hpc_plugins/action/interactive.rb +44 -0
  34. data/lib/hybrid_platforms_conductor/hpc_plugins/action/my_action.rb.sample +79 -0
  35. data/lib/hybrid_platforms_conductor/hpc_plugins/action/remote_bash.rb +63 -0
  36. data/lib/hybrid_platforms_conductor/hpc_plugins/action/ruby.rb +69 -0
  37. data/lib/hybrid_platforms_conductor/hpc_plugins/action/scp.rb +61 -0
  38. data/lib/hybrid_platforms_conductor/hpc_plugins/cmdb/config.rb +78 -0
  39. data/lib/hybrid_platforms_conductor/hpc_plugins/cmdb/host_ip.rb +104 -0
  40. data/lib/hybrid_platforms_conductor/hpc_plugins/cmdb/host_keys.rb +114 -0
  41. data/lib/hybrid_platforms_conductor/hpc_plugins/cmdb/my_cmdb.rb.sample +129 -0
  42. data/lib/hybrid_platforms_conductor/hpc_plugins/cmdb/platform_handlers.rb +66 -0
  43. data/lib/hybrid_platforms_conductor/hpc_plugins/connector/my_connector.rb.sample +156 -0
  44. data/lib/hybrid_platforms_conductor/hpc_plugins/connector/ssh.rb +702 -0
  45. data/lib/hybrid_platforms_conductor/hpc_plugins/platform_handler/platform_handler_plugin.rb.sample +292 -0
  46. data/lib/hybrid_platforms_conductor/hpc_plugins/provisioner/docker.rb +148 -0
  47. data/lib/hybrid_platforms_conductor/hpc_plugins/provisioner/my_provisioner.rb.sample +103 -0
  48. data/lib/hybrid_platforms_conductor/hpc_plugins/provisioner/podman.rb +125 -0
  49. data/lib/hybrid_platforms_conductor/hpc_plugins/provisioner/proxmox.rb +522 -0
  50. data/lib/hybrid_platforms_conductor/hpc_plugins/provisioner/proxmox/proxmox_waiter.rb +707 -0
  51. data/lib/hybrid_platforms_conductor/hpc_plugins/provisioner/proxmox/reserve_proxmox_container +122 -0
  52. data/lib/hybrid_platforms_conductor/hpc_plugins/report/confluence.rb +69 -0
  53. data/lib/hybrid_platforms_conductor/hpc_plugins/report/mediawiki.rb +164 -0
  54. data/lib/hybrid_platforms_conductor/hpc_plugins/report/my_report_plugin.rb.sample +88 -0
  55. data/lib/hybrid_platforms_conductor/hpc_plugins/report/stdout.rb +61 -0
  56. data/lib/hybrid_platforms_conductor/hpc_plugins/report/templates/confluence_inventory.html.erb +33 -0
  57. data/lib/hybrid_platforms_conductor/hpc_plugins/test/bitbucket_conf.rb +137 -0
  58. data/lib/hybrid_platforms_conductor/hpc_plugins/test/can_be_checked.rb +21 -0
  59. data/lib/hybrid_platforms_conductor/hpc_plugins/test/check_deploy_and_idempotence.rb +112 -0
  60. data/lib/hybrid_platforms_conductor/hpc_plugins/test/check_from_scratch.rb +35 -0
  61. data/lib/hybrid_platforms_conductor/hpc_plugins/test/connection.rb +28 -0
  62. data/lib/hybrid_platforms_conductor/hpc_plugins/test/deploy_freshness.rb +44 -0
  63. data/lib/hybrid_platforms_conductor/hpc_plugins/test/deploy_from_scratch.rb +36 -0
  64. data/lib/hybrid_platforms_conductor/hpc_plugins/test/deploy_removes_root_access.rb +49 -0
  65. data/lib/hybrid_platforms_conductor/hpc_plugins/test/divergence.rb +25 -0
  66. data/lib/hybrid_platforms_conductor/hpc_plugins/test/executables.rb +46 -0
  67. data/lib/hybrid_platforms_conductor/hpc_plugins/test/file_system.rb +45 -0
  68. data/lib/hybrid_platforms_conductor/hpc_plugins/test/file_system_hdfs.rb +45 -0
  69. data/lib/hybrid_platforms_conductor/hpc_plugins/test/hostname.rb +25 -0
  70. data/lib/hybrid_platforms_conductor/hpc_plugins/test/idempotence.rb +77 -0
  71. data/lib/hybrid_platforms_conductor/hpc_plugins/test/ip.rb +38 -0
  72. data/lib/hybrid_platforms_conductor/hpc_plugins/test/jenkins_ci_conf.rb +56 -0
  73. data/lib/hybrid_platforms_conductor/hpc_plugins/test/jenkins_ci_masters_ok.rb +54 -0
  74. data/lib/hybrid_platforms_conductor/hpc_plugins/test/linear_strategy.rb +47 -0
  75. data/lib/hybrid_platforms_conductor/hpc_plugins/test/local_users.rb +82 -0
  76. data/lib/hybrid_platforms_conductor/hpc_plugins/test/mounts.rb +120 -0
  77. data/lib/hybrid_platforms_conductor/hpc_plugins/test/my_test_plugin.rb.sample +143 -0
  78. data/lib/hybrid_platforms_conductor/hpc_plugins/test/orphan_files.rb +74 -0
  79. data/lib/hybrid_platforms_conductor/hpc_plugins/test/ports.rb +85 -0
  80. data/lib/hybrid_platforms_conductor/hpc_plugins/test/private_ips.rb +38 -0
  81. data/lib/hybrid_platforms_conductor/hpc_plugins/test/public_ips.rb +38 -0
  82. data/lib/hybrid_platforms_conductor/hpc_plugins/test/spectre-meltdown-checker.sh +1930 -0
  83. data/lib/hybrid_platforms_conductor/hpc_plugins/test/spectre.rb +56 -0
  84. data/lib/hybrid_platforms_conductor/hpc_plugins/test/veids.rb +31 -0
  85. data/lib/hybrid_platforms_conductor/hpc_plugins/test/vulnerabilities.rb +159 -0
  86. data/lib/hybrid_platforms_conductor/hpc_plugins/test_report/confluence.rb +122 -0
  87. data/lib/hybrid_platforms_conductor/hpc_plugins/test_report/my_test_report.rb.sample +48 -0
  88. data/lib/hybrid_platforms_conductor/hpc_plugins/test_report/stdout.rb +120 -0
  89. data/lib/hybrid_platforms_conductor/hpc_plugins/test_report/templates/_confluence_errors_status.html.erb +46 -0
  90. data/lib/hybrid_platforms_conductor/hpc_plugins/test_report/templates/_confluence_gauge.html.erb +49 -0
  91. data/lib/hybrid_platforms_conductor/hpc_plugins/test_report/templates/confluence.html.erb +242 -0
  92. data/lib/hybrid_platforms_conductor/io_router.rb +70 -0
  93. data/lib/hybrid_platforms_conductor/json_dumper.rb +88 -0
  94. data/lib/hybrid_platforms_conductor/logger_helpers.rb +319 -0
  95. data/lib/hybrid_platforms_conductor/mutex_dir +76 -0
  96. data/lib/hybrid_platforms_conductor/nodes_handler.rb +597 -0
  97. data/lib/hybrid_platforms_conductor/parallel_threads.rb +97 -0
  98. data/lib/hybrid_platforms_conductor/platform_handler.rb +188 -0
  99. data/lib/hybrid_platforms_conductor/platforms_handler.rb +118 -0
  100. data/lib/hybrid_platforms_conductor/plugin.rb +53 -0
  101. data/lib/hybrid_platforms_conductor/plugins.rb +101 -0
  102. data/lib/hybrid_platforms_conductor/provisioner.rb +181 -0
  103. data/lib/hybrid_platforms_conductor/report.rb +31 -0
  104. data/lib/hybrid_platforms_conductor/reports_handler.rb +84 -0
  105. data/lib/hybrid_platforms_conductor/services_handler.rb +274 -0
  106. data/lib/hybrid_platforms_conductor/test.rb +141 -0
  107. data/lib/hybrid_platforms_conductor/test_by_service.rb +22 -0
  108. data/lib/hybrid_platforms_conductor/test_report.rb +282 -0
  109. data/lib/hybrid_platforms_conductor/tests_runner.rb +590 -0
  110. data/lib/hybrid_platforms_conductor/thycotic.rb +92 -0
  111. data/lib/hybrid_platforms_conductor/topographer.rb +859 -0
  112. data/lib/hybrid_platforms_conductor/topographer/plugin.rb +20 -0
  113. data/lib/hybrid_platforms_conductor/topographer/plugins/graphviz.rb +127 -0
  114. data/lib/hybrid_platforms_conductor/topographer/plugins/json.rb +72 -0
  115. data/lib/hybrid_platforms_conductor/topographer/plugins/my_topographer_output_plugin.rb.sample +37 -0
  116. data/lib/hybrid_platforms_conductor/topographer/plugins/svg.rb +30 -0
  117. data/lib/hybrid_platforms_conductor/version.rb +5 -0
  118. data/spec/hybrid_platforms_conductor_test.rb +159 -0
  119. data/spec/hybrid_platforms_conductor_test/api/actions_executor/actions/bash_spec.rb +43 -0
  120. data/spec/hybrid_platforms_conductor_test/api/actions_executor/actions/interactive_spec.rb +18 -0
  121. data/spec/hybrid_platforms_conductor_test/api/actions_executor/actions/remote_bash_spec.rb +102 -0
  122. data/spec/hybrid_platforms_conductor_test/api/actions_executor/actions/ruby_spec.rb +108 -0
  123. data/spec/hybrid_platforms_conductor_test/api/actions_executor/actions/scp_spec.rb +79 -0
  124. data/spec/hybrid_platforms_conductor_test/api/actions_executor/actions_spec.rb +199 -0
  125. data/spec/hybrid_platforms_conductor_test/api/actions_executor/connection_spec.rb +212 -0
  126. data/spec/hybrid_platforms_conductor_test/api/actions_executor/connectors/ssh/cli_options_spec.rb +125 -0
  127. data/spec/hybrid_platforms_conductor_test/api/actions_executor/connectors/ssh/config_dsl_spec.rb +50 -0
  128. data/spec/hybrid_platforms_conductor_test/api/actions_executor/connectors/ssh/connectable_nodes_spec.rb +28 -0
  129. data/spec/hybrid_platforms_conductor_test/api/actions_executor/connectors/ssh/connections_spec.rb +448 -0
  130. data/spec/hybrid_platforms_conductor_test/api/actions_executor/connectors/ssh/global_helpers_spec.rb +313 -0
  131. data/spec/hybrid_platforms_conductor_test/api/actions_executor/connectors/ssh/node_helpers_spec.rb +32 -0
  132. data/spec/hybrid_platforms_conductor_test/api/actions_executor/connectors/ssh/remote_actions_spec.rb +134 -0
  133. data/spec/hybrid_platforms_conductor_test/api/actions_executor/logging_spec.rb +256 -0
  134. data/spec/hybrid_platforms_conductor_test/api/actions_executor/parallel_spec.rb +338 -0
  135. data/spec/hybrid_platforms_conductor_test/api/actions_executor/timeout_spec.rb +101 -0
  136. data/spec/hybrid_platforms_conductor_test/api/cmd_runner_spec.rb +165 -0
  137. data/spec/hybrid_platforms_conductor_test/api/config_spec.rb +238 -0
  138. data/spec/hybrid_platforms_conductor_test/api/deployer/check_spec.rb +9 -0
  139. data/spec/hybrid_platforms_conductor_test/api/deployer/deploy_spec.rb +243 -0
  140. data/spec/hybrid_platforms_conductor_test/api/deployer/parse_deploy_output_spec.rb +104 -0
  141. data/spec/hybrid_platforms_conductor_test/api/deployer/provisioner_spec.rb +131 -0
  142. data/spec/hybrid_platforms_conductor_test/api/deployer/provisioners/docker/Dockerfile +10 -0
  143. data/spec/hybrid_platforms_conductor_test/api/deployer/provisioners/docker_spec.rb +123 -0
  144. data/spec/hybrid_platforms_conductor_test/api/deployer/provisioners/podman_spec.rb +211 -0
  145. data/spec/hybrid_platforms_conductor_test/api/deployer/provisioners/proxmox/config_dsl_spec.rb +126 -0
  146. data/spec/hybrid_platforms_conductor_test/api/deployer/provisioners/proxmox/create_spec.rb +290 -0
  147. data/spec/hybrid_platforms_conductor_test/api/deployer/provisioners/proxmox/destroy_spec.rb +43 -0
  148. data/spec/hybrid_platforms_conductor_test/api/deployer/provisioners/proxmox/ip_spec.rb +60 -0
  149. data/spec/hybrid_platforms_conductor_test/api/deployer/provisioners/proxmox/proxmox.json +3 -0
  150. data/spec/hybrid_platforms_conductor_test/api/deployer/provisioners/proxmox/reserve_proxmox_container/destroy_vm_spec.rb +82 -0
  151. data/spec/hybrid_platforms_conductor_test/api/deployer/provisioners/proxmox/reserve_proxmox_container/expired_containers_spec.rb +786 -0
  152. data/spec/hybrid_platforms_conductor_test/api/deployer/provisioners/proxmox/reserve_proxmox_container/ips_assignment_spec.rb +112 -0
  153. data/spec/hybrid_platforms_conductor_test/api/deployer/provisioners/proxmox/reserve_proxmox_container/other_lxc_containers_resources_spec.rb +190 -0
  154. data/spec/hybrid_platforms_conductor_test/api/deployer/provisioners/proxmox/reserve_proxmox_container/pve_node_resources_spec.rb +200 -0
  155. data/spec/hybrid_platforms_conductor_test/api/deployer/provisioners/proxmox/reserve_proxmox_container/retries_spec.rb +35 -0
  156. data/spec/hybrid_platforms_conductor_test/api/deployer/provisioners/proxmox/reserve_proxmox_container/vm_ids_assignment_spec.rb +67 -0
  157. data/spec/hybrid_platforms_conductor_test/api/deployer/provisioners/proxmox/start_spec.rb +79 -0
  158. data/spec/hybrid_platforms_conductor_test/api/deployer/provisioners/proxmox/state_spec.rb +28 -0
  159. data/spec/hybrid_platforms_conductor_test/api/deployer/provisioners/proxmox/stop_spec.rb +41 -0
  160. data/spec/hybrid_platforms_conductor_test/api/nodes_handler/cmdbs/config_spec.rb +33 -0
  161. data/spec/hybrid_platforms_conductor_test/api/nodes_handler/cmdbs/host_ip_spec.rb +64 -0
  162. data/spec/hybrid_platforms_conductor_test/api/nodes_handler/cmdbs/host_keys_spec.rb +133 -0
  163. data/spec/hybrid_platforms_conductor_test/api/nodes_handler/cmdbs/platform_handlers_spec.rb +19 -0
  164. data/spec/hybrid_platforms_conductor_test/api/nodes_handler/cmdbs_plugins_api_spec.rb +446 -0
  165. data/spec/hybrid_platforms_conductor_test/api/nodes_handler/common_spec.rb +127 -0
  166. data/spec/hybrid_platforms_conductor_test/api/nodes_handler/git_diff_impacts_spec.rb +318 -0
  167. data/spec/hybrid_platforms_conductor_test/api/nodes_handler/nodes_selectors_spec.rb +132 -0
  168. data/spec/hybrid_platforms_conductor_test/api/nodes_handler/platform_handlers_plugins_api_spec.rb +60 -0
  169. data/spec/hybrid_platforms_conductor_test/api/nodes_handler/several_platforms_spec.rb +58 -0
  170. data/spec/hybrid_platforms_conductor_test/api/platform_handler_spec.rb +97 -0
  171. data/spec/hybrid_platforms_conductor_test/api/platforms_handler_spec.rb +104 -0
  172. data/spec/hybrid_platforms_conductor_test/api/plugins_spec.rb +243 -0
  173. data/spec/hybrid_platforms_conductor_test/api/reports_handler_spec.rb +44 -0
  174. data/spec/hybrid_platforms_conductor_test/api/services_handler/actions_to_deploy_spec.rb +121 -0
  175. data/spec/hybrid_platforms_conductor_test/api/services_handler/deploy_allowed_spec.rb +142 -0
  176. data/spec/hybrid_platforms_conductor_test/api/services_handler/log_info_spec.rb +101 -0
  177. data/spec/hybrid_platforms_conductor_test/api/services_handler/package_spec.rb +388 -0
  178. data/spec/hybrid_platforms_conductor_test/api/services_handler/parse_deploy_output_spec.rb +274 -0
  179. data/spec/hybrid_platforms_conductor_test/api/services_handler/prepare_for_deploy_spec.rb +264 -0
  180. data/spec/hybrid_platforms_conductor_test/api/tests_runner/common_spec.rb +194 -0
  181. data/spec/hybrid_platforms_conductor_test/api/tests_runner/global_spec.rb +37 -0
  182. data/spec/hybrid_platforms_conductor_test/api/tests_runner/node_check_spec.rb +194 -0
  183. data/spec/hybrid_platforms_conductor_test/api/tests_runner/node_spec.rb +137 -0
  184. data/spec/hybrid_platforms_conductor_test/api/tests_runner/node_ssh_spec.rb +257 -0
  185. data/spec/hybrid_platforms_conductor_test/api/tests_runner/platform_spec.rb +110 -0
  186. data/spec/hybrid_platforms_conductor_test/api/tests_runner/reports_spec.rb +367 -0
  187. data/spec/hybrid_platforms_conductor_test/api/tests_runner/test_plugins/bitbucket_conf_spec.rb +111 -0
  188. data/spec/hybrid_platforms_conductor_test/api/tests_runner/test_reports_plugins/confluence_spec.rb +29 -0
  189. data/spec/hybrid_platforms_conductor_test/cmdb_plugins/test_cmdb.rb +166 -0
  190. data/spec/hybrid_platforms_conductor_test/cmdb_plugins/test_cmdb2.rb +93 -0
  191. data/spec/hybrid_platforms_conductor_test/cmdb_plugins/test_cmdb_others.rb +60 -0
  192. data/spec/hybrid_platforms_conductor_test/cmdb_plugins/test_cmdb_others2.rb +58 -0
  193. data/spec/hybrid_platforms_conductor_test/executables/check-node_spec.rb +35 -0
  194. data/spec/hybrid_platforms_conductor_test/executables/deploy_spec.rb +35 -0
  195. data/spec/hybrid_platforms_conductor_test/executables/get_impacted_nodes_spec.rb +158 -0
  196. data/spec/hybrid_platforms_conductor_test/executables/last_deploys_spec.rb +173 -0
  197. data/spec/hybrid_platforms_conductor_test/executables/nodes_to_deploy_spec.rb +283 -0
  198. data/spec/hybrid_platforms_conductor_test/executables/options/actions_executor_spec.rb +28 -0
  199. data/spec/hybrid_platforms_conductor_test/executables/options/cmd_runner_spec.rb +28 -0
  200. data/spec/hybrid_platforms_conductor_test/executables/options/common_spec.rb +67 -0
  201. data/spec/hybrid_platforms_conductor_test/executables/options/deployer_spec.rb +251 -0
  202. data/spec/hybrid_platforms_conductor_test/executables/options/nodes_handler_spec.rb +111 -0
  203. data/spec/hybrid_platforms_conductor_test/executables/options/nodes_selectors_spec.rb +71 -0
  204. data/spec/hybrid_platforms_conductor_test/executables/options/reports_handler_spec.rb +54 -0
  205. data/spec/hybrid_platforms_conductor_test/executables/options/tests_runner_spec.rb +139 -0
  206. data/spec/hybrid_platforms_conductor_test/executables/report_spec.rb +60 -0
  207. data/spec/hybrid_platforms_conductor_test/executables/run_spec.rb +173 -0
  208. data/spec/hybrid_platforms_conductor_test/executables/ssh_config_spec.rb +35 -0
  209. data/spec/hybrid_platforms_conductor_test/executables/test_spec.rb +41 -0
  210. data/spec/hybrid_platforms_conductor_test/helpers/actions_executor_helpers.rb +98 -0
  211. data/spec/hybrid_platforms_conductor_test/helpers/cmd_runner_helpers.rb +92 -0
  212. data/spec/hybrid_platforms_conductor_test/helpers/cmdb_helpers.rb +37 -0
  213. data/spec/hybrid_platforms_conductor_test/helpers/config_helpers.rb +20 -0
  214. data/spec/hybrid_platforms_conductor_test/helpers/connector_ssh_helpers.rb +130 -0
  215. data/spec/hybrid_platforms_conductor_test/helpers/deployer_helpers.rb +149 -0
  216. data/spec/hybrid_platforms_conductor_test/helpers/deployer_test_helpers.rb +812 -0
  217. data/spec/hybrid_platforms_conductor_test/helpers/executables_helpers.rb +96 -0
  218. data/spec/hybrid_platforms_conductor_test/helpers/nodes_handler_helpers.rb +20 -0
  219. data/spec/hybrid_platforms_conductor_test/helpers/platform_handler_helpers.rb +35 -0
  220. data/spec/hybrid_platforms_conductor_test/helpers/platforms_handler_helpers.rb +127 -0
  221. data/spec/hybrid_platforms_conductor_test/helpers/plugins_helpers.rb +48 -0
  222. data/spec/hybrid_platforms_conductor_test/helpers/provisioner_proxmox_helpers.rb +789 -0
  223. data/spec/hybrid_platforms_conductor_test/helpers/reports_handler_helpers.rb +29 -0
  224. data/spec/hybrid_platforms_conductor_test/helpers/services_handler_helpers.rb +20 -0
  225. data/spec/hybrid_platforms_conductor_test/helpers/tests_runner_helpers.rb +38 -0
  226. data/spec/hybrid_platforms_conductor_test/mocked_lib/my_test_gem/hpc_plugins/test_plugin_type/test_plugin_id1.rb +22 -0
  227. data/spec/hybrid_platforms_conductor_test/mocked_lib/my_test_gem/hpc_plugins/test_plugin_type/test_plugin_id2.rb +22 -0
  228. data/spec/hybrid_platforms_conductor_test/mocked_lib/my_test_gem2/sub_dir/hpc_plugins/test_plugin_type/test_plugin_id3.rb +26 -0
  229. data/spec/hybrid_platforms_conductor_test/mocked_lib/my_test_gem2/sub_dir/hpc_plugins/test_plugin_type2/test_plugin_id4.rb +26 -0
  230. data/spec/hybrid_platforms_conductor_test/platform_handler_plugins/test.rb +225 -0
  231. data/spec/hybrid_platforms_conductor_test/platform_handler_plugins/test2.rb +11 -0
  232. data/spec/hybrid_platforms_conductor_test/report_plugin.rb +35 -0
  233. data/spec/hybrid_platforms_conductor_test/test_action.rb +66 -0
  234. data/spec/hybrid_platforms_conductor_test/test_connector.rb +151 -0
  235. data/spec/hybrid_platforms_conductor_test/test_plugins/global.rb +30 -0
  236. data/spec/hybrid_platforms_conductor_test/test_plugins/node.rb +53 -0
  237. data/spec/hybrid_platforms_conductor_test/test_plugins/node_check.rb +47 -0
  238. data/spec/hybrid_platforms_conductor_test/test_plugins/node_ssh.rb +42 -0
  239. data/spec/hybrid_platforms_conductor_test/test_plugins/platform.rb +50 -0
  240. data/spec/hybrid_platforms_conductor_test/test_plugins/several_checks.rb +50 -0
  241. data/spec/hybrid_platforms_conductor_test/test_provisioner.rb +95 -0
  242. data/spec/hybrid_platforms_conductor_test/tests_report_plugin.rb +49 -0
  243. data/spec/spec_helper.rb +111 -0
  244. metadata +566 -0
@@ -0,0 +1,786 @@
1
+ require 'hybrid_platforms_conductor/hpc_plugins/provisioner/proxmox'
2
+
3
+ describe HybridPlatformsConductor::HpcPlugins::Provisioner::Proxmox do
4
+
5
+ context 'checking the reserve_proxmox_container sync tool' do
6
+
7
+ context 'checking expiration strategy for containers' do
8
+
9
+ it 'does not expire a VM when there are enough free resources on a PVE node' do
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 }
17
+ }
18
+ }
19
+ })
20
+ expect(call_reserve_proxmox_container(2, 1024, 1)).to eq(
21
+ pve_node: 'pve_node_name',
22
+ vm_id: 1001,
23
+ vm_ip: '192.168.0.101'
24
+ )
25
+ end
26
+ end
27
+
28
+ it 'expires a VM when there are not enough free resources on a PVE node' do
29
+ with_sync_node do
30
+ 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 }
37
+ }
38
+ }
39
+ })
40
+ expect(call_reserve_proxmox_container(2, 1024, 1)).to eq(
41
+ pve_node: 'pve_node_name',
42
+ vm_id: 1000,
43
+ vm_ip: '192.168.0.100'
44
+ )
45
+ expect_proxmox_actions_to_be [
46
+ [:post, 'nodes/pve_node_name/lxc/1000/status/stop'],
47
+ [:delete, 'nodes/pve_node_name/lxc/1000'],
48
+ [
49
+ :post,
50
+ 'nodes/pve_node_name/lxc',
51
+ {
52
+ 'cores' => 2,
53
+ 'cpulimit' => 2,
54
+ 'description' => /^===== HPC info =====\nnode: test_node\nenvironment: test_env\ncreation_date: .+\n/,
55
+ 'hostname' => 'test.hostname.my-domain.com',
56
+ 'memory' => 1024,
57
+ 'net0' => 'name=eth0,bridge=vmbr0,gw=172.16.16.16,ip=192.168.0.100/32',
58
+ 'ostemplate' => 'test_template.iso',
59
+ 'rootfs' => 'local-lvm:1',
60
+ 'vmid' => 1000
61
+ }
62
+ ]
63
+ ]
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
65
+ end
66
+ end
67
+
68
+ 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
+ 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
80
+ }
81
+ }
82
+ }
83
+ })
84
+ expect(call_reserve_proxmox_container(2, 1024, 1)).to eq(
85
+ pve_node: 'pve_node_name',
86
+ vm_id: 1000,
87
+ vm_ip: '192.168.0.100'
88
+ )
89
+ expect_proxmox_actions_to_be [
90
+ [:delete, 'nodes/pve_node_name/lxc/1000'],
91
+ [:post, 'nodes/pve_node_name/lxc', {
92
+ 'cores' => 2,
93
+ 'cpulimit' => 2,
94
+ 'description' => /^===== HPC info =====\nnode: test_node\nenvironment: test_env\ncreation_date: .+\n/,
95
+ 'hostname' => 'test.hostname.my-domain.com',
96
+ 'memory' => 1024,
97
+ 'net0' => 'name=eth0,bridge=vmbr0,gw=172.16.16.16,ip=192.168.0.100/32',
98
+ 'ostemplate' => 'test_template.iso',
99
+ 'rootfs' => 'local-lvm:1',
100
+ 'vmid' => 1000
101
+ }]
102
+ ]
103
+ end
104
+ end
105
+
106
+ 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
+ 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 }
115
+ }
116
+ }
117
+ })
118
+ expect(call_reserve_proxmox_container(2, 1024, 1)).to eq(
119
+ pve_node: 'pve_node_name',
120
+ vm_id: 1001,
121
+ vm_ip: '192.168.0.101'
122
+ )
123
+ expect_proxmox_actions_to_be [
124
+ [:post, 'nodes/pve_node_name/lxc/1001/status/stop'],
125
+ [:delete, 'nodes/pve_node_name/lxc/1001'],
126
+ [:post, 'nodes/pve_node_name/lxc', {
127
+ 'cores' => 2,
128
+ 'cpulimit' => 2,
129
+ 'description' => /^===== HPC info =====\nnode: test_node\nenvironment: test_env\ncreation_date: .+\n/,
130
+ 'hostname' => 'test.hostname.my-domain.com',
131
+ 'memory' => 1024,
132
+ 'net0' => 'name=eth0,bridge=vmbr0,gw=172.16.16.16,ip=192.168.0.101/32',
133
+ 'ostemplate' => 'test_template.iso',
134
+ 'rootfs' => 'local-lvm:1',
135
+ 'vmid' => 1001
136
+ }]
137
+ ]
138
+ end
139
+ end
140
+
141
+ it 'does not try to expire expired VMs when the freed resources would not be enough anyway for the new container' do
142
+ 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 }
150
+ }
151
+ }
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')
163
+ expect_proxmox_actions_to_be []
164
+ end
165
+ end
166
+
167
+ it 'expires all expired containers of a PVE node if needed' do
168
+ 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 }
176
+ }
177
+ }
178
+ })
179
+ expect(call_reserve_proxmox_container(2, 1024, 1)).to eq(
180
+ pve_node: 'pve_node_name',
181
+ vm_id: 1001,
182
+ vm_ip: '192.168.0.101'
183
+ )
184
+ expect_proxmox_actions_to_be [
185
+ [:post, 'nodes/pve_node_name/lxc/1001/status/stop'],
186
+ [:delete, 'nodes/pve_node_name/lxc/1001'],
187
+ [:post, 'nodes/pve_node_name/lxc/1002/status/stop'],
188
+ [:delete, 'nodes/pve_node_name/lxc/1002'],
189
+ [:post, 'nodes/pve_node_name/lxc', {
190
+ 'cores' => 2,
191
+ 'cpulimit' => 2,
192
+ 'description' => /^===== HPC info =====\nnode: test_node\nenvironment: test_env\ncreation_date: .+\n/,
193
+ 'hostname' => 'test.hostname.my-domain.com',
194
+ 'memory' => 1024,
195
+ 'net0' => 'name=eth0,bridge=vmbr0,gw=172.16.16.16,ip=192.168.0.101/32',
196
+ 'ostemplate' => 'test_template.iso',
197
+ 'rootfs' => 'local-lvm:1',
198
+ 'vmid' => 1001
199
+ }]
200
+ ]
201
+ end
202
+ end
203
+
204
+ it 'does not expire containers that don\'t belong to the VM IDs range' do
205
+ 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 }
213
+ }
214
+ }
215
+ })
216
+ expect(call_reserve_proxmox_container(2, 1024, 1)).to eq(
217
+ pve_node: 'pve_node_name',
218
+ vm_id: 1001,
219
+ vm_ip: '192.168.0.101'
220
+ )
221
+ expect_proxmox_actions_to_be [
222
+ [:post, 'nodes/pve_node_name/lxc/1001/status/stop'],
223
+ [:delete, 'nodes/pve_node_name/lxc/1001'],
224
+ [:post, 'nodes/pve_node_name/lxc', {
225
+ 'cores' => 2,
226
+ 'cpulimit' => 2,
227
+ 'description' => /^===== HPC info =====\nnode: test_node\nenvironment: test_env\ncreation_date: .+\n/,
228
+ 'hostname' => 'test.hostname.my-domain.com',
229
+ 'memory' => 1024,
230
+ 'net0' => 'name=eth0,bridge=vmbr0,gw=172.16.16.16,ip=192.168.0.101/32',
231
+ 'ostemplate' => 'test_template.iso',
232
+ 'rootfs' => 'local-lvm:1',
233
+ 'vmid' => 1001
234
+ }]
235
+ ]
236
+ end
237
+ end
238
+
239
+ it 'selects a PVE node that still has free resources without expiring VMs even if it would have freed more resources' do
240
+ 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 }
254
+ }
255
+ }
256
+ })
257
+ expect(call_reserve_proxmox_container(2, 1024, 1, config: { pve_nodes: nil })).to eq(
258
+ pve_node: 'pve_node_2',
259
+ vm_id: 1002,
260
+ vm_ip: '192.168.0.102'
261
+ )
262
+ expect_proxmox_actions_to_be [
263
+ [:post, 'nodes/pve_node_2/lxc', {
264
+ 'cores' => 2,
265
+ 'cpulimit' => 2,
266
+ 'description' => /^===== HPC info =====\nnode: test_node\nenvironment: test_env\ncreation_date: .+\n/,
267
+ 'hostname' => 'test.hostname.my-domain.com',
268
+ 'memory' => 1024,
269
+ 'net0' => 'name=eth0,bridge=vmbr0,gw=172.16.16.16,ip=192.168.0.102/32',
270
+ 'ostemplate' => 'test_template.iso',
271
+ 'rootfs' => 'local-lvm:1',
272
+ 'vmid' => 1002
273
+ }]
274
+ ]
275
+ end
276
+ end
277
+
278
+ it 'selects the PVE node that would have the more resources free after expiration when no other PVE node has free resources' do
279
+ 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 }
293
+ }
294
+ }
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(
308
+ pve_node: 'pve_node_1',
309
+ vm_id: 1001,
310
+ vm_ip: '192.168.0.101'
311
+ )
312
+ expect_proxmox_actions_to_be [
313
+ [:post, 'nodes/pve_node_1/lxc/1001/status/stop'],
314
+ [:delete, 'nodes/pve_node_1/lxc/1001'],
315
+ [:post, 'nodes/pve_node_1/lxc', {
316
+ 'cores' => 2,
317
+ 'cpulimit' => 2,
318
+ 'description' => /^===== HPC info =====\nnode: test_node\nenvironment: test_env\ncreation_date: .+\n/,
319
+ 'hostname' => 'test.hostname.my-domain.com',
320
+ 'memory' => 1024,
321
+ 'net0' => 'name=eth0,bridge=vmbr0,gw=172.16.16.16,ip=192.168.0.101/32',
322
+ 'ostemplate' => 'test_template.iso',
323
+ 'rootfs' => 'local-lvm:1',
324
+ 'vmid' => 1001
325
+ }]
326
+ ]
327
+ end
328
+ end
329
+
330
+ it 'expires VMs even if free resources are available when IPs are all used' do
331
+ 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 }
339
+ }
340
+ }
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(
351
+ pve_node: 'pve_node_name',
352
+ vm_id: 1001,
353
+ vm_ip: '192.168.0.101'
354
+ )
355
+ expect_proxmox_actions_to_be [
356
+ [:post, 'nodes/pve_node_name/lxc/1001/status/stop'],
357
+ [:delete, 'nodes/pve_node_name/lxc/1001'],
358
+ [:post, 'nodes/pve_node_name/lxc', {
359
+ 'cores' => 2,
360
+ 'cpulimit' => 2,
361
+ 'description' => /^===== HPC info =====\nnode: test_node\nenvironment: test_env\ncreation_date: .+\n/,
362
+ 'hostname' => 'test.hostname.my-domain.com',
363
+ 'memory' => 1024,
364
+ 'net0' => 'name=eth0,bridge=vmbr0,gw=172.16.16.16,ip=192.168.0.101/32',
365
+ 'ostemplate' => 'test_template.iso',
366
+ 'rootfs' => 'local-lvm:1',
367
+ 'vmid' => 1001
368
+ }]
369
+ ]
370
+ end
371
+ end
372
+
373
+ it 'expires VMs from non-selected PVE nodes even if free resources are available when IPs are all used' do
374
+ 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 }
389
+ }
390
+ }
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(
402
+ pve_node: 'pve_node_1',
403
+ vm_id: 1001,
404
+ vm_ip: '192.168.0.101'
405
+ )
406
+ expect_proxmox_actions_to_be [
407
+ [:post, 'nodes/pve_node_2/lxc/1001/status/stop'],
408
+ [:delete, 'nodes/pve_node_2/lxc/1001'],
409
+ [:post, 'nodes/pve_node_1/lxc', {
410
+ 'cores' => 2,
411
+ 'cpulimit' => 2,
412
+ 'description' => /^===== HPC info =====\nnode: test_node\nenvironment: test_env\ncreation_date: .+\n/,
413
+ 'hostname' => 'test.hostname.my-domain.com',
414
+ 'memory' => 1024,
415
+ 'net0' => 'name=eth0,bridge=vmbr0,gw=172.16.16.16,ip=192.168.0.101/32',
416
+ 'ostemplate' => 'test_template.iso',
417
+ 'rootfs' => 'local-lvm:1',
418
+ 'vmid' => 1001
419
+ }]
420
+ ]
421
+ end
422
+ end
423
+
424
+ it 'expires VMs even if free resources are available when VM IDs are all used' do
425
+ 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 }
433
+ }
434
+ }
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(
447
+ pve_node: 'pve_node_name',
448
+ vm_id: 1001,
449
+ vm_ip: '192.168.0.101'
450
+ )
451
+ expect_proxmox_actions_to_be [
452
+ [:post, 'nodes/pve_node_name/lxc/1001/status/stop'],
453
+ [:delete, 'nodes/pve_node_name/lxc/1001'],
454
+ [:post, 'nodes/pve_node_name/lxc', {
455
+ 'cores' => 2,
456
+ 'cpulimit' => 2,
457
+ 'description' => /^===== HPC info =====\nnode: test_node\nenvironment: test_env\ncreation_date: .+\n/,
458
+ 'hostname' => 'test.hostname.my-domain.com',
459
+ 'memory' => 1024,
460
+ 'net0' => 'name=eth0,bridge=vmbr0,gw=172.16.16.16,ip=192.168.0.101/32',
461
+ 'ostemplate' => 'test_template.iso',
462
+ 'rootfs' => 'local-lvm:1',
463
+ 'vmid' => 1001
464
+ }]
465
+ ]
466
+ end
467
+ end
468
+
469
+ it 'expires VMs from non-selected PVE nodes even if free resources are available when VM IDs are all used' do
470
+ 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 }
485
+ }
486
+ }
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(
500
+ pve_node: 'pve_node_1',
501
+ vm_id: 1001,
502
+ vm_ip: '192.168.0.101'
503
+ )
504
+ expect_proxmox_actions_to_be [
505
+ [:post, 'nodes/pve_node_2/lxc/1001/status/stop'],
506
+ [:delete, 'nodes/pve_node_2/lxc/1001'],
507
+ [:post, 'nodes/pve_node_1/lxc', {
508
+ 'cores' => 2,
509
+ 'cpulimit' => 2,
510
+ 'description' => /^===== HPC info =====\nnode: test_node\nenvironment: test_env\ncreation_date: .+\n/,
511
+ 'hostname' => 'test.hostname.my-domain.com',
512
+ 'memory' => 1024,
513
+ 'net0' => 'name=eth0,bridge=vmbr0,gw=172.16.16.16,ip=192.168.0.101/32',
514
+ 'ostemplate' => 'test_template.iso',
515
+ 'rootfs' => 'local-lvm:1',
516
+ 'vmid' => 1001
517
+ }]
518
+ ]
519
+ end
520
+ end
521
+
522
+ it 'expires VMs even if free resources are available when the maximum number of VMs has been reached' do
523
+ 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 }
531
+ }
532
+ }
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
547
+ }
548
+ }
549
+ )).to eq(
550
+ pve_node: 'pve_node_name',
551
+ vm_id: 1001,
552
+ vm_ip: '192.168.0.101'
553
+ )
554
+ expect_proxmox_actions_to_be [
555
+ [:post, 'nodes/pve_node_name/lxc/1001/status/stop'],
556
+ [:delete, 'nodes/pve_node_name/lxc/1001'],
557
+ [:post, 'nodes/pve_node_name/lxc', {
558
+ 'cores' => 2,
559
+ 'cpulimit' => 2,
560
+ 'description' => /^===== HPC info =====\nnode: test_node\nenvironment: test_env\ncreation_date: .+\n/,
561
+ 'hostname' => 'test.hostname.my-domain.com',
562
+ 'memory' => 1024,
563
+ 'net0' => 'name=eth0,bridge=vmbr0,gw=172.16.16.16,ip=192.168.0.101/32',
564
+ 'ostemplate' => 'test_template.iso',
565
+ 'rootfs' => 'local-lvm:1',
566
+ 'vmid' => 1001
567
+ }]
568
+ ]
569
+ end
570
+ end
571
+
572
+ 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
+ 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 }
588
+ }
589
+ }
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
605
+ }
606
+ }
607
+ )).to eq(
608
+ pve_node: 'pve_node_1',
609
+ vm_id: 1001,
610
+ vm_ip: '192.168.0.101'
611
+ )
612
+ expect_proxmox_actions_to_be [
613
+ [:post, 'nodes/pve_node_2/lxc/1001/status/stop'],
614
+ [:delete, 'nodes/pve_node_2/lxc/1001'],
615
+ [:post, 'nodes/pve_node_1/lxc', {
616
+ 'cores' => 2,
617
+ 'cpulimit' => 2,
618
+ 'description' => /^===== HPC info =====\nnode: test_node\nenvironment: test_env\ncreation_date: .+\n/,
619
+ 'hostname' => 'test.hostname.my-domain.com',
620
+ 'memory' => 1024,
621
+ 'net0' => 'name=eth0,bridge=vmbr0,gw=172.16.16.16,ip=192.168.0.101/32',
622
+ 'ostemplate' => 'test_template.iso',
623
+ 'rootfs' => 'local-lvm:1',
624
+ 'vmid' => 1001
625
+ }]
626
+ ]
627
+ end
628
+ end
629
+
630
+ it 'does not expire a VM that is stopped for long time but still used for debug purposes' do
631
+ 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
643
+ }
644
+ }
645
+ }
646
+ })
647
+ expect(call_reserve_proxmox_container(2, 1024, 1)).to eq(error: 'not_enough_resources')
648
+ expect_proxmox_actions_to_be []
649
+ end
650
+ end
651
+
652
+ it 'expires a VM that is stopped for long time and is not used for debug purposes' do
653
+ with_sync_node do
654
+ mock_proxmox(mocked_pve_nodes: [{
655
+ 'pve_node_name' => {
656
+ memory_total: 4 * 1024 * 1024 * 1024,
657
+ lxc_containers: {
658
+ # Make sure it is not expired
659
+ 1000 => {
660
+ ip: '192.168.0.100',
661
+ maxmem: 4 * 1024 * 1024 * 1024,
662
+ creation_date: Time.now.utc,
663
+ status: 'stopped',
664
+ debug: false
665
+ }
666
+ }
667
+ }
668
+ }] * 3)
669
+ # Timeout for a non-debug stopped container to be considered expired is 3 seconds in tests
670
+ expect(call_reserve_proxmox_container(2, 1024, 1, max_retries: 5, wait_before_retry: 2)).to eq(
671
+ pve_node: 'pve_node_name',
672
+ vm_id: 1000,
673
+ vm_ip: '192.168.0.100'
674
+ )
675
+ expect_proxmox_actions_to_be [
676
+ [:delete, 'nodes/pve_node_name/lxc/1000'],
677
+ [:post, 'nodes/pve_node_name/lxc', {
678
+ 'cores' => 2,
679
+ 'cpulimit' => 2,
680
+ 'description' => /^===== HPC info =====\nnode: test_node\nenvironment: test_env\ncreation_date: .+\n/,
681
+ 'hostname' => 'test.hostname.my-domain.com',
682
+ 'memory' => 1024,
683
+ 'net0' => 'name=eth0,bridge=vmbr0,gw=172.16.16.16,ip=192.168.0.100/32',
684
+ 'ostemplate' => 'test_template.iso',
685
+ 'rootfs' => 'local-lvm:1',
686
+ 'vmid' => 1000
687
+ }]
688
+ ]
689
+ end
690
+ end
691
+
692
+ it 'does not expire a VM that is stopped for some time even when it is not used for debug purposes' do
693
+ with_sync_node do
694
+ mock_proxmox(mocked_pve_nodes: [{
695
+ # 2 seconds separate each run.
696
+ # Make sure the third and later runs mock the container as running instead of stopped
697
+ 'pve_node_name' => {
698
+ memory_total: 4 * 1024 * 1024 * 1024,
699
+ lxc_containers: {
700
+ # Make sure it is not expired
701
+ 1000 => {
702
+ ip: '192.168.0.100',
703
+ maxmem: 4 * 1024 * 1024 * 1024,
704
+ creation_date: Time.now.utc,
705
+ # Make it stopped first, then running
706
+ status: 'stopped',
707
+ debug: false
708
+ }
709
+ }
710
+ }
711
+ }] * 2 +
712
+ [{
713
+ # 2 seconds separate each run.
714
+ # Make sure the third and later runs mock the container as running instead of stopped
715
+ 'pve_node_name' => {
716
+ memory_total: 4 * 1024 * 1024 * 1024,
717
+ lxc_containers: {
718
+ # Make sure it is not expired
719
+ 1000 => {
720
+ ip: '192.168.0.100',
721
+ maxmem: 4 * 1024 * 1024 * 1024,
722
+ creation_date: Time.now.utc,
723
+ # Make it stopped first, then running
724
+ status: 'running',
725
+ debug: false
726
+ }
727
+ }
728
+ }
729
+ }] * 2
730
+ )
731
+ # Timeout for a non-debug stopped container to be considered expired is 3 seconds in tests
732
+ expect(call_reserve_proxmox_container(2, 1024, 1, max_retries: 4, wait_before_retry: 2)).to eq(error: 'not_enough_resources')
733
+ expect_proxmox_actions_to_be []
734
+ end
735
+ end
736
+
737
+ it 'does not expire a VM that is stopped but has been recreated, even with the same VM ID when it is not used for debug purposes' do
738
+ with_sync_node do
739
+ creation_date_1 = (Time.now - 20).utc
740
+ creation_date_2 = (Time.now - 10).utc
741
+ mock_proxmox(mocked_pve_nodes: [{
742
+ # 2 seconds separate each run.
743
+ # Make sure the third and later runs mock the container as another one, still stopped
744
+ 'pve_node_name' => {
745
+ memory_total: 4 * 1024 * 1024 * 1024,
746
+ lxc_containers: {
747
+ # Make sure it is not expired
748
+ 1000 => {
749
+ ip: '192.168.0.100',
750
+ maxmem: 4 * 1024 * 1024 * 1024,
751
+ creation_date: creation_date_1,
752
+ status: 'stopped',
753
+ debug: false
754
+ }
755
+ }
756
+ }
757
+ }] * 2 +
758
+ [{
759
+ # 2 seconds separate each run.
760
+ # Make sure the third and later runs mock the container as another one, still stopped
761
+ 'pve_node_name' => {
762
+ memory_total: 4 * 1024 * 1024 * 1024,
763
+ lxc_containers: {
764
+ # Make sure it is not expired
765
+ 1000 => {
766
+ ip: '192.168.0.100',
767
+ maxmem: 4 * 1024 * 1024 * 1024,
768
+ creation_date: creation_date_2,
769
+ status: 'stopped',
770
+ debug: false
771
+ }
772
+ }
773
+ }
774
+ }] * 2
775
+ )
776
+ # Timeout for a non-debug stopped container to be considered expired is 3 seconds in tests
777
+ expect(call_reserve_proxmox_container(2, 1024, 1, max_retries: 4, wait_before_retry: 2)).to eq(error: 'not_enough_resources')
778
+ expect_proxmox_actions_to_be []
779
+ end
780
+ end
781
+
782
+ end
783
+
784
+ end
785
+
786
+ end