hybrid_platforms_conductor 32.17.1 → 33.0.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (268) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +36 -0
  3. data/README.md +6 -3
  4. data/bin/check-node +0 -1
  5. data/bin/deploy +0 -1
  6. data/bin/get_impacted_nodes +0 -1
  7. data/bin/last_deploys +12 -8
  8. data/bin/nodes_to_deploy +6 -6
  9. data/bin/setup +6 -6
  10. data/bin/topograph +1 -1
  11. data/docs/config_dsl.md +45 -1
  12. data/docs/executables.md +6 -7
  13. data/docs/executables/check-node.md +3 -3
  14. data/docs/executables/deploy.md +3 -3
  15. data/docs/executables/dump_nodes_json.md +3 -3
  16. data/docs/executables/test.md +3 -3
  17. data/docs/executables/topograph.md +3 -3
  18. data/docs/gen/mermaid/README.md-0.png +0 -0
  19. data/docs/gen/mermaid/docs/executables/check-node.md-0.png +0 -0
  20. data/docs/gen/mermaid/docs/executables/deploy.md-0.png +0 -0
  21. data/docs/gen/mermaid/docs/executables/free_ips.md-0.png +0 -0
  22. data/docs/gen/mermaid/docs/executables/get_impacted_nodes.md-0.png +0 -0
  23. data/docs/gen/mermaid/docs/executables/last_deploys.md-0.png +0 -0
  24. data/docs/gen/mermaid/docs/executables/nodes_to_deploy.md-0.png +0 -0
  25. data/docs/gen/mermaid/docs/executables/report.md-0.png +0 -0
  26. data/docs/gen/mermaid/docs/executables/run.md-0.png +0 -0
  27. data/docs/gen/mermaid/docs/executables/ssh_config.md-0.png +0 -0
  28. data/docs/gen/mermaid/docs/executables/test.md-0.png +0 -0
  29. data/docs/plugins.md +46 -0
  30. data/docs/plugins/log/remote_fs.md +26 -0
  31. data/docs/plugins/secrets_reader/cli.md +31 -0
  32. data/docs/plugins/secrets_reader/thycotic.md +46 -0
  33. data/lib/hybrid_platforms_conductor/action.rb +4 -4
  34. data/lib/hybrid_platforms_conductor/actions_executor.rb +45 -43
  35. data/lib/hybrid_platforms_conductor/bitbucket.rb +5 -4
  36. data/lib/hybrid_platforms_conductor/cmd_runner.rb +13 -12
  37. data/lib/hybrid_platforms_conductor/cmdb.rb +2 -2
  38. data/lib/hybrid_platforms_conductor/common_config_dsl/bitbucket.rb +2 -1
  39. data/lib/hybrid_platforms_conductor/common_config_dsl/confluence.rb +2 -1
  40. data/lib/hybrid_platforms_conductor/common_config_dsl/file_system_tests.rb +5 -4
  41. data/lib/hybrid_platforms_conductor/common_config_dsl/github.rb +4 -3
  42. data/lib/hybrid_platforms_conductor/common_config_dsl/idempotence_tests.rb +2 -2
  43. data/lib/hybrid_platforms_conductor/config.rb +8 -4
  44. data/lib/hybrid_platforms_conductor/confluence.rb +1 -1
  45. data/lib/hybrid_platforms_conductor/connector.rb +5 -2
  46. data/lib/hybrid_platforms_conductor/core_extensions/cleanroom/fix_kwargs.rb +116 -0
  47. data/lib/hybrid_platforms_conductor/core_extensions/symbol/zero.rb +24 -0
  48. data/lib/hybrid_platforms_conductor/credentials.rb +39 -36
  49. data/lib/hybrid_platforms_conductor/current_dir_monitor.rb +4 -1
  50. data/lib/hybrid_platforms_conductor/deployer.rb +275 -225
  51. data/lib/hybrid_platforms_conductor/executable.rb +20 -15
  52. data/lib/hybrid_platforms_conductor/hpc_plugins/cmdb/config.rb +10 -7
  53. data/lib/hybrid_platforms_conductor/hpc_plugins/cmdb/host_ip.rb +1 -1
  54. data/lib/hybrid_platforms_conductor/hpc_plugins/cmdb/host_keys.rb +2 -2
  55. data/lib/hybrid_platforms_conductor/hpc_plugins/cmdb/platform_handlers.rb +4 -4
  56. data/lib/hybrid_platforms_conductor/hpc_plugins/connector/local.rb +2 -0
  57. data/lib/hybrid_platforms_conductor/hpc_plugins/connector/ssh.rb +45 -49
  58. data/lib/hybrid_platforms_conductor/hpc_plugins/log/my_log_plugin.rb.sample +100 -0
  59. data/lib/hybrid_platforms_conductor/hpc_plugins/log/remote_fs.rb +180 -0
  60. data/lib/hybrid_platforms_conductor/hpc_plugins/platform_handler/serverless_chef.rb +68 -66
  61. data/lib/hybrid_platforms_conductor/hpc_plugins/platform_handler/serverless_chef/dsl_parser.rb +13 -0
  62. data/lib/hybrid_platforms_conductor/hpc_plugins/platform_handler/serverless_chef/recipes_tree_builder.rb +39 -38
  63. data/lib/hybrid_platforms_conductor/hpc_plugins/platform_handler/yaml_inventory.rb +5 -4
  64. data/lib/hybrid_platforms_conductor/hpc_plugins/provisioner/docker.rb +43 -45
  65. data/lib/hybrid_platforms_conductor/hpc_plugins/provisioner/podman.rb +18 -20
  66. data/lib/hybrid_platforms_conductor/hpc_plugins/provisioner/proxmox.rb +119 -118
  67. data/lib/hybrid_platforms_conductor/hpc_plugins/provisioner/proxmox/proxmox_waiter.rb +39 -43
  68. data/lib/hybrid_platforms_conductor/hpc_plugins/provisioner/proxmox/reserve_proxmox_container +9 -13
  69. data/lib/hybrid_platforms_conductor/hpc_plugins/report/confluence.rb +2 -2
  70. data/lib/hybrid_platforms_conductor/hpc_plugins/report/mediawiki.rb +28 -21
  71. data/lib/hybrid_platforms_conductor/hpc_plugins/report/stdout.rb +26 -22
  72. data/lib/hybrid_platforms_conductor/hpc_plugins/secrets_reader/cli.rb +77 -0
  73. data/lib/hybrid_platforms_conductor/hpc_plugins/secrets_reader/my_secrets_reader_plugin.rb.sample +46 -0
  74. data/lib/hybrid_platforms_conductor/hpc_plugins/secrets_reader/thycotic.rb +90 -0
  75. data/lib/hybrid_platforms_conductor/hpc_plugins/test/bitbucket_conf.rb +3 -3
  76. data/lib/hybrid_platforms_conductor/hpc_plugins/test/check_deploy_and_idempotence.rb +4 -2
  77. data/lib/hybrid_platforms_conductor/hpc_plugins/test/deploy_freshness.rb +7 -21
  78. data/lib/hybrid_platforms_conductor/hpc_plugins/test/deploy_removes_root_access.rb +21 -19
  79. data/lib/hybrid_platforms_conductor/hpc_plugins/test/divergence.rb +2 -2
  80. data/lib/hybrid_platforms_conductor/hpc_plugins/test/executables.rb +2 -2
  81. data/lib/hybrid_platforms_conductor/hpc_plugins/test/file_system.rb +19 -21
  82. data/lib/hybrid_platforms_conductor/hpc_plugins/test/file_system_hdfs.rb +19 -21
  83. data/lib/hybrid_platforms_conductor/hpc_plugins/test/github_ci.rb +2 -3
  84. data/lib/hybrid_platforms_conductor/hpc_plugins/test/idempotence.rb +2 -2
  85. data/lib/hybrid_platforms_conductor/hpc_plugins/test/ip.rb +1 -1
  86. data/lib/hybrid_platforms_conductor/hpc_plugins/test/jenkins_ci_conf.rb +21 -22
  87. data/lib/hybrid_platforms_conductor/hpc_plugins/test/jenkins_ci_masters_ok.rb +10 -12
  88. data/lib/hybrid_platforms_conductor/hpc_plugins/test/linear_strategy.rb +9 -9
  89. data/lib/hybrid_platforms_conductor/hpc_plugins/test/local_users.rb +2 -2
  90. data/lib/hybrid_platforms_conductor/hpc_plugins/test/mounts.rb +2 -2
  91. data/lib/hybrid_platforms_conductor/hpc_plugins/test/orphan_files.rb +10 -9
  92. data/lib/hybrid_platforms_conductor/hpc_plugins/test/ports.rb +2 -2
  93. data/lib/hybrid_platforms_conductor/hpc_plugins/test/private_ips.rb +5 -5
  94. data/lib/hybrid_platforms_conductor/hpc_plugins/test/public_ips.rb +5 -5
  95. data/lib/hybrid_platforms_conductor/hpc_plugins/test/spectre.rb +4 -6
  96. data/lib/hybrid_platforms_conductor/hpc_plugins/test/veids.rb +3 -3
  97. data/lib/hybrid_platforms_conductor/hpc_plugins/test/vulnerabilities.rb +25 -24
  98. data/lib/hybrid_platforms_conductor/hpc_plugins/test_report/confluence.rb +2 -2
  99. data/lib/hybrid_platforms_conductor/hpc_plugins/test_report/stdout.rb +8 -6
  100. data/lib/hybrid_platforms_conductor/io_router.rb +14 -13
  101. data/lib/hybrid_platforms_conductor/json_dumper.rb +2 -2
  102. data/lib/hybrid_platforms_conductor/log.rb +31 -0
  103. data/lib/hybrid_platforms_conductor/logger_helpers.rb +19 -16
  104. data/lib/hybrid_platforms_conductor/nodes_handler.rb +89 -71
  105. data/lib/hybrid_platforms_conductor/parallel_threads.rb +7 -11
  106. data/lib/hybrid_platforms_conductor/platform_handler.rb +7 -7
  107. data/lib/hybrid_platforms_conductor/platforms_handler.rb +5 -3
  108. data/lib/hybrid_platforms_conductor/plugin.rb +2 -2
  109. data/lib/hybrid_platforms_conductor/plugins.rb +14 -8
  110. data/lib/hybrid_platforms_conductor/provisioner.rb +4 -4
  111. data/lib/hybrid_platforms_conductor/report.rb +2 -2
  112. data/lib/hybrid_platforms_conductor/reports_handler.rb +3 -2
  113. data/lib/hybrid_platforms_conductor/secrets_reader.rb +31 -0
  114. data/lib/hybrid_platforms_conductor/services_handler.rb +32 -29
  115. data/lib/hybrid_platforms_conductor/test_only_remote_node.rb +1 -1
  116. data/lib/hybrid_platforms_conductor/test_report.rb +15 -18
  117. data/lib/hybrid_platforms_conductor/tests_runner.rb +116 -118
  118. data/lib/hybrid_platforms_conductor/thycotic.rb +28 -19
  119. data/lib/hybrid_platforms_conductor/topographer.rb +200 -190
  120. data/lib/hybrid_platforms_conductor/topographer/plugins/graphviz.rb +8 -8
  121. data/lib/hybrid_platforms_conductor/topographer/plugins/json.rb +4 -4
  122. data/lib/hybrid_platforms_conductor/version.rb +1 -1
  123. data/spec/hybrid_platforms_conductor_test.rb +51 -12
  124. data/spec/hybrid_platforms_conductor_test/api/actions_executor/actions/bash_spec.rb +18 -11
  125. data/spec/hybrid_platforms_conductor_test/api/actions_executor/actions/interactive_spec.rb +2 -2
  126. data/spec/hybrid_platforms_conductor_test/api/actions_executor/actions/remote_bash_spec.rb +32 -21
  127. data/spec/hybrid_platforms_conductor_test/api/actions_executor/actions/ruby_spec.rb +75 -49
  128. data/spec/hybrid_platforms_conductor_test/api/actions_executor/actions/scp_spec.rb +27 -15
  129. data/spec/hybrid_platforms_conductor_test/api/actions_executor/actions_spec.rb +90 -59
  130. data/spec/hybrid_platforms_conductor_test/api/actions_executor/connection_spec.rb +46 -44
  131. data/spec/hybrid_platforms_conductor_test/api/actions_executor/connectors/local/connectable_nodes_spec.rb +12 -8
  132. data/spec/hybrid_platforms_conductor_test/api/actions_executor/connectors/local/remote_actions_spec.rb +4 -7
  133. data/spec/hybrid_platforms_conductor_test/api/actions_executor/connectors/ssh/cli_options_spec.rb +21 -22
  134. data/spec/hybrid_platforms_conductor_test/api/actions_executor/connectors/ssh/config_dsl_spec.rb +23 -24
  135. data/spec/hybrid_platforms_conductor_test/api/actions_executor/connectors/ssh/connectable_nodes_spec.rb +10 -6
  136. data/spec/hybrid_platforms_conductor_test/api/actions_executor/connectors/ssh/connections_spec.rb +106 -75
  137. data/spec/hybrid_platforms_conductor_test/api/actions_executor/connectors/ssh/global_helpers_spec.rb +145 -126
  138. data/spec/hybrid_platforms_conductor_test/api/actions_executor/connectors/ssh/node_helpers_spec.rb +3 -3
  139. data/spec/hybrid_platforms_conductor_test/api/actions_executor/connectors/ssh/remote_actions_spec.rb +29 -25
  140. data/spec/hybrid_platforms_conductor_test/api/actions_executor/logging_spec.rb +167 -142
  141. data/spec/hybrid_platforms_conductor_test/api/actions_executor/parallel_spec.rb +272 -244
  142. data/spec/hybrid_platforms_conductor_test/api/actions_executor/timeout_spec.rb +16 -16
  143. data/spec/hybrid_platforms_conductor_test/api/cmd_runner_spec.rb +36 -36
  144. data/spec/hybrid_platforms_conductor_test/api/config_spec.rb +24 -22
  145. data/spec/hybrid_platforms_conductor_test/api/deployer/check_spec.rb +4 -2
  146. data/spec/hybrid_platforms_conductor_test/api/deployer/config_dsl_spec.rb +43 -5
  147. data/spec/hybrid_platforms_conductor_test/api/deployer/deploy_spec.rb +199 -216
  148. data/spec/hybrid_platforms_conductor_test/api/deployer/log_plugins/remote_fs_spec.rb +223 -0
  149. data/spec/hybrid_platforms_conductor_test/api/deployer/parse_deploy_output_spec.rb +55 -59
  150. data/spec/hybrid_platforms_conductor_test/api/deployer/provisioner_spec.rb +36 -62
  151. data/spec/hybrid_platforms_conductor_test/api/deployer/provisioners/podman_spec.rb +17 -17
  152. data/spec/hybrid_platforms_conductor_test/api/deployer/provisioners/proxmox/config_dsl_spec.rb +4 -4
  153. data/spec/hybrid_platforms_conductor_test/api/deployer/provisioners/proxmox/create_spec.rb +44 -51
  154. data/spec/hybrid_platforms_conductor_test/api/deployer/provisioners/proxmox/destroy_spec.rb +3 -3
  155. data/spec/hybrid_platforms_conductor_test/api/deployer/provisioners/proxmox/ip_spec.rb +12 -16
  156. data/spec/hybrid_platforms_conductor_test/api/deployer/provisioners/proxmox/reserve_proxmox_container/destroy_vm_spec.rb +31 -19
  157. data/spec/hybrid_platforms_conductor_test/api/deployer/provisioners/proxmox/reserve_proxmox_container/expired_containers_spec.rb +324 -266
  158. data/spec/hybrid_platforms_conductor_test/api/deployer/provisioners/proxmox/reserve_proxmox_container/ips_assignment_spec.rb +89 -61
  159. data/spec/hybrid_platforms_conductor_test/api/deployer/provisioners/proxmox/reserve_proxmox_container/other_lxc_containers_resources_spec.rb +117 -93
  160. data/spec/hybrid_platforms_conductor_test/api/deployer/provisioners/proxmox/reserve_proxmox_container/pve_node_resources_spec.rb +71 -54
  161. data/spec/hybrid_platforms_conductor_test/api/deployer/provisioners/proxmox/reserve_proxmox_container/retries_spec.rb +10 -8
  162. data/spec/hybrid_platforms_conductor_test/api/deployer/provisioners/proxmox/reserve_proxmox_container/vm_ids_assignment_spec.rb +80 -60
  163. data/spec/hybrid_platforms_conductor_test/api/deployer/provisioners/proxmox/start_spec.rb +1 -1
  164. data/spec/hybrid_platforms_conductor_test/api/deployer/provisioners/proxmox/state_spec.rb +1 -1
  165. data/spec/hybrid_platforms_conductor_test/api/deployer/provisioners/proxmox/stop_spec.rb +1 -1
  166. data/spec/hybrid_platforms_conductor_test/api/deployer/secrets_reader_plugins/cli_spec.rb +64 -0
  167. data/spec/hybrid_platforms_conductor_test/api/deployer/secrets_reader_plugins/thycotic_spec.rb +268 -0
  168. data/spec/hybrid_platforms_conductor_test/api/nodes_handler/cmdbs/config_spec.rb +8 -10
  169. data/spec/hybrid_platforms_conductor_test/api/nodes_handler/cmdbs/host_ip_spec.rb +33 -24
  170. data/spec/hybrid_platforms_conductor_test/api/nodes_handler/cmdbs/host_keys_spec.rb +64 -51
  171. data/spec/hybrid_platforms_conductor_test/api/nodes_handler/cmdbs/platform_handlers_spec.rb +3 -3
  172. data/spec/hybrid_platforms_conductor_test/api/nodes_handler/cmdbs_plugins_api_spec.rb +50 -51
  173. data/spec/hybrid_platforms_conductor_test/api/nodes_handler/common_spec.rb +91 -81
  174. data/spec/hybrid_platforms_conductor_test/api/nodes_handler/config_dsl_spec.rb +14 -16
  175. data/spec/hybrid_platforms_conductor_test/api/nodes_handler/git_diff_impacts_spec.rb +51 -75
  176. data/spec/hybrid_platforms_conductor_test/api/nodes_handler/nodes_selectors_spec.rb +35 -26
  177. data/spec/hybrid_platforms_conductor_test/api/nodes_handler/platform_handlers_plugins_api_spec.rb +24 -16
  178. data/spec/hybrid_platforms_conductor_test/api/nodes_handler/several_platforms_spec.rb +29 -19
  179. data/spec/hybrid_platforms_conductor_test/api/platform_handler_spec.rb +4 -4
  180. data/spec/hybrid_platforms_conductor_test/api/platform_handlers/serverless_chef/config_dsl_spec.rb +2 -2
  181. data/spec/hybrid_platforms_conductor_test/api/platform_handlers/serverless_chef/deploy_output_parsing_spec.rb +6 -6
  182. data/spec/hybrid_platforms_conductor_test/api/platform_handlers/serverless_chef/diff_impacts_spec.rb +57 -99
  183. data/spec/hybrid_platforms_conductor_test/api/platform_handlers/serverless_chef/inventory_spec.rb +4 -4
  184. data/spec/hybrid_platforms_conductor_test/api/platform_handlers/serverless_chef/packaging_spec.rb +32 -35
  185. data/spec/hybrid_platforms_conductor_test/api/platform_handlers/serverless_chef/services_deployment_spec.rb +10 -10
  186. data/spec/hybrid_platforms_conductor_test/api/platforms_handler_spec.rb +38 -27
  187. data/spec/hybrid_platforms_conductor_test/api/plugins_spec.rb +46 -52
  188. data/spec/hybrid_platforms_conductor_test/api/reports_handler_spec.rb +2 -2
  189. data/spec/hybrid_platforms_conductor_test/api/services_handler/actions_to_deploy_spec.rb +90 -58
  190. data/spec/hybrid_platforms_conductor_test/api/services_handler/deploy_allowed_spec.rb +38 -34
  191. data/spec/hybrid_platforms_conductor_test/api/services_handler/log_info_spec.rb +11 -9
  192. data/spec/hybrid_platforms_conductor_test/api/services_handler/package_spec.rb +193 -171
  193. data/spec/hybrid_platforms_conductor_test/api/services_handler/parse_deploy_output_spec.rb +66 -54
  194. data/spec/hybrid_platforms_conductor_test/api/services_handler/prepare_for_deploy_spec.rb +147 -133
  195. data/spec/hybrid_platforms_conductor_test/api/tests_runner/common_spec.rb +69 -49
  196. data/spec/hybrid_platforms_conductor_test/api/tests_runner/global_spec.rb +5 -4
  197. data/spec/hybrid_platforms_conductor_test/api/tests_runner/node_check_spec.rb +8 -5
  198. data/spec/hybrid_platforms_conductor_test/api/tests_runner/node_spec.rb +8 -5
  199. data/spec/hybrid_platforms_conductor_test/api/tests_runner/node_ssh_spec.rb +30 -27
  200. data/spec/hybrid_platforms_conductor_test/api/tests_runner/platform_spec.rb +12 -9
  201. data/spec/hybrid_platforms_conductor_test/api/tests_runner/reports_spec.rb +48 -47
  202. data/spec/hybrid_platforms_conductor_test/api/tests_runner/test_plugins/bitbucket_conf_spec.rb +5 -5
  203. data/spec/hybrid_platforms_conductor_test/api/tests_runner/test_plugins/github_ci_spec.rb +5 -5
  204. data/spec/hybrid_platforms_conductor_test/api/tests_runner/test_reports_plugins/confluence_spec.rb +5 -5
  205. data/spec/hybrid_platforms_conductor_test/cmdb_plugins/test_cmdb.rb +9 -9
  206. data/spec/hybrid_platforms_conductor_test/cmdb_plugins/{test_cmdb2.rb → test_cmdb_2.rb} +6 -6
  207. data/spec/hybrid_platforms_conductor_test/cmdb_plugins/test_cmdb_others.rb +3 -3
  208. data/spec/hybrid_platforms_conductor_test/cmdb_plugins/{test_cmdb_others2.rb → test_cmdb_others_2.rb} +2 -2
  209. data/spec/hybrid_platforms_conductor_test/docs_spec.rb +1 -1
  210. data/spec/hybrid_platforms_conductor_test/executables/{check-node_spec.rb → check_node_spec.rb} +4 -6
  211. data/spec/hybrid_platforms_conductor_test/executables/deploy_spec.rb +4 -6
  212. data/spec/hybrid_platforms_conductor_test/executables/get_impacted_nodes_spec.rb +76 -77
  213. data/spec/hybrid_platforms_conductor_test/executables/last_deploys_spec.rb +159 -113
  214. data/spec/hybrid_platforms_conductor_test/executables/nodes_to_deploy_spec.rb +299 -160
  215. data/spec/hybrid_platforms_conductor_test/executables/options/actions_executor_spec.rb +4 -6
  216. data/spec/hybrid_platforms_conductor_test/executables/options/cmd_runner_spec.rb +3 -5
  217. data/spec/hybrid_platforms_conductor_test/executables/options/common_spec.rb +8 -8
  218. data/spec/hybrid_platforms_conductor_test/executables/options/deployer_spec.rb +12 -196
  219. data/spec/hybrid_platforms_conductor_test/executables/options/nodes_handler_spec.rb +9 -10
  220. data/spec/hybrid_platforms_conductor_test/executables/options/nodes_selectors_spec.rb +9 -10
  221. data/spec/hybrid_platforms_conductor_test/executables/options/reports_handler_spec.rb +1 -1
  222. data/spec/hybrid_platforms_conductor_test/executables/options/tests_runner_spec.rb +22 -22
  223. data/spec/hybrid_platforms_conductor_test/executables/report_spec.rb +22 -16
  224. data/spec/hybrid_platforms_conductor_test/executables/run_spec.rb +32 -32
  225. data/spec/hybrid_platforms_conductor_test/executables/ssh_config_spec.rb +7 -9
  226. data/spec/hybrid_platforms_conductor_test/executables/test_spec.rb +3 -5
  227. data/spec/hybrid_platforms_conductor_test/helpers/actions_executor_helpers.rb +2 -2
  228. data/spec/hybrid_platforms_conductor_test/helpers/cmd_runner_helpers.rb +4 -3
  229. data/spec/hybrid_platforms_conductor_test/helpers/cmdb_helpers.rb +2 -2
  230. data/spec/hybrid_platforms_conductor_test/helpers/config_helpers.rb +1 -1
  231. data/spec/hybrid_platforms_conductor_test/helpers/connector_ssh_helpers.rb +12 -13
  232. data/spec/hybrid_platforms_conductor_test/helpers/deployer_helpers.rb +245 -56
  233. data/spec/hybrid_platforms_conductor_test/helpers/executables_helpers.rb +11 -11
  234. data/spec/hybrid_platforms_conductor_test/helpers/nodes_handler_helpers.rb +1 -1
  235. data/spec/hybrid_platforms_conductor_test/helpers/platforms_handler_helpers.rb +39 -28
  236. data/spec/hybrid_platforms_conductor_test/helpers/plugins_helpers.rb +1 -1
  237. data/spec/hybrid_platforms_conductor_test/helpers/provisioner_proxmox_helpers.rb +86 -111
  238. data/spec/hybrid_platforms_conductor_test/helpers/reports_handler_helpers.rb +1 -1
  239. data/spec/hybrid_platforms_conductor_test/helpers/serverless_chef_helpers.rb +3 -3
  240. data/spec/hybrid_platforms_conductor_test/helpers/services_handler_helpers.rb +1 -1
  241. data/spec/hybrid_platforms_conductor_test/helpers/tests_runner_helpers.rb +1 -1
  242. 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
  243. 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
  244. 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
  245. 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
  246. data/spec/hybrid_platforms_conductor_test/platform_handler_plugins/test.rb +1 -1
  247. data/spec/hybrid_platforms_conductor_test/platform_handler_plugins/{test2.rb → test_2.rb} +0 -0
  248. data/spec/hybrid_platforms_conductor_test/rubocop_spec.rb +31 -0
  249. data/spec/hybrid_platforms_conductor_test/serverless_chef_repositories/1_node/nodes/node.json +3 -3
  250. data/spec/hybrid_platforms_conductor_test/serverless_chef_repositories/data_bags/nodes/node.json +3 -3
  251. data/spec/hybrid_platforms_conductor_test/serverless_chef_repositories/recipes/cookbooks/test_cookbook_2/libraries/default.rb +1 -0
  252. data/spec/hybrid_platforms_conductor_test/serverless_chef_repositories/several_cookbooks/other_cookbooks/test_cookbook_2/libraries/default.rb +1 -0
  253. data/spec/hybrid_platforms_conductor_test/shared_examples/deployer.rb +952 -0
  254. data/spec/hybrid_platforms_conductor_test/test_connector.rb +4 -3
  255. data/spec/hybrid_platforms_conductor_test/test_log_no_read_plugin.rb +84 -0
  256. data/spec/hybrid_platforms_conductor_test/test_log_plugin.rb +105 -0
  257. data/spec/hybrid_platforms_conductor_test/test_plugins/global.rb +1 -0
  258. data/spec/hybrid_platforms_conductor_test/test_plugins/node.rb +1 -0
  259. data/spec/hybrid_platforms_conductor_test/test_plugins/node_check.rb +1 -0
  260. data/spec/hybrid_platforms_conductor_test/test_plugins/platform.rb +1 -0
  261. data/spec/hybrid_platforms_conductor_test/test_plugins/several_checks.rb +2 -2
  262. data/spec/hybrid_platforms_conductor_test/test_secrets_reader_plugin.rb +45 -0
  263. data/spec/hybrid_platforms_conductor_test/tests_report_plugin.rb +5 -6
  264. data/spec/spec_helper.rb +17 -18
  265. data/tools/check_md +16 -20
  266. data/tools/generate_mermaid +1 -1
  267. metadata +194 -144
  268. data/spec/hybrid_platforms_conductor_test/helpers/deployer_test_helpers.rb +0 -916
@@ -2,9 +2,9 @@ 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 resources limits at the PVE node level' do
7
+ context 'when checking resources limits at the PVE node level' do
8
8
 
9
9
  it 'reserves a resource on an empty PVE node having enough resources' do
10
10
  with_sync_node do
@@ -86,12 +86,14 @@ describe HybridPlatformsConductor::HpcPlugins::Provisioner::Proxmox do
86
86
 
87
87
  it 'chooses among several PVE nodes the one having enough resources' do
88
88
  with_sync_node do
89
- mock_proxmox(mocked_pve_nodes: {
90
- 'pve_node_1' => { loadavg: [0.1, 11, 0.1] },
91
- 'pve_node_2' => { memory_total: 1126 * 1024 * 1024 },
92
- 'pve_node_3' => {},
93
- 'pve_node_4' => { storage_total: 512 * 1024 * 1024 }
94
- })
89
+ mock_proxmox(
90
+ mocked_pve_nodes: {
91
+ 'pve_node_1' => { loadavg: [0.1, 11, 0.1] },
92
+ 'pve_node_2' => { memory_total: 1126 * 1024 * 1024 },
93
+ 'pve_node_3' => {},
94
+ 'pve_node_4' => { storage_total: 512 * 1024 * 1024 }
95
+ }
96
+ )
95
97
  expect(call_reserve_proxmox_container(2, 1024, 4, config: { pve_nodes: %w[pve_node_1 pve_node_2 pve_node_3 pve_node_4] })).to eq(
96
98
  pve_node: 'pve_node_3',
97
99
  vm_id: 1000,
@@ -102,12 +104,14 @@ describe HybridPlatformsConductor::HpcPlugins::Provisioner::Proxmox do
102
104
 
103
105
  it 'chooses among several PVE nodes by discovering them instead of limiting them in the config' do
104
106
  with_sync_node do
105
- mock_proxmox(mocked_pve_nodes: {
106
- 'pve_node_1' => { loadavg: [0.1, 11, 0.1] },
107
- 'pve_node_2' => { memory_total: 1126 * 1024 * 1024 },
108
- 'pve_node_3' => {},
109
- 'pve_node_4' => { storage_total: 512 * 1024 * 1024 }
110
- })
107
+ mock_proxmox(
108
+ mocked_pve_nodes: {
109
+ 'pve_node_1' => { loadavg: [0.1, 11, 0.1] },
110
+ 'pve_node_2' => { memory_total: 1126 * 1024 * 1024 },
111
+ 'pve_node_3' => {},
112
+ 'pve_node_4' => { storage_total: 512 * 1024 * 1024 }
113
+ }
114
+ )
111
115
  expect(call_reserve_proxmox_container(2, 1024, 4, config: { pve_nodes: nil })).to eq(
112
116
  pve_node: 'pve_node_3',
113
117
  vm_id: 1000,
@@ -118,13 +122,15 @@ describe HybridPlatformsConductor::HpcPlugins::Provisioner::Proxmox do
118
122
 
119
123
  it 'chooses among several PVE nodes the one having the most free resources' do
120
124
  with_sync_node do
121
- mock_proxmox(mocked_pve_nodes: {
122
- 'pve_node_1gb' => { memory_total: 1 * 1024 * 1024 * 1024 },
123
- 'pve_node_4.5gb' => { memory_total: 4608 * 1024 * 1024 },
124
- 'pve_node_5gb' => { memory_total: 5 * 1024 * 1024 * 1024 },
125
- 'pve_node_10gb' => { memory_total: 10 * 1024 * 1024 * 1024 },
126
- 'pve_node_7gb' => { memory_total: 7 * 1024 * 1024 * 1024 }
127
- })
125
+ mock_proxmox(
126
+ mocked_pve_nodes: {
127
+ 'pve_node_1gb' => { memory_total: 1 * 1024 * 1024 * 1024 },
128
+ 'pve_node_4.5gb' => { memory_total: 4608 * 1024 * 1024 },
129
+ 'pve_node_5gb' => { memory_total: 5 * 1024 * 1024 * 1024 },
130
+ 'pve_node_10gb' => { memory_total: 10 * 1024 * 1024 * 1024 },
131
+ 'pve_node_7gb' => { memory_total: 7 * 1024 * 1024 * 1024 }
132
+ }
133
+ )
128
134
  expect(call_reserve_proxmox_container(2, 4096, 4, config: { pve_nodes: %w[pve_node_1gb pve_node_4.5gb pve_node_5gb pve_node_10gb pve_node_7gb] })).to eq(
129
135
  pve_node: 'pve_node_10gb',
130
136
  vm_id: 1000,
@@ -135,13 +141,15 @@ describe HybridPlatformsConductor::HpcPlugins::Provisioner::Proxmox do
135
141
 
136
142
  it 'chooses among several PVE nodes the one having the most free resources and that are part of the authorized PVE nodes' do
137
143
  with_sync_node do
138
- mock_proxmox(mocked_pve_nodes: {
139
- 'pve_node_1gb' => { memory_total: 1 * 1024 * 1024 * 1024 },
140
- 'pve_node_4.5gb' => { memory_total: 4608 * 1024 * 1024 },
141
- 'pve_node_5gb' => { memory_total: 5 * 1024 * 1024 * 1024 },
142
- 'pve_node_10gb' => { memory_total: 10 * 1024 * 1024 * 1024 },
143
- 'pve_node_7gb' => { memory_total: 7 * 1024 * 1024 * 1024 }
144
- })
144
+ mock_proxmox(
145
+ mocked_pve_nodes: {
146
+ 'pve_node_1gb' => { memory_total: 1 * 1024 * 1024 * 1024 },
147
+ 'pve_node_4.5gb' => { memory_total: 4608 * 1024 * 1024 },
148
+ 'pve_node_5gb' => { memory_total: 5 * 1024 * 1024 * 1024 },
149
+ 'pve_node_10gb' => { memory_total: 10 * 1024 * 1024 * 1024 },
150
+ 'pve_node_7gb' => { memory_total: 7 * 1024 * 1024 * 1024 }
151
+ }
152
+ )
145
153
  expect(call_reserve_proxmox_container(2, 4096, 4, config: { pve_nodes: %w[pve_node_1gb pve_node_5gb pve_node_7gb] })).to eq(
146
154
  pve_node: 'pve_node_7gb',
147
155
  vm_id: 1000,
@@ -152,13 +160,15 @@ describe HybridPlatformsConductor::HpcPlugins::Provisioner::Proxmox do
152
160
 
153
161
  it 'does not reserve a resource if the only PVE nodes having resources are not in the list of authorized PVE nodes' do
154
162
  with_sync_node do
155
- mock_proxmox(mocked_pve_nodes: {
156
- 'pve_node_1gb' => { memory_total: 1 * 1024 * 1024 * 1024 },
157
- 'pve_node_4.5gb' => { memory_total: 4608 * 1024 * 1024 },
158
- 'pve_node_5gb' => { memory_total: 5 * 1024 * 1024 * 1024 },
159
- 'pve_node_10gb' => { memory_total: 10 * 1024 * 1024 * 1024 },
160
- 'pve_node_7gb' => { memory_total: 7 * 1024 * 1024 * 1024 }
161
- })
163
+ mock_proxmox(
164
+ mocked_pve_nodes: {
165
+ 'pve_node_1gb' => { memory_total: 1 * 1024 * 1024 * 1024 },
166
+ 'pve_node_4.5gb' => { memory_total: 4608 * 1024 * 1024 },
167
+ 'pve_node_5gb' => { memory_total: 5 * 1024 * 1024 * 1024 },
168
+ 'pve_node_10gb' => { memory_total: 10 * 1024 * 1024 * 1024 },
169
+ 'pve_node_7gb' => { memory_total: 7 * 1024 * 1024 * 1024 }
170
+ }
171
+ )
162
172
  expect(call_reserve_proxmox_container(2, 4096, 4, config: { pve_nodes: %w[pve_node_1gb pve_node_4.5gb] })).to eq(error: 'not_enough_resources')
163
173
  end
164
174
  end
@@ -167,25 +177,32 @@ describe HybridPlatformsConductor::HpcPlugins::Provisioner::Proxmox do
167
177
  with_sync_node do
168
178
  # We ask to reserve 1GB of RAM and 1GB of disk.
169
179
  # Commented are the % of those resources' usage when having such a container in each PVE node, with the resulting score considering RAM 3 times as important than disk.
170
- mock_proxmox(mocked_pve_nodes: {
171
- # 100% RAM 25% disk => 325
172
- 'pve_node_1gb_4gb' => { memory_total: 1 * 1024 * 1024 * 1024, storage_total: 4 * 1024 * 1024 * 1024 },
173
- # 50% RAM 25% disk => 175
174
- 'pve_node_2gb_4gb' => { memory_total: 2 * 1024 * 1024 * 1024, storage_total: 4 * 1024 * 1024 * 1024 },
175
- # 50% RAM 50% disk => 200
176
- 'pve_node_2gb_2gb' => { memory_total: 2 * 1024 * 1024 * 1024, storage_total: 2 * 1024 * 1024 * 1024 },
177
- # 40% RAM 10% disk => 130
178
- 'pve_node_2.5gb_10gb' => { memory_total: 2560 * 1024 * 1024, storage_total: 10 * 1024 * 1024 * 1024 },
179
- # 25% RAM 50% disk => 125
180
- 'pve_node_4gb_2gb' => { memory_total: 4 * 1024 * 1024 * 1024, storage_total: 2 * 1024 * 1024 * 1024 },
181
- # 25% RAM 100% disk => 175
182
- 'pve_node_4gb_1gb' => { memory_total: 4 * 1024 * 1024 * 1024, storage_total: 1 * 1024 * 1024 * 1024 }
183
- })
184
- expect(call_reserve_proxmox_container(2, 1024, 1, config: {
185
- coeff_ram_consumption: 3,
186
- coeff_disk_consumption: 1,
187
- pve_nodes: nil
188
- })).to eq(
180
+ mock_proxmox(
181
+ mocked_pve_nodes: {
182
+ # 100% RAM 25% disk => 325
183
+ 'pve_node_1gb_4gb' => { memory_total: 1 * 1024 * 1024 * 1024, storage_total: 4 * 1024 * 1024 * 1024 },
184
+ # 50% RAM 25% disk => 175
185
+ 'pve_node_2gb_4gb' => { memory_total: 2 * 1024 * 1024 * 1024, storage_total: 4 * 1024 * 1024 * 1024 },
186
+ # 50% RAM 50% disk => 200
187
+ 'pve_node_2gb_2gb' => { memory_total: 2 * 1024 * 1024 * 1024, storage_total: 2 * 1024 * 1024 * 1024 },
188
+ # 40% RAM 10% disk => 130
189
+ 'pve_node_2.5gb_10gb' => { memory_total: 2560 * 1024 * 1024, storage_total: 10 * 1024 * 1024 * 1024 },
190
+ # 25% RAM 50% disk => 125
191
+ 'pve_node_4gb_2gb' => { memory_total: 4 * 1024 * 1024 * 1024, storage_total: 2 * 1024 * 1024 * 1024 },
192
+ # 25% RAM 100% disk => 175
193
+ 'pve_node_4gb_1gb' => { memory_total: 4 * 1024 * 1024 * 1024, storage_total: 1 * 1024 * 1024 * 1024 }
194
+ }
195
+ )
196
+ expect(
197
+ call_reserve_proxmox_container(
198
+ 2, 1024, 1,
199
+ config: {
200
+ coeff_ram_consumption: 3,
201
+ coeff_disk_consumption: 1,
202
+ pve_nodes: nil
203
+ }
204
+ )
205
+ ).to eq(
189
206
  pve_node: 'pve_node_4gb_2gb',
190
207
  vm_id: 1000,
191
208
  vm_ip: '192.168.0.100'
@@ -2,9 +2,9 @@ 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 retries mechanism' do
7
+ context 'when checking retries mechanism' do
8
8
 
9
9
  it 'retries a few times before ending in error' do
10
10
  with_sync_node do
@@ -16,11 +16,13 @@ describe HybridPlatformsConductor::HpcPlugins::Provisioner::Proxmox do
16
16
 
17
17
  it 'retries errors a few times until it gets resolved' do
18
18
  with_sync_node do
19
- mock_proxmox(mocked_pve_nodes: [
20
- { 'pve_node_name' => { loadavg: [0.1, 11, 0.1] } },
21
- { 'pve_node_name' => { loadavg: [0.1, 11, 0.1] } },
22
- { 'pve_node_name' => { loadavg: [0.1, 9, 0.1] } }
23
- ])
19
+ mock_proxmox(
20
+ mocked_pve_nodes: [
21
+ { 'pve_node_name' => { loadavg: [0.1, 11, 0.1] } },
22
+ { 'pve_node_name' => { loadavg: [0.1, 11, 0.1] } },
23
+ { 'pve_node_name' => { loadavg: [0.1, 9, 0.1] } }
24
+ ]
25
+ )
24
26
  expect(call_reserve_proxmox_container(2, 1024, 4, max_retries: 5)).to eq(
25
27
  pve_node: 'pve_node_name',
26
28
  vm_id: 1000,
@@ -51,7 +53,7 @@ describe HybridPlatformsConductor::HpcPlugins::Provisioner::Proxmox do
51
53
  mock_proxmox(mocked_pve_nodes: [{ 'pve_node_name' => { error_strings: ['NOK: error code = 500'] * 5 } }])
52
54
  result = call_reserve_proxmox_container(2, 1024, 4, config: { api_max_retries: 4 })
53
55
  expect(result[:error]).not_to eq nil
54
- expect(result[:error]).to match /Unhandled exception from reserve_proxmox_container: Proxmox API get nodes\/pve_node_name\/lxc returns NOK: error code = 500 continuously \(tried 5 times\)/
56
+ expect(result[:error]).to match(%r{Unhandled exception from reserve_proxmox_container: Proxmox API get nodes/pve_node_name/lxc returns NOK: error code = 500 continuously \(tried 5 times\)})
55
57
  expect_proxmox_actions_to_be [
56
58
  [:create_ticket],
57
59
  [:create_ticket],
@@ -2,20 +2,22 @@ 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 how VM IDs are being assigned to containers' do
7
+ context 'when checking how VM IDs are being assigned to containers' do
8
8
 
9
9
  it 'makes sure to not use a VM ID already assigned to another container' do
10
10
  with_sync_node do
11
- mock_proxmox(mocked_pve_nodes: {
12
- 'pve_node_name' => {
13
- lxc_containers: {
14
- 1000 => { ip: '192.168.1.100' },
15
- 1001 => { ip: '192.168.1.101' }
11
+ mock_proxmox(
12
+ mocked_pve_nodes: {
13
+ 'pve_node_name' => {
14
+ lxc_containers: {
15
+ 1000 => { ip: '192.168.1.100' },
16
+ 1001 => { ip: '192.168.1.101' }
17
+ }
16
18
  }
17
19
  }
18
- })
20
+ )
19
21
  expect(call_reserve_proxmox_container(2, 1024, 1, config: { vm_ids_range: [1000, 1100] })).to eq(
20
22
  pve_node: 'pve_node_name',
21
23
  vm_id: 1002,
@@ -26,15 +28,17 @@ describe HybridPlatformsConductor::HpcPlugins::Provisioner::Proxmox do
26
28
 
27
29
  it 'makes sure to not use a VM ID already assigned to another container even on another PVE node' do
28
30
  with_sync_node do
29
- mock_proxmox(mocked_pve_nodes: {
30
- 'pve_node_name' => {},
31
- 'pve_other_node_name' => {
32
- lxc_containers: {
33
- 1000 => { ip: '192.168.1.100' },
34
- 1001 => { ip: '192.168.1.101' }
31
+ mock_proxmox(
32
+ mocked_pve_nodes: {
33
+ 'pve_node_name' => {},
34
+ 'pve_other_node_name' => {
35
+ lxc_containers: {
36
+ 1000 => { ip: '192.168.1.100' },
37
+ 1001 => { ip: '192.168.1.101' }
38
+ }
35
39
  }
36
40
  }
37
- })
41
+ )
38
42
  expect(call_reserve_proxmox_container(2, 1024, 1, config: { vm_ids_range: [1000, 1100] })).to eq(
39
43
  pve_node: 'pve_node_name',
40
44
  vm_id: 1002,
@@ -45,33 +49,39 @@ describe HybridPlatformsConductor::HpcPlugins::Provisioner::Proxmox do
45
49
 
46
50
  it 'does not reserve when no VM ID is available' do
47
51
  with_sync_node do
48
- mock_proxmox(mocked_pve_nodes: {
49
- 'pve_node_name' => {},
50
- 'pve_other_node_name' => {
51
- lxc_containers: {
52
- 1000 => { ip: '192.168.1.100' },
53
- 1001 => { ip: '192.168.1.101' },
54
- 1002 => { ip: '192.168.1.102' },
55
- 1003 => { ip: '192.168.1.103' }
52
+ mock_proxmox(
53
+ mocked_pve_nodes: {
54
+ 'pve_node_name' => {},
55
+ 'pve_other_node_name' => {
56
+ lxc_containers: {
57
+ 1000 => { ip: '192.168.1.100' },
58
+ 1001 => { ip: '192.168.1.101' },
59
+ 1002 => { ip: '192.168.1.102' },
60
+ 1003 => { ip: '192.168.1.103' }
61
+ }
56
62
  }
57
63
  }
58
- })
64
+ )
59
65
  expect(call_reserve_proxmox_container(2, 1024, 1, config: { vm_ids_range: [1000, 1002] })).to eq(error: 'no_available_vm_id')
60
66
  end
61
67
  end
62
68
 
63
69
  it 'makes sure to remove cgroup files that are leftovers of removed containers' do
64
- with_sync_node(leftovers: [
65
- '/sys/fs/cgroup/memory/lxc/1003'
66
- ]) do
67
- mock_proxmox(mocked_pve_nodes: {
68
- 'pve_node_name' => {
69
- lxc_containers: {
70
- 1000 => { ip: '192.168.1.100' },
71
- 1001 => { ip: '192.168.1.101' }
70
+ with_sync_node(
71
+ leftovers: [
72
+ '/sys/fs/cgroup/memory/lxc/1003'
73
+ ]
74
+ ) do
75
+ mock_proxmox(
76
+ mocked_pve_nodes: {
77
+ 'pve_node_name' => {
78
+ lxc_containers: {
79
+ 1000 => { ip: '192.168.1.100' },
80
+ 1001 => { ip: '192.168.1.101' }
81
+ }
72
82
  }
73
83
  }
74
- })
84
+ )
75
85
  expect(call_reserve_proxmox_container(2, 1024, 1, config: { vm_ids_range: [1000, 1100] })).to eq(
76
86
  pve_node: 'pve_node_name',
77
87
  vm_id: 1002,
@@ -81,17 +91,21 @@ describe HybridPlatformsConductor::HpcPlugins::Provisioner::Proxmox do
81
91
  end
82
92
 
83
93
  it 'makes sure to remove cgroup files that are leftovers of removed containers even when they are reusing the VM ID' do
84
- with_sync_node(leftovers: [
85
- '/sys/fs/cgroup/memory/lxc/1002'
86
- ]) do
87
- mock_proxmox(mocked_pve_nodes: {
88
- 'pve_node_name' => {
89
- lxc_containers: {
90
- 1000 => { ip: '192.168.1.100' },
91
- 1001 => { ip: '192.168.1.101' }
94
+ with_sync_node(
95
+ leftovers: [
96
+ '/sys/fs/cgroup/memory/lxc/1002'
97
+ ]
98
+ ) do
99
+ mock_proxmox(
100
+ mocked_pve_nodes: {
101
+ 'pve_node_name' => {
102
+ lxc_containers: {
103
+ 1000 => { ip: '192.168.1.100' },
104
+ 1001 => { ip: '192.168.1.101' }
105
+ }
92
106
  }
93
107
  }
94
- })
108
+ )
95
109
  expect(call_reserve_proxmox_container(2, 1024, 1, config: { vm_ids_range: [1000, 1100] })).to eq(
96
110
  pve_node: 'pve_node_name',
97
111
  vm_id: 1002,
@@ -101,19 +115,23 @@ describe HybridPlatformsConductor::HpcPlugins::Provisioner::Proxmox do
101
115
  end
102
116
 
103
117
  it 'makes sure to remove cgroup files that are leftovers of removed containers when several cgroups contain files' do
104
- with_sync_node(leftovers: [
105
- '/sys/fs/cgroup/memory/lxc/1003',
106
- '/sys/fs/cgroup/network/lxc/1003',
107
- '/sys/fs/cgroup/cpu/lxc/1003'
108
- ]) do
109
- mock_proxmox(mocked_pve_nodes: {
110
- 'pve_node_name' => {
111
- lxc_containers: {
112
- 1000 => { ip: '192.168.1.100' },
113
- 1001 => { ip: '192.168.1.101' }
118
+ with_sync_node(
119
+ leftovers: [
120
+ '/sys/fs/cgroup/memory/lxc/1003',
121
+ '/sys/fs/cgroup/network/lxc/1003',
122
+ '/sys/fs/cgroup/cpu/lxc/1003'
123
+ ]
124
+ ) do
125
+ mock_proxmox(
126
+ mocked_pve_nodes: {
127
+ 'pve_node_name' => {
128
+ lxc_containers: {
129
+ 1000 => { ip: '192.168.1.100' },
130
+ 1001 => { ip: '192.168.1.101' }
131
+ }
114
132
  }
115
133
  }
116
- })
134
+ )
117
135
  expect(call_reserve_proxmox_container(2, 1024, 1, config: { vm_ids_range: [1000, 1100] })).to eq(
118
136
  pve_node: 'pve_node_name',
119
137
  vm_id: 1002,
@@ -135,15 +153,17 @@ describe HybridPlatformsConductor::HpcPlugins::Provisioner::Proxmox do
135
153
  '/sys/fs/cgroup/memory/lxc/1001'
136
154
  ]
137
155
  ) do
138
- mock_proxmox(mocked_pve_nodes: {
139
- 'pve_node_name' => {
140
- lxc_containers: {
141
- 100 => { ip: '192.168.1.10' },
142
- 1000 => { ip: '192.168.1.100' },
143
- 1001 => { ip: '192.168.1.101' }
156
+ mock_proxmox(
157
+ mocked_pve_nodes: {
158
+ 'pve_node_name' => {
159
+ lxc_containers: {
160
+ 100 => { ip: '192.168.1.10' },
161
+ 1000 => { ip: '192.168.1.100' },
162
+ 1001 => { ip: '192.168.1.101' }
163
+ }
144
164
  }
145
165
  }
146
- })
166
+ )
147
167
  expect(call_reserve_proxmox_container(2, 1024, 1, config: { vm_ids_range: [1000, 1100] })).to eq(
148
168
  pve_node: 'pve_node_name',
149
169
  vm_id: 1002,
@@ -2,7 +2,7 @@ require 'hybrid_platforms_conductor/hpc_plugins/provisioner/proxmox'
2
2
 
3
3
  describe HybridPlatformsConductor::HpcPlugins::Provisioner::Proxmox do
4
4
 
5
- context 'checking containers start' do
5
+ context 'when checking containers start' do
6
6
 
7
7
  it 'starts an instance' do
8
8
  with_test_proxmox_platform do |instance|
@@ -2,7 +2,7 @@ require 'hybrid_platforms_conductor/hpc_plugins/provisioner/proxmox'
2
2
 
3
3
  describe HybridPlatformsConductor::HpcPlugins::Provisioner::Proxmox do
4
4
 
5
- context 'checking containers state' do
5
+ context 'when checking containers state' do
6
6
 
7
7
  it 'gets the status of a missing instance' do
8
8
  with_test_proxmox_platform do |instance|
@@ -2,7 +2,7 @@ require 'hybrid_platforms_conductor/hpc_plugins/provisioner/proxmox'
2
2
 
3
3
  describe HybridPlatformsConductor::HpcPlugins::Provisioner::Proxmox do
4
4
 
5
- context 'checking containers stop' do
5
+ context 'when checking containers stop' do
6
6
 
7
7
  it 'stops an instance' do
8
8
  with_test_proxmox_platform do |instance|
@@ -0,0 +1,64 @@
1
+ describe HybridPlatformsConductor::Deployer do
2
+
3
+ context 'when checking secrets_reader plugins' do
4
+
5
+ context 'with cli' do
6
+
7
+ # Setup a platform for tests
8
+ #
9
+ # Parameters::
10
+ # * *block* (Proc): Code called when the platform is setup
11
+ # * Parameters::
12
+ # * *repository* (String): Platform's repository
13
+ def with_test_platform_for_cli_test(&block)
14
+ with_test_platform(
15
+ {
16
+ nodes: { 'node' => { services: %w[service] } },
17
+ deployable_services: %w[service]
18
+ },
19
+ additional_config: 'read_secrets_from :cli',
20
+ &block
21
+ )
22
+ end
23
+
24
+ it 'gets secrets from a file' do
25
+ with_test_platform_for_cli_test do |repository|
26
+ secrets_file = "#{repository}/my_secrets.json"
27
+ File.write(secrets_file, '{ "secret_name": "secret_value" }')
28
+ expect(test_services_handler).to receive(:package).with(
29
+ services: { 'node' => %w[service] },
30
+ secrets: { 'secret_name' => 'secret_value' },
31
+ local_environment: false
32
+ ) { raise 'Abort as testing secrets is enough' }
33
+ expect { run 'deploy', '--node', 'node', '--secrets', secrets_file }.to raise_error 'Abort as testing secrets is enough'
34
+ end
35
+ end
36
+
37
+ it 'gets secrets from several files' do
38
+ with_test_platform_for_cli_test do |repository|
39
+ secrets_file_1 = "#{repository}/my_secrets1.json"
40
+ File.write(secrets_file_1, '{ "secret1": "value1" }')
41
+ secrets_file_2 = "#{repository}/my_secrets2.json"
42
+ File.write(secrets_file_2, '{ "secret2": "value2" }')
43
+ expect(test_services_handler).to receive(:package).with(
44
+ services: { 'node' => %w[service] },
45
+ secrets: { 'secret1' => 'value1', 'secret2' => 'value2' },
46
+ local_environment: false
47
+ ) { raise 'Abort as testing secrets is enough' }
48
+ expect { run 'deploy', '--node', 'node', '--secrets', secrets_file_1, '--secrets', secrets_file_2 }.to raise_error 'Abort as testing secrets is enough'
49
+ end
50
+ end
51
+
52
+ it 'fails to get secrets from a missing file' do
53
+ with_test_platform_for_cli_test do
54
+ expect do
55
+ run 'deploy', '--node', 'node', '--secrets', 'unknown_file.json'
56
+ end.to raise_error 'Missing secrets file: unknown_file.json'
57
+ end
58
+ end
59
+
60
+ end
61
+
62
+ end
63
+
64
+ end