hybrid_platforms_conductor 32.17.0 → 33.0.2

Sign up to get free protection for your applications and to get access to all the features.
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,24 +1,24 @@
1
1
  describe HybridPlatformsConductor::ActionsExecutor do
2
2
 
3
- context 'checking timeouts' do
3
+ context 'when checking timeouts' do
4
4
 
5
5
  # Get a test platform to test timeouts
6
6
  #
7
7
  # Parameters::
8
- # * Proc: Code called with platform setup
9
- def with_test_platform_for_timeouts_tests
10
- with_test_platform_for_executor(nodes: { 'node' => {} }) do
11
- yield
12
- end
8
+ # * *block* (Proc): Code called with platform setup
9
+ def with_test_platform_for_timeouts_tests(&block)
10
+ with_test_platform_for_executor(nodes: { 'node' => {} }, &block)
13
11
  end
14
12
 
15
13
  it 'executes an action without timeout' do
16
14
  with_test_platform_for_timeouts_tests do
17
15
  expect(test_actions_executor.execute_actions(
18
- 'node' => { test_action: { code: proc do |stdout, _stderr, action|
19
- expect(action.timeout).to eq nil
20
- stdout << 'Hello'
21
- end } }
16
+ {
17
+ 'node' => { test_action: { code: proc do |stdout, _stderr, action|
18
+ expect(action.timeout).to eq nil
19
+ stdout << 'Hello'
20
+ end } }
21
+ }
22
22
  )['node']).to eq [0, 'Hello', '']
23
23
  end
24
24
  end
@@ -38,7 +38,7 @@ describe HybridPlatformsConductor::ActionsExecutor do
38
38
  it 'executes an action that fails because of timeout' do
39
39
  with_test_platform_for_timeouts_tests do
40
40
  expect(test_actions_executor.execute_actions(
41
- { 'node' => { test_action: { code: proc do |_stdout, _stderr, action|
41
+ { 'node' => { test_action: { code: proc do
42
42
  raise HybridPlatformsConductor::CmdRunner::TimeoutError
43
43
  end } } },
44
44
  timeout: 1
@@ -49,7 +49,7 @@ describe HybridPlatformsConductor::ActionsExecutor do
49
49
  it 'executes an action that fails because of timeout and outputs data before' do
50
50
  with_test_platform_for_timeouts_tests do
51
51
  expect(test_actions_executor.execute_actions(
52
- { 'node' => { test_action: { code: proc do |stdout, _stderr, action|
52
+ { 'node' => { test_action: { code: proc do |stdout|
53
53
  stdout << 'Hello'
54
54
  raise HybridPlatformsConductor::CmdRunner::TimeoutError
55
55
  end } } },
@@ -66,7 +66,7 @@ describe HybridPlatformsConductor::ActionsExecutor do
66
66
  sleep 1
67
67
  stdout << 'Hello'
68
68
  end } },
69
- { test_action: { code: proc do |stdout, _stderr, action|
69
+ { test_action: { code: proc do
70
70
  raise HybridPlatformsConductor::CmdRunner::TimeoutError
71
71
  end } }
72
72
  ] },
@@ -79,15 +79,15 @@ describe HybridPlatformsConductor::ActionsExecutor do
79
79
  with_test_platform_for_timeouts_tests do
80
80
  expect(test_actions_executor.execute_actions(
81
81
  { 'node' => [
82
- { test_action: { code: proc do |stdout, _stderr, action|
82
+ { test_action: { code: proc do |_stdout, _stderr, action|
83
83
  expect(action.timeout).to eq 5
84
84
  sleep 1
85
85
  end } },
86
- { test_action: { code: proc do |stdout, _stderr, action|
86
+ { test_action: { code: proc do |_stdout, _stderr, action|
87
87
  expect(action.timeout).to be_between(3.8, 4)
88
88
  sleep 1
89
89
  end } },
90
- { test_action: { code: proc do |stdout, _stderr, action|
90
+ { test_action: { code: proc do |_stdout, _stderr, action|
91
91
  expect(action.timeout).to be_between(2.8, 3)
92
92
  end } }
93
93
  ] },
@@ -8,21 +8,21 @@ describe HybridPlatformsConductor::CmdRunner do
8
8
  end
9
9
 
10
10
  it 'runs a simple bash command and returns exit code, stdout and stderr correctly' do
11
- with_repository do |repository|
12
- expect(test_cmd_runner.run_cmd "echo TestStderr 1>&2 ; echo TestStdout").to eq [0, "TestStdout\n", "TestStderr\n"]
11
+ with_repository do
12
+ expect(test_cmd_runner.run_cmd('echo TestStderr 1>&2 ; echo TestStdout')).to eq [0, "TestStdout\n", "TestStderr\n"]
13
13
  end
14
14
  end
15
15
 
16
16
  it 'runs a simple bash command and forces usage of bash' do
17
- with_repository do |repository|
17
+ with_repository do
18
18
  # Use set -o pipefail that does not work in /bin/sh
19
- expect(test_cmd_runner.run_cmd "set -o pipefail ; echo TestStderr 1>&2 ; echo TestStdout", force_bash: true).to eq [0, "TestStdout\n", "TestStderr\n"]
19
+ expect(test_cmd_runner.run_cmd('set -o pipefail ; echo TestStderr 1>&2 ; echo TestStdout', force_bash: true)).to eq [0, "TestStdout\n", "TestStderr\n"]
20
20
  end
21
21
  end
22
22
 
23
23
  it 'runs a simple bash command and logs stdout and stderr to a file' do
24
24
  with_repository do |repository|
25
- test_cmd_runner.run_cmd "echo TestStderr 1>&2 ; sleep 1 ; echo TestStdout", log_to_file: "#{repository}/test_file"
25
+ test_cmd_runner.run_cmd 'echo TestStderr 1>&2 ; sleep 1 ; echo TestStdout', log_to_file: "#{repository}/test_file"
26
26
  expect(File.read("#{repository}/test_file")).to eq "TestStderr\nTestStdout\n"
27
27
  end
28
28
  end
@@ -30,102 +30,102 @@ describe HybridPlatformsConductor::CmdRunner do
30
30
  it 'runs a simple bash command and logs stdout and stderr to an existing file' do
31
31
  with_repository do |repository|
32
32
  File.write("#{repository}/test_file", "Before\n")
33
- test_cmd_runner.run_cmd "echo TestStderr 1>&2 ; sleep 1 ; echo TestStdout", log_to_file: "#{repository}/test_file"
33
+ test_cmd_runner.run_cmd 'echo TestStderr 1>&2 ; sleep 1 ; echo TestStdout', log_to_file: "#{repository}/test_file"
34
34
  expect(File.read("#{repository}/test_file")).to eq "Before\nTestStderr\nTestStdout\n"
35
35
  end
36
36
  end
37
37
 
38
38
  it 'runs a simple bash command and logs stdout and stderr to IO objects' do
39
- with_repository do |repository|
39
+ with_repository do
40
40
  stdout = ''
41
41
  stderr = ''
42
- test_cmd_runner.run_cmd "echo TestStderr 1>&2 ; sleep 1 ; echo TestStdout", log_stdout_to_io: stdout, log_stderr_to_io: stderr
42
+ test_cmd_runner.run_cmd 'echo TestStderr 1>&2 ; sleep 1 ; echo TestStdout', log_stdout_to_io: stdout, log_stderr_to_io: stderr
43
43
  expect(stdout).to eq "TestStdout\n"
44
44
  expect(stderr).to eq "TestStderr\n"
45
45
  end
46
46
  end
47
47
 
48
48
  it 'fails when the command does not exit 0' do
49
- with_repository do |repository|
49
+ with_repository do
50
50
  expect { test_cmd_runner.run_cmd 'exit 1' }.to raise_error(HybridPlatformsConductor::CmdRunner::UnexpectedExitCodeError, 'Command \'exit 1\' returned error code 1 (expected 0).')
51
51
  end
52
52
  end
53
53
 
54
54
  it 'fails when the command does not exit with the expected code' do
55
- with_repository do |repository|
55
+ with_repository do
56
56
  expect { test_cmd_runner.run_cmd 'exit 1', expected_code: 2 }.to raise_error(HybridPlatformsConductor::CmdRunner::UnexpectedExitCodeError, 'Command \'exit 1\' returned error code 1 (expected 2).')
57
57
  end
58
58
  end
59
59
 
60
60
  it 'fails when the command does not exit with one of the expected codes' do
61
- with_repository do |repository|
61
+ with_repository do
62
62
  expect { test_cmd_runner.run_cmd 'exit 1', expected_code: [0, 2, 3] }.to raise_error(HybridPlatformsConductor::CmdRunner::UnexpectedExitCodeError, 'Command \'exit 1\' returned error code 1 (expected 0, 2, 3).')
63
63
  end
64
64
  end
65
65
 
66
66
  it 'does not fail when the command exits with the expected code' do
67
- with_repository do |repository|
68
- expect(test_cmd_runner.run_cmd 'exit 2', expected_code: 2).to eq [2, '', '']
67
+ with_repository do
68
+ expect(test_cmd_runner.run_cmd('exit 2', expected_code: 2)).to eq [2, '', '']
69
69
  end
70
70
  end
71
71
 
72
72
  it 'does not fail when the command exits with one of the expected codes' do
73
- with_repository do |repository|
74
- expect(test_cmd_runner.run_cmd 'exit 2', expected_code: [0, 2, 3]).to eq [2, '', '']
73
+ with_repository do
74
+ expect(test_cmd_runner.run_cmd('exit 2', expected_code: [0, 2, 3])).to eq [2, '', '']
75
75
  end
76
76
  end
77
77
 
78
78
  it 'does not fail when the command does not exit 0 and we specify no exception' do
79
- with_repository do |repository|
80
- expect(test_cmd_runner.run_cmd 'exit 1', no_exception: true).to eq [1, '', '']
79
+ with_repository do
80
+ expect(test_cmd_runner.run_cmd('exit 1', no_exception: true)).to eq [1, '', '']
81
81
  end
82
82
  end
83
83
 
84
84
  it 'does not fail when the command can\'t be run and we specify no exception' do
85
- with_repository do |repository|
85
+ with_repository do
86
86
  exit_status, stdout, stderr = test_cmd_runner.run_cmd 'unknown_command', no_exception: true
87
87
  expect(exit_status).to eq :command_error
88
88
  expect(stdout).to eq ''
89
- expect(stderr).to match /^No such file or directory - unknown_command.*/
89
+ expect(stderr).to match(/^No such file or directory - unknown_command.*/)
90
90
  end
91
91
  end
92
92
 
93
93
  it 'does not fail when the command is expected to not be run' do
94
- with_repository do |repository|
94
+ with_repository do
95
95
  exit_status, stdout, stderr = test_cmd_runner.run_cmd 'unknown_command', expected_code: :command_error
96
96
  expect(exit_status).to eq :command_error
97
97
  expect(stdout).to eq ''
98
- expect(stderr).to match /^No such file or directory - unknown_command.*/
98
+ expect(stderr).to match(/^No such file or directory - unknown_command.*/)
99
99
  end
100
100
  end
101
101
 
102
102
  it 'fails when the command times out' do
103
- with_repository do |repository|
103
+ with_repository do
104
104
  expect { test_cmd_runner.run_cmd 'sleep 5', timeout: 1 }.to raise_error(HybridPlatformsConductor::CmdRunner::TimeoutError, 'Command \'sleep 5\' returned error code timeout (expected 0).')
105
105
  end
106
106
  end
107
107
 
108
108
  it 'returns the timeout error when the command times out and we specify no exception' do
109
- with_repository do |repository|
110
- expect(test_cmd_runner.run_cmd 'sleep 5', timeout: 1, no_exception: true).to eq [:timeout, '', 'Timeout of 1 triggered']
109
+ with_repository do
110
+ expect(test_cmd_runner.run_cmd('sleep 5', timeout: 1, no_exception: true)).to eq [:timeout, '', 'Timeout of 1 triggered']
111
111
  end
112
112
  end
113
113
 
114
114
  it 'returns the timeout error when the command is expected to time out' do
115
- with_repository do |repository|
116
- expect(test_cmd_runner.run_cmd 'sleep 5', timeout: 1, expected_code: :timeout).to eq [:timeout, '', 'Timeout of 1 triggered']
115
+ with_repository do
116
+ expect(test_cmd_runner.run_cmd('sleep 5', timeout: 1, expected_code: :timeout)).to eq [:timeout, '', 'Timeout of 1 triggered']
117
117
  end
118
118
  end
119
119
 
120
120
  it 'returns the timeout error with previously output stdout and stderr when the command times out and we specify no exception' do
121
- with_repository do |repository|
122
- expect(test_cmd_runner.run_cmd 'echo TestStderr 1>&2 ; sleep 1 ; echo TestStdout ; sleep 5 ; echo NeverDisplayed', timeout: 2, no_exception: true).to eq [:timeout, "TestStdout\n", "TestStderr\n\nTimeout of 2 triggered"]
121
+ with_repository do
122
+ expect(test_cmd_runner.run_cmd('echo TestStderr 1>&2 ; sleep 1 ; echo TestStdout ; sleep 5 ; echo NeverDisplayed', timeout: 2, no_exception: true)).to eq [:timeout, "TestStdout\n", "TestStderr\n\nTimeout of 2 triggered"]
123
123
  end
124
124
  end
125
125
 
126
126
  it 'returns the timeout error with previously output stdout and stderr when the command times out as expected' do
127
- with_repository do |repository|
128
- expect(test_cmd_runner.run_cmd 'echo TestStderr 1>&2 ; sleep 1 ; echo TestStdout ; sleep 5 ; echo NeverDisplayed', timeout: 2, expected_code: :timeout).to eq [:timeout, "TestStdout\n", "TestStderr\n\nTimeout of 2 triggered"]
127
+ with_repository do
128
+ expect(test_cmd_runner.run_cmd('echo TestStderr 1>&2 ; sleep 1 ; echo TestStdout ; sleep 5 ; echo NeverDisplayed', timeout: 2, expected_code: :timeout)).to eq [:timeout, "TestStdout\n", "TestStderr\n\nTimeout of 2 triggered"]
129
129
  end
130
130
  end
131
131
 
@@ -133,7 +133,7 @@ describe HybridPlatformsConductor::CmdRunner do
133
133
  with_repository do |repository|
134
134
  cmd_runner = test_cmd_runner
135
135
  cmd_runner.dry_run = true
136
- expect(cmd_runner.run_cmd "echo TestContent >#{repository}/test_file").to eq [0, '', '']
136
+ expect(cmd_runner.run_cmd("echo TestContent >#{repository}/test_file")).to eq [0, '', '']
137
137
  expect(File.exist?("#{repository}/test_file")).to eq false
138
138
  end
139
139
  end
@@ -142,31 +142,31 @@ describe HybridPlatformsConductor::CmdRunner do
142
142
  with_repository do |repository|
143
143
  cmd_runner = test_cmd_runner
144
144
  cmd_runner.dry_run = true
145
- expect(cmd_runner.run_cmd "echo TestContent >#{repository}/test_file", expected_code: 2).to eq [2, '', '']
145
+ expect(cmd_runner.run_cmd("echo TestContent >#{repository}/test_file", expected_code: 2)).to eq [2, '', '']
146
146
  expect(File.exist?("#{repository}/test_file")).to eq false
147
147
  end
148
148
  end
149
149
 
150
150
  it 'returns the currently logged user' do
151
151
  cmd_runner = test_cmd_runner
152
- expect(cmd_runner).to receive(:run_cmd).with('whoami', log_to_stdout: false) { [0, 'test_user', ''] }
152
+ expect(cmd_runner).to receive(:run_cmd).with('whoami', log_to_stdout: false).and_return [0, 'test_user', '']
153
153
  expect(cmd_runner.whoami).to eq 'test_user'
154
154
  end
155
155
 
156
156
  it 'returns non-root user when user is not root' do
157
157
  cmd_runner = test_cmd_runner
158
- expect(cmd_runner).to receive(:run_cmd).with('whoami', log_to_stdout: false) { [0, 'not_root', ''] }
158
+ expect(cmd_runner).to receive(:run_cmd).with('whoami', log_to_stdout: false).and_return [0, 'not_root', '']
159
159
  expect(cmd_runner.root?).to eq false
160
160
  end
161
161
 
162
162
  it 'returns root user when user is root' do
163
163
  cmd_runner = test_cmd_runner
164
- expect(cmd_runner).to receive(:run_cmd).with('whoami', log_to_stdout: false) { [0, 'root', ''] }
164
+ expect(cmd_runner).to receive(:run_cmd).with('whoami', log_to_stdout: false).and_return [0, 'root', '']
165
165
  expect(cmd_runner.root?).to eq true
166
166
  end
167
167
 
168
168
  it 'returns the correct executable prefix' do
169
- expect(HybridPlatformsConductor::CmdRunner.executables_prefix).to eq "#{File.dirname($0)}/"
169
+ expect(described_class.executables_prefix).to eq "#{File.dirname($PROGRAM_NAME)}/"
170
170
  end
171
171
 
172
172
  end
@@ -7,23 +7,23 @@ describe HybridPlatformsConductor::Config do
7
7
  end
8
8
 
9
9
  it 'returns 1 defined OS image' do
10
- with_platforms 'os_image :image1, \'/path/to/image1\'' do
11
- expect(test_config.known_os_images).to eq [:image1]
10
+ with_platforms 'os_image :image_1, \'/path/to/image_1\'' do
11
+ expect(test_config.known_os_images).to eq [:image_1]
12
12
  end
13
13
  end
14
14
 
15
15
  it 'returns 1 defined OS image with its directory' do
16
- with_platforms 'os_image :image1, \'/path/to/image1\'' do
17
- expect(test_config.os_image_dir(:image1)).to eq '/path/to/image1'
16
+ with_platforms 'os_image :image_1, \'/path/to/image_1\'' do
17
+ expect(test_config.os_image_dir(:image_1)).to eq '/path/to/image_1'
18
18
  end
19
19
  end
20
20
 
21
21
  it 'returns several defined OS images' do
22
22
  with_platforms '
23
- os_image :image1, \'/path/to/image1\'
24
- os_image :image2, \'/path/to/image2\'
23
+ os_image :image_1, \'/path/to/image_1\'
24
+ os_image :image_2, \'/path/to/image_2\'
25
25
  ' do
26
- expect(test_config.known_os_images.sort).to eq %i[image1 image2].sort
26
+ expect(test_config.known_os_images.sort).to eq %i[image_1 image_2].sort
27
27
  end
28
28
  end
29
29
 
@@ -35,30 +35,32 @@ describe HybridPlatformsConductor::Config do
35
35
 
36
36
  it 'accesses the platform handler repositories if needed from the config' do
37
37
  with_repository do |repository|
38
- with_platforms "
39
- test_platform path: '#{repository}' do |repository_path|
40
- os_image :image1, \"\#{repository_path}/image_path\"
41
- end
42
- " do
43
- expect(test_config.known_os_images.sort).to eq %i[image1].sort
44
- expect(test_config.os_image_dir(:image1)).to eq "#{repository}/image_path"
38
+ with_platforms(
39
+ <<~EO_CONFIG
40
+ test_platform path: '#{repository}' do |repository_path|
41
+ os_image :image_1, "\#{repository_path}/image_path"
42
+ end
43
+ EO_CONFIG
44
+ ) do
45
+ expect(test_config.known_os_images.sort).to eq %i[image_1].sort
46
+ expect(test_config.os_image_dir(:image_1)).to eq "#{repository}/image_path"
45
47
  end
46
48
  end
47
49
  end
48
50
 
49
51
  it 'includes several configuration files' do
50
52
  with_platforms '
51
- os_image :image1, \'/path/to/image1\'
53
+ os_image :image_1, \'/path/to/image_1\'
52
54
  include_config_from "#{__dir__}/my_conf_1.rb"
53
55
  include_config_from "#{__dir__}/my_conf_2.rb"
54
56
  ' do |hybrid_platforms_dir|
55
- File.write("#{hybrid_platforms_dir}/my_conf_1.rb", <<~EOS)
56
- os_image :image4, '/path/to/image4'
57
- include_config_from "\#{__dir__}/my_conf_3.rb"
58
- EOS
59
- File.write("#{hybrid_platforms_dir}/my_conf_2.rb", 'os_image :image2, \'/path/to/image2\'')
60
- File.write("#{hybrid_platforms_dir}/my_conf_3.rb", 'os_image :image3, \'/path/to/image3\'')
61
- expect(test_config.known_os_images.sort).to eq %i[image1 image2 image3 image4].sort
57
+ File.write("#{hybrid_platforms_dir}/my_conf_1.rb", <<~'EO_CONFIG')
58
+ os_image :image_4, '/path/to/image_4'
59
+ include_config_from "#{__dir__}/my_conf_3.rb"
60
+ EO_CONFIG
61
+ File.write("#{hybrid_platforms_dir}/my_conf_2.rb", 'os_image :image_2, \'/path/to/image_2\'')
62
+ File.write("#{hybrid_platforms_dir}/my_conf_3.rb", 'os_image :image_3, \'/path/to/image_3\'')
63
+ expect(test_config.known_os_images.sort).to eq %i[image_1 image_2 image_3 image_4].sort
62
64
  end
63
65
  end
64
66
 
@@ -1,8 +1,10 @@
1
1
  describe HybridPlatformsConductor::Deployer do
2
2
 
3
- context 'checking why-run mode' do
3
+ context 'when checking why-run mode' do
4
4
 
5
- deploy_specs_for(check_mode: true)
5
+ it_behaves_like 'a deployer' do
6
+ let(:check_mode) { true }
7
+ end
6
8
 
7
9
  end
8
10
 
@@ -1,12 +1,50 @@
1
1
  describe HybridPlatformsConductor::Deployer do
2
2
 
3
- context 'checking deployer specific config DSL' do
3
+ context 'when checking deployer specific config DSL' do
4
4
 
5
5
  it 'declares a packaging timeout' do
6
- with_repository do |repository|
7
- with_platforms('packaging_timeout 666') do
8
- expect(test_config.packaging_timeout_secs).to eq 666
9
- end
6
+ with_platforms('packaging_timeout 666') do
7
+ expect(test_config.packaging_timeout_secs).to eq 666
8
+ end
9
+ end
10
+
11
+ it 'declares log plugins to be used' do
12
+ with_platforms(
13
+ <<~EO_CONFIG
14
+ send_logs_to %i[log_plugin_1 log_plugin_2]
15
+ for_nodes('node2') { send_logs_to :log_plugin_3 }
16
+ EO_CONFIG
17
+ ) do
18
+ expect(test_config.deployment_logs).to eq [
19
+ {
20
+ nodes_selectors_stack: [],
21
+ log_plugins: %i[log_plugin_1 log_plugin_2]
22
+ },
23
+ {
24
+ nodes_selectors_stack: %w[node2],
25
+ log_plugins: %i[log_plugin_3]
26
+ }
27
+ ]
28
+ end
29
+ end
30
+
31
+ it 'declares secrets readers plugins to be used' do
32
+ with_platforms(
33
+ <<~EO_CONFIG
34
+ read_secrets_from %i[secrets_reader_plugin_1 secrets_reader_plugin_2]
35
+ for_nodes('node2') { read_secrets_from :secrets_reader_plugin_3 }
36
+ EO_CONFIG
37
+ ) do
38
+ expect(test_config.secrets_readers).to eq [
39
+ {
40
+ nodes_selectors_stack: [],
41
+ secrets_readers: %i[secrets_reader_plugin_1 secrets_reader_plugin_2]
42
+ },
43
+ {
44
+ nodes_selectors_stack: %w[node2],
45
+ secrets_readers: %i[secrets_reader_plugin_3]
46
+ }
47
+ ]
10
48
  end
11
49
  end
12
50
 
@@ -1,241 +1,224 @@
1
1
  describe HybridPlatformsConductor::Deployer do
2
2
 
3
- context 'checking real deploy mode' do
3
+ context 'when checking real deploy mode' do
4
4
 
5
- deploy_specs_for(check_mode: false)
5
+ it_behaves_like 'a deployer' do
6
+ let(:check_mode) { false }
7
+ end
8
+
9
+ context 'when checking log plugins usage' do
6
10
 
7
- # Expect the test services handler to be called to deploy a given list of services
8
- #
9
- # Parameters::
10
- # * *services* (Hash<String, Array<String> >): List of services to be expected, per node name
11
- def expect_services_handler_to_deploy(services)
12
- expect(test_services_handler).to receive(:deploy_allowed?).with(
13
- services: services,
14
- secrets: {},
15
- local_environment: false
16
- ) do
17
- nil
11
+ # Prepare the test platform with test log plugins
12
+ #
13
+ # Parameters::
14
+ # * *platforms_info* (Hash): The platforms info
15
+ # * *as_git* (Boolean): As a git repository? [default: false]
16
+ # * *additional_config* (String): Additional config [default: 'send_logs_to :test_log']
17
+ # * *block* (Proc): Code called with the platform setup
18
+ # * Parameters::
19
+ # * *repository* (String): Platform's repository
20
+ def with_test_platform_for_deploy_tests(platforms_info, as_git: false, additional_config: 'send_logs_to :test_log', &block)
21
+ with_test_platform(platforms_info, as_git: as_git, additional_config: additional_config, &block)
18
22
  end
19
- expect(test_services_handler).to receive(:package).with(
20
- services: services,
21
- secrets: {},
22
- local_environment: false
23
- )
24
- expect(test_services_handler).to receive(:prepare_for_deploy).with(
25
- services: services,
26
- secrets: {},
27
- local_environment: false,
28
- why_run: false
29
- )
30
- services.each do |node, services|
31
- expect(test_services_handler).to receive(:actions_to_deploy_on).with(node, services, false) do
32
- [{ bash: "echo \"Deploying on #{node}\"" }]
33
- end
34
- expect(test_services_handler).to receive(:log_info_for).with(node, services) do
35
- {
36
- repo_name_0: 'platform',
37
- commit_id_0: '123456',
38
- commit_message_0: "Test commit for #{node}: #{services.join(', ')}"
39
- }
23
+
24
+ it 'deploys correct logs information on 1 node' do
25
+ with_test_platform_for_deploy_tests({ nodes: { 'node' => { services: %w[service1 service2] } } }, as_git: true) do
26
+ with_connections_mocked_on ['node'] do
27
+ test_actions_executor.connector(:ssh).ssh_user = 'test_user'
28
+ expect_services_handler_to_deploy('node' => %w[service1 service2])
29
+ expect_actions_executor_runs [
30
+ # First run, we expect the mutex to be setup, and the deployment actions to be run
31
+ proc { |actions_per_nodes| expect_actions_to_deploy_on(actions_per_nodes, 'node') },
32
+ # Second run, we expect the mutex to be released
33
+ proc { |actions_per_nodes| expect_actions_to_unlock(actions_per_nodes, 'node') },
34
+ # Third run, we expect logs to be uploaded on the node
35
+ proc { |actions_per_nodes| expect(actions_per_nodes).to eq('node' => [{ bash: 'echo Save test logs to node' }]) }
36
+ ]
37
+ expect(test_deployer.deploy_on('node')).to eq('node' => [0, 'Deploy successful', ''])
38
+ expect(HybridPlatformsConductorTest::TestLogPlugin.calls).to eq [
39
+ {
40
+ method: :actions_to_save_logs,
41
+ node: 'node',
42
+ services: %w[service1 service2],
43
+ deployment_info: {
44
+ repo_name_0: 'platform',
45
+ commit_id_0: '123456',
46
+ commit_message_0: 'Test commit for node: service1, service2',
47
+ user: 'test_user'
48
+ },
49
+ exit_status: 0,
50
+ stdout: 'Deploy successful',
51
+ stderr: ''
52
+ }
53
+ ]
54
+ end
40
55
  end
41
56
  end
42
- end
43
57
 
44
- it 'deploys correct logs information on 1 node' do
45
- with_test_platform({ nodes: { 'node' => { services: %w[service1 service2] } } }, true) do
46
- with_connections_mocked_on ['node'] do
47
- test_actions_executor.connector(:ssh).ssh_user = 'test_user'
48
- expect_services_handler_to_deploy('node' => %w[service1 service2])
49
- expect_actions_executor_runs([
50
- # First run, we expect the mutex to be setup, and the deployment actions to be run
51
- proc { |actions_per_nodes| expect_actions_to_deploy_on(actions_per_nodes, 'node') },
52
- # Second run, we expect the mutex to be released
53
- proc { |actions_per_nodes| expect_actions_to_unlock(actions_per_nodes, 'node') },
54
- # Third run, we expect logs to be uploaded on the node
55
- proc do |actions_per_nodes|
56
- # Check logs content
57
- local_log_file = actions_per_nodes['node'][:scp].first[0]
58
- expect(File.exist?(local_log_file)).to eq true
59
- expect_logs_to_be(File.read(local_log_file), 'Deploy successful', '',
60
- date: /\d\d\d\d-\d\d-\d\d \d\d:\d\d:\d\d/,
61
- user: 'test_user',
62
- debug: 'No',
63
- repo_name_0: 'platform',
64
- commit_id_0: '123456',
65
- commit_message_0: 'Test commit for node: service1, service2',
66
- services: 'service1, service2',
67
- exit_status: '0'
68
- )
69
- expect_actions_to_upload_logs(actions_per_nodes, 'node')
70
- end
71
- ])
72
- expect(test_deployer.deploy_on('node')).to eq('node' => [0, 'Deploy successful', ''])
58
+ it 'deploys correct logs information on several nodes' do
59
+ with_test_platform_for_deploy_tests(
60
+ {
61
+ nodes: {
62
+ 'node1' => { services: %w[service1] },
63
+ 'node2' => { services: %w[service2] }
64
+ }
65
+ },
66
+ as_git: true
67
+ ) do
68
+ with_connections_mocked_on %w[node1 node2] do
69
+ test_actions_executor.connector(:ssh).ssh_user = 'test_user'
70
+ expect_services_handler_to_deploy(
71
+ 'node1' => %w[service1],
72
+ 'node2' => %w[service2]
73
+ )
74
+ expect_actions_executor_runs [
75
+ # First run, we expect the mutex to be setup, and the deployment actions to be run
76
+ proc { |actions_per_nodes| expect_actions_to_deploy_on(actions_per_nodes, %w[node1 node2]) },
77
+ # Second run, we expect the mutex to be released
78
+ proc { |actions_per_nodes| expect_actions_to_unlock(actions_per_nodes, %w[node1 node2]) },
79
+ # Third run, we expect logs to be uploaded on the node
80
+ proc do |actions_per_nodes|
81
+ expect(actions_per_nodes).to eq(
82
+ 'node1' => [{ bash: 'echo Save test logs to node1' }],
83
+ 'node2' => [{ bash: 'echo Save test logs to node2' }]
84
+ )
85
+ end
86
+ ]
87
+ expect(test_deployer.deploy_on(%w[node1 node2])).to eq(
88
+ 'node1' => [0, 'Deploy successful', ''],
89
+ 'node2' => [0, 'Deploy successful', '']
90
+ )
91
+ expect(HybridPlatformsConductorTest::TestLogPlugin.calls).to eq [
92
+ {
93
+ method: :actions_to_save_logs,
94
+ node: 'node1',
95
+ services: %w[service1],
96
+ deployment_info: {
97
+ repo_name_0: 'platform',
98
+ commit_id_0: '123456',
99
+ commit_message_0: 'Test commit for node1: service1',
100
+ user: 'test_user'
101
+ },
102
+ exit_status: 0,
103
+ stdout: 'Deploy successful',
104
+ stderr: ''
105
+ },
106
+ {
107
+ method: :actions_to_save_logs,
108
+ node: 'node2',
109
+ services: %w[service2],
110
+ deployment_info: {
111
+ repo_name_0: 'platform',
112
+ commit_id_0: '123456',
113
+ commit_message_0: 'Test commit for node2: service2',
114
+ user: 'test_user'
115
+ },
116
+ exit_status: 0,
117
+ stdout: 'Deploy successful',
118
+ stderr: ''
119
+ }
120
+ ]
121
+ end
73
122
  end
74
123
  end
75
- end
76
124
 
77
- it 'deploys correct logs information on several nodes' do
78
- with_test_platform({ nodes: {
79
- 'node1' => { services: %w[service1] },
80
- 'node2' => { services: %w[service2] }
81
- } }, true) do
82
- with_connections_mocked_on %w[node1 node2] do
83
- test_actions_executor.connector(:ssh).ssh_user = 'test_user'
84
- expect_services_handler_to_deploy(
85
- 'node1' => %w[service1],
86
- 'node2' => %w[service2]
87
- )
88
- expect_actions_executor_runs([
89
- # First run, we expect the mutex to be setup, and the deployment actions to be run
90
- proc { |actions_per_nodes| expect_actions_to_deploy_on(actions_per_nodes, %w[node1 node2]) },
91
- # Second run, we expect the mutex to be released
92
- proc { |actions_per_nodes| expect_actions_to_unlock(actions_per_nodes, %w[node1 node2]) },
93
- # Third run, we expect logs to be uploaded on the node
94
- proc do |actions_per_nodes|
95
- # Check logs content
96
- local_log_file1 = actions_per_nodes['node1'][:scp].first[0]
97
- expect(File.exist?(local_log_file1)).to eq true
98
- expect_logs_to_be(File.read(local_log_file1), 'Deploy successful', '',
99
- date: /\d\d\d\d-\d\d-\d\d \d\d:\d\d:\d\d/,
100
- user: 'test_user',
101
- debug: 'No',
102
- repo_name_0: 'platform',
103
- commit_id_0: '123456',
104
- commit_message_0: 'Test commit for node1: service1',
105
- services: 'service1',
106
- exit_status: '0'
107
- )
108
- local_log_file2 = actions_per_nodes['node2'][:scp].first[0]
109
- expect(File.exist?(local_log_file2)).to eq true
110
- expect_logs_to_be(File.read(local_log_file2), 'Deploy successful', '',
111
- date: /\d\d\d\d-\d\d-\d\d \d\d:\d\d:\d\d/,
112
- user: 'test_user',
113
- debug: 'No',
114
- repo_name_0: 'platform',
115
- commit_id_0: '123456',
116
- commit_message_0: 'Test commit for node2: service2',
117
- services: 'service2',
118
- exit_status: '0'
119
- )
120
- expect_actions_to_upload_logs(actions_per_nodes, %w[node1 node2])
121
- end
122
- ])
123
- expect(test_deployer.deploy_on(%w[node1 node2])).to eq(
124
- 'node1' => [0, 'Deploy successful', ''],
125
- 'node2' => [0, 'Deploy successful', '']
126
- )
125
+ it 'deploys correct logs information on 1 node even when there is a failing deploy' do
126
+ with_test_platform_for_deploy_tests({ nodes: { 'node' => { services: %w[service1 service2] } } }, as_git: true) do
127
+ with_connections_mocked_on ['node'] do
128
+ test_actions_executor.connector(:ssh).ssh_user = 'test_user'
129
+ expect_services_handler_to_deploy('node' => %w[service1 service2])
130
+ expect_actions_executor_runs [
131
+ # First run, we expect the mutex to be setup, and the deployment actions to be run
132
+ proc do |actions_per_nodes|
133
+ expect_actions_to_deploy_on(
134
+ actions_per_nodes,
135
+ 'node',
136
+ mocked_result: { 'node' => [:failed_action, 'Failed deploy stdout', 'Failed deploy stderr'] }
137
+ )
138
+ end,
139
+ # Second run, we expect the mutex to be released
140
+ proc { |actions_per_nodes| expect_actions_to_unlock(actions_per_nodes, 'node') },
141
+ # Third run, we expect logs to be uploaded on the node
142
+ proc { |actions_per_nodes| expect(actions_per_nodes).to eq('node' => [{ bash: 'echo Save test logs to node' }]) }
143
+ ]
144
+ expect(test_deployer.deploy_on('node')).to eq('node' => [:failed_action, 'Failed deploy stdout', 'Failed deploy stderr'])
145
+ expect(HybridPlatformsConductorTest::TestLogPlugin.calls).to eq [
146
+ {
147
+ method: :actions_to_save_logs,
148
+ node: 'node',
149
+ services: %w[service1 service2],
150
+ deployment_info: {
151
+ repo_name_0: 'platform',
152
+ commit_id_0: '123456',
153
+ commit_message_0: 'Test commit for node: service1, service2',
154
+ user: 'test_user'
155
+ },
156
+ exit_status: :failed_action,
157
+ stdout: 'Failed deploy stdout',
158
+ stderr: 'Failed deploy stderr'
159
+ }
160
+ ]
161
+ end
127
162
  end
128
163
  end
129
- end
130
164
 
131
- it 'deploys correct logs information on 1 node even when there is a failing deploy' do
132
- with_test_platform({ nodes: { 'node' => { services: %w[service1 service2] } } }, true) do
133
- with_connections_mocked_on ['node'] do
134
- test_actions_executor.connector(:ssh).ssh_user = 'test_user'
135
- expect_services_handler_to_deploy('node' => %w[service1 service2])
136
- expect_actions_executor_runs([
137
- # First run, we expect the mutex to be setup, and the deployment actions to be run
165
+ it 'gets deployment info from log plugins' do
166
+ with_test_platform_for_deploy_tests({ nodes: { 'node' => {} } }) do
167
+ expect_actions_executor_runs [
168
+ # Expect the actions to get log files
138
169
  proc do |actions_per_nodes|
139
- expect_actions_to_deploy_on(
140
- actions_per_nodes,
141
- 'node',
142
- mocked_result: { 'node' => [:failed_action, "Failed deploy stdout\n", "Failed deploy stderr\n"] }
143
- )
144
- end,
145
- # Second run, we expect the mutex to be released
146
- proc { |actions_per_nodes| expect_actions_to_unlock(actions_per_nodes, 'node') },
147
- # Third run, we expect logs to be uploaded on the node
148
- proc do |actions_per_nodes|
149
- # Check logs content
150
- local_log_file = actions_per_nodes['node'][:scp].first[0]
151
- expect(File.exist?(local_log_file)).to eq true
152
- expect_logs_to_be(File.read(local_log_file), "Failed deploy stdout\n", 'Failed deploy stderr',
153
- date: /\d\d\d\d-\d\d-\d\d \d\d:\d\d:\d\d/,
154
- user: 'test_user',
155
- debug: 'No',
156
- repo_name_0: 'platform',
157
- commit_id_0: '123456',
158
- commit_message_0: 'Test commit for node: service1, service2',
159
- services: 'service1, service2',
160
- exit_status: 'failed_action'
161
- )
162
- expect_actions_to_upload_logs(actions_per_nodes, 'node')
170
+ expect(actions_per_nodes).to eq('node' => [{ bash: 'echo Read logs for node' }])
171
+ { 'node' => [42, 'Log files read stdout', 'Log files read stderr'] }
163
172
  end
164
- ])
165
- expect(test_deployer.deploy_on('node')).to eq('node' => [:failed_action, "Failed deploy stdout\n", "Failed deploy stderr\n"])
173
+ ]
174
+ expect(test_deployer.deployment_info_from('node')).to eq(
175
+ 'node' => {
176
+ deployment_info: { user: 'test_user' },
177
+ exit_status: 666,
178
+ services: %w[unknown],
179
+ stderr: 'Deployment test stderr',
180
+ stdout: 'Deployment test stdout'
181
+ }
182
+ )
183
+ expect(HybridPlatformsConductorTest::TestLogPlugin.calls).to eq [
184
+ {
185
+ method: :actions_to_read_logs,
186
+ node: 'node'
187
+ },
188
+ {
189
+ method: :logs_for,
190
+ node: 'node',
191
+ exit_status: 42,
192
+ stdout: 'Log files read stdout',
193
+ stderr: 'Log files read stderr'
194
+ }
195
+ ]
166
196
  end
167
197
  end
168
- end
169
-
170
- it 'gets deployment info from log files' do
171
- with_test_platform({ nodes: { 'node' => {} } }) do |repository|
172
- expect_actions_executor_runs([
173
- # Expect the actions to get log files
174
- proc do |actions_per_nodes|
175
- expect(actions_per_nodes).to eq('node' => { remote_bash: 'cd /var/log/deployments && ls -t | head -1 | xargs sed \'/===== STDOUT =====/q\'' })
176
- { 'node' => [0, "Property1: Value1\nProperty2: Value2", ''] }
177
- end
178
- ])
179
- expect(test_deployer.deployment_info_from('node')).to eq(
180
- 'node' => {
181
- Property1: 'Value1',
182
- Property2: 'Value2'
183
- }
184
- )
185
- end
186
- end
187
-
188
- it 'gets deployment info with some properties converted from log files' do
189
- with_test_platform({ nodes: { 'node' => {} } }) do |repository|
190
- expect_actions_executor_runs([
191
- # Expect the actions to get log files
192
- proc do |actions_per_nodes|
193
- expect(actions_per_nodes).to eq('node' => { remote_bash: 'cd /var/log/deployments && ls -t | head -1 | xargs sed \'/===== STDOUT =====/q\'' })
194
- { 'node' => [0, <<~EOS, ''] }
195
- date: Thu Nov 23 18:43:01 UTC 2017
196
- debug: Yes
197
- diff_files_0: file1, file2, file3
198
- services: service1, service2, service3
199
- EOS
200
- end
201
- ])
202
- expect(test_deployer.deployment_info_from('node')).to eq(
203
- 'node' => {
204
- date: Time.parse('2017-11-23 18:43:01 UTC'),
205
- debug: true,
206
- diff_files_0: %w[file1 file2 file3],
207
- services: %w[service1 service2 service3]
208
- }
209
- )
210
- end
211
- end
212
198
 
213
- it 'gets deployment info from several log files' do
214
- with_test_platform({ nodes: { 'node1' => {}, 'node2' => {} } }) do |repository|
215
- expect_actions_executor_runs([
216
- # Expect the actions to get log files
217
- proc do |actions_per_nodes|
218
- expect(actions_per_nodes).to eq(
219
- 'node1' => { remote_bash: 'cd /var/log/deployments && ls -t | head -1 | xargs sed \'/===== STDOUT =====/q\'' },
220
- 'node2' => { remote_bash: 'cd /var/log/deployments && ls -t | head -1 | xargs sed \'/===== STDOUT =====/q\'' }
221
- )
199
+ it 'gets deployment info from log plugins not having actions_to_read_logs' do
200
+ with_test_platform_for_deploy_tests({ nodes: { 'node' => {} } }, additional_config: 'send_logs_to :test_log_no_read') do
201
+ expect(test_deployer.deployment_info_from('node')).to eq(
202
+ 'node' => {
203
+ deployment_info: { user: 'test_user' },
204
+ exit_status: 666,
205
+ services: %w[unknown],
206
+ stderr: 'Deployment test stderr',
207
+ stdout: 'Deployment test stdout'
208
+ }
209
+ )
210
+ expect(HybridPlatformsConductorTest::TestLogNoReadPlugin.calls).to eq [
222
211
  {
223
- 'node1' => [0, "Property1: Value1\nProperty2: Value2", ''],
224
- 'node2' => [0, "Property3: Value3\nProperty4: Value4", '']
212
+ method: :logs_for,
213
+ node: 'node',
214
+ exit_status: nil,
215
+ stdout: nil,
216
+ stderr: nil
225
217
  }
226
- end
227
- ])
228
- expect(test_deployer.deployment_info_from(%w[node1 node2])).to eq(
229
- 'node1' => {
230
- Property1: 'Value1',
231
- Property2: 'Value2'
232
- },
233
- 'node2' => {
234
- Property3: 'Value3',
235
- Property4: 'Value4'
236
- }
237
- )
218
+ ]
219
+ end
238
220
  end
221
+
239
222
  end
240
223
 
241
224
  end