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
@@ -1,916 +0,0 @@
1
- require 'timeout'
2
-
3
- module HybridPlatformsConductorTest
4
-
5
- module Helpers
6
-
7
- module DeployerTestHelpers
8
-
9
- # Define deployment specs that are common for check mode and real deployment
10
- #
11
- # Parameters::
12
- # * *check_mode* (Boolean): Are we in check-mode? [default: true]
13
- def deploy_specs_for(check_mode: true)
14
- expected_deploy_result = [0, "#{check_mode ? 'Check' : 'Deploy'} successful", '']
15
- platform_name = check_mode ? 'platform' : 'my_remote_platform'
16
-
17
- context "testing deployment#{check_mode ? ' in why-run mode' : ''}" do
18
-
19
- # Get expected actions for a deployment
20
- #
21
- # Parameters::
22
- # * *services* (Hash<String, Array<String> >): Expected nodes that should be deployed, with their corresponding services [default: { 'node' => %w[service] }]
23
- # * *sudo* (String or nil): sudo supposed to be used, or nil if none [default: 'sudo -u root']
24
- # * *check_mode* (Boolean): Are we testing in check mode? [default: @check_mode]
25
- # * *mocked_deploy_result* (Hash or nil): Mocked result of the deployment actions, or nil to use the helper's default [default: nil]
26
- # * *additional_expected_actions* (Array): Additional expected actions [default: []]
27
- # * *expect_concurrent_actions* (Boolean): Are actions expected to be run in parallel? [default: false]
28
- # * *expect_actions_timeout* (Integer or nil): Expected timeout in actions, or nil for none [default: nil]
29
- def expected_actions_for_deploy_on(
30
- services: { 'node' => %w[service] },
31
- sudo: 'sudo -u root',
32
- check_mode: @check_mode,
33
- mocked_deploy_result: nil,
34
- additional_expected_actions: [],
35
- expect_concurrent_actions: false,
36
- expect_actions_timeout: nil
37
- )
38
- actions = [
39
- # First run, we expect the mutex to be setup, and the deployment actions to be run
40
- proc do |actions_per_nodes, timeout: nil, concurrent: false, log_to_dir: 'run_logs', log_to_stdout: true|
41
- expect(timeout).to eq expect_actions_timeout
42
- expect(concurrent).to eq expect_concurrent_actions
43
- expect(log_to_dir).to eq 'run_logs'
44
- expect_actions_to_deploy_on(
45
- actions_per_nodes,
46
- services.keys,
47
- check: check_mode,
48
- sudo: sudo,
49
- mocked_result: mocked_deploy_result,
50
- expected_actions: additional_expected_actions
51
- )
52
- end,
53
- # Second run, we expect the mutex to be released
54
- proc { |actions_per_nodes| expect_actions_to_unlock(actions_per_nodes, services.keys, sudo: sudo) }
55
- ]
56
- services.each do |node, node_services|
57
- expect(test_services_handler).to receive(:actions_to_deploy_on).with(node, node_services, check_mode) do
58
- [{ bash: "echo \"#{check_mode ? 'Checking' : 'Deploying'} on #{node}\"" }]
59
- end
60
- end
61
- # Third run, we expect logs to be uploaded on the node (only if not check mode)
62
- unless check_mode
63
- services.each do |node, node_services|
64
- expect(test_services_handler).to receive(:log_info_for).with(node, node_services) do
65
- {
66
- repo_name_0: 'platform',
67
- commit_id_0: '123456',
68
- commit_message_0: 'Test commit'
69
- }
70
- end
71
- end
72
- actions << proc { |actions_per_nodes| expect_actions_to_upload_logs(actions_per_nodes, services.keys, sudo: sudo) }
73
- end
74
- actions
75
- end
76
-
77
- # Prepare a platform ready to test deployments on.
78
- #
79
- # Parameters::
80
- # * *nodes_info* (Hash): Node info to give the platform [default: 1 node having 1 service]
81
- # * *expect_package* (Boolean): Should we expect packaging? [default: true]
82
- # * *expect_prepare_for_deploy* (Boolean): Should we expect calls to prepare for deploy? [default: true]
83
- # * *expect_connections_to_nodes* (Boolean): Should we expect connections to nodes? [default: true]
84
- # * *expect_default_actions* (Boolean): Should we expect default actions? [default: true]
85
- # * *expect_sudo* (String or nil): Expected sudo command, or nil if none [default: 'sudo -u root']
86
- # * *expect_secrets* (Hash): Secrets to be expected during deployment [default: {}]
87
- # * *expect_local_environment* (Boolean): Expected local environment flag [default: false]
88
- # * *expect_additional_actions* (Array): Additional expected actions [default: []]
89
- # * *expect_concurrent_actions* (Boolean): Are actions expected to be run in parallel? [default: false]
90
- # * *expect_actions_timeout* (Integer or nil): Expected timeout in actions, or nil for none [default: nil]
91
- # * *check_mode* (Boolean): Are we testing in check mode? [default: @check_mode]
92
- # * *additional_config* (String): Additional configuration to set [default: '']
93
- # * Proc: Code called once the platform is ready for testing the deployer
94
- # * Parameters::
95
- # * *repository* (String): Path to the repository
96
- def with_platform_to_deploy(
97
- nodes_info: { nodes: { 'node' => { services: %w[service] } } },
98
- expect_package: true,
99
- expect_prepare_for_deploy: true,
100
- expect_connections_to_nodes: true,
101
- expect_default_actions: true,
102
- expect_sudo: 'sudo -u root',
103
- expect_secrets: {},
104
- expect_local_environment: false,
105
- expect_additional_actions: [],
106
- expect_concurrent_actions: false,
107
- expect_actions_timeout: nil,
108
- check_mode: @check_mode,
109
- additional_config: ''
110
- )
111
- platform_name = check_mode ? 'platform' : 'my_remote_platform'
112
- with_test_platform(nodes_info, !check_mode, additional_config) do |repository|
113
- # Mock the ServicesHandler accesses
114
- expect_services_to_deploy = Hash[nodes_info[:nodes].map do |node, node_info|
115
- [node, node_info[:services]]
116
- end]
117
- unless check_mode
118
- expect(test_services_handler).to receive(:deploy_allowed?).with(
119
- services: expect_services_to_deploy,
120
- secrets: expect_secrets,
121
- local_environment: expect_local_environment
122
- ) do
123
- nil
124
- end
125
- end
126
- if expect_package
127
- expect(test_services_handler).to receive(:package).with(
128
- services: expect_services_to_deploy,
129
- secrets: expect_secrets,
130
- local_environment: expect_local_environment
131
- )
132
- else
133
- expect(test_services_handler).not_to receive(:package)
134
- end
135
- if expect_prepare_for_deploy
136
- expect(test_services_handler).to receive(:prepare_for_deploy).with(
137
- services: expect_services_to_deploy,
138
- secrets: expect_secrets,
139
- local_environment: expect_local_environment,
140
- why_run: check_mode
141
- )
142
- else
143
- expect(test_services_handler).not_to receive(:prepare_for_deploy)
144
- end
145
- test_deployer.use_why_run = true if check_mode
146
- if expect_connections_to_nodes
147
- with_connections_mocked_on(nodes_info[:nodes].keys) do
148
- expect_actions_executor_runs(expected_actions_for_deploy_on(
149
- services: expect_services_to_deploy,
150
- check_mode: check_mode,
151
- sudo: expect_sudo,
152
- additional_expected_actions: expect_additional_actions,
153
- expect_concurrent_actions: expect_concurrent_actions,
154
- expect_actions_timeout: expect_actions_timeout
155
- )) if expect_default_actions
156
- yield repository
157
- end
158
- else
159
- yield repository
160
- end
161
- end
162
- end
163
-
164
- # Prepare a directory with certificates
165
- #
166
- # Parameters::
167
- # * Proc: Code called with the directory created with a mocked certificate
168
- # * Parameters::
169
- # * *certs_dir* (String): Directory containing certificates
170
- def with_certs_dir
171
- with_repository do |repository|
172
- certs_dir = "#{repository}/certificates"
173
- FileUtils.mkdir_p certs_dir
174
- File.write("#{certs_dir}/test_cert.crt", 'Hello')
175
- yield certs_dir
176
- end
177
- end
178
-
179
- before :each do
180
- @check_mode = check_mode
181
- end
182
-
183
- it 'deploys on 1 node' do
184
- with_platform_to_deploy do
185
- expect(test_deployer.deploy_on('node')).to eq('node' => expected_deploy_result)
186
- end
187
- end
188
-
189
- it 'deploys on 1 node having several services' do
190
- with_platform_to_deploy(nodes_info: { nodes: { 'node' => { services: %w[service1 service2 service3] } } }) do
191
- expect(test_deployer.deploy_on('node')).to eq('node' => expected_deploy_result)
192
- end
193
- end
194
-
195
- it 'deploys on 1 node in a local environment' do
196
- with_platform_to_deploy(expect_local_environment: true) do
197
- test_deployer.local_environment = true
198
- expect(test_deployer.deploy_on('node')).to eq('node' => expected_deploy_result)
199
- expect(test_deployer.local_environment).to eq true
200
- end
201
- end
202
-
203
- it 'deploys on 1 node using root' do
204
- with_platform_to_deploy(expect_sudo: nil) do
205
- test_actions_executor.connector(:ssh).ssh_user = 'root'
206
- expect(test_deployer.deploy_on('node')).to eq('node' => expected_deploy_result)
207
- end
208
- end
209
-
210
- it 'deploys on 1 node using an alternate sudo' do
211
- with_platform_to_deploy(
212
- expect_sudo: 'other_sudo --user root',
213
- additional_config: 'sudo_for { |user| "other_sudo --user #{user}" }'
214
- ) do
215
- expect(test_deployer.deploy_on('node')).to eq('node' => expected_deploy_result)
216
- end
217
- end
218
-
219
- it 'deploys on 1 node using 1 secret' do
220
- with_platform_to_deploy(expect_secrets: { 'secret1' => 'password1' }) do
221
- test_deployer.secrets = [{ 'secret1' => 'password1' }]
222
- expect(test_deployer.deploy_on('node')).to eq('node' => expected_deploy_result)
223
- end
224
- end
225
-
226
- it 'deploys on 1 node using several secrets' do
227
- with_platform_to_deploy(expect_secrets: { 'secret1' => 'password1', 'secret2' => 'password2' }) do
228
- test_deployer.secrets = [{ 'secret1' => 'password1' }, { 'secret2' => 'password2' }]
229
- expect(test_deployer.deploy_on('node')).to eq('node' => expected_deploy_result)
230
- end
231
- end
232
-
233
- it 'deploys on 1 node in local environment with certificates to install using hpc_certificates on Debian' do
234
- with_certs_dir do |certs_dir|
235
- with_platform_to_deploy(
236
- nodes_info: { nodes: { 'node' => { meta: { image: 'debian_9' }, services: %w[service] } } },
237
- expect_local_environment: true,
238
- expect_additional_actions: [
239
- { remote_bash: 'sudo -u root apt update && sudo -u root apt install -y ca-certificates' },
240
- {
241
- remote_bash: 'sudo -u root update-ca-certificates',
242
- scp: {
243
- certs_dir => '/usr/local/share/ca-certificates',
244
- :sudo => true
245
- }
246
- }
247
- ]
248
- ) do
249
- ENV['hpc_certificates'] = certs_dir
250
- test_deployer.local_environment = true
251
- expect(test_deployer.deploy_on('node')).to eq('node' => expected_deploy_result)
252
- end
253
- end
254
- end
255
-
256
- it 'deploys on 1 node in local environment with certificates to install using hpc_certificates on Debian and an alternate sudo' do
257
- with_certs_dir do |certs_dir|
258
- with_platform_to_deploy(
259
- nodes_info: { nodes: { 'node' => { meta: { image: 'debian_9' }, services: %w[service] } } },
260
- expect_sudo: 'other_sudo --user root',
261
- expect_local_environment: true,
262
- expect_additional_actions: [
263
- { remote_bash: 'other_sudo --user root apt update && other_sudo --user root apt install -y ca-certificates' },
264
- {
265
- remote_bash: 'other_sudo --user root update-ca-certificates',
266
- scp: {
267
- certs_dir => '/usr/local/share/ca-certificates',
268
- :sudo => true
269
- }
270
- }
271
- ],
272
- additional_config: 'sudo_for { |user| "other_sudo --user #{user}" }'
273
- ) do
274
- ENV['hpc_certificates'] = certs_dir
275
- test_deployer.local_environment = true
276
- expect(test_deployer.deploy_on('node')).to eq('node' => expected_deploy_result)
277
- end
278
- end
279
- end
280
-
281
- it 'deploys on 1 node with certificates to install using hpc_certificates on Debian but ignores them in non-local environment' do
282
- with_certs_dir do |certs_dir|
283
- with_platform_to_deploy(nodes_info: { nodes: { 'node' => { meta: { image: 'debian_9' }, services: %w[service] } } }) do
284
- ENV['hpc_certificates'] = certs_dir
285
- expect(test_deployer.deploy_on('node')).to eq('node' => expected_deploy_result)
286
- end
287
- end
288
- end
289
-
290
- it 'deploys on 1 node with certificates to install using hpc_certificates on Debian using root' do
291
- with_certs_dir do |certs_dir|
292
- with_platform_to_deploy(
293
- nodes_info: { nodes: { 'node' => { meta: { image: 'debian_9' }, services: %w[service] } } },
294
- expect_sudo: nil,
295
- expect_local_environment: true,
296
- expect_additional_actions: [
297
- { remote_bash: 'apt update && apt install -y ca-certificates' },
298
- {
299
- remote_bash: 'update-ca-certificates',
300
- scp: {
301
- certs_dir => '/usr/local/share/ca-certificates',
302
- :sudo => false
303
- }
304
- }
305
- ]
306
- ) do
307
- ENV['hpc_certificates'] = certs_dir
308
- test_actions_executor.connector(:ssh).ssh_user = 'root'
309
- test_deployer.local_environment = true
310
- expect(test_deployer.deploy_on('node')).to eq('node' => expected_deploy_result)
311
- end
312
- end
313
- end
314
-
315
- it 'deploys on 1 node with certificates to install using hpc_certificates on CentOS' do
316
- with_certs_dir do |certs_dir|
317
- with_platform_to_deploy(
318
- nodes_info: { nodes: { 'node' => { meta: { image: 'centos_7' }, services: %w[service] } } },
319
- expect_local_environment: true,
320
- expect_additional_actions: [
321
- { remote_bash: 'sudo -u root yum install -y ca-certificates' },
322
- {
323
- remote_bash: ['sudo -u root update-ca-trust enable', 'sudo -u root update-ca-trust extract'],
324
- scp: {
325
- "#{certs_dir}/test_cert.crt" => '/etc/pki/ca-trust/source/anchors',
326
- :sudo => true
327
- }
328
- }
329
- ]
330
- ) do
331
- ENV['hpc_certificates'] = certs_dir
332
- test_deployer.local_environment = true
333
- expect(test_deployer.deploy_on('node')).to eq('node' => expected_deploy_result)
334
- end
335
- end
336
- end
337
-
338
- it 'deploys on 1 node with certificates to install using hpc_certificates on CentOS and an alternate sudo' do
339
- with_certs_dir do |certs_dir|
340
- with_platform_to_deploy(
341
- nodes_info: { nodes: { 'node' => { meta: { image: 'centos_7' }, services: %w[service] } } },
342
- expect_sudo: 'other_sudo --user root',
343
- expect_local_environment: true,
344
- expect_additional_actions: [
345
- { remote_bash: 'other_sudo --user root yum install -y ca-certificates' },
346
- {
347
- remote_bash: ['other_sudo --user root update-ca-trust enable', 'other_sudo --user root update-ca-trust extract'],
348
- scp: {
349
- "#{certs_dir}/test_cert.crt" => '/etc/pki/ca-trust/source/anchors',
350
- :sudo => true
351
- }
352
- }
353
- ],
354
- additional_config: 'sudo_for { |user| "other_sudo --user #{user}" }'
355
- ) do
356
- ENV['hpc_certificates'] = certs_dir
357
- test_deployer.local_environment = true
358
- expect(test_deployer.deploy_on('node')).to eq('node' => expected_deploy_result)
359
- end
360
- end
361
- end
362
-
363
- it 'deploys on 1 node with certificates to install using hpc_certificates on CentOS using root' do
364
- with_certs_dir do |certs_dir|
365
- with_platform_to_deploy(
366
- nodes_info: { nodes: { 'node' => { meta: { image: 'centos_7' }, services: %w[service] } } },
367
- expect_sudo: nil,
368
- expect_local_environment: true,
369
- expect_additional_actions: [
370
- { remote_bash: 'yum install -y ca-certificates' },
371
- {
372
- remote_bash: ['update-ca-trust enable', 'update-ca-trust extract'],
373
- scp: {
374
- "#{certs_dir}/test_cert.crt" => '/etc/pki/ca-trust/source/anchors',
375
- :sudo => false
376
- }
377
- }
378
- ]
379
- ) do
380
- ENV['hpc_certificates'] = certs_dir
381
- test_actions_executor.connector(:ssh).ssh_user = 'root'
382
- test_deployer.local_environment = true
383
- expect(test_deployer.deploy_on('node')).to eq('node' => expected_deploy_result)
384
- end
385
- end
386
- end
387
-
388
- it 'deploys on several nodes' do
389
- with_platform_to_deploy(nodes_info: { nodes: {
390
- 'node1' => { services: %w[service1] },
391
- 'node2' => { services: %w[service2] },
392
- 'node3' => { services: %w[service3] }
393
- } }) do
394
- expect(test_deployer.deploy_on(%w[node1 node2 node3])).to eq(
395
- 'node1' => expected_deploy_result,
396
- 'node2' => expected_deploy_result,
397
- 'node3' => expected_deploy_result
398
- )
399
- end
400
- end
401
-
402
- it 'deploys on several nodes in parallel' do
403
- with_platform_to_deploy(
404
- nodes_info: {
405
- nodes: {
406
- 'node1' => { services: %w[service1] },
407
- 'node2' => { services: %w[service2] },
408
- 'node3' => { services: %w[service3] }
409
- }
410
- },
411
- expect_concurrent_actions: true
412
- ) do
413
- test_deployer.concurrent_execution = true
414
- expect(test_deployer.deploy_on(%w[node1 node2 node3])).to eq(
415
- 'node1' => expected_deploy_result,
416
- 'node2' => expected_deploy_result,
417
- 'node3' => expected_deploy_result
418
- )
419
- end
420
- end
421
-
422
- it 'deploys on several nodes with timeout' do
423
- with_platform_to_deploy(
424
- nodes_info: {
425
- nodes: {
426
- 'node1' => { services: %w[service1] },
427
- 'node2' => { services: %w[service2] },
428
- 'node3' => { services: %w[service3] }
429
- }
430
- },
431
- expect_actions_timeout: 5
432
- ) do
433
- test_deployer.timeout = 5
434
- expect(test_deployer.deploy_on(%w[node1 node2 node3])).to eq(
435
- 'node1' => expected_deploy_result,
436
- 'node2' => expected_deploy_result,
437
- 'node3' => expected_deploy_result
438
- )
439
- end
440
- end
441
-
442
- it 'fails when packaging timeout has been reached while taking the futex' do
443
- with_platform_to_deploy(
444
- additional_config: 'packaging_timeout 1',
445
- expect_package: false,
446
- expect_prepare_for_deploy: false,
447
- expect_connections_to_nodes: false
448
- ) do
449
- # Simulate another process taking the packaging futex
450
- futex_file = HybridPlatformsConductor::Deployer.const_get(:PACKAGING_FUTEX_FILE)
451
- Futex.new(futex_file).open do
452
- # Expect the error to be raised within 2 seconds (as it should timeout after 1 second)
453
- begin
454
- Timeout::timeout(2) {
455
- expect { test_deployer.deploy_on('node') }.to raise_error(
456
- Futex::CantLock,
457
- /can't get exclusive access to the file #{Regexp.escape(futex_file)} because of the lock at #{Regexp.escape(futex_file)}\.lock, after 1\.\d+s of waiting/
458
- )
459
- }
460
- rescue Timeout::Error
461
- raise 'The packaging timeout (set to 1 seconds) did not fire within 2 seconds. Looks like it is not working properly.'
462
- end
463
- end
464
- end
465
- end
466
-
467
- context 'checking deployment retries' do
468
-
469
- # Prepare a platform ready to test deployments' retries on.
470
- #
471
- # Parameters::
472
- # * *nodes_info* (Hash): Node info to give the platform [default: { nodes: { 'node' => {} } }]
473
- # * Proc: Code called once the platform is ready for testing the deployer
474
- # * Parameters::
475
- # * *repository* (String): Path to the repository
476
- def with_platform_to_retry_deploy(nodes_info: { nodes: { 'node' => { services: %w[service] } } })
477
- with_platform_to_deploy(
478
- nodes_info: nodes_info,
479
- expect_default_actions: false,
480
- additional_config: "
481
- for_nodes([#{nodes_info[:nodes].keys.map { |node| "'#{node}'" }.join(', ')}]) do
482
- retry_deploy_for_errors_on_stdout [
483
- 'stdout non-deterministic error'
484
- ]
485
- retry_deploy_for_errors_on_stderr [
486
- 'stderr non-deterministic error',
487
- /stderr regexp error \\d+/
488
- ]
489
- end
490
- for_nodes([#{nodes_info[:nodes].keys.map { |node| "'#{node}'" }.join(', ')}]) do
491
- retry_deploy_for_errors_on_stdout [
492
- /stdout regexp error \\d+/
493
- ]
494
- end
495
- "
496
- ) do |repository|
497
- yield repository
498
- end
499
- end
500
-
501
- # Mock a sequential list of deployments
502
- #
503
- # Parameters::
504
- # * *statuses* (Array<Hash<String,Status> or Status>)>): List of mocked deployment statuses per node name, or just the status for the default node.
505
- # A status is a triplet [Integer or Symbol, String, String]: exit status, stdout and stderr.
506
- def mock_deploys_with(statuses)
507
- expect_actions_executor_runs(statuses.map do |status|
508
- status = { 'node' => status } if status.is_a?(Array)
509
- expected_actions_for_deploy_on(
510
- services: Hash[status.keys.map { |node| [node, %w[service]] }],
511
- mocked_deploy_result: status
512
- )
513
- end.flatten)
514
- end
515
-
516
- it 'restarts deployment for a non-deterministic error' do
517
- with_platform_to_retry_deploy do
518
- test_deployer.nbr_retries_on_error = 1
519
- mock_deploys_with [
520
- [1, "Error: This is a stdout non-deterministic error\nDeploy failed\n", ''],
521
- [0, 'Deploy ok', '']
522
- ]
523
- expect(test_deployer.deploy_on('node')).to eq('node' => [
524
- 0,
525
- <<~EOS,
526
- Error: This is a stdout non-deterministic error
527
- Deploy failed
528
-
529
- Deployment exit status code: 1
530
- !!! Retry deployment due to non-deterministic error (0 remaining attempts)...
531
- Deploy ok
532
- EOS
533
- <<~EOS
534
- !!! 1 retriable errors detected in this deployment:
535
- * stdout non-deterministic error
536
-
537
- !!! Retry deployment due to non-deterministic error (0 remaining attempts)...
538
-
539
- EOS
540
- ])
541
- end
542
- end
543
-
544
- it 'restarts deployment for a non-deterministic error matched with a Regexp' do
545
- with_platform_to_retry_deploy do
546
- test_deployer.nbr_retries_on_error = 1
547
- mock_deploys_with [
548
- [1, "Error: This is a stdout regexp error 42\nDeploy failed\n", ''],
549
- [0, 'Deploy ok', '']
550
- ]
551
- expect(test_deployer.deploy_on('node')).to eq('node' => [
552
- 0,
553
- <<~EOS,
554
- Error: This is a stdout regexp error 42
555
- Deploy failed
556
-
557
- Deployment exit status code: 1
558
- !!! Retry deployment due to non-deterministic error (0 remaining attempts)...
559
- Deploy ok
560
- EOS
561
- <<~EOS
562
- !!! 1 retriable errors detected in this deployment:
563
- * /stdout regexp error \\d+/ matched 'stdout regexp error 42'
564
-
565
- !!! Retry deployment due to non-deterministic error (0 remaining attempts)...
566
-
567
- EOS
568
- ])
569
- end
570
- end
571
-
572
- it 'restarts deployment for a non-deterministic error on stderr' do
573
- with_platform_to_retry_deploy do
574
- test_deployer.nbr_retries_on_error = 1
575
- mock_deploys_with [
576
- [1, '', "Error: This is a stderr non-deterministic error\nDeploy failed\n"],
577
- [0, 'Deploy ok', '']
578
- ]
579
- expect(test_deployer.deploy_on('node')).to eq('node' => [
580
- 0,
581
- <<~EOS,
582
-
583
- Deployment exit status code: 1
584
- !!! Retry deployment due to non-deterministic error (0 remaining attempts)...
585
- Deploy ok
586
- EOS
587
- <<~EOS
588
- Error: This is a stderr non-deterministic error
589
- Deploy failed
590
- !!! 1 retriable errors detected in this deployment:
591
- * stderr non-deterministic error
592
-
593
- !!! Retry deployment due to non-deterministic error (0 remaining attempts)...
594
-
595
- EOS
596
- ])
597
- end
598
- end
599
-
600
- it 'restarts deployment for a non-deterministic error on stderr matched with a Regexp' do
601
- with_platform_to_retry_deploy do
602
- test_deployer.nbr_retries_on_error = 1
603
- mock_deploys_with [
604
- [1, '', "Error: This is a stderr regexp error 42\nDeploy failed\n"],
605
- [0, 'Deploy ok', '']
606
- ]
607
- expect(test_deployer.deploy_on('node')).to eq('node' => [
608
- 0,
609
- <<~EOS,
610
-
611
- Deployment exit status code: 1
612
- !!! Retry deployment due to non-deterministic error (0 remaining attempts)...
613
- Deploy ok
614
- EOS
615
- <<~EOS
616
- Error: This is a stderr regexp error 42
617
- Deploy failed
618
- !!! 1 retriable errors detected in this deployment:
619
- * /stderr regexp error \\d+/ matched 'stderr regexp error 42'
620
-
621
- !!! Retry deployment due to non-deterministic error (0 remaining attempts)...
622
-
623
- EOS
624
- ])
625
- end
626
- end
627
-
628
- it 'stops restarting deployments for a non-deterministic error when errors has disappeared, even if retries were remaining' do
629
- with_platform_to_retry_deploy do
630
- test_deployer.nbr_retries_on_error = 5
631
- mock_deploys_with [
632
- [1, "Error: This is a stdout non-deterministic error 1\nDeploy failed", ''],
633
- [1, "Error: This is a stdout non-deterministic error 2\nDeploy failed", ''],
634
- [0, 'Deploy ok', '']
635
- ]
636
- expect(test_deployer.deploy_on('node')).to eq('node' => [
637
- 0,
638
- <<~EOS,
639
- Error: This is a stdout non-deterministic error 1
640
- Deploy failed
641
- Deployment exit status code: 1
642
- !!! Retry deployment due to non-deterministic error (4 remaining attempts)...
643
- Error: This is a stdout non-deterministic error 2
644
- Deploy failed
645
-
646
- Deployment exit status code: 1
647
- !!! Retry deployment due to non-deterministic error (3 remaining attempts)...
648
- Deploy ok
649
- EOS
650
- <<~EOS
651
- !!! 1 retriable errors detected in this deployment:
652
- * stdout non-deterministic error
653
-
654
- !!! Retry deployment due to non-deterministic error (4 remaining attempts)...
655
- !!! 1 retriable errors detected in this deployment:
656
- * stdout non-deterministic error
657
-
658
-
659
- !!! Retry deployment due to non-deterministic error (3 remaining attempts)...
660
-
661
- EOS
662
- ])
663
- end
664
- end
665
-
666
- it 'stops restarting deployments for a non-deterministic error that became deterministic, even if retries were remaining' do
667
- with_platform_to_retry_deploy do
668
- test_deployer.nbr_retries_on_error = 5
669
- mock_deploys_with [
670
- [1, "Error: This is a stdout non-deterministic error 1\nDeploy failed", ''],
671
- [1, "Error: This is a stdout non-deterministic error 2\nDeploy failed", ''],
672
- [1, "Error: This is a stdout deterministic error 3\nDeploy failed", '']
673
- ]
674
- expect(test_deployer.deploy_on('node')).to eq('node' => [
675
- 1,
676
- <<~EOS,
677
- Error: This is a stdout non-deterministic error 1
678
- Deploy failed
679
- Deployment exit status code: 1
680
- !!! Retry deployment due to non-deterministic error (4 remaining attempts)...
681
- Error: This is a stdout non-deterministic error 2
682
- Deploy failed
683
-
684
- Deployment exit status code: 1
685
- !!! Retry deployment due to non-deterministic error (3 remaining attempts)...
686
- Error: This is a stdout deterministic error 3
687
- Deploy failed
688
- EOS
689
- <<~EOS
690
- !!! 1 retriable errors detected in this deployment:
691
- * stdout non-deterministic error
692
-
693
- !!! Retry deployment due to non-deterministic error (4 remaining attempts)...
694
- !!! 1 retriable errors detected in this deployment:
695
- * stdout non-deterministic error
696
-
697
-
698
- !!! Retry deployment due to non-deterministic error (3 remaining attempts)...
699
-
700
- EOS
701
- ])
702
- end
703
- end
704
-
705
- it 'does not restart deployment for a deterministic error' do
706
- with_platform_to_retry_deploy do
707
- test_deployer.nbr_retries_on_error = 5
708
- mock_deploys_with [
709
- [1, "Error: This is a stdout deterministic error\nDeploy failed\n", '']
710
- ]
711
- expect(test_deployer.deploy_on('node')).to eq('node' => [
712
- 1,
713
- <<~EOS,
714
- Error: This is a stdout deterministic error
715
- Deploy failed
716
- EOS
717
- ''
718
- ])
719
- end
720
- end
721
-
722
- it 'does not restart deployment for a non-deterministic error logged during a successful deploy' do
723
- with_platform_to_retry_deploy do
724
- test_deployer.nbr_retries_on_error = 5
725
- mock_deploys_with [
726
- [0, "Error: This is a stdout non-deterministic error\nDeploy failed\n", '']
727
- ]
728
- expect(test_deployer.deploy_on('node')).to eq('node' => [
729
- 0,
730
- <<~EOS,
731
- Error: This is a stdout non-deterministic error
732
- Deploy failed
733
- EOS
734
- ''
735
- ])
736
- end
737
- end
738
-
739
- it 'does not restart deployment for a non-deterministic error if retries are 0' do
740
- with_platform_to_retry_deploy do
741
- test_deployer.nbr_retries_on_error = 0
742
- mock_deploys_with [
743
- [1, "Error: This is a stdout non-deterministic error\nDeploy failed\n", '']
744
- ]
745
- expect(test_deployer.deploy_on('node')).to eq('node' => [
746
- 1,
747
- <<~EOS,
748
- Error: This is a stdout non-deterministic error
749
- Deploy failed
750
- EOS
751
- ''
752
- ])
753
- end
754
- end
755
-
756
- it 'restarts deployment for non-deterministic errors with a limited amount of retries' do
757
- with_platform_to_retry_deploy do
758
- test_deployer.nbr_retries_on_error = 2
759
- mock_deploys_with [
760
- [1, "Error: This is a stdout non-deterministic error 1\nDeploy failed", ''],
761
- [1, "Error: This is a stdout non-deterministic error 2\nDeploy failed", ''],
762
- [1, "Error: This is a stdout non-deterministic error 3\nDeploy failed", '']
763
- ]
764
- expect(test_deployer.deploy_on('node')).to eq('node' => [
765
- 1,
766
- <<~EOS,
767
- Error: This is a stdout non-deterministic error 1
768
- Deploy failed
769
- Deployment exit status code: 1
770
- !!! Retry deployment due to non-deterministic error (1 remaining attempts)...
771
- Error: This is a stdout non-deterministic error 2
772
- Deploy failed
773
-
774
- Deployment exit status code: 1
775
- !!! Retry deployment due to non-deterministic error (0 remaining attempts)...
776
- Error: This is a stdout non-deterministic error 3
777
- Deploy failed
778
- EOS
779
- <<~EOS
780
- !!! 1 retriable errors detected in this deployment:
781
- * stdout non-deterministic error
782
-
783
- !!! Retry deployment due to non-deterministic error (1 remaining attempts)...
784
- !!! 1 retriable errors detected in this deployment:
785
- * stdout non-deterministic error
786
-
787
-
788
- !!! Retry deployment due to non-deterministic error (0 remaining attempts)...
789
-
790
- EOS
791
- ])
792
- end
793
- end
794
-
795
- it 'restarts deployment for non-deterministic errors only on nodes needing it' do
796
- with_platform_to_retry_deploy(nodes_info: { nodes: {
797
- 'node1' => { services: %w[service] },
798
- 'node2' => { services: %w[service] },
799
- 'node3' => { services: %w[service] },
800
- 'node4' => { services: %w[service] }
801
- } }) do
802
- test_deployer.nbr_retries_on_error = 2
803
- # Some nodes deploy successfully,
804
- # others have deterministic errors,
805
- # others have non-deterministic errors being corrected
806
- # others have non-deterministic errors not being corrected
807
- mock_deploys_with [
808
- {
809
- 'node1' => [1, "Error: This is a stdout non-deterministic error\n[node1] Deploy failed\n", ''],
810
- 'node2' => [0, '[node2] Deploy ok', ''],
811
- 'node3' => [1, "Error: This is a stdout non-deterministic error\n[node3] Deploy failed\n", ''],
812
- 'node4' => [1, "Error: This is a stdout non-deterministic error\n[node4] Deploy failed\n", '']
813
- },
814
- {
815
- 'node1' => [0, '[node1] Deploy ok', ''],
816
- 'node3' => [1, "Error: This is a stdout deterministic error\n[node3] Deploy failed\n", ''],
817
- 'node4' => [1, "Error: This is a stdout non-deterministic error\n[node4] Deploy failed\n", '']
818
- },
819
- {
820
- 'node4' => [1, "Error: This is a stdout non-deterministic error\n[node4] Deploy failed\n", '']
821
- }
822
- ]
823
- expect(test_deployer.deploy_on(%w[node1 node2 node3 node4])).to eq(
824
- 'node1' => [
825
- 0,
826
- <<~EOS,
827
- Error: This is a stdout non-deterministic error
828
- [node1] Deploy failed
829
-
830
- Deployment exit status code: 1
831
- !!! Retry deployment due to non-deterministic error (1 remaining attempts)...
832
- [node1] Deploy ok
833
- EOS
834
- <<~EOS
835
- !!! 1 retriable errors detected in this deployment:
836
- * stdout non-deterministic error
837
-
838
- !!! Retry deployment due to non-deterministic error (1 remaining attempts)...
839
-
840
- EOS
841
- ],
842
- 'node2' => [
843
- 0,
844
- '[node2] Deploy ok',
845
- ''
846
- ],
847
- 'node3' => [
848
- 1,
849
- <<~EOS,
850
- Error: This is a stdout non-deterministic error
851
- [node3] Deploy failed
852
-
853
- Deployment exit status code: 1
854
- !!! Retry deployment due to non-deterministic error (1 remaining attempts)...
855
- Error: This is a stdout deterministic error
856
- [node3] Deploy failed
857
-
858
- EOS
859
- <<~EOS
860
- !!! 1 retriable errors detected in this deployment:
861
- * stdout non-deterministic error
862
-
863
- !!! Retry deployment due to non-deterministic error (1 remaining attempts)...
864
-
865
- EOS
866
- ],
867
- 'node4' => [
868
- 1,
869
- <<~EOS,
870
- Error: This is a stdout non-deterministic error
871
- [node4] Deploy failed
872
-
873
- Deployment exit status code: 1
874
- !!! Retry deployment due to non-deterministic error (1 remaining attempts)...
875
- Error: This is a stdout non-deterministic error
876
- [node4] Deploy failed
877
-
878
-
879
- Deployment exit status code: 1
880
- !!! Retry deployment due to non-deterministic error (0 remaining attempts)...
881
- Error: This is a stdout non-deterministic error
882
- [node4] Deploy failed
883
-
884
- EOS
885
- <<~EOS
886
- !!! 1 retriable errors detected in this deployment:
887
- * stdout non-deterministic error
888
-
889
- !!! Retry deployment due to non-deterministic error (1 remaining attempts)...
890
- !!! 1 retriable errors detected in this deployment:
891
- * stdout non-deterministic error
892
-
893
-
894
- !!! Retry deployment due to non-deterministic error (0 remaining attempts)...
895
-
896
- EOS
897
- ]
898
- )
899
- end
900
- end
901
-
902
- end
903
-
904
- end
905
-
906
- end
907
-
908
- end
909
-
910
- end
911
-
912
- end
913
-
914
- RSpec.configure do |c|
915
- c.extend HybridPlatformsConductorTest::Helpers::DeployerTestHelpers
916
- end