hybrid_platforms_conductor 32.18.0 → 33.0.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (255) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +36 -0
  3. data/README.md +3 -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 +8 -7
  8. data/bin/nodes_to_deploy +2 -2
  9. data/bin/setup +6 -6
  10. data/bin/topograph +1 -1
  11. data/docs/config_dsl.md +23 -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/plugins.md +21 -0
  19. data/docs/plugins/secrets_reader/cli.md +31 -0
  20. data/docs/plugins/secrets_reader/thycotic.md +46 -0
  21. data/lib/hybrid_platforms_conductor/action.rb +4 -4
  22. data/lib/hybrid_platforms_conductor/actions_executor.rb +37 -42
  23. data/lib/hybrid_platforms_conductor/bitbucket.rb +5 -4
  24. data/lib/hybrid_platforms_conductor/cmd_runner.rb +26 -23
  25. data/lib/hybrid_platforms_conductor/cmdb.rb +2 -2
  26. data/lib/hybrid_platforms_conductor/common_config_dsl/bitbucket.rb +2 -1
  27. data/lib/hybrid_platforms_conductor/common_config_dsl/confluence.rb +2 -1
  28. data/lib/hybrid_platforms_conductor/common_config_dsl/file_system_tests.rb +5 -4
  29. data/lib/hybrid_platforms_conductor/common_config_dsl/github.rb +4 -3
  30. data/lib/hybrid_platforms_conductor/common_config_dsl/idempotence_tests.rb +2 -2
  31. data/lib/hybrid_platforms_conductor/config.rb +8 -4
  32. data/lib/hybrid_platforms_conductor/confluence.rb +1 -1
  33. data/lib/hybrid_platforms_conductor/connector.rb +5 -2
  34. data/lib/hybrid_platforms_conductor/core_extensions/cleanroom/fix_kwargs.rb +116 -0
  35. data/lib/hybrid_platforms_conductor/core_extensions/symbol/zero.rb +24 -0
  36. data/lib/hybrid_platforms_conductor/credentials.rb +39 -36
  37. data/lib/hybrid_platforms_conductor/current_dir_monitor.rb +4 -1
  38. data/lib/hybrid_platforms_conductor/deployer.rb +185 -127
  39. data/lib/hybrid_platforms_conductor/executable.rb +20 -15
  40. data/lib/hybrid_platforms_conductor/hpc_plugins/cmdb/config.rb +10 -7
  41. data/lib/hybrid_platforms_conductor/hpc_plugins/cmdb/host_ip.rb +1 -1
  42. data/lib/hybrid_platforms_conductor/hpc_plugins/cmdb/host_keys.rb +2 -2
  43. data/lib/hybrid_platforms_conductor/hpc_plugins/cmdb/platform_handlers.rb +4 -4
  44. data/lib/hybrid_platforms_conductor/hpc_plugins/connector/local.rb +5 -1
  45. data/lib/hybrid_platforms_conductor/hpc_plugins/connector/ssh.rb +45 -49
  46. data/lib/hybrid_platforms_conductor/hpc_plugins/log/remote_fs.rb +6 -5
  47. data/lib/hybrid_platforms_conductor/hpc_plugins/platform_handler/serverless_chef.rb +77 -79
  48. data/lib/hybrid_platforms_conductor/hpc_plugins/platform_handler/serverless_chef/dsl_parser.rb +13 -0
  49. data/lib/hybrid_platforms_conductor/hpc_plugins/platform_handler/serverless_chef/recipes_tree_builder.rb +39 -38
  50. data/lib/hybrid_platforms_conductor/hpc_plugins/platform_handler/yaml_inventory.rb +5 -4
  51. data/lib/hybrid_platforms_conductor/hpc_plugins/provisioner/docker.rb +43 -45
  52. data/lib/hybrid_platforms_conductor/hpc_plugins/provisioner/podman.rb +18 -20
  53. data/lib/hybrid_platforms_conductor/hpc_plugins/provisioner/proxmox.rb +119 -118
  54. data/lib/hybrid_platforms_conductor/hpc_plugins/provisioner/proxmox/proxmox_waiter.rb +39 -43
  55. data/lib/hybrid_platforms_conductor/hpc_plugins/provisioner/proxmox/reserve_proxmox_container +9 -13
  56. data/lib/hybrid_platforms_conductor/hpc_plugins/report/confluence.rb +2 -2
  57. data/lib/hybrid_platforms_conductor/hpc_plugins/report/mediawiki.rb +28 -21
  58. data/lib/hybrid_platforms_conductor/hpc_plugins/report/stdout.rb +26 -22
  59. data/lib/hybrid_platforms_conductor/hpc_plugins/secrets_reader/cli.rb +77 -0
  60. data/lib/hybrid_platforms_conductor/hpc_plugins/secrets_reader/my_secrets_reader_plugin.rb.sample +46 -0
  61. data/lib/hybrid_platforms_conductor/hpc_plugins/secrets_reader/thycotic.rb +90 -0
  62. data/lib/hybrid_platforms_conductor/hpc_plugins/test/bitbucket_conf.rb +3 -3
  63. data/lib/hybrid_platforms_conductor/hpc_plugins/test/check_deploy_and_idempotence.rb +4 -2
  64. data/lib/hybrid_platforms_conductor/hpc_plugins/test/deploy_freshness.rb +0 -1
  65. data/lib/hybrid_platforms_conductor/hpc_plugins/test/deploy_removes_root_access.rb +21 -19
  66. data/lib/hybrid_platforms_conductor/hpc_plugins/test/divergence.rb +2 -2
  67. data/lib/hybrid_platforms_conductor/hpc_plugins/test/executables.rb +2 -2
  68. data/lib/hybrid_platforms_conductor/hpc_plugins/test/file_system.rb +19 -21
  69. data/lib/hybrid_platforms_conductor/hpc_plugins/test/file_system_hdfs.rb +19 -21
  70. data/lib/hybrid_platforms_conductor/hpc_plugins/test/github_ci.rb +2 -3
  71. data/lib/hybrid_platforms_conductor/hpc_plugins/test/idempotence.rb +2 -2
  72. data/lib/hybrid_platforms_conductor/hpc_plugins/test/ip.rb +1 -1
  73. data/lib/hybrid_platforms_conductor/hpc_plugins/test/jenkins_ci_conf.rb +21 -22
  74. data/lib/hybrid_platforms_conductor/hpc_plugins/test/jenkins_ci_masters_ok.rb +10 -12
  75. data/lib/hybrid_platforms_conductor/hpc_plugins/test/linear_strategy.rb +9 -9
  76. data/lib/hybrid_platforms_conductor/hpc_plugins/test/local_users.rb +2 -2
  77. data/lib/hybrid_platforms_conductor/hpc_plugins/test/mounts.rb +2 -2
  78. data/lib/hybrid_platforms_conductor/hpc_plugins/test/orphan_files.rb +10 -9
  79. data/lib/hybrid_platforms_conductor/hpc_plugins/test/ports.rb +2 -2
  80. data/lib/hybrid_platforms_conductor/hpc_plugins/test/private_ips.rb +5 -5
  81. data/lib/hybrid_platforms_conductor/hpc_plugins/test/public_ips.rb +5 -5
  82. data/lib/hybrid_platforms_conductor/hpc_plugins/test/spectre.rb +4 -6
  83. data/lib/hybrid_platforms_conductor/hpc_plugins/test/veids.rb +3 -3
  84. data/lib/hybrid_platforms_conductor/hpc_plugins/test/vulnerabilities.rb +25 -24
  85. data/lib/hybrid_platforms_conductor/hpc_plugins/test_report/confluence.rb +2 -2
  86. data/lib/hybrid_platforms_conductor/hpc_plugins/test_report/stdout.rb +8 -6
  87. data/lib/hybrid_platforms_conductor/io_router.rb +14 -13
  88. data/lib/hybrid_platforms_conductor/json_dumper.rb +2 -2
  89. data/lib/hybrid_platforms_conductor/log.rb +2 -2
  90. data/lib/hybrid_platforms_conductor/logger_helpers.rb +19 -16
  91. data/lib/hybrid_platforms_conductor/nodes_handler.rb +89 -71
  92. data/lib/hybrid_platforms_conductor/parallel_threads.rb +7 -11
  93. data/lib/hybrid_platforms_conductor/platform_handler.rb +7 -7
  94. data/lib/hybrid_platforms_conductor/platforms_handler.rb +5 -3
  95. data/lib/hybrid_platforms_conductor/plugin.rb +2 -2
  96. data/lib/hybrid_platforms_conductor/plugins.rb +14 -8
  97. data/lib/hybrid_platforms_conductor/provisioner.rb +4 -4
  98. data/lib/hybrid_platforms_conductor/report.rb +2 -2
  99. data/lib/hybrid_platforms_conductor/reports_handler.rb +3 -2
  100. data/lib/hybrid_platforms_conductor/secrets_reader.rb +31 -0
  101. data/lib/hybrid_platforms_conductor/services_handler.rb +32 -29
  102. data/lib/hybrid_platforms_conductor/test_only_remote_node.rb +1 -1
  103. data/lib/hybrid_platforms_conductor/test_report.rb +15 -18
  104. data/lib/hybrid_platforms_conductor/tests_runner.rb +116 -118
  105. data/lib/hybrid_platforms_conductor/thycotic.rb +28 -19
  106. data/lib/hybrid_platforms_conductor/topographer.rb +200 -190
  107. data/lib/hybrid_platforms_conductor/topographer/plugins/graphviz.rb +8 -8
  108. data/lib/hybrid_platforms_conductor/topographer/plugins/json.rb +4 -4
  109. data/lib/hybrid_platforms_conductor/version.rb +1 -1
  110. data/spec/hybrid_platforms_conductor_test.rb +29 -6
  111. data/spec/hybrid_platforms_conductor_test/api/actions_executor/actions/bash_spec.rb +18 -11
  112. data/spec/hybrid_platforms_conductor_test/api/actions_executor/actions/interactive_spec.rb +2 -2
  113. data/spec/hybrid_platforms_conductor_test/api/actions_executor/actions/remote_bash_spec.rb +32 -21
  114. data/spec/hybrid_platforms_conductor_test/api/actions_executor/actions/ruby_spec.rb +75 -49
  115. data/spec/hybrid_platforms_conductor_test/api/actions_executor/actions/scp_spec.rb +27 -15
  116. data/spec/hybrid_platforms_conductor_test/api/actions_executor/actions_spec.rb +90 -59
  117. data/spec/hybrid_platforms_conductor_test/api/actions_executor/connection_spec.rb +46 -44
  118. data/spec/hybrid_platforms_conductor_test/api/actions_executor/connectors/local/connectable_nodes_spec.rb +12 -8
  119. data/spec/hybrid_platforms_conductor_test/api/actions_executor/connectors/local/remote_actions_spec.rb +4 -7
  120. data/spec/hybrid_platforms_conductor_test/api/actions_executor/connectors/ssh/cli_options_spec.rb +21 -22
  121. data/spec/hybrid_platforms_conductor_test/api/actions_executor/connectors/ssh/config_dsl_spec.rb +23 -24
  122. data/spec/hybrid_platforms_conductor_test/api/actions_executor/connectors/ssh/connectable_nodes_spec.rb +10 -6
  123. data/spec/hybrid_platforms_conductor_test/api/actions_executor/connectors/ssh/connections_spec.rb +106 -75
  124. data/spec/hybrid_platforms_conductor_test/api/actions_executor/connectors/ssh/global_helpers_spec.rb +145 -126
  125. data/spec/hybrid_platforms_conductor_test/api/actions_executor/connectors/ssh/node_helpers_spec.rb +3 -3
  126. data/spec/hybrid_platforms_conductor_test/api/actions_executor/connectors/ssh/remote_actions_spec.rb +29 -25
  127. data/spec/hybrid_platforms_conductor_test/api/actions_executor/logging_spec.rb +167 -142
  128. data/spec/hybrid_platforms_conductor_test/api/actions_executor/parallel_spec.rb +272 -244
  129. data/spec/hybrid_platforms_conductor_test/api/actions_executor/timeout_spec.rb +16 -16
  130. data/spec/hybrid_platforms_conductor_test/api/cmd_runner_spec.rb +42 -36
  131. data/spec/hybrid_platforms_conductor_test/api/config_spec.rb +24 -22
  132. data/spec/hybrid_platforms_conductor_test/api/deployer/check_spec.rb +4 -2
  133. data/spec/hybrid_platforms_conductor_test/api/deployer/config_dsl_spec.rb +24 -6
  134. data/spec/hybrid_platforms_conductor_test/api/deployer/deploy_spec.rb +34 -26
  135. data/spec/hybrid_platforms_conductor_test/api/deployer/log_plugins/remote_fs_spec.rb +21 -21
  136. data/spec/hybrid_platforms_conductor_test/api/deployer/parse_deploy_output_spec.rb +55 -59
  137. data/spec/hybrid_platforms_conductor_test/api/deployer/provisioner_spec.rb +36 -62
  138. data/spec/hybrid_platforms_conductor_test/api/deployer/provisioners/podman_spec.rb +17 -17
  139. data/spec/hybrid_platforms_conductor_test/api/deployer/provisioners/proxmox/config_dsl_spec.rb +4 -4
  140. data/spec/hybrid_platforms_conductor_test/api/deployer/provisioners/proxmox/create_spec.rb +44 -51
  141. data/spec/hybrid_platforms_conductor_test/api/deployer/provisioners/proxmox/destroy_spec.rb +3 -3
  142. data/spec/hybrid_platforms_conductor_test/api/deployer/provisioners/proxmox/ip_spec.rb +12 -16
  143. data/spec/hybrid_platforms_conductor_test/api/deployer/provisioners/proxmox/reserve_proxmox_container/destroy_vm_spec.rb +31 -19
  144. data/spec/hybrid_platforms_conductor_test/api/deployer/provisioners/proxmox/reserve_proxmox_container/expired_containers_spec.rb +324 -266
  145. data/spec/hybrid_platforms_conductor_test/api/deployer/provisioners/proxmox/reserve_proxmox_container/ips_assignment_spec.rb +89 -61
  146. data/spec/hybrid_platforms_conductor_test/api/deployer/provisioners/proxmox/reserve_proxmox_container/other_lxc_containers_resources_spec.rb +117 -93
  147. data/spec/hybrid_platforms_conductor_test/api/deployer/provisioners/proxmox/reserve_proxmox_container/pve_node_resources_spec.rb +71 -54
  148. data/spec/hybrid_platforms_conductor_test/api/deployer/provisioners/proxmox/reserve_proxmox_container/retries_spec.rb +10 -8
  149. data/spec/hybrid_platforms_conductor_test/api/deployer/provisioners/proxmox/reserve_proxmox_container/vm_ids_assignment_spec.rb +80 -60
  150. data/spec/hybrid_platforms_conductor_test/api/deployer/provisioners/proxmox/start_spec.rb +1 -1
  151. data/spec/hybrid_platforms_conductor_test/api/deployer/provisioners/proxmox/state_spec.rb +1 -1
  152. data/spec/hybrid_platforms_conductor_test/api/deployer/provisioners/proxmox/stop_spec.rb +1 -1
  153. data/spec/hybrid_platforms_conductor_test/api/deployer/secrets_reader_plugins/cli_spec.rb +64 -0
  154. data/spec/hybrid_platforms_conductor_test/api/deployer/secrets_reader_plugins/thycotic_spec.rb +268 -0
  155. data/spec/hybrid_platforms_conductor_test/api/nodes_handler/cmdbs/config_spec.rb +8 -10
  156. data/spec/hybrid_platforms_conductor_test/api/nodes_handler/cmdbs/host_ip_spec.rb +33 -24
  157. data/spec/hybrid_platforms_conductor_test/api/nodes_handler/cmdbs/host_keys_spec.rb +64 -51
  158. data/spec/hybrid_platforms_conductor_test/api/nodes_handler/cmdbs/platform_handlers_spec.rb +3 -3
  159. data/spec/hybrid_platforms_conductor_test/api/nodes_handler/cmdbs_plugins_api_spec.rb +50 -51
  160. data/spec/hybrid_platforms_conductor_test/api/nodes_handler/common_spec.rb +91 -81
  161. data/spec/hybrid_platforms_conductor_test/api/nodes_handler/config_dsl_spec.rb +14 -16
  162. data/spec/hybrid_platforms_conductor_test/api/nodes_handler/git_diff_impacts_spec.rb +51 -75
  163. data/spec/hybrid_platforms_conductor_test/api/nodes_handler/nodes_selectors_spec.rb +35 -26
  164. data/spec/hybrid_platforms_conductor_test/api/nodes_handler/platform_handlers_plugins_api_spec.rb +24 -16
  165. data/spec/hybrid_platforms_conductor_test/api/nodes_handler/several_platforms_spec.rb +29 -19
  166. data/spec/hybrid_platforms_conductor_test/api/platform_handler_spec.rb +4 -4
  167. data/spec/hybrid_platforms_conductor_test/api/platform_handlers/serverless_chef/config_dsl_spec.rb +2 -2
  168. data/spec/hybrid_platforms_conductor_test/api/platform_handlers/serverless_chef/deploy_output_parsing_spec.rb +6 -6
  169. data/spec/hybrid_platforms_conductor_test/api/platform_handlers/serverless_chef/diff_impacts_spec.rb +57 -99
  170. data/spec/hybrid_platforms_conductor_test/api/platform_handlers/serverless_chef/inventory_spec.rb +4 -4
  171. data/spec/hybrid_platforms_conductor_test/api/platform_handlers/serverless_chef/packaging_spec.rb +32 -35
  172. data/spec/hybrid_platforms_conductor_test/api/platform_handlers/serverless_chef/services_deployment_spec.rb +10 -10
  173. data/spec/hybrid_platforms_conductor_test/api/platforms_handler_spec.rb +38 -27
  174. data/spec/hybrid_platforms_conductor_test/api/plugins_spec.rb +46 -52
  175. data/spec/hybrid_platforms_conductor_test/api/reports_handler_spec.rb +2 -2
  176. data/spec/hybrid_platforms_conductor_test/api/services_handler/actions_to_deploy_spec.rb +90 -58
  177. data/spec/hybrid_platforms_conductor_test/api/services_handler/deploy_allowed_spec.rb +38 -34
  178. data/spec/hybrid_platforms_conductor_test/api/services_handler/log_info_spec.rb +11 -9
  179. data/spec/hybrid_platforms_conductor_test/api/services_handler/package_spec.rb +193 -171
  180. data/spec/hybrid_platforms_conductor_test/api/services_handler/parse_deploy_output_spec.rb +66 -54
  181. data/spec/hybrid_platforms_conductor_test/api/services_handler/prepare_for_deploy_spec.rb +147 -133
  182. data/spec/hybrid_platforms_conductor_test/api/tests_runner/common_spec.rb +69 -49
  183. data/spec/hybrid_platforms_conductor_test/api/tests_runner/global_spec.rb +4 -3
  184. data/spec/hybrid_platforms_conductor_test/api/tests_runner/node_check_spec.rb +8 -5
  185. data/spec/hybrid_platforms_conductor_test/api/tests_runner/node_spec.rb +8 -5
  186. data/spec/hybrid_platforms_conductor_test/api/tests_runner/node_ssh_spec.rb +30 -27
  187. data/spec/hybrid_platforms_conductor_test/api/tests_runner/platform_spec.rb +12 -9
  188. data/spec/hybrid_platforms_conductor_test/api/tests_runner/reports_spec.rb +48 -47
  189. data/spec/hybrid_platforms_conductor_test/api/tests_runner/test_plugins/bitbucket_conf_spec.rb +5 -5
  190. data/spec/hybrid_platforms_conductor_test/api/tests_runner/test_plugins/github_ci_spec.rb +5 -5
  191. data/spec/hybrid_platforms_conductor_test/api/tests_runner/test_reports_plugins/confluence_spec.rb +5 -5
  192. data/spec/hybrid_platforms_conductor_test/cmdb_plugins/test_cmdb.rb +9 -9
  193. data/spec/hybrid_platforms_conductor_test/cmdb_plugins/{test_cmdb2.rb → test_cmdb_2.rb} +6 -6
  194. data/spec/hybrid_platforms_conductor_test/cmdb_plugins/test_cmdb_others.rb +3 -3
  195. data/spec/hybrid_platforms_conductor_test/cmdb_plugins/{test_cmdb_others2.rb → test_cmdb_others_2.rb} +2 -2
  196. data/spec/hybrid_platforms_conductor_test/docs_spec.rb +1 -1
  197. data/spec/hybrid_platforms_conductor_test/executables/{check-node_spec.rb → check_node_spec.rb} +4 -6
  198. data/spec/hybrid_platforms_conductor_test/executables/deploy_spec.rb +4 -6
  199. data/spec/hybrid_platforms_conductor_test/executables/get_impacted_nodes_spec.rb +76 -77
  200. data/spec/hybrid_platforms_conductor_test/executables/last_deploys_spec.rb +13 -15
  201. data/spec/hybrid_platforms_conductor_test/executables/nodes_to_deploy_spec.rb +289 -307
  202. data/spec/hybrid_platforms_conductor_test/executables/options/actions_executor_spec.rb +4 -6
  203. data/spec/hybrid_platforms_conductor_test/executables/options/cmd_runner_spec.rb +3 -5
  204. data/spec/hybrid_platforms_conductor_test/executables/options/common_spec.rb +8 -9
  205. data/spec/hybrid_platforms_conductor_test/executables/options/deployer_spec.rb +12 -196
  206. data/spec/hybrid_platforms_conductor_test/executables/options/nodes_handler_spec.rb +9 -10
  207. data/spec/hybrid_platforms_conductor_test/executables/options/nodes_selectors_spec.rb +9 -10
  208. data/spec/hybrid_platforms_conductor_test/executables/options/reports_handler_spec.rb +1 -1
  209. data/spec/hybrid_platforms_conductor_test/executables/options/tests_runner_spec.rb +22 -22
  210. data/spec/hybrid_platforms_conductor_test/executables/report_spec.rb +22 -16
  211. data/spec/hybrid_platforms_conductor_test/executables/run_spec.rb +32 -32
  212. data/spec/hybrid_platforms_conductor_test/executables/ssh_config_spec.rb +7 -9
  213. data/spec/hybrid_platforms_conductor_test/executables/test_spec.rb +3 -5
  214. data/spec/hybrid_platforms_conductor_test/helpers/actions_executor_helpers.rb +2 -2
  215. data/spec/hybrid_platforms_conductor_test/helpers/cmd_runner_helpers.rb +4 -3
  216. data/spec/hybrid_platforms_conductor_test/helpers/cmdb_helpers.rb +2 -2
  217. data/spec/hybrid_platforms_conductor_test/helpers/config_helpers.rb +1 -1
  218. data/spec/hybrid_platforms_conductor_test/helpers/connector_ssh_helpers.rb +12 -13
  219. data/spec/hybrid_platforms_conductor_test/helpers/deployer_helpers.rb +216 -14
  220. data/spec/hybrid_platforms_conductor_test/helpers/executables_helpers.rb +11 -11
  221. data/spec/hybrid_platforms_conductor_test/helpers/nodes_handler_helpers.rb +1 -1
  222. data/spec/hybrid_platforms_conductor_test/helpers/platforms_handler_helpers.rb +39 -28
  223. data/spec/hybrid_platforms_conductor_test/helpers/plugins_helpers.rb +1 -1
  224. data/spec/hybrid_platforms_conductor_test/helpers/provisioner_proxmox_helpers.rb +86 -111
  225. data/spec/hybrid_platforms_conductor_test/helpers/reports_handler_helpers.rb +1 -1
  226. data/spec/hybrid_platforms_conductor_test/helpers/serverless_chef_helpers.rb +3 -3
  227. data/spec/hybrid_platforms_conductor_test/helpers/services_handler_helpers.rb +1 -1
  228. data/spec/hybrid_platforms_conductor_test/helpers/tests_runner_helpers.rb +1 -1
  229. 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
  230. 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
  231. 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
  232. 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
  233. data/spec/hybrid_platforms_conductor_test/platform_handler_plugins/test.rb +1 -1
  234. data/spec/hybrid_platforms_conductor_test/platform_handler_plugins/{test2.rb → test_2.rb} +0 -0
  235. data/spec/hybrid_platforms_conductor_test/rubocop_spec.rb +31 -0
  236. data/spec/hybrid_platforms_conductor_test/serverless_chef_repositories/1_node/nodes/node.json +3 -3
  237. data/spec/hybrid_platforms_conductor_test/serverless_chef_repositories/data_bags/nodes/node.json +3 -3
  238. data/spec/hybrid_platforms_conductor_test/serverless_chef_repositories/recipes/cookbooks/test_cookbook_2/libraries/default.rb +1 -0
  239. data/spec/hybrid_platforms_conductor_test/serverless_chef_repositories/several_cookbooks/other_cookbooks/test_cookbook_2/libraries/default.rb +1 -0
  240. data/spec/hybrid_platforms_conductor_test/shared_examples/deployer.rb +952 -0
  241. data/spec/hybrid_platforms_conductor_test/test_connector.rb +4 -3
  242. data/spec/hybrid_platforms_conductor_test/test_log_no_read_plugin.rb +3 -1
  243. data/spec/hybrid_platforms_conductor_test/test_log_plugin.rb +3 -1
  244. data/spec/hybrid_platforms_conductor_test/test_plugins/global.rb +1 -0
  245. data/spec/hybrid_platforms_conductor_test/test_plugins/node.rb +1 -0
  246. data/spec/hybrid_platforms_conductor_test/test_plugins/node_check.rb +1 -0
  247. data/spec/hybrid_platforms_conductor_test/test_plugins/platform.rb +1 -0
  248. data/spec/hybrid_platforms_conductor_test/test_plugins/several_checks.rb +2 -2
  249. data/spec/hybrid_platforms_conductor_test/test_secrets_reader_plugin.rb +45 -0
  250. data/spec/hybrid_platforms_conductor_test/tests_report_plugin.rb +5 -6
  251. data/spec/spec_helper.rb +17 -18
  252. data/tools/check_md +16 -20
  253. data/tools/generate_mermaid +1 -1
  254. metadata +186 -144
  255. 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,108 @@ 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
+ it 'runs a command in an un-bundled environment' do
49
+ with_repository do
50
+ expect(test_cmd_runner.run_cmd('echo "${BUNDLE_GEMFILE}"')).to eq [0, "\n", '']
51
+ end
52
+ end
53
+
48
54
  it 'fails when the command does not exit 0' do
49
- with_repository do |repository|
55
+ with_repository do
50
56
  expect { test_cmd_runner.run_cmd 'exit 1' }.to raise_error(HybridPlatformsConductor::CmdRunner::UnexpectedExitCodeError, 'Command \'exit 1\' returned error code 1 (expected 0).')
51
57
  end
52
58
  end
53
59
 
54
60
  it 'fails when the command does not exit with the expected code' do
55
- with_repository do |repository|
61
+ with_repository do
56
62
  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
63
  end
58
64
  end
59
65
 
60
66
  it 'fails when the command does not exit with one of the expected codes' do
61
- with_repository do |repository|
67
+ with_repository do
62
68
  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
69
  end
64
70
  end
65
71
 
66
72
  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, '', '']
73
+ with_repository do
74
+ expect(test_cmd_runner.run_cmd('exit 2', expected_code: 2)).to eq [2, '', '']
69
75
  end
70
76
  end
71
77
 
72
78
  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, '', '']
79
+ with_repository do
80
+ expect(test_cmd_runner.run_cmd('exit 2', expected_code: [0, 2, 3])).to eq [2, '', '']
75
81
  end
76
82
  end
77
83
 
78
84
  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, '', '']
85
+ with_repository do
86
+ expect(test_cmd_runner.run_cmd('exit 1', no_exception: true)).to eq [1, '', '']
81
87
  end
82
88
  end
83
89
 
84
90
  it 'does not fail when the command can\'t be run and we specify no exception' do
85
- with_repository do |repository|
91
+ with_repository do
86
92
  exit_status, stdout, stderr = test_cmd_runner.run_cmd 'unknown_command', no_exception: true
87
93
  expect(exit_status).to eq :command_error
88
94
  expect(stdout).to eq ''
89
- expect(stderr).to match /^No such file or directory - unknown_command.*/
95
+ expect(stderr).to match(/^No such file or directory - unknown_command.*/)
90
96
  end
91
97
  end
92
98
 
93
99
  it 'does not fail when the command is expected to not be run' do
94
- with_repository do |repository|
100
+ with_repository do
95
101
  exit_status, stdout, stderr = test_cmd_runner.run_cmd 'unknown_command', expected_code: :command_error
96
102
  expect(exit_status).to eq :command_error
97
103
  expect(stdout).to eq ''
98
- expect(stderr).to match /^No such file or directory - unknown_command.*/
104
+ expect(stderr).to match(/^No such file or directory - unknown_command.*/)
99
105
  end
100
106
  end
101
107
 
102
108
  it 'fails when the command times out' do
103
- with_repository do |repository|
109
+ with_repository do
104
110
  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
111
  end
106
112
  end
107
113
 
108
114
  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']
115
+ with_repository do
116
+ expect(test_cmd_runner.run_cmd('sleep 5', timeout: 1, no_exception: true)).to eq [:timeout, '', 'Timeout of 1 triggered']
111
117
  end
112
118
  end
113
119
 
114
120
  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']
121
+ with_repository do
122
+ expect(test_cmd_runner.run_cmd('sleep 5', timeout: 1, expected_code: :timeout)).to eq [:timeout, '', 'Timeout of 1 triggered']
117
123
  end
118
124
  end
119
125
 
120
126
  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"]
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, no_exception: true)).to eq [:timeout, "TestStdout\n", "TestStderr\n\nTimeout of 2 triggered"]
123
129
  end
124
130
  end
125
131
 
126
132
  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"]
133
+ with_repository do
134
+ 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
135
  end
130
136
  end
131
137
 
@@ -133,7 +139,7 @@ describe HybridPlatformsConductor::CmdRunner do
133
139
  with_repository do |repository|
134
140
  cmd_runner = test_cmd_runner
135
141
  cmd_runner.dry_run = true
136
- expect(cmd_runner.run_cmd "echo TestContent >#{repository}/test_file").to eq [0, '', '']
142
+ expect(cmd_runner.run_cmd("echo TestContent >#{repository}/test_file")).to eq [0, '', '']
137
143
  expect(File.exist?("#{repository}/test_file")).to eq false
138
144
  end
139
145
  end
@@ -142,31 +148,31 @@ describe HybridPlatformsConductor::CmdRunner do
142
148
  with_repository do |repository|
143
149
  cmd_runner = test_cmd_runner
144
150
  cmd_runner.dry_run = true
145
- expect(cmd_runner.run_cmd "echo TestContent >#{repository}/test_file", expected_code: 2).to eq [2, '', '']
151
+ expect(cmd_runner.run_cmd("echo TestContent >#{repository}/test_file", expected_code: 2)).to eq [2, '', '']
146
152
  expect(File.exist?("#{repository}/test_file")).to eq false
147
153
  end
148
154
  end
149
155
 
150
156
  it 'returns the currently logged user' do
151
157
  cmd_runner = test_cmd_runner
152
- expect(cmd_runner).to receive(:run_cmd).with('whoami', log_to_stdout: false) { [0, 'test_user', ''] }
158
+ expect(cmd_runner).to receive(:run_cmd).with('whoami', log_to_stdout: false).and_return [0, 'test_user', '']
153
159
  expect(cmd_runner.whoami).to eq 'test_user'
154
160
  end
155
161
 
156
162
  it 'returns non-root user when user is not root' do
157
163
  cmd_runner = test_cmd_runner
158
- expect(cmd_runner).to receive(:run_cmd).with('whoami', log_to_stdout: false) { [0, 'not_root', ''] }
164
+ expect(cmd_runner).to receive(:run_cmd).with('whoami', log_to_stdout: false).and_return [0, 'not_root', '']
159
165
  expect(cmd_runner.root?).to eq false
160
166
  end
161
167
 
162
168
  it 'returns root user when user is root' do
163
169
  cmd_runner = test_cmd_runner
164
- expect(cmd_runner).to receive(:run_cmd).with('whoami', log_to_stdout: false) { [0, 'root', ''] }
170
+ expect(cmd_runner).to receive(:run_cmd).with('whoami', log_to_stdout: false).and_return [0, 'root', '']
165
171
  expect(cmd_runner.root?).to eq true
166
172
  end
167
173
 
168
174
  it 'returns the correct executable prefix' do
169
- expect(HybridPlatformsConductor::CmdRunner.executables_prefix).to eq "#{File.dirname($0)}/"
175
+ expect(described_class.executables_prefix).to eq "#{File.dirname($PROGRAM_NAME)}/"
170
176
  end
171
177
 
172
178
  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,6 +1,6 @@
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
6
  with_platforms('packaging_timeout 666') do
@@ -9,13 +9,11 @@ describe HybridPlatformsConductor::Deployer do
9
9
  end
10
10
 
11
11
  it 'declares log plugins to be used' do
12
- with_test_platforms(
13
- { nodes: { 'node1' => {}, 'node2' => {} } },
14
- false,
15
- <<~EOS
12
+ with_platforms(
13
+ <<~EO_CONFIG
16
14
  send_logs_to %i[log_plugin_1 log_plugin_2]
17
15
  for_nodes('node2') { send_logs_to :log_plugin_3 }
18
- EOS
16
+ EO_CONFIG
19
17
  ) do
20
18
  expect(test_config.deployment_logs).to eq [
21
19
  {
@@ -30,6 +28,26 @@ describe HybridPlatformsConductor::Deployer do
30
28
  end
31
29
  end
32
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
+ ]
48
+ end
49
+ end
50
+
33
51
  end
34
52
 
35
53
  end
@@ -1,36 +1,39 @@
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
6
8
 
7
- context 'checking log plugins usage' do
9
+ context 'when checking log plugins usage' do
8
10
 
9
11
  # Prepare the test platform with test log plugins
10
12
  #
11
13
  # Parameters::
12
- # * *platforms_info* (Hash): The platforms info [default = {}]
13
- # * *as_git* (Boolean): As a git repository? [default = false]
14
- # * *additional_config* (String): Additional config [default = 'send_logs_to :test_log']
15
- def with_test_platform_for_deploy_tests(platforms_info = {}, as_git = false, additional_config = 'send_logs_to :test_log')
16
- with_test_platform(platforms_info, false, additional_config) do
17
- yield
18
- end
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)
19
22
  end
20
23
 
21
24
  it 'deploys correct logs information on 1 node' do
22
- with_test_platform_for_deploy_tests({ nodes: { 'node' => { services: %w[service1 service2] } } }, true) do
25
+ with_test_platform_for_deploy_tests({ nodes: { 'node' => { services: %w[service1 service2] } } }, as_git: true) do
23
26
  with_connections_mocked_on ['node'] do
24
27
  test_actions_executor.connector(:ssh).ssh_user = 'test_user'
25
28
  expect_services_handler_to_deploy('node' => %w[service1 service2])
26
- expect_actions_executor_runs([
29
+ expect_actions_executor_runs [
27
30
  # First run, we expect the mutex to be setup, and the deployment actions to be run
28
31
  proc { |actions_per_nodes| expect_actions_to_deploy_on(actions_per_nodes, 'node') },
29
32
  # Second run, we expect the mutex to be released
30
33
  proc { |actions_per_nodes| expect_actions_to_unlock(actions_per_nodes, 'node') },
31
34
  # Third run, we expect logs to be uploaded on the node
32
35
  proc { |actions_per_nodes| expect(actions_per_nodes).to eq('node' => [{ bash: 'echo Save test logs to node' }]) }
33
- ])
36
+ ]
34
37
  expect(test_deployer.deploy_on('node')).to eq('node' => [0, 'Deploy successful', ''])
35
38
  expect(HybridPlatformsConductorTest::TestLogPlugin.calls).to eq [
36
39
  {
@@ -53,17 +56,22 @@ describe HybridPlatformsConductor::Deployer do
53
56
  end
54
57
 
55
58
  it 'deploys correct logs information on several nodes' do
56
- with_test_platform_for_deploy_tests({ nodes: {
57
- 'node1' => { services: %w[service1] },
58
- 'node2' => { services: %w[service2] }
59
- } }, true) 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
60
68
  with_connections_mocked_on %w[node1 node2] do
61
69
  test_actions_executor.connector(:ssh).ssh_user = 'test_user'
62
70
  expect_services_handler_to_deploy(
63
71
  'node1' => %w[service1],
64
72
  'node2' => %w[service2]
65
73
  )
66
- expect_actions_executor_runs([
74
+ expect_actions_executor_runs [
67
75
  # First run, we expect the mutex to be setup, and the deployment actions to be run
68
76
  proc { |actions_per_nodes| expect_actions_to_deploy_on(actions_per_nodes, %w[node1 node2]) },
69
77
  # Second run, we expect the mutex to be released
@@ -75,7 +83,7 @@ describe HybridPlatformsConductor::Deployer do
75
83
  'node2' => [{ bash: 'echo Save test logs to node2' }]
76
84
  )
77
85
  end
78
- ])
86
+ ]
79
87
  expect(test_deployer.deploy_on(%w[node1 node2])).to eq(
80
88
  'node1' => [0, 'Deploy successful', ''],
81
89
  'node2' => [0, 'Deploy successful', '']
@@ -115,11 +123,11 @@ describe HybridPlatformsConductor::Deployer do
115
123
  end
116
124
 
117
125
  it 'deploys correct logs information on 1 node even when there is a failing deploy' do
118
- with_test_platform_for_deploy_tests({ nodes: { 'node' => { services: %w[service1 service2] } } }, true) do
126
+ with_test_platform_for_deploy_tests({ nodes: { 'node' => { services: %w[service1 service2] } } }, as_git: true) do
119
127
  with_connections_mocked_on ['node'] do
120
128
  test_actions_executor.connector(:ssh).ssh_user = 'test_user'
121
129
  expect_services_handler_to_deploy('node' => %w[service1 service2])
122
- expect_actions_executor_runs([
130
+ expect_actions_executor_runs [
123
131
  # First run, we expect the mutex to be setup, and the deployment actions to be run
124
132
  proc do |actions_per_nodes|
125
133
  expect_actions_to_deploy_on(
@@ -132,7 +140,7 @@ describe HybridPlatformsConductor::Deployer do
132
140
  proc { |actions_per_nodes| expect_actions_to_unlock(actions_per_nodes, 'node') },
133
141
  # Third run, we expect logs to be uploaded on the node
134
142
  proc { |actions_per_nodes| expect(actions_per_nodes).to eq('node' => [{ bash: 'echo Save test logs to node' }]) }
135
- ])
143
+ ]
136
144
  expect(test_deployer.deploy_on('node')).to eq('node' => [:failed_action, 'Failed deploy stdout', 'Failed deploy stderr'])
137
145
  expect(HybridPlatformsConductorTest::TestLogPlugin.calls).to eq [
138
146
  {
@@ -155,14 +163,14 @@ describe HybridPlatformsConductor::Deployer do
155
163
  end
156
164
 
157
165
  it 'gets deployment info from log plugins' do
158
- with_test_platform_for_deploy_tests({ nodes: { 'node' => {} } }) do |repository|
159
- expect_actions_executor_runs([
166
+ with_test_platform_for_deploy_tests({ nodes: { 'node' => {} } }) do
167
+ expect_actions_executor_runs [
160
168
  # Expect the actions to get log files
161
169
  proc do |actions_per_nodes|
162
170
  expect(actions_per_nodes).to eq('node' => [{ bash: 'echo Read logs for node' }])
163
171
  { 'node' => [42, 'Log files read stdout', 'Log files read stderr'] }
164
172
  end
165
- ])
173
+ ]
166
174
  expect(test_deployer.deployment_info_from('node')).to eq(
167
175
  'node' => {
168
176
  deployment_info: { user: 'test_user' },
@@ -189,7 +197,7 @@ describe HybridPlatformsConductor::Deployer do
189
197
  end
190
198
 
191
199
  it 'gets deployment info from log plugins not having actions_to_read_logs' do
192
- with_test_platform_for_deploy_tests({ nodes: { 'node' => {} } }, false, 'send_logs_to :test_log_no_read') do |repository|
200
+ with_test_platform_for_deploy_tests({ nodes: { 'node' => {} } }, additional_config: 'send_logs_to :test_log_no_read') do
193
201
  expect(test_deployer.deployment_info_from('node')).to eq(
194
202
  'node' => {
195
203
  deployment_info: { user: 'test_user' },