hybrid_platforms_conductor 33.0.0 → 33.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (242) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +6 -0
  3. data/bin/check-node +0 -1
  4. data/bin/deploy +0 -1
  5. data/bin/get_impacted_nodes +0 -1
  6. data/bin/last_deploys +8 -7
  7. data/bin/nodes_to_deploy +2 -2
  8. data/bin/setup +6 -6
  9. data/bin/topograph +1 -1
  10. data/lib/hybrid_platforms_conductor/action.rb +4 -4
  11. data/lib/hybrid_platforms_conductor/actions_executor.rb +37 -42
  12. data/lib/hybrid_platforms_conductor/bitbucket.rb +5 -4
  13. data/lib/hybrid_platforms_conductor/cmd_runner.rb +13 -12
  14. data/lib/hybrid_platforms_conductor/cmdb.rb +2 -2
  15. data/lib/hybrid_platforms_conductor/common_config_dsl/bitbucket.rb +2 -1
  16. data/lib/hybrid_platforms_conductor/common_config_dsl/confluence.rb +2 -1
  17. data/lib/hybrid_platforms_conductor/common_config_dsl/file_system_tests.rb +5 -4
  18. data/lib/hybrid_platforms_conductor/common_config_dsl/github.rb +4 -3
  19. data/lib/hybrid_platforms_conductor/common_config_dsl/idempotence_tests.rb +2 -2
  20. data/lib/hybrid_platforms_conductor/config.rb +7 -4
  21. data/lib/hybrid_platforms_conductor/confluence.rb +1 -1
  22. data/lib/hybrid_platforms_conductor/connector.rb +5 -2
  23. data/lib/hybrid_platforms_conductor/core_extensions/symbol/zero.rb +24 -0
  24. data/lib/hybrid_platforms_conductor/credentials.rb +39 -36
  25. data/lib/hybrid_platforms_conductor/current_dir_monitor.rb +4 -1
  26. data/lib/hybrid_platforms_conductor/deployer.rb +95 -96
  27. data/lib/hybrid_platforms_conductor/executable.rb +20 -15
  28. data/lib/hybrid_platforms_conductor/hpc_plugins/cmdb/config.rb +10 -7
  29. data/lib/hybrid_platforms_conductor/hpc_plugins/cmdb/host_ip.rb +1 -1
  30. data/lib/hybrid_platforms_conductor/hpc_plugins/cmdb/host_keys.rb +2 -2
  31. data/lib/hybrid_platforms_conductor/hpc_plugins/cmdb/platform_handlers.rb +4 -4
  32. data/lib/hybrid_platforms_conductor/hpc_plugins/connector/local.rb +2 -0
  33. data/lib/hybrid_platforms_conductor/hpc_plugins/connector/ssh.rb +45 -49
  34. data/lib/hybrid_platforms_conductor/hpc_plugins/log/remote_fs.rb +6 -5
  35. data/lib/hybrid_platforms_conductor/hpc_plugins/platform_handler/serverless_chef.rb +68 -66
  36. data/lib/hybrid_platforms_conductor/hpc_plugins/platform_handler/serverless_chef/dsl_parser.rb +13 -0
  37. data/lib/hybrid_platforms_conductor/hpc_plugins/platform_handler/serverless_chef/recipes_tree_builder.rb +39 -38
  38. data/lib/hybrid_platforms_conductor/hpc_plugins/platform_handler/yaml_inventory.rb +5 -4
  39. data/lib/hybrid_platforms_conductor/hpc_plugins/provisioner/docker.rb +43 -45
  40. data/lib/hybrid_platforms_conductor/hpc_plugins/provisioner/podman.rb +18 -20
  41. data/lib/hybrid_platforms_conductor/hpc_plugins/provisioner/proxmox.rb +118 -117
  42. data/lib/hybrid_platforms_conductor/hpc_plugins/provisioner/proxmox/proxmox_waiter.rb +39 -43
  43. data/lib/hybrid_platforms_conductor/hpc_plugins/provisioner/proxmox/reserve_proxmox_container +9 -13
  44. data/lib/hybrid_platforms_conductor/hpc_plugins/report/confluence.rb +2 -2
  45. data/lib/hybrid_platforms_conductor/hpc_plugins/report/mediawiki.rb +28 -21
  46. data/lib/hybrid_platforms_conductor/hpc_plugins/report/stdout.rb +26 -22
  47. data/lib/hybrid_platforms_conductor/hpc_plugins/secrets_reader/cli.rb +8 -6
  48. data/lib/hybrid_platforms_conductor/hpc_plugins/secrets_reader/thycotic.rb +7 -4
  49. data/lib/hybrid_platforms_conductor/hpc_plugins/test/bitbucket_conf.rb +3 -3
  50. data/lib/hybrid_platforms_conductor/hpc_plugins/test/check_deploy_and_idempotence.rb +4 -2
  51. data/lib/hybrid_platforms_conductor/hpc_plugins/test/deploy_freshness.rb +0 -1
  52. data/lib/hybrid_platforms_conductor/hpc_plugins/test/deploy_removes_root_access.rb +21 -19
  53. data/lib/hybrid_platforms_conductor/hpc_plugins/test/divergence.rb +2 -2
  54. data/lib/hybrid_platforms_conductor/hpc_plugins/test/executables.rb +2 -2
  55. data/lib/hybrid_platforms_conductor/hpc_plugins/test/file_system.rb +19 -21
  56. data/lib/hybrid_platforms_conductor/hpc_plugins/test/file_system_hdfs.rb +19 -21
  57. data/lib/hybrid_platforms_conductor/hpc_plugins/test/github_ci.rb +2 -3
  58. data/lib/hybrid_platforms_conductor/hpc_plugins/test/idempotence.rb +2 -2
  59. data/lib/hybrid_platforms_conductor/hpc_plugins/test/ip.rb +1 -1
  60. data/lib/hybrid_platforms_conductor/hpc_plugins/test/jenkins_ci_conf.rb +21 -22
  61. data/lib/hybrid_platforms_conductor/hpc_plugins/test/jenkins_ci_masters_ok.rb +10 -12
  62. data/lib/hybrid_platforms_conductor/hpc_plugins/test/linear_strategy.rb +9 -9
  63. data/lib/hybrid_platforms_conductor/hpc_plugins/test/local_users.rb +2 -2
  64. data/lib/hybrid_platforms_conductor/hpc_plugins/test/mounts.rb +2 -2
  65. data/lib/hybrid_platforms_conductor/hpc_plugins/test/orphan_files.rb +10 -9
  66. data/lib/hybrid_platforms_conductor/hpc_plugins/test/ports.rb +2 -2
  67. data/lib/hybrid_platforms_conductor/hpc_plugins/test/private_ips.rb +5 -5
  68. data/lib/hybrid_platforms_conductor/hpc_plugins/test/public_ips.rb +5 -5
  69. data/lib/hybrid_platforms_conductor/hpc_plugins/test/spectre.rb +4 -6
  70. data/lib/hybrid_platforms_conductor/hpc_plugins/test/veids.rb +3 -3
  71. data/lib/hybrid_platforms_conductor/hpc_plugins/test/vulnerabilities.rb +25 -24
  72. data/lib/hybrid_platforms_conductor/hpc_plugins/test_report/confluence.rb +2 -2
  73. data/lib/hybrid_platforms_conductor/hpc_plugins/test_report/stdout.rb +8 -6
  74. data/lib/hybrid_platforms_conductor/io_router.rb +14 -13
  75. data/lib/hybrid_platforms_conductor/json_dumper.rb +2 -2
  76. data/lib/hybrid_platforms_conductor/log.rb +2 -2
  77. data/lib/hybrid_platforms_conductor/logger_helpers.rb +19 -16
  78. data/lib/hybrid_platforms_conductor/nodes_handler.rb +89 -71
  79. data/lib/hybrid_platforms_conductor/parallel_threads.rb +7 -11
  80. data/lib/hybrid_platforms_conductor/platform_handler.rb +7 -7
  81. data/lib/hybrid_platforms_conductor/platforms_handler.rb +5 -3
  82. data/lib/hybrid_platforms_conductor/plugin.rb +2 -2
  83. data/lib/hybrid_platforms_conductor/plugins.rb +13 -8
  84. data/lib/hybrid_platforms_conductor/provisioner.rb +4 -4
  85. data/lib/hybrid_platforms_conductor/report.rb +2 -2
  86. data/lib/hybrid_platforms_conductor/reports_handler.rb +3 -2
  87. data/lib/hybrid_platforms_conductor/secrets_reader.rb +2 -2
  88. data/lib/hybrid_platforms_conductor/services_handler.rb +32 -29
  89. data/lib/hybrid_platforms_conductor/test_only_remote_node.rb +1 -1
  90. data/lib/hybrid_platforms_conductor/test_report.rb +15 -18
  91. data/lib/hybrid_platforms_conductor/tests_runner.rb +116 -118
  92. data/lib/hybrid_platforms_conductor/thycotic.rb +28 -19
  93. data/lib/hybrid_platforms_conductor/topographer.rb +200 -190
  94. data/lib/hybrid_platforms_conductor/topographer/plugins/graphviz.rb +8 -8
  95. data/lib/hybrid_platforms_conductor/topographer/plugins/json.rb +4 -4
  96. data/lib/hybrid_platforms_conductor/version.rb +1 -1
  97. data/spec/hybrid_platforms_conductor_test.rb +6 -6
  98. data/spec/hybrid_platforms_conductor_test/api/actions_executor/actions/bash_spec.rb +16 -11
  99. data/spec/hybrid_platforms_conductor_test/api/actions_executor/actions/interactive_spec.rb +1 -1
  100. data/spec/hybrid_platforms_conductor_test/api/actions_executor/actions/remote_bash_spec.rb +23 -18
  101. data/spec/hybrid_platforms_conductor_test/api/actions_executor/actions/ruby_spec.rb +67 -49
  102. data/spec/hybrid_platforms_conductor_test/api/actions_executor/actions/scp_spec.rb +20 -14
  103. data/spec/hybrid_platforms_conductor_test/api/actions_executor/actions_spec.rb +63 -50
  104. data/spec/hybrid_platforms_conductor_test/api/actions_executor/connection_spec.rb +35 -35
  105. data/spec/hybrid_platforms_conductor_test/api/actions_executor/connectors/local/connectable_nodes_spec.rb +12 -8
  106. data/spec/hybrid_platforms_conductor_test/api/actions_executor/connectors/local/remote_actions_spec.rb +4 -7
  107. data/spec/hybrid_platforms_conductor_test/api/actions_executor/connectors/ssh/cli_options_spec.rb +21 -22
  108. data/spec/hybrid_platforms_conductor_test/api/actions_executor/connectors/ssh/config_dsl_spec.rb +23 -24
  109. data/spec/hybrid_platforms_conductor_test/api/actions_executor/connectors/ssh/connectable_nodes_spec.rb +10 -6
  110. data/spec/hybrid_platforms_conductor_test/api/actions_executor/connectors/ssh/connections_spec.rb +73 -54
  111. data/spec/hybrid_platforms_conductor_test/api/actions_executor/connectors/ssh/global_helpers_spec.rb +145 -126
  112. data/spec/hybrid_platforms_conductor_test/api/actions_executor/connectors/ssh/node_helpers_spec.rb +3 -3
  113. data/spec/hybrid_platforms_conductor_test/api/actions_executor/connectors/ssh/remote_actions_spec.rb +29 -25
  114. data/spec/hybrid_platforms_conductor_test/api/actions_executor/logging_spec.rb +106 -91
  115. data/spec/hybrid_platforms_conductor_test/api/actions_executor/parallel_spec.rb +272 -244
  116. data/spec/hybrid_platforms_conductor_test/api/actions_executor/timeout_spec.rb +10 -12
  117. data/spec/hybrid_platforms_conductor_test/api/cmd_runner_spec.rb +36 -36
  118. data/spec/hybrid_platforms_conductor_test/api/config_spec.rb +24 -22
  119. data/spec/hybrid_platforms_conductor_test/api/deployer/check_spec.rb +4 -2
  120. data/spec/hybrid_platforms_conductor_test/api/deployer/config_dsl_spec.rb +7 -11
  121. data/spec/hybrid_platforms_conductor_test/api/deployer/deploy_spec.rb +34 -26
  122. data/spec/hybrid_platforms_conductor_test/api/deployer/log_plugins/remote_fs_spec.rb +21 -21
  123. data/spec/hybrid_platforms_conductor_test/api/deployer/parse_deploy_output_spec.rb +55 -59
  124. data/spec/hybrid_platforms_conductor_test/api/deployer/provisioner_spec.rb +36 -62
  125. data/spec/hybrid_platforms_conductor_test/api/deployer/provisioners/podman_spec.rb +17 -17
  126. data/spec/hybrid_platforms_conductor_test/api/deployer/provisioners/proxmox/config_dsl_spec.rb +4 -4
  127. data/spec/hybrid_platforms_conductor_test/api/deployer/provisioners/proxmox/create_spec.rb +44 -51
  128. data/spec/hybrid_platforms_conductor_test/api/deployer/provisioners/proxmox/destroy_spec.rb +3 -3
  129. data/spec/hybrid_platforms_conductor_test/api/deployer/provisioners/proxmox/ip_spec.rb +12 -16
  130. data/spec/hybrid_platforms_conductor_test/api/deployer/provisioners/proxmox/reserve_proxmox_container/destroy_vm_spec.rb +31 -19
  131. data/spec/hybrid_platforms_conductor_test/api/deployer/provisioners/proxmox/reserve_proxmox_container/expired_containers_spec.rb +324 -266
  132. data/spec/hybrid_platforms_conductor_test/api/deployer/provisioners/proxmox/reserve_proxmox_container/ips_assignment_spec.rb +89 -61
  133. data/spec/hybrid_platforms_conductor_test/api/deployer/provisioners/proxmox/reserve_proxmox_container/other_lxc_containers_resources_spec.rb +117 -93
  134. data/spec/hybrid_platforms_conductor_test/api/deployer/provisioners/proxmox/reserve_proxmox_container/pve_node_resources_spec.rb +71 -54
  135. data/spec/hybrid_platforms_conductor_test/api/deployer/provisioners/proxmox/reserve_proxmox_container/retries_spec.rb +10 -8
  136. data/spec/hybrid_platforms_conductor_test/api/deployer/provisioners/proxmox/reserve_proxmox_container/vm_ids_assignment_spec.rb +80 -60
  137. data/spec/hybrid_platforms_conductor_test/api/deployer/provisioners/proxmox/start_spec.rb +1 -1
  138. data/spec/hybrid_platforms_conductor_test/api/deployer/provisioners/proxmox/state_spec.rb +1 -1
  139. data/spec/hybrid_platforms_conductor_test/api/deployer/provisioners/proxmox/stop_spec.rb +1 -1
  140. data/spec/hybrid_platforms_conductor_test/api/deployer/secrets_reader_plugins/cli_spec.rb +21 -20
  141. data/spec/hybrid_platforms_conductor_test/api/deployer/secrets_reader_plugins/thycotic_spec.rb +70 -55
  142. data/spec/hybrid_platforms_conductor_test/api/nodes_handler/cmdbs/config_spec.rb +8 -10
  143. data/spec/hybrid_platforms_conductor_test/api/nodes_handler/cmdbs/host_ip_spec.rb +33 -24
  144. data/spec/hybrid_platforms_conductor_test/api/nodes_handler/cmdbs/host_keys_spec.rb +64 -51
  145. data/spec/hybrid_platforms_conductor_test/api/nodes_handler/cmdbs/platform_handlers_spec.rb +3 -3
  146. data/spec/hybrid_platforms_conductor_test/api/nodes_handler/cmdbs_plugins_api_spec.rb +50 -51
  147. data/spec/hybrid_platforms_conductor_test/api/nodes_handler/common_spec.rb +91 -81
  148. data/spec/hybrid_platforms_conductor_test/api/nodes_handler/config_dsl_spec.rb +14 -16
  149. data/spec/hybrid_platforms_conductor_test/api/nodes_handler/git_diff_impacts_spec.rb +51 -75
  150. data/spec/hybrid_platforms_conductor_test/api/nodes_handler/nodes_selectors_spec.rb +35 -26
  151. data/spec/hybrid_platforms_conductor_test/api/nodes_handler/platform_handlers_plugins_api_spec.rb +24 -16
  152. data/spec/hybrid_platforms_conductor_test/api/nodes_handler/several_platforms_spec.rb +29 -19
  153. data/spec/hybrid_platforms_conductor_test/api/platform_handler_spec.rb +4 -4
  154. data/spec/hybrid_platforms_conductor_test/api/platform_handlers/serverless_chef/config_dsl_spec.rb +2 -2
  155. data/spec/hybrid_platforms_conductor_test/api/platform_handlers/serverless_chef/deploy_output_parsing_spec.rb +6 -6
  156. data/spec/hybrid_platforms_conductor_test/api/platform_handlers/serverless_chef/diff_impacts_spec.rb +57 -99
  157. data/spec/hybrid_platforms_conductor_test/api/platform_handlers/serverless_chef/inventory_spec.rb +4 -4
  158. data/spec/hybrid_platforms_conductor_test/api/platform_handlers/serverless_chef/packaging_spec.rb +32 -35
  159. data/spec/hybrid_platforms_conductor_test/api/platform_handlers/serverless_chef/services_deployment_spec.rb +10 -10
  160. data/spec/hybrid_platforms_conductor_test/api/platforms_handler_spec.rb +38 -27
  161. data/spec/hybrid_platforms_conductor_test/api/plugins_spec.rb +46 -52
  162. data/spec/hybrid_platforms_conductor_test/api/reports_handler_spec.rb +2 -2
  163. data/spec/hybrid_platforms_conductor_test/api/services_handler/actions_to_deploy_spec.rb +90 -58
  164. data/spec/hybrid_platforms_conductor_test/api/services_handler/deploy_allowed_spec.rb +38 -34
  165. data/spec/hybrid_platforms_conductor_test/api/services_handler/log_info_spec.rb +11 -9
  166. data/spec/hybrid_platforms_conductor_test/api/services_handler/package_spec.rb +193 -171
  167. data/spec/hybrid_platforms_conductor_test/api/services_handler/parse_deploy_output_spec.rb +66 -54
  168. data/spec/hybrid_platforms_conductor_test/api/services_handler/prepare_for_deploy_spec.rb +147 -133
  169. data/spec/hybrid_platforms_conductor_test/api/tests_runner/common_spec.rb +69 -49
  170. data/spec/hybrid_platforms_conductor_test/api/tests_runner/global_spec.rb +4 -3
  171. data/spec/hybrid_platforms_conductor_test/api/tests_runner/node_check_spec.rb +8 -5
  172. data/spec/hybrid_platforms_conductor_test/api/tests_runner/node_spec.rb +8 -5
  173. data/spec/hybrid_platforms_conductor_test/api/tests_runner/node_ssh_spec.rb +30 -27
  174. data/spec/hybrid_platforms_conductor_test/api/tests_runner/platform_spec.rb +12 -9
  175. data/spec/hybrid_platforms_conductor_test/api/tests_runner/reports_spec.rb +48 -47
  176. data/spec/hybrid_platforms_conductor_test/api/tests_runner/test_plugins/bitbucket_conf_spec.rb +5 -5
  177. data/spec/hybrid_platforms_conductor_test/api/tests_runner/test_plugins/github_ci_spec.rb +5 -5
  178. data/spec/hybrid_platforms_conductor_test/api/tests_runner/test_reports_plugins/confluence_spec.rb +5 -5
  179. data/spec/hybrid_platforms_conductor_test/cmdb_plugins/test_cmdb.rb +9 -9
  180. data/spec/hybrid_platforms_conductor_test/cmdb_plugins/{test_cmdb2.rb → test_cmdb_2.rb} +6 -6
  181. data/spec/hybrid_platforms_conductor_test/cmdb_plugins/test_cmdb_others.rb +3 -3
  182. data/spec/hybrid_platforms_conductor_test/cmdb_plugins/{test_cmdb_others2.rb → test_cmdb_others_2.rb} +2 -2
  183. data/spec/hybrid_platforms_conductor_test/docs_spec.rb +1 -1
  184. data/spec/hybrid_platforms_conductor_test/executables/{check-node_spec.rb → check_node_spec.rb} +4 -6
  185. data/spec/hybrid_platforms_conductor_test/executables/deploy_spec.rb +4 -6
  186. data/spec/hybrid_platforms_conductor_test/executables/get_impacted_nodes_spec.rb +76 -77
  187. data/spec/hybrid_platforms_conductor_test/executables/last_deploys_spec.rb +13 -15
  188. data/spec/hybrid_platforms_conductor_test/executables/nodes_to_deploy_spec.rb +289 -307
  189. data/spec/hybrid_platforms_conductor_test/executables/options/actions_executor_spec.rb +4 -6
  190. data/spec/hybrid_platforms_conductor_test/executables/options/cmd_runner_spec.rb +3 -5
  191. data/spec/hybrid_platforms_conductor_test/executables/options/common_spec.rb +8 -9
  192. data/spec/hybrid_platforms_conductor_test/executables/options/deployer_spec.rb +12 -14
  193. data/spec/hybrid_platforms_conductor_test/executables/options/nodes_handler_spec.rb +9 -10
  194. data/spec/hybrid_platforms_conductor_test/executables/options/nodes_selectors_spec.rb +9 -10
  195. data/spec/hybrid_platforms_conductor_test/executables/options/reports_handler_spec.rb +1 -1
  196. data/spec/hybrid_platforms_conductor_test/executables/options/tests_runner_spec.rb +22 -22
  197. data/spec/hybrid_platforms_conductor_test/executables/report_spec.rb +22 -16
  198. data/spec/hybrid_platforms_conductor_test/executables/run_spec.rb +32 -32
  199. data/spec/hybrid_platforms_conductor_test/executables/ssh_config_spec.rb +7 -9
  200. data/spec/hybrid_platforms_conductor_test/executables/test_spec.rb +3 -5
  201. data/spec/hybrid_platforms_conductor_test/helpers/actions_executor_helpers.rb +2 -2
  202. data/spec/hybrid_platforms_conductor_test/helpers/cmd_runner_helpers.rb +4 -3
  203. data/spec/hybrid_platforms_conductor_test/helpers/cmdb_helpers.rb +2 -2
  204. data/spec/hybrid_platforms_conductor_test/helpers/config_helpers.rb +1 -1
  205. data/spec/hybrid_platforms_conductor_test/helpers/connector_ssh_helpers.rb +12 -13
  206. data/spec/hybrid_platforms_conductor_test/helpers/deployer_helpers.rb +216 -14
  207. data/spec/hybrid_platforms_conductor_test/helpers/executables_helpers.rb +11 -11
  208. data/spec/hybrid_platforms_conductor_test/helpers/nodes_handler_helpers.rb +1 -1
  209. data/spec/hybrid_platforms_conductor_test/helpers/platforms_handler_helpers.rb +39 -28
  210. data/spec/hybrid_platforms_conductor_test/helpers/plugins_helpers.rb +1 -1
  211. data/spec/hybrid_platforms_conductor_test/helpers/provisioner_proxmox_helpers.rb +86 -111
  212. data/spec/hybrid_platforms_conductor_test/helpers/reports_handler_helpers.rb +1 -1
  213. data/spec/hybrid_platforms_conductor_test/helpers/serverless_chef_helpers.rb +3 -3
  214. data/spec/hybrid_platforms_conductor_test/helpers/services_handler_helpers.rb +1 -1
  215. data/spec/hybrid_platforms_conductor_test/helpers/tests_runner_helpers.rb +1 -1
  216. 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
  217. 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
  218. 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
  219. 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
  220. data/spec/hybrid_platforms_conductor_test/platform_handler_plugins/test.rb +1 -1
  221. data/spec/hybrid_platforms_conductor_test/platform_handler_plugins/{test2.rb → test_2.rb} +0 -0
  222. data/spec/hybrid_platforms_conductor_test/rubocop_spec.rb +31 -0
  223. data/spec/hybrid_platforms_conductor_test/serverless_chef_repositories/1_node/nodes/node.json +3 -3
  224. data/spec/hybrid_platforms_conductor_test/serverless_chef_repositories/data_bags/nodes/node.json +3 -3
  225. data/spec/hybrid_platforms_conductor_test/serverless_chef_repositories/recipes/cookbooks/test_cookbook_2/libraries/default.rb +1 -0
  226. data/spec/hybrid_platforms_conductor_test/serverless_chef_repositories/several_cookbooks/other_cookbooks/test_cookbook_2/libraries/default.rb +1 -0
  227. data/spec/hybrid_platforms_conductor_test/shared_examples/deployer.rb +952 -0
  228. data/spec/hybrid_platforms_conductor_test/test_connector.rb +3 -3
  229. data/spec/hybrid_platforms_conductor_test/test_log_no_read_plugin.rb +3 -1
  230. data/spec/hybrid_platforms_conductor_test/test_log_plugin.rb +3 -1
  231. data/spec/hybrid_platforms_conductor_test/test_plugins/global.rb +1 -0
  232. data/spec/hybrid_platforms_conductor_test/test_plugins/node.rb +1 -0
  233. data/spec/hybrid_platforms_conductor_test/test_plugins/node_check.rb +1 -0
  234. data/spec/hybrid_platforms_conductor_test/test_plugins/platform.rb +1 -0
  235. data/spec/hybrid_platforms_conductor_test/test_plugins/several_checks.rb +2 -2
  236. data/spec/hybrid_platforms_conductor_test/test_secrets_reader_plugin.rb +4 -4
  237. data/spec/hybrid_platforms_conductor_test/tests_report_plugin.rb +5 -6
  238. data/spec/spec_helper.rb +17 -18
  239. data/tools/check_md +16 -20
  240. data/tools/generate_mermaid +1 -1
  241. metadata +43 -13
  242. data/spec/hybrid_platforms_conductor_test/helpers/deployer_test_helpers.rb +0 -1152
@@ -1,15 +1,13 @@
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
@@ -38,7 +36,7 @@ describe HybridPlatformsConductor::ActionsExecutor do
38
36
  it 'executes an action that fails because of timeout' do
39
37
  with_test_platform_for_timeouts_tests do
40
38
  expect(test_actions_executor.execute_actions(
41
- { 'node' => { test_action: { code: proc do |_stdout, _stderr, action|
39
+ { 'node' => { test_action: { code: proc do
42
40
  raise HybridPlatformsConductor::CmdRunner::TimeoutError
43
41
  end } } },
44
42
  timeout: 1
@@ -49,7 +47,7 @@ describe HybridPlatformsConductor::ActionsExecutor do
49
47
  it 'executes an action that fails because of timeout and outputs data before' do
50
48
  with_test_platform_for_timeouts_tests do
51
49
  expect(test_actions_executor.execute_actions(
52
- { 'node' => { test_action: { code: proc do |stdout, _stderr, action|
50
+ { 'node' => { test_action: { code: proc do |stdout|
53
51
  stdout << 'Hello'
54
52
  raise HybridPlatformsConductor::CmdRunner::TimeoutError
55
53
  end } } },
@@ -66,7 +64,7 @@ describe HybridPlatformsConductor::ActionsExecutor do
66
64
  sleep 1
67
65
  stdout << 'Hello'
68
66
  end } },
69
- { test_action: { code: proc do |stdout, _stderr, action|
67
+ { test_action: { code: proc do
70
68
  raise HybridPlatformsConductor::CmdRunner::TimeoutError
71
69
  end } }
72
70
  ] },
@@ -79,15 +77,15 @@ describe HybridPlatformsConductor::ActionsExecutor do
79
77
  with_test_platform_for_timeouts_tests do
80
78
  expect(test_actions_executor.execute_actions(
81
79
  { 'node' => [
82
- { test_action: { code: proc do |stdout, _stderr, action|
80
+ { test_action: { code: proc do |_stdout, _stderr, action|
83
81
  expect(action.timeout).to eq 5
84
82
  sleep 1
85
83
  end } },
86
- { test_action: { code: proc do |stdout, _stderr, action|
84
+ { test_action: { code: proc do |_stdout, _stderr, action|
87
85
  expect(action.timeout).to be_between(3.8, 4)
88
86
  sleep 1
89
87
  end } },
90
- { test_action: { code: proc do |stdout, _stderr, action|
88
+ { test_action: { code: proc do |_stdout, _stderr, action|
91
89
  expect(action.timeout).to be_between(2.8, 3)
92
90
  end } }
93
91
  ] },
@@ -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,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
  {
@@ -31,13 +29,11 @@ describe HybridPlatformsConductor::Deployer do
31
29
  end
32
30
 
33
31
  it 'declares secrets readers plugins to be used' do
34
- with_test_platforms(
35
- { nodes: { 'node1' => {}, 'node2' => {} } },
36
- false,
37
- <<~EOS
32
+ with_platforms(
33
+ <<~EO_CONFIG
38
34
  read_secrets_from %i[secrets_reader_plugin_1 secrets_reader_plugin_2]
39
35
  for_nodes('node2') { read_secrets_from :secrets_reader_plugin_3 }
40
- EOS
36
+ EO_CONFIG
41
37
  ) do
42
38
  expect(test_config.secrets_readers).to eq [
43
39
  {
@@ -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' },