hybrid_platforms_conductor 32.17.0 → 33.0.2

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 (283) 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/connector/ssh.md +1 -1
  31. data/docs/plugins/log/remote_fs.md +26 -0
  32. data/docs/plugins/secrets_reader/cli.md +31 -0
  33. data/docs/plugins/secrets_reader/thycotic.md +46 -0
  34. data/docs/plugins/test/check_deploy_and_idempotence.md +1 -1
  35. data/docs/plugins/test/connection.md +1 -0
  36. data/docs/plugins/test/deploy_removes_root_access.md +1 -1
  37. data/docs/plugins/test/file_system.md +1 -0
  38. data/docs/plugins/test/hostname.md +1 -0
  39. data/docs/plugins/test/ip.md +1 -0
  40. data/docs/plugins/test/local_users.md +1 -0
  41. data/docs/plugins/test/mounts.md +1 -0
  42. data/docs/plugins/test/orphan_files.md +1 -0
  43. data/docs/plugins/test/ports.md +1 -0
  44. data/docs/plugins/test/spectre.md +1 -0
  45. data/docs/plugins/test/vulnerabilities.md +1 -0
  46. data/lib/hybrid_platforms_conductor/action.rb +4 -4
  47. data/lib/hybrid_platforms_conductor/actions_executor.rb +45 -43
  48. data/lib/hybrid_platforms_conductor/bitbucket.rb +5 -4
  49. data/lib/hybrid_platforms_conductor/cmd_runner.rb +13 -12
  50. data/lib/hybrid_platforms_conductor/cmdb.rb +2 -2
  51. data/lib/hybrid_platforms_conductor/common_config_dsl/bitbucket.rb +2 -1
  52. data/lib/hybrid_platforms_conductor/common_config_dsl/confluence.rb +2 -1
  53. data/lib/hybrid_platforms_conductor/common_config_dsl/file_system_tests.rb +5 -4
  54. data/lib/hybrid_platforms_conductor/common_config_dsl/github.rb +4 -3
  55. data/lib/hybrid_platforms_conductor/common_config_dsl/idempotence_tests.rb +2 -2
  56. data/lib/hybrid_platforms_conductor/config.rb +8 -4
  57. data/lib/hybrid_platforms_conductor/confluence.rb +1 -1
  58. data/lib/hybrid_platforms_conductor/connector.rb +5 -2
  59. data/lib/hybrid_platforms_conductor/core_extensions/cleanroom/fix_kwargs.rb +116 -0
  60. data/lib/hybrid_platforms_conductor/core_extensions/symbol/zero.rb +24 -0
  61. data/lib/hybrid_platforms_conductor/credentials.rb +39 -36
  62. data/lib/hybrid_platforms_conductor/current_dir_monitor.rb +4 -1
  63. data/lib/hybrid_platforms_conductor/deployer.rb +275 -224
  64. data/lib/hybrid_platforms_conductor/executable.rb +20 -15
  65. data/lib/hybrid_platforms_conductor/hpc_plugins/cmdb/config.rb +10 -7
  66. data/lib/hybrid_platforms_conductor/hpc_plugins/cmdb/host_ip.rb +1 -1
  67. data/lib/hybrid_platforms_conductor/hpc_plugins/cmdb/host_keys.rb +2 -2
  68. data/lib/hybrid_platforms_conductor/hpc_plugins/cmdb/platform_handlers.rb +4 -4
  69. data/lib/hybrid_platforms_conductor/hpc_plugins/connector/local.rb +2 -0
  70. data/lib/hybrid_platforms_conductor/hpc_plugins/connector/ssh.rb +45 -49
  71. data/lib/hybrid_platforms_conductor/hpc_plugins/log/my_log_plugin.rb.sample +100 -0
  72. data/lib/hybrid_platforms_conductor/hpc_plugins/log/remote_fs.rb +180 -0
  73. data/lib/hybrid_platforms_conductor/hpc_plugins/platform_handler/serverless_chef.rb +68 -66
  74. data/lib/hybrid_platforms_conductor/hpc_plugins/platform_handler/serverless_chef/dsl_parser.rb +13 -0
  75. data/lib/hybrid_platforms_conductor/hpc_plugins/platform_handler/serverless_chef/recipes_tree_builder.rb +39 -38
  76. data/lib/hybrid_platforms_conductor/hpc_plugins/platform_handler/yaml_inventory.rb +5 -4
  77. data/lib/hybrid_platforms_conductor/hpc_plugins/provisioner/docker.rb +43 -45
  78. data/lib/hybrid_platforms_conductor/hpc_plugins/provisioner/podman.rb +18 -20
  79. data/lib/hybrid_platforms_conductor/hpc_plugins/provisioner/proxmox.rb +118 -117
  80. data/lib/hybrid_platforms_conductor/hpc_plugins/provisioner/proxmox/proxmox_waiter.rb +39 -43
  81. data/lib/hybrid_platforms_conductor/hpc_plugins/provisioner/proxmox/reserve_proxmox_container +9 -13
  82. data/lib/hybrid_platforms_conductor/hpc_plugins/report/confluence.rb +2 -2
  83. data/lib/hybrid_platforms_conductor/hpc_plugins/report/mediawiki.rb +28 -21
  84. data/lib/hybrid_platforms_conductor/hpc_plugins/report/stdout.rb +26 -22
  85. data/lib/hybrid_platforms_conductor/hpc_plugins/secrets_reader/cli.rb +77 -0
  86. data/lib/hybrid_platforms_conductor/hpc_plugins/secrets_reader/my_secrets_reader_plugin.rb.sample +46 -0
  87. data/lib/hybrid_platforms_conductor/hpc_plugins/secrets_reader/thycotic.rb +90 -0
  88. data/lib/hybrid_platforms_conductor/hpc_plugins/test/bitbucket_conf.rb +3 -3
  89. data/lib/hybrid_platforms_conductor/hpc_plugins/test/check_deploy_and_idempotence.rb +4 -2
  90. data/lib/hybrid_platforms_conductor/hpc_plugins/test/connection.rb +3 -1
  91. data/lib/hybrid_platforms_conductor/hpc_plugins/test/deploy_freshness.rb +7 -21
  92. data/lib/hybrid_platforms_conductor/hpc_plugins/test/deploy_removes_root_access.rb +21 -19
  93. data/lib/hybrid_platforms_conductor/hpc_plugins/test/divergence.rb +2 -2
  94. data/lib/hybrid_platforms_conductor/hpc_plugins/test/executables.rb +2 -2
  95. data/lib/hybrid_platforms_conductor/hpc_plugins/test/file_system.rb +21 -22
  96. data/lib/hybrid_platforms_conductor/hpc_plugins/test/file_system_hdfs.rb +19 -21
  97. data/lib/hybrid_platforms_conductor/hpc_plugins/test/github_ci.rb +2 -3
  98. data/lib/hybrid_platforms_conductor/hpc_plugins/test/hostname.rb +3 -1
  99. data/lib/hybrid_platforms_conductor/hpc_plugins/test/idempotence.rb +2 -2
  100. data/lib/hybrid_platforms_conductor/hpc_plugins/test/ip.rb +4 -2
  101. data/lib/hybrid_platforms_conductor/hpc_plugins/test/jenkins_ci_conf.rb +21 -22
  102. data/lib/hybrid_platforms_conductor/hpc_plugins/test/jenkins_ci_masters_ok.rb +10 -12
  103. data/lib/hybrid_platforms_conductor/hpc_plugins/test/linear_strategy.rb +9 -9
  104. data/lib/hybrid_platforms_conductor/hpc_plugins/test/local_users.rb +5 -3
  105. data/lib/hybrid_platforms_conductor/hpc_plugins/test/mounts.rb +5 -3
  106. data/lib/hybrid_platforms_conductor/hpc_plugins/test/orphan_files.rb +13 -10
  107. data/lib/hybrid_platforms_conductor/hpc_plugins/test/ports.rb +5 -3
  108. data/lib/hybrid_platforms_conductor/hpc_plugins/test/private_ips.rb +5 -5
  109. data/lib/hybrid_platforms_conductor/hpc_plugins/test/public_ips.rb +5 -5
  110. data/lib/hybrid_platforms_conductor/hpc_plugins/test/spectre.rb +7 -7
  111. data/lib/hybrid_platforms_conductor/hpc_plugins/test/veids.rb +3 -3
  112. data/lib/hybrid_platforms_conductor/hpc_plugins/test/vulnerabilities.rb +27 -25
  113. data/lib/hybrid_platforms_conductor/hpc_plugins/test_report/confluence.rb +2 -2
  114. data/lib/hybrid_platforms_conductor/hpc_plugins/test_report/stdout.rb +8 -6
  115. data/lib/hybrid_platforms_conductor/io_router.rb +14 -13
  116. data/lib/hybrid_platforms_conductor/json_dumper.rb +2 -2
  117. data/lib/hybrid_platforms_conductor/log.rb +31 -0
  118. data/lib/hybrid_platforms_conductor/logger_helpers.rb +19 -16
  119. data/lib/hybrid_platforms_conductor/nodes_handler.rb +89 -71
  120. data/lib/hybrid_platforms_conductor/parallel_threads.rb +7 -11
  121. data/lib/hybrid_platforms_conductor/platform_handler.rb +7 -7
  122. data/lib/hybrid_platforms_conductor/platforms_handler.rb +5 -3
  123. data/lib/hybrid_platforms_conductor/plugin.rb +2 -2
  124. data/lib/hybrid_platforms_conductor/plugins.rb +14 -8
  125. data/lib/hybrid_platforms_conductor/provisioner.rb +4 -4
  126. data/lib/hybrid_platforms_conductor/report.rb +2 -2
  127. data/lib/hybrid_platforms_conductor/reports_handler.rb +3 -2
  128. data/lib/hybrid_platforms_conductor/secrets_reader.rb +31 -0
  129. data/lib/hybrid_platforms_conductor/services_handler.rb +32 -29
  130. data/lib/hybrid_platforms_conductor/test_only_remote_node.rb +18 -0
  131. data/lib/hybrid_platforms_conductor/test_report.rb +15 -18
  132. data/lib/hybrid_platforms_conductor/tests_runner.rb +116 -118
  133. data/lib/hybrid_platforms_conductor/thycotic.rb +28 -19
  134. data/lib/hybrid_platforms_conductor/topographer.rb +200 -190
  135. data/lib/hybrid_platforms_conductor/topographer/plugins/graphviz.rb +8 -8
  136. data/lib/hybrid_platforms_conductor/topographer/plugins/json.rb +4 -4
  137. data/lib/hybrid_platforms_conductor/version.rb +1 -1
  138. data/spec/hybrid_platforms_conductor_test.rb +33 -12
  139. data/spec/hybrid_platforms_conductor_test/api/actions_executor/actions/bash_spec.rb +18 -11
  140. data/spec/hybrid_platforms_conductor_test/api/actions_executor/actions/interactive_spec.rb +2 -2
  141. data/spec/hybrid_platforms_conductor_test/api/actions_executor/actions/remote_bash_spec.rb +32 -21
  142. data/spec/hybrid_platforms_conductor_test/api/actions_executor/actions/ruby_spec.rb +75 -49
  143. data/spec/hybrid_platforms_conductor_test/api/actions_executor/actions/scp_spec.rb +27 -15
  144. data/spec/hybrid_platforms_conductor_test/api/actions_executor/actions_spec.rb +90 -59
  145. data/spec/hybrid_platforms_conductor_test/api/actions_executor/connection_spec.rb +46 -44
  146. data/spec/hybrid_platforms_conductor_test/api/actions_executor/connectors/local/connectable_nodes_spec.rb +12 -8
  147. data/spec/hybrid_platforms_conductor_test/api/actions_executor/connectors/local/remote_actions_spec.rb +4 -7
  148. data/spec/hybrid_platforms_conductor_test/api/actions_executor/connectors/ssh/cli_options_spec.rb +21 -22
  149. data/spec/hybrid_platforms_conductor_test/api/actions_executor/connectors/ssh/config_dsl_spec.rb +23 -24
  150. data/spec/hybrid_platforms_conductor_test/api/actions_executor/connectors/ssh/connectable_nodes_spec.rb +10 -6
  151. data/spec/hybrid_platforms_conductor_test/api/actions_executor/connectors/ssh/connections_spec.rb +106 -75
  152. data/spec/hybrid_platforms_conductor_test/api/actions_executor/connectors/ssh/global_helpers_spec.rb +145 -126
  153. data/spec/hybrid_platforms_conductor_test/api/actions_executor/connectors/ssh/node_helpers_spec.rb +3 -3
  154. data/spec/hybrid_platforms_conductor_test/api/actions_executor/connectors/ssh/remote_actions_spec.rb +29 -25
  155. data/spec/hybrid_platforms_conductor_test/api/actions_executor/logging_spec.rb +167 -142
  156. data/spec/hybrid_platforms_conductor_test/api/actions_executor/parallel_spec.rb +272 -244
  157. data/spec/hybrid_platforms_conductor_test/api/actions_executor/timeout_spec.rb +16 -16
  158. data/spec/hybrid_platforms_conductor_test/api/cmd_runner_spec.rb +36 -36
  159. data/spec/hybrid_platforms_conductor_test/api/config_spec.rb +24 -22
  160. data/spec/hybrid_platforms_conductor_test/api/deployer/check_spec.rb +4 -2
  161. data/spec/hybrid_platforms_conductor_test/api/deployer/config_dsl_spec.rb +43 -5
  162. data/spec/hybrid_platforms_conductor_test/api/deployer/deploy_spec.rb +199 -216
  163. data/spec/hybrid_platforms_conductor_test/api/deployer/log_plugins/remote_fs_spec.rb +223 -0
  164. data/spec/hybrid_platforms_conductor_test/api/deployer/parse_deploy_output_spec.rb +55 -59
  165. data/spec/hybrid_platforms_conductor_test/api/deployer/provisioner_spec.rb +36 -62
  166. data/spec/hybrid_platforms_conductor_test/api/deployer/provisioners/podman_spec.rb +17 -17
  167. data/spec/hybrid_platforms_conductor_test/api/deployer/provisioners/proxmox/config_dsl_spec.rb +4 -4
  168. data/spec/hybrid_platforms_conductor_test/api/deployer/provisioners/proxmox/create_spec.rb +44 -51
  169. data/spec/hybrid_platforms_conductor_test/api/deployer/provisioners/proxmox/destroy_spec.rb +3 -3
  170. data/spec/hybrid_platforms_conductor_test/api/deployer/provisioners/proxmox/ip_spec.rb +12 -16
  171. data/spec/hybrid_platforms_conductor_test/api/deployer/provisioners/proxmox/reserve_proxmox_container/destroy_vm_spec.rb +31 -19
  172. data/spec/hybrid_platforms_conductor_test/api/deployer/provisioners/proxmox/reserve_proxmox_container/expired_containers_spec.rb +324 -266
  173. data/spec/hybrid_platforms_conductor_test/api/deployer/provisioners/proxmox/reserve_proxmox_container/ips_assignment_spec.rb +89 -61
  174. data/spec/hybrid_platforms_conductor_test/api/deployer/provisioners/proxmox/reserve_proxmox_container/other_lxc_containers_resources_spec.rb +117 -93
  175. data/spec/hybrid_platforms_conductor_test/api/deployer/provisioners/proxmox/reserve_proxmox_container/pve_node_resources_spec.rb +71 -54
  176. data/spec/hybrid_platforms_conductor_test/api/deployer/provisioners/proxmox/reserve_proxmox_container/retries_spec.rb +10 -8
  177. data/spec/hybrid_platforms_conductor_test/api/deployer/provisioners/proxmox/reserve_proxmox_container/vm_ids_assignment_spec.rb +80 -60
  178. data/spec/hybrid_platforms_conductor_test/api/deployer/provisioners/proxmox/start_spec.rb +1 -1
  179. data/spec/hybrid_platforms_conductor_test/api/deployer/provisioners/proxmox/state_spec.rb +1 -1
  180. data/spec/hybrid_platforms_conductor_test/api/deployer/provisioners/proxmox/stop_spec.rb +1 -1
  181. data/spec/hybrid_platforms_conductor_test/api/deployer/secrets_reader_plugins/cli_spec.rb +64 -0
  182. data/spec/hybrid_platforms_conductor_test/api/deployer/secrets_reader_plugins/thycotic_spec.rb +268 -0
  183. data/spec/hybrid_platforms_conductor_test/api/nodes_handler/cmdbs/config_spec.rb +8 -10
  184. data/spec/hybrid_platforms_conductor_test/api/nodes_handler/cmdbs/host_ip_spec.rb +33 -24
  185. data/spec/hybrid_platforms_conductor_test/api/nodes_handler/cmdbs/host_keys_spec.rb +64 -51
  186. data/spec/hybrid_platforms_conductor_test/api/nodes_handler/cmdbs/platform_handlers_spec.rb +3 -3
  187. data/spec/hybrid_platforms_conductor_test/api/nodes_handler/cmdbs_plugins_api_spec.rb +50 -51
  188. data/spec/hybrid_platforms_conductor_test/api/nodes_handler/common_spec.rb +91 -81
  189. data/spec/hybrid_platforms_conductor_test/api/nodes_handler/config_dsl_spec.rb +14 -16
  190. data/spec/hybrid_platforms_conductor_test/api/nodes_handler/git_diff_impacts_spec.rb +51 -75
  191. data/spec/hybrid_platforms_conductor_test/api/nodes_handler/nodes_selectors_spec.rb +35 -26
  192. data/spec/hybrid_platforms_conductor_test/api/nodes_handler/platform_handlers_plugins_api_spec.rb +24 -16
  193. data/spec/hybrid_platforms_conductor_test/api/nodes_handler/several_platforms_spec.rb +29 -19
  194. data/spec/hybrid_platforms_conductor_test/api/platform_handler_spec.rb +4 -4
  195. data/spec/hybrid_platforms_conductor_test/api/platform_handlers/serverless_chef/config_dsl_spec.rb +2 -2
  196. data/spec/hybrid_platforms_conductor_test/api/platform_handlers/serverless_chef/deploy_output_parsing_spec.rb +6 -6
  197. data/spec/hybrid_platforms_conductor_test/api/platform_handlers/serverless_chef/diff_impacts_spec.rb +57 -99
  198. data/spec/hybrid_platforms_conductor_test/api/platform_handlers/serverless_chef/inventory_spec.rb +4 -4
  199. data/spec/hybrid_platforms_conductor_test/api/platform_handlers/serverless_chef/packaging_spec.rb +32 -35
  200. data/spec/hybrid_platforms_conductor_test/api/platform_handlers/serverless_chef/services_deployment_spec.rb +10 -10
  201. data/spec/hybrid_platforms_conductor_test/api/platforms_handler_spec.rb +38 -27
  202. data/spec/hybrid_platforms_conductor_test/api/plugins_spec.rb +46 -52
  203. data/spec/hybrid_platforms_conductor_test/api/reports_handler_spec.rb +2 -2
  204. data/spec/hybrid_platforms_conductor_test/api/services_handler/actions_to_deploy_spec.rb +90 -58
  205. data/spec/hybrid_platforms_conductor_test/api/services_handler/deploy_allowed_spec.rb +38 -34
  206. data/spec/hybrid_platforms_conductor_test/api/services_handler/log_info_spec.rb +11 -9
  207. data/spec/hybrid_platforms_conductor_test/api/services_handler/package_spec.rb +193 -171
  208. data/spec/hybrid_platforms_conductor_test/api/services_handler/parse_deploy_output_spec.rb +66 -54
  209. data/spec/hybrid_platforms_conductor_test/api/services_handler/prepare_for_deploy_spec.rb +147 -133
  210. data/spec/hybrid_platforms_conductor_test/api/tests_runner/common_spec.rb +69 -49
  211. data/spec/hybrid_platforms_conductor_test/api/tests_runner/global_spec.rb +5 -4
  212. data/spec/hybrid_platforms_conductor_test/api/tests_runner/node_check_spec.rb +8 -5
  213. data/spec/hybrid_platforms_conductor_test/api/tests_runner/node_spec.rb +8 -5
  214. data/spec/hybrid_platforms_conductor_test/api/tests_runner/node_ssh_spec.rb +30 -27
  215. data/spec/hybrid_platforms_conductor_test/api/tests_runner/platform_spec.rb +12 -9
  216. data/spec/hybrid_platforms_conductor_test/api/tests_runner/reports_spec.rb +48 -47
  217. data/spec/hybrid_platforms_conductor_test/api/tests_runner/test_plugins/bitbucket_conf_spec.rb +5 -5
  218. data/spec/hybrid_platforms_conductor_test/api/tests_runner/test_plugins/github_ci_spec.rb +5 -5
  219. data/spec/hybrid_platforms_conductor_test/api/tests_runner/test_reports_plugins/confluence_spec.rb +5 -5
  220. data/spec/hybrid_platforms_conductor_test/cmdb_plugins/test_cmdb.rb +9 -9
  221. data/spec/hybrid_platforms_conductor_test/cmdb_plugins/{test_cmdb2.rb → test_cmdb_2.rb} +6 -6
  222. data/spec/hybrid_platforms_conductor_test/cmdb_plugins/test_cmdb_others.rb +3 -3
  223. data/spec/hybrid_platforms_conductor_test/cmdb_plugins/{test_cmdb_others2.rb → test_cmdb_others_2.rb} +2 -2
  224. data/spec/hybrid_platforms_conductor_test/docs_spec.rb +1 -1
  225. data/spec/hybrid_platforms_conductor_test/executables/{check-node_spec.rb → check_node_spec.rb} +4 -6
  226. data/spec/hybrid_platforms_conductor_test/executables/deploy_spec.rb +4 -6
  227. data/spec/hybrid_platforms_conductor_test/executables/get_impacted_nodes_spec.rb +76 -77
  228. data/spec/hybrid_platforms_conductor_test/executables/last_deploys_spec.rb +159 -113
  229. data/spec/hybrid_platforms_conductor_test/executables/nodes_to_deploy_spec.rb +299 -160
  230. data/spec/hybrid_platforms_conductor_test/executables/options/actions_executor_spec.rb +4 -6
  231. data/spec/hybrid_platforms_conductor_test/executables/options/cmd_runner_spec.rb +3 -5
  232. data/spec/hybrid_platforms_conductor_test/executables/options/common_spec.rb +8 -8
  233. data/spec/hybrid_platforms_conductor_test/executables/options/deployer_spec.rb +12 -196
  234. data/spec/hybrid_platforms_conductor_test/executables/options/nodes_handler_spec.rb +9 -10
  235. data/spec/hybrid_platforms_conductor_test/executables/options/nodes_selectors_spec.rb +9 -10
  236. data/spec/hybrid_platforms_conductor_test/executables/options/reports_handler_spec.rb +1 -1
  237. data/spec/hybrid_platforms_conductor_test/executables/options/tests_runner_spec.rb +22 -22
  238. data/spec/hybrid_platforms_conductor_test/executables/report_spec.rb +22 -16
  239. data/spec/hybrid_platforms_conductor_test/executables/run_spec.rb +32 -32
  240. data/spec/hybrid_platforms_conductor_test/executables/ssh_config_spec.rb +7 -9
  241. data/spec/hybrid_platforms_conductor_test/executables/test_spec.rb +3 -5
  242. data/spec/hybrid_platforms_conductor_test/helpers/actions_executor_helpers.rb +2 -2
  243. data/spec/hybrid_platforms_conductor_test/helpers/cmd_runner_helpers.rb +4 -3
  244. data/spec/hybrid_platforms_conductor_test/helpers/cmdb_helpers.rb +2 -2
  245. data/spec/hybrid_platforms_conductor_test/helpers/config_helpers.rb +1 -1
  246. data/spec/hybrid_platforms_conductor_test/helpers/connector_ssh_helpers.rb +12 -13
  247. data/spec/hybrid_platforms_conductor_test/helpers/deployer_helpers.rb +245 -56
  248. data/spec/hybrid_platforms_conductor_test/helpers/executables_helpers.rb +11 -11
  249. data/spec/hybrid_platforms_conductor_test/helpers/nodes_handler_helpers.rb +1 -1
  250. data/spec/hybrid_platforms_conductor_test/helpers/platforms_handler_helpers.rb +39 -28
  251. data/spec/hybrid_platforms_conductor_test/helpers/plugins_helpers.rb +1 -1
  252. data/spec/hybrid_platforms_conductor_test/helpers/provisioner_proxmox_helpers.rb +86 -111
  253. data/spec/hybrid_platforms_conductor_test/helpers/reports_handler_helpers.rb +1 -1
  254. data/spec/hybrid_platforms_conductor_test/helpers/serverless_chef_helpers.rb +3 -3
  255. data/spec/hybrid_platforms_conductor_test/helpers/services_handler_helpers.rb +1 -1
  256. data/spec/hybrid_platforms_conductor_test/helpers/tests_runner_helpers.rb +1 -1
  257. 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
  258. 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
  259. 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
  260. 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
  261. data/spec/hybrid_platforms_conductor_test/platform_handler_plugins/test.rb +1 -1
  262. data/spec/hybrid_platforms_conductor_test/platform_handler_plugins/{test2.rb → test_2.rb} +0 -0
  263. data/spec/hybrid_platforms_conductor_test/rubocop_spec.rb +31 -0
  264. data/spec/hybrid_platforms_conductor_test/serverless_chef_repositories/1_node/nodes/node.json +3 -3
  265. data/spec/hybrid_platforms_conductor_test/serverless_chef_repositories/data_bags/nodes/node.json +3 -3
  266. data/spec/hybrid_platforms_conductor_test/serverless_chef_repositories/recipes/cookbooks/test_cookbook_2/libraries/default.rb +1 -0
  267. data/spec/hybrid_platforms_conductor_test/serverless_chef_repositories/several_cookbooks/other_cookbooks/test_cookbook_2/libraries/default.rb +1 -0
  268. data/spec/hybrid_platforms_conductor_test/shared_examples/deployer.rb +952 -0
  269. data/spec/hybrid_platforms_conductor_test/test_connector.rb +3 -3
  270. data/spec/hybrid_platforms_conductor_test/test_log_no_read_plugin.rb +84 -0
  271. data/spec/hybrid_platforms_conductor_test/test_log_plugin.rb +105 -0
  272. data/spec/hybrid_platforms_conductor_test/test_plugins/global.rb +1 -0
  273. data/spec/hybrid_platforms_conductor_test/test_plugins/node.rb +1 -0
  274. data/spec/hybrid_platforms_conductor_test/test_plugins/node_check.rb +1 -0
  275. data/spec/hybrid_platforms_conductor_test/test_plugins/platform.rb +1 -0
  276. data/spec/hybrid_platforms_conductor_test/test_plugins/several_checks.rb +2 -2
  277. data/spec/hybrid_platforms_conductor_test/test_secrets_reader_plugin.rb +45 -0
  278. data/spec/hybrid_platforms_conductor_test/tests_report_plugin.rb +5 -6
  279. data/spec/spec_helper.rb +17 -18
  280. data/tools/check_md +16 -20
  281. data/tools/generate_mermaid +1 -1
  282. metadata +195 -144
  283. data/spec/hybrid_platforms_conductor_test/helpers/deployer_test_helpers.rb +0 -916
@@ -21,12 +21,12 @@ module HybridPlatformsConductorTest
21
21
  def register_test_cmdb(cmdb_names = [:test_cmdb])
22
22
  register_plugins(
23
23
  :cmdb,
24
- Hash[cmdb_names.map do |plugin_id|
24
+ cmdb_names.map do |plugin_id|
25
25
  [
26
26
  plugin_id,
27
27
  HybridPlatformsConductorTest::CmdbPlugins.const_get(plugin_id.to_s.split('_').collect(&:capitalize).join.to_sym)
28
28
  ]
29
- end]
29
+ end.to_h
30
30
  )
31
31
  end
32
32
 
@@ -9,7 +9,7 @@ module HybridPlatformsConductorTest
9
9
  # Result::
10
10
  # * Config: Config on which we can do testing
11
11
  def test_config
12
- @config = HybridPlatformsConductor::Config.new logger: logger, logger_stderr: logger unless @config
12
+ @config ||= HybridPlatformsConductor::Config.new logger: logger, logger_stderr: logger
13
13
  @config
14
14
  end
15
15
 
@@ -41,30 +41,30 @@ module HybridPlatformsConductorTest
41
41
  ssh_commands_per_connection = []
42
42
  if with_strict_host_key_checking
43
43
  ip = node_connection_info[:ip] || node_connection_info[:connection]
44
- ssh_commands_once.concat([
44
+ ssh_commands_once.concat(
45
45
  [
46
- "ssh-keyscan #{ip}",
47
- proc { [0, "#{ip} ssh-rsa fake_host_key_for_#{ip}", ''] }
46
+ [
47
+ "ssh-keyscan #{ip}",
48
+ proc { [0, "#{ip} ssh-rsa fake_host_key_for_#{ip}", ''] }
49
+ ]
48
50
  ]
49
- ])
51
+ )
50
52
  end
51
53
  if with_control_master_create
52
54
  control_master_created = false
53
55
  ssh_commands_per_connection << [
54
56
  if with_session_exec
55
- /^.+\/ssh #{with_batch_mode ? '-o BatchMode=yes ' : ''}-o ControlMaster=yes -o ControlPersist=yes hpc\.#{Regexp.escape(node)} true$/
57
+ %r{^.+/ssh #{with_batch_mode ? '-o BatchMode=yes ' : ''}-o ControlMaster=yes -o ControlPersist=yes hpc\.#{Regexp.escape(node)} true$}
56
58
  else
57
59
  unless ENV['hpc_interactive'] == 'false'
58
60
  # Mock the user hitting enter as the Control Master will be created in another thread and the main thread waits for user input.
59
61
  expect($stdin).to receive(:gets) do
60
62
  # We have to wait for the Control Master creation thread to actually create the Control Master before hitting Enter.
61
- while !control_master_created do
62
- sleep 0.1
63
- end
63
+ sleep 0.1 until control_master_created
64
64
  "\n"
65
65
  end
66
66
  end
67
- /^xterm -e '.+\/ssh -o ControlMaster=yes -o ControlPersist=yes hpc\.#{Regexp.escape(node)}'$/
67
+ %r{^xterm -e '.+/ssh -o ControlMaster=yes -o ControlPersist=yes hpc\.#{Regexp.escape(node)}'$}
68
68
  end,
69
69
  proc do
70
70
  control_file = test_actions_executor.connector(:ssh).send(:control_master_file, node_connection_info[:connection], '22', node_connection_info[:user])
@@ -88,13 +88,13 @@ module HybridPlatformsConductorTest
88
88
  end
89
89
  if with_control_master_check
90
90
  ssh_commands_per_connection << [
91
- /^.+\/ssh -O check hpc\.#{Regexp.escape(node)}$/,
91
+ %r{^.+/ssh -O check hpc\.#{Regexp.escape(node)}$},
92
92
  proc { [0, '', ''] }
93
93
  ]
94
94
  end
95
95
  if with_control_master_destroy
96
96
  ssh_commands_per_connection << [
97
- /^.+\/ssh -O exit hpc\.#{Regexp.escape(node)} 2>&1 \| grep -v 'Exit request sent\.'$/,
97
+ %r{^.+/ssh -O exit hpc\.#{Regexp.escape(node)} 2>&1 \| grep -v 'Exit request sent\.'$},
98
98
  proc do
99
99
  # Really mock the control file deletion
100
100
  File.unlink(test_actions_executor.connector(:ssh).send(:control_master_file, node_connection_info[:connection], '22', node_connection_info[:user]))
@@ -137,8 +137,7 @@ module HybridPlatformsConductorTest
137
137
  )
138
138
  with_test_platform(
139
139
  { nodes: { 'node' => { meta: { host_ip: '192.168.42.42', ssh_session_exec: session_exec } } } },
140
- false,
141
- additional_config
140
+ additional_config: additional_config
142
141
  ) do
143
142
  with_cmd_runner_mocked(
144
143
  [
@@ -12,7 +12,7 @@ module HybridPlatformsConductorTest
12
12
  # * *sudo* (String or nil): sudo supposed to be used, or nil if none [default: 'sudo -u root']
13
13
  def expect_action_to_lock_node(action, node, sudo: 'sudo -u root')
14
14
  expect(action[:scp].size).to eq 1
15
- expect(action[:scp].first[0]).to match /^.+\/mutex_dir$/
15
+ expect(action[:scp].first[0]).to match(%r{^.+/mutex_dir$})
16
16
  expect(action[:scp].first[1]).to eq '.'
17
17
  expect(action[:remote_bash]).to eq "while ! #{sudo ? "#{sudo} " : ''}./mutex_dir lock /tmp/hybrid_platforms_conductor_deploy_lock \"$(ps -o ppid= -p $$)\"; do echo -e 'Another deployment is running on #{node}. Waiting for it to finish to continue...' ; sleep 5 ; done"
18
18
  end
@@ -23,7 +23,7 @@ module HybridPlatformsConductorTest
23
23
  # * *action* (Hash<Symbol,Object>): The action to check
24
24
  # * *node* (String): The concerned node
25
25
  # * *sudo* (String or nil): sudo supposed to be used, or nil if none [default: 'sudo -u root']
26
- def expect_action_to_unlock_node(action, node, sudo: 'sudo -u root')
26
+ def expect_action_to_unlock_node(action, _node, sudo: 'sudo -u root')
27
27
  expect(action).to eq(remote_bash: "#{sudo ? "#{sudo} " : ''}./mutex_dir unlock /tmp/hybrid_platforms_conductor_deploy_lock")
28
28
  end
29
29
 
@@ -40,7 +40,7 @@ module HybridPlatformsConductorTest
40
40
  # * Hash<String, [Integer or Symbol, String, String] >: Expected result of those expected actions
41
41
  def expect_actions_to_deploy_on(actions, nodes, check: false, sudo: 'sudo -u root', expected_actions: [], mocked_result: nil)
42
42
  nodes = [nodes] if nodes.is_a?(String)
43
- mocked_result = Hash[nodes.map { |node| [node, [0, "#{check ? 'Check' : 'Deploy'} successful", '']] }] if mocked_result.nil?
43
+ mocked_result = nodes.map { |node| [node, [0, "#{check ? 'Check' : 'Deploy'} successful", '']] }.to_h if mocked_result.nil?
44
44
  expect(actions.size).to eq nodes.size
45
45
  nodes.each do |node|
46
46
  expect(actions.key?(node)).to eq true
@@ -65,81 +65,270 @@ module HybridPlatformsConductorTest
65
65
  expect(actions.key?(node)).to eq true
66
66
  expect_action_to_unlock_node(actions[node], node, sudo: sudo)
67
67
  end
68
- Hash[nodes.map { |node| [node, [0, 'Release mutex successful', '']] }]
68
+ nodes.map { |node| [node, [0, 'Release mutex successful', '']] }.to_h
69
69
  end
70
70
 
71
- # Expect a given set of actions to upload log files on a list of nodes
71
+ # Expect a given set of actions to upload log files on a list of nodes (using the test_log log plugin)
72
72
  #
73
73
  # Parameters::
74
74
  # * *actions* (Object): Actions
75
75
  # * *nodes* (String or Array<String>): Node (or list of nodes) that should be checked
76
- # * *sudo* (String or nil): sudo supposed to be used, or nil if none [default: 'sudo -u root']
77
- def expect_actions_to_upload_logs(actions, nodes, sudo: 'sudo -u root')
76
+ def expect_actions_to_upload_logs(actions, nodes)
78
77
  nodes = [nodes] if nodes.is_a?(String)
79
78
  expect(actions.size).to eq nodes.size
80
79
  nodes.each do |node|
81
80
  expect(actions.key?(node)).to eq true
82
- expect(actions[node][:remote_bash]).to eq "#{sudo ? "#{sudo} " : ''}mkdir -p /var/log/deployments"
83
- expect(actions[node][:scp].first[1]).to eq '/var/log/deployments'
84
- expect(actions[node][:scp][:group]).to eq 'root'
85
- expect(actions[node][:scp][:owner]).to eq 'root'
86
- expect(actions[node][:scp][:sudo]).to eq (!sudo.nil?)
81
+ expect(actions[node]).to eq [{ bash: "echo Save test logs to #{node}" }]
87
82
  end
88
- Hash[nodes.map { |node| [node, [0, 'Logs uploaded', '']] }]
83
+ nodes.map { |node| [node, [0, 'Logs uploaded', '']] }.to_h
84
+ end
85
+
86
+ # Get a test Deployer
87
+ #
88
+ # Result::
89
+ # * Deployer: Deployer on which we can do testing
90
+ def test_deployer
91
+ @deployer ||= HybridPlatformsConductor::Deployer.new logger: logger, logger_stderr: logger, config: test_config, cmd_runner: test_cmd_runner, nodes_handler: test_nodes_handler, actions_executor: test_actions_executor, services_handler: test_services_handler
92
+ @deployer
89
93
  end
90
94
 
91
- # Expect some logs to have the following information.
92
- # Expected logs format:
95
+ # Expect the test services handler to be called to deploy a given list of services
93
96
  #
94
- # date: 2019-08-14 17:02:57
95
- # user: muriel
96
- # debug: Yes
97
- # repo_name: my_remote_platform
98
- # commit_id: c0d16b1b7ae286ae4a059185957e08f0ddc95517
99
- # commit_message: Test commit
100
- # diff_files:
101
- # ===== STDOUT =====
102
- # Deploy successful
103
- # ===== STDERR =====
97
+ # Parameters::
98
+ # * *services* (Hash<String, Array<String> >): List of services to be expected, per node name
99
+ def expect_services_handler_to_deploy(services)
100
+ expect(test_services_handler).to receive(:deploy_allowed?).with(
101
+ services: services,
102
+ local_environment: false
103
+ ).and_return(nil)
104
+ expect(test_services_handler).to receive(:package).with(
105
+ services: services,
106
+ secrets: {},
107
+ local_environment: false
108
+ )
109
+ expect(test_services_handler).to receive(:prepare_for_deploy).with(
110
+ services: services,
111
+ secrets: {},
112
+ local_environment: false,
113
+ why_run: false
114
+ )
115
+ services.each do |node, node_services|
116
+ expect(test_services_handler).to receive(:actions_to_deploy_on).with(node, node_services, false) do
117
+ [{ bash: "echo \"Deploying on #{node}\"" }]
118
+ end
119
+ expect(test_services_handler).to receive(:log_info_for).with(node, node_services) do
120
+ {
121
+ repo_name_0: 'platform',
122
+ commit_id_0: '123456',
123
+ commit_message_0: "Test commit for #{node}: #{node_services.join(', ')}"
124
+ }
125
+ end
126
+ end
127
+ end
128
+
129
+ # Get expected actions for a deployment
130
+ #
131
+ # Parameters::
132
+ # * *services* (Hash<String, Array<String> >): Expected nodes that should be deployed, with their corresponding services [default: { 'node' => %w[service] }]
133
+ # * *sudo* (String or nil): sudo supposed to be used, or nil if none [default: 'sudo -u root']
134
+ # * *check_mode* (Boolean): Are we testing in check mode? [default: @check_mode]
135
+ # * *mocked_deploy_result* (Hash or nil): Mocked result of the deployment actions, or nil to use the helper's default [default: nil]
136
+ # * *additional_expected_actions* (Array): Additional expected actions [default: []]
137
+ # * *expect_concurrent_actions* (Boolean): Are actions expected to be run in parallel? [default: false]
138
+ # * *expect_actions_timeout* (Integer or nil): Expected timeout in actions, or nil for none [default: nil]
139
+ def expected_actions_for_deploy_on(
140
+ services: { 'node' => %w[service] },
141
+ sudo: 'sudo -u root',
142
+ check_mode: @check_mode,
143
+ mocked_deploy_result: nil,
144
+ additional_expected_actions: [],
145
+ expect_concurrent_actions: false,
146
+ expect_actions_timeout: nil
147
+ )
148
+ actions = [
149
+ # First run, we expect the mutex to be setup, and the deployment actions to be run
150
+ proc do |actions_per_nodes, timeout: nil, concurrent: false, log_to_dir: 'run_logs', log_to_stdout: true|
151
+ expect(timeout).to eq expect_actions_timeout
152
+ expect(concurrent).to eq expect_concurrent_actions
153
+ expect(log_to_dir).to eq 'run_logs'
154
+ expect_actions_to_deploy_on(
155
+ actions_per_nodes,
156
+ services.keys,
157
+ check: check_mode,
158
+ sudo: sudo,
159
+ mocked_result: mocked_deploy_result,
160
+ expected_actions: additional_expected_actions
161
+ )
162
+ end,
163
+ # Second run, we expect the mutex to be released
164
+ proc { |actions_per_nodes| expect_actions_to_unlock(actions_per_nodes, services.keys, sudo: sudo) }
165
+ ]
166
+ services.each do |node, node_services|
167
+ expect(test_services_handler).to receive(:actions_to_deploy_on).with(node, node_services, check_mode) do
168
+ [{ bash: "echo \"#{check_mode ? 'Checking' : 'Deploying'} on #{node}\"" }]
169
+ end
170
+ end
171
+ # Third run, we expect logs to be uploaded on the node (only if not check mode)
172
+ unless check_mode
173
+ services.each do |node, node_services|
174
+ expect(test_services_handler).to receive(:log_info_for).with(node, node_services).and_return(
175
+ repo_name_0: 'platform',
176
+ commit_id_0: '123456',
177
+ commit_message_0: 'Test commit'
178
+ )
179
+ end
180
+ actions << proc { |actions_per_nodes| expect_actions_to_upload_logs(actions_per_nodes, services.keys) }
181
+ end
182
+ actions
183
+ end
184
+
185
+ # Prepare a platform ready to test deployments on.
104
186
  #
105
187
  # Parameters::
106
- # * *logs* (String): The logs content
107
- # * *stdout* (String): Expected STDOUT
108
- # * *stderr* (String): Expected STDERR
109
- # * *properties* (Hash<Symbol, String or Regexp>): Expected properties values, per name. Values can be exact strings or regexps.
110
- def expect_logs_to_be(logs, stdout, stderr, properties)
111
- lines = logs.split("\n")
112
- idx_stdout = lines.index('===== STDOUT =====')
113
- expect(idx_stdout).not_to eq nil
114
- idx_stderr = lines.index('===== STDERR =====')
115
- expect(idx_stderr).not_to eq nil
116
- logs_properties = Hash[lines[0..idx_stdout - 1].map do |property_line|
117
- property_fields = property_line.split(': ')
118
- [
119
- property_fields.first.to_sym,
120
- property_fields[1..-1].join(': ')
121
- ]
122
- end]
123
- expect(logs_properties.size).to eq properties.size
124
- properties.each do |expected_property, expected_property_value|
125
- expect(logs_properties.key?(expected_property)).to eq true
126
- if expected_property_value.is_a?(String)
127
- expect(logs_properties[expected_property]).to eq expected_property_value
188
+ # * *nodes_info* (Hash): Node info to give the platform [default: 1 node having 1 service]
189
+ # * *expect_services_to_deploy* (Hash<String,Array<String>>): Expected services to be deployed [default: all services from nodes_info]
190
+ # * *expect_deploy_allowed* (Boolean): Should we expect the call to deploy_allowed? [default: true]
191
+ # * *expect_package* (Boolean): Should we expect packaging? [default: true]
192
+ # * *expect_prepare_for_deploy* (Boolean): Should we expect calls to prepare for deploy? [default: true]
193
+ # * *expect_connections_to_nodes* (Boolean): Should we expect connections to nodes? [default: true]
194
+ # * *expect_default_actions* (Boolean): Should we expect default actions? [default: true]
195
+ # * *expect_sudo* (String or nil): Expected sudo command, or nil if none [default: 'sudo -u root']
196
+ # * *expect_secrets* (Hash): Secrets to be expected during deployment [default: {}]
197
+ # * *expect_local_environment* (Boolean): Expected local environment flag [default: false]
198
+ # * *expect_additional_actions* (Array): Additional expected actions [default: []]
199
+ # * *expect_concurrent_actions* (Boolean): Are actions expected to be run in parallel? [default: false]
200
+ # * *expect_actions_timeout* (Integer or nil): Expected timeout in actions, or nil for none [default: nil]
201
+ # * *check_mode* (Boolean): Are we testing in check mode? [default: @check_mode]
202
+ # * *additional_config* (String): Additional configuration to set [default: '']
203
+ # * Proc: Code called once the platform is ready for testing the deployer
204
+ # * Parameters::
205
+ # * *repository* (String): Path to the repository
206
+ def with_platform_to_deploy(
207
+ nodes_info: { nodes: { 'node' => { services: %w[service] } } },
208
+ expect_services_to_deploy: nodes_info[:nodes].transform_values { |node_info| node_info[:services] },
209
+ expect_deploy_allowed: true,
210
+ expect_package: true,
211
+ expect_prepare_for_deploy: true,
212
+ expect_connections_to_nodes: true,
213
+ expect_default_actions: true,
214
+ expect_sudo: 'sudo -u root',
215
+ expect_secrets: {},
216
+ expect_local_environment: false,
217
+ expect_additional_actions: [],
218
+ expect_concurrent_actions: false,
219
+ expect_actions_timeout: nil,
220
+ check_mode: @check_mode,
221
+ additional_config: ''
222
+ )
223
+ with_test_platform(nodes_info, as_git: !check_mode, additional_config: "#{additional_config}\nsend_logs_to :test_log") do |repository|
224
+ # Mock the ServicesHandler accesses
225
+ if !check_mode && expect_deploy_allowed
226
+ expect(test_services_handler).to receive(:deploy_allowed?).with(
227
+ services: expect_services_to_deploy,
228
+ local_environment: expect_local_environment
229
+ ).and_return(nil)
230
+ end
231
+ if expect_package
232
+ expect(test_services_handler).to receive(:package).with(
233
+ services: expect_services_to_deploy,
234
+ secrets: expect_secrets,
235
+ local_environment: expect_local_environment
236
+ )
237
+ else
238
+ expect(test_services_handler).not_to receive(:package)
239
+ end
240
+ if expect_prepare_for_deploy
241
+ expect(test_services_handler).to receive(:prepare_for_deploy).with(
242
+ services: expect_services_to_deploy,
243
+ secrets: expect_secrets,
244
+ local_environment: expect_local_environment,
245
+ why_run: check_mode
246
+ )
247
+ else
248
+ expect(test_services_handler).not_to receive(:prepare_for_deploy)
249
+ end
250
+ test_deployer.use_why_run = true if check_mode
251
+ if expect_connections_to_nodes
252
+ with_connections_mocked_on(expect_services_to_deploy.keys) do
253
+ if expect_default_actions
254
+ expect_actions_executor_runs(
255
+ expected_actions_for_deploy_on(
256
+ services: expect_services_to_deploy,
257
+ check_mode: check_mode,
258
+ sudo: expect_sudo,
259
+ additional_expected_actions: expect_additional_actions,
260
+ expect_concurrent_actions: expect_concurrent_actions,
261
+ expect_actions_timeout: expect_actions_timeout
262
+ )
263
+ )
264
+ end
265
+ yield repository
266
+ end
128
267
  else
129
- expect(logs_properties[expected_property]).to match expected_property_value
268
+ yield repository
130
269
  end
131
270
  end
132
- expect(lines[idx_stdout + 1..idx_stderr - 1].join("\n")).to eq stdout
133
- expect(lines[idx_stderr + 1..-1].join("\n")).to eq stderr
134
271
  end
135
272
 
136
- # Get a test Deployer
273
+ # Prepare a directory with certificates
137
274
  #
138
- # Result::
139
- # * Deployer: Deployer on which we can do testing
140
- def test_deployer
141
- @deployer = HybridPlatformsConductor::Deployer.new logger: logger, logger_stderr: logger, config: test_config, cmd_runner: test_cmd_runner, nodes_handler: test_nodes_handler, actions_executor: test_actions_executor, services_handler: test_services_handler unless @deployer
142
- @deployer
275
+ # Parameters::
276
+ # * Proc: Code called with the directory created with a mocked certificate
277
+ # * Parameters::
278
+ # * *certs_dir* (String): Directory containing certificates
279
+ def with_certs_dir
280
+ with_repository do |repository|
281
+ certs_dir = "#{repository}/certificates"
282
+ FileUtils.mkdir_p certs_dir
283
+ File.write("#{certs_dir}/test_cert.crt", 'Hello')
284
+ yield certs_dir
285
+ end
286
+ end
287
+
288
+ # Prepare a platform ready to test deployments' retries on.
289
+ #
290
+ # Parameters::
291
+ # * *nodes_info* (Hash): Node info to give the platform [default: { nodes: { 'node' => {} } }]
292
+ # * *block* (Proc): Code called once the platform is ready for testing the deployer
293
+ # * Parameters::
294
+ # * *repository* (String): Path to the repository
295
+ def with_platform_to_retry_deploy(nodes_info: { nodes: { 'node' => { services: %w[service] } } }, &block)
296
+ with_platform_to_deploy(
297
+ nodes_info: nodes_info,
298
+ expect_default_actions: false,
299
+ additional_config: "
300
+ for_nodes([#{nodes_info[:nodes].keys.map { |node| "'#{node}'" }.join(', ')}]) do
301
+ retry_deploy_for_errors_on_stdout [
302
+ 'stdout non-deterministic error'
303
+ ]
304
+ retry_deploy_for_errors_on_stderr [
305
+ 'stderr non-deterministic error',
306
+ /stderr regexp error \\d+/
307
+ ]
308
+ end
309
+ for_nodes([#{nodes_info[:nodes].keys.map { |node| "'#{node}'" }.join(', ')}]) do
310
+ retry_deploy_for_errors_on_stdout [
311
+ /stdout regexp error \\d+/
312
+ ]
313
+ end
314
+ ",
315
+ &block
316
+ )
317
+ end
318
+
319
+ # Mock a sequential list of deployments
320
+ #
321
+ # Parameters::
322
+ # * *statuses* (Array<Hash<String,Status> or Status>)>): List of mocked deployment statuses per node name, or just the status for the default node.
323
+ # A status is a triplet [Integer or Symbol, String, String]: exit status, stdout and stderr.
324
+ def mock_deploys_with(statuses)
325
+ expect_actions_executor_runs(statuses.map do |status|
326
+ status = { 'node' => status } if status.is_a?(Array)
327
+ expected_actions_for_deploy_on(
328
+ services: status.keys.map { |node| [node, %w[service]] }.to_h,
329
+ mocked_deploy_result: status
330
+ )
331
+ end.flatten)
143
332
  end
144
333
 
145
334
  end
@@ -18,8 +18,8 @@ module HybridPlatformsConductorTest
18
18
  stderr_file = "#{Dir.tmpdir}/hpc_test/run.stderr"
19
19
  File.open(stdout_file, 'w') { |f| f.truncate(0) }
20
20
  File.open(stderr_file, 'w') { |f| f.truncate(0) }
21
- logger_stdout = Logger.new(stdout_file, level: :info)
22
- logger_stderr = Logger.new(stderr_file, level: :info)
21
+ test_logger_stdout = Logger.new(stdout_file, level: :info)
22
+ test_logger_stderr = Logger.new(stderr_file, level: :info)
23
23
  # Mock the Executable creation to redirect stdout and stderr correctly
24
24
  expect(HybridPlatformsConductor::Executable).to receive(:new).once.and_wrap_original do |original_method,
25
25
  check_options: true,
@@ -27,8 +27,8 @@ module HybridPlatformsConductorTest
27
27
  parallel_options: true,
28
28
  timeout_options: true,
29
29
  deploy_options: true,
30
- original_logger: Logger.new(STDOUT, level: :info),
31
- original_logger_stderr: Logger.new(STDERR, level: :info),
30
+ _logger: Logger.new($stdout, level: :info),
31
+ _logger_stderr: Logger.new($stderr, level: :info),
32
32
  &opts_block|
33
33
  original_method.call(
34
34
  check_options: check_options,
@@ -36,8 +36,8 @@ module HybridPlatformsConductorTest
36
36
  parallel_options: parallel_options,
37
37
  timeout_options: timeout_options,
38
38
  deploy_options: deploy_options,
39
- logger: logger_stdout,
40
- logger_stderr: logger_stderr,
39
+ logger: test_logger_stdout,
40
+ logger_stderr: test_logger_stderr,
41
41
  &opts_block
42
42
  )
43
43
  end
@@ -53,18 +53,18 @@ module HybridPlatformsConductorTest
53
53
  HybridPlatformsConductor::TestsRunner => test_tests_runner
54
54
  }
55
55
  # Make sure the tested components use the same loggers as the executable.
56
- components_to_mock.values.each do |component|
56
+ components_to_mock.each_value do |component|
57
57
  component.stdout_device = stdout_file
58
58
  component.stderr_device = stderr_file
59
59
  end
60
60
  # Make sure that when the executable creates components it uses ours
61
61
  components_to_mock.each do |component_class, component|
62
- allow(component_class).to receive(:new).once { component }
62
+ allow(component_class).to(receive(:new).once { component })
63
63
  end
64
64
  # Run the executable
65
65
  args.concat(['--debug']) if ENV['TEST_DEBUG'] == '1'
66
66
  ARGV.replace(args)
67
- old_0 = $0
67
+ old_program_name = $PROGRAM_NAME
68
68
  $0 = executable
69
69
  begin
70
70
  exit_code = nil
@@ -72,10 +72,10 @@ module HybridPlatformsConductorTest
72
72
  load "#{__dir__}/../../../bin/#{executable}"
73
73
  exit_code = 0
74
74
  rescue SystemExit
75
- exit_code = $!.status
75
+ exit_code = $ERROR_INFO.status
76
76
  end
77
77
  ensure
78
- $0 = old_0
78
+ $0 = old_program_name
79
79
  end
80
80
  stdout = File.read(stdout_file)
81
81
  stderr = File.read(stderr_file)