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,15 @@
1
1
  describe HybridPlatformsConductor::NodesHandler do
2
2
 
3
- context 'checking CMDB plugin PlatformHandlers' do
3
+ context 'when checking CMDB plugin PlatformHandlers' do
4
4
 
5
5
  it 'returns metadata published by the Platform\'s handler' do
6
- with_test_platform(nodes: { 'test_node' => { meta: { property: 'value' } } }) do
6
+ with_test_platform({ nodes: { 'test_node' => { meta: { property: 'value' } } } }) do
7
7
  expect(cmdb(:platform_handlers).get_others(['test_node'], {})).to eq('test_node' => { property: 'value' })
8
8
  end
9
9
  end
10
10
 
11
11
  it 'returns services published by the Platform\'s handler' do
12
- with_test_platform(nodes: { 'test_node' => { services: %w[service1 service2] } }) do
12
+ with_test_platform({ nodes: { 'test_node' => { services: %w[service1 service2] } } }) do
13
13
  expect(cmdb(:platform_handlers).get_services(['test_node'], {})).to eq('test_node' => %w[service1 service2])
14
14
  end
15
15
  end
@@ -1,14 +1,14 @@
1
1
  describe HybridPlatformsConductor::NodesHandler do
2
2
 
3
- context 'checking CMDB plugins\' API called by NodesHandler' do
3
+ context 'when checking CMDB plugins\' API called by NodesHandler' do
4
4
 
5
5
  # Get a test platform ready to test using the test CMDB
6
6
  #
7
7
  # Parameters::
8
8
  # * *cmdbs* (Array<Symbol>): The test CMDBs to register [default: [:test_cmdb]]
9
- # * *additional_platforms_content* (String): Additional configuration [default: '']
9
+ # * *additional_config* (String): Additional configuration [default: '']
10
10
  # * Proc: The code to be caklled for tests
11
- def with_cmdb_test_platform(cmdbs: [:test_cmdb], additional_platforms_content: '')
11
+ def with_cmdb_test_platform(cmdbs: [:test_cmdb], additional_config: '')
12
12
  with_test_platform(
13
13
  {
14
14
  nodes: {
@@ -18,8 +18,7 @@ describe HybridPlatformsConductor::NodesHandler do
18
18
  'node4' => {}
19
19
  }
20
20
  },
21
- false,
22
- additional_platforms_content
21
+ additional_config: additional_config
23
22
  ) do
24
23
  register_test_cmdb(cmdbs)
25
24
  yield
@@ -205,36 +204,36 @@ describe HybridPlatformsConductor::NodesHandler do
205
204
  end
206
205
 
207
206
  it 'tries different CMDBs to get a property until one gives it' do
208
- with_cmdb_test_platform(cmdbs: %i[test_cmdb test_cmdb2]) do
207
+ with_cmdb_test_platform(cmdbs: %i[test_cmdb test_cmdb_2]) do
209
208
  expect(test_nodes_handler.get_nothing_of('node1')).to eq 'node1 has nothing'
210
209
  expect(cmdb(:test_cmdb).calls).to eq [
211
210
  [:get_nothing, ['node1'], {}]
212
211
  ]
213
- expect(cmdb(:test_cmdb2).calls).to eq [
212
+ expect(cmdb(:test_cmdb_2).calls).to eq [
214
213
  [:get_nothing, ['node1'], {}]
215
214
  ]
216
215
  end
217
216
  end
218
217
 
219
218
  it 'fails when different CMDBs get a property having conflicting values' do
220
- with_cmdb_test_platform(cmdbs: %i[test_cmdb test_cmdb2]) do
221
- expect { test_nodes_handler.get_different_comment_of('node1') }.to raise_error '[CMDB TestCmdb2.different_comment] - Returned a conflicting value for metadata different_comment of node node1: Comment from test_cmdb2 whereas the value was already set to Comment from test_cmdb'
219
+ with_cmdb_test_platform(cmdbs: %i[test_cmdb test_cmdb_2]) do
220
+ expect { test_nodes_handler.get_different_comment_of('node1') }.to raise_error '[CMDB TestCmdb2.different_comment] - Returned a conflicting value for metadata different_comment of node node1: Comment from test_cmdb_2 whereas the value was already set to Comment from test_cmdb'
222
221
  expect(cmdb(:test_cmdb).calls).to eq [
223
222
  [:get_different_comment, ['node1'], {}]
224
223
  ]
225
- expect(cmdb(:test_cmdb2).calls).to eq [
224
+ expect(cmdb(:test_cmdb_2).calls).to eq [
226
225
  [:get_different_comment, ['node1'], {}]
227
226
  ]
228
227
  end
229
228
  end
230
229
 
231
230
  it 'does not fail when different CMDBs get a property having same values' do
232
- with_cmdb_test_platform(cmdbs: %i[test_cmdb test_cmdb2]) do
231
+ with_cmdb_test_platform(cmdbs: %i[test_cmdb test_cmdb_2]) do
233
232
  expect(test_nodes_handler.get_same_comment_of('node1')).to eq 'Comment for node1'
234
233
  expect(cmdb(:test_cmdb).calls).to eq [
235
234
  [:get_same_comment, ['node1'], {}]
236
235
  ]
237
- expect(cmdb(:test_cmdb2).calls).to eq [
236
+ expect(cmdb(:test_cmdb_2).calls).to eq [
238
237
  [:get_same_comment, ['node1'], {}]
239
238
  ]
240
239
  end
@@ -242,12 +241,12 @@ describe HybridPlatformsConductor::NodesHandler do
242
241
 
243
242
  it 'does not fail when different CMDBs get a property having conflicting values but one is defined as priority' do
244
243
  with_cmdb_test_platform(
245
- cmdbs: %i[test_cmdb test_cmdb2],
246
- additional_platforms_content: 'master_cmdbs(test_cmdb2: :different_comment)'
244
+ cmdbs: %i[test_cmdb test_cmdb_2],
245
+ additional_config: 'master_cmdbs(test_cmdb_2: :different_comment)'
247
246
  ) do
248
- expect(test_nodes_handler.get_different_comment_of('node1')).to eq 'Comment from test_cmdb2'
247
+ expect(test_nodes_handler.get_different_comment_of('node1')).to eq 'Comment from test_cmdb_2'
249
248
  expect(cmdb(:test_cmdb).calls).to eq nil
250
- expect(cmdb(:test_cmdb2).calls).to eq [
249
+ expect(cmdb(:test_cmdb_2).calls).to eq [
251
250
  [:get_different_comment, ['node1'], {}]
252
251
  ]
253
252
  end
@@ -255,20 +254,20 @@ describe HybridPlatformsConductor::NodesHandler do
255
254
 
256
255
  it 'can configure different priority rules for different properties' do
257
256
  with_cmdb_test_platform(
258
- cmdbs: %i[test_cmdb test_cmdb2],
259
- additional_platforms_content: '
257
+ cmdbs: %i[test_cmdb test_cmdb_2],
258
+ additional_config: '
260
259
  master_cmdbs(
261
- test_cmdb: :different_comment2,
262
- test_cmdb2: :different_comment
260
+ test_cmdb: :different_comment_2,
261
+ test_cmdb_2: :different_comment
263
262
  )
264
263
  '
265
264
  ) do
266
- expect(test_nodes_handler.get_different_comment_of('node1')).to eq 'Comment from test_cmdb2'
267
- expect(test_nodes_handler.get_different_comment2_of('node1')).to eq 'Comment2 from test_cmdb'
265
+ expect(test_nodes_handler.get_different_comment_of('node1')).to eq 'Comment from test_cmdb_2'
266
+ expect(test_nodes_handler.get_different_comment_2_of('node1')).to eq 'Comment2 from test_cmdb'
268
267
  expect(cmdb(:test_cmdb).calls).to eq [
269
- [:get_different_comment2, ['node1'], { 'node1' => { different_comment: 'Comment from test_cmdb2' } }]
268
+ [:get_different_comment_2, ['node1'], { 'node1' => { different_comment: 'Comment from test_cmdb_2' } }]
270
269
  ]
271
- expect(cmdb(:test_cmdb2).calls).to eq [
270
+ expect(cmdb(:test_cmdb_2).calls).to eq [
272
271
  [:get_different_comment, ['node1'], {}]
273
272
  ]
274
273
  end
@@ -276,75 +275,75 @@ describe HybridPlatformsConductor::NodesHandler do
276
275
 
277
276
  it 'can configure different priority rules for different properties on different nodes' do
278
277
  with_cmdb_test_platform(
279
- cmdbs: %i[test_cmdb test_cmdb2],
280
- additional_platforms_content: '
281
- for_nodes(\'node1\') do
278
+ cmdbs: %i[test_cmdb test_cmdb_2],
279
+ additional_config: <<~'EO_CONFIG'
280
+ for_nodes('node1') do
282
281
  master_cmdbs(
283
- test_cmdb: :different_comment2,
284
- test_cmdb2: :different_comment
282
+ test_cmdb: :different_comment_2,
283
+ test_cmdb_2: :different_comment
285
284
  )
286
285
  end
287
- for_nodes(\'node2\') do
286
+ for_nodes('node2') do
288
287
  master_cmdbs(
289
288
  test_cmdb: :different_comment,
290
- test_cmdb2: :different_comment2
289
+ test_cmdb_2: :different_comment_2
291
290
  )
292
291
  end
293
- '
292
+ EO_CONFIG
294
293
  ) do
295
- expect(test_nodes_handler.get_different_comment_of('node1')).to eq 'Comment from test_cmdb2'
294
+ expect(test_nodes_handler.get_different_comment_of('node1')).to eq 'Comment from test_cmdb_2'
296
295
  expect(test_nodes_handler.get_different_comment_of('node2')).to eq 'Comment from test_cmdb'
297
- expect(test_nodes_handler.get_different_comment2_of('node1')).to eq 'Comment2 from test_cmdb'
298
- expect(test_nodes_handler.get_different_comment2_of('node2')).to eq 'Comment2 from test_cmdb2'
296
+ expect(test_nodes_handler.get_different_comment_2_of('node1')).to eq 'Comment2 from test_cmdb'
297
+ expect(test_nodes_handler.get_different_comment_2_of('node2')).to eq 'Comment2 from test_cmdb_2'
299
298
  expect(cmdb(:test_cmdb).calls).to eq [
300
299
  [:get_different_comment, %w[node2], {}],
301
- [:get_different_comment2, %w[node1], { 'node1' => { different_comment: 'Comment from test_cmdb2' } }]
300
+ [:get_different_comment_2, %w[node1], { 'node1' => { different_comment: 'Comment from test_cmdb_2' } }]
302
301
  ]
303
- expect(cmdb(:test_cmdb2).calls).to eq [
302
+ expect(cmdb(:test_cmdb_2).calls).to eq [
304
303
  [:get_different_comment, %w[node1], {}],
305
- [:get_different_comment2, %w[node2], { 'node2' => { different_comment: 'Comment from test_cmdb' } }]
304
+ [:get_different_comment_2, %w[node2], { 'node2' => { different_comment: 'Comment from test_cmdb' } }]
306
305
  ]
307
306
  end
308
307
  end
309
308
 
310
309
  it 'fails when there are conflicts in the definition of master CMDBs' do
311
310
  with_cmdb_test_platform(
312
- cmdbs: %i[test_cmdb test_cmdb2],
313
- additional_platforms_content: '
311
+ cmdbs: %i[test_cmdb test_cmdb_2],
312
+ additional_config: <<~'EO_CONFIG'
314
313
  master_cmdbs(
315
- test_cmdb: %i[different_comment different_comment2]
314
+ test_cmdb: %i[different_comment different_comment_2]
316
315
  )
317
316
  master_cmdbs(
318
317
  test_cmdb: :different_comment,
319
- test_cmdb2: :different_comment2
318
+ test_cmdb_2: :different_comment_2
320
319
  )
321
- '
320
+ EO_CONFIG
322
321
  ) do
323
- expect { test_nodes_handler.get_different_comment_of('node1') }.to raise_error 'Property different_comment2 have conflicting CMDB masters for node1 declared in the configuration: HybridPlatformsConductorTest::CmdbPlugins::TestCmdb and HybridPlatformsConductorTest::CmdbPlugins::TestCmdb2'
322
+ expect { test_nodes_handler.get_different_comment_of('node1') }.to raise_error 'Property different_comment_2 have conflicting CMDB masters for node1 declared in the configuration: HybridPlatformsConductorTest::CmdbPlugins::TestCmdb and HybridPlatformsConductorTest::CmdbPlugins::TestCmdb2'
324
323
  end
325
324
  end
326
325
 
327
326
  it 'fails when the CMDB marked as master does not implement the property' do
328
327
  with_cmdb_test_platform(
329
- cmdbs: %i[test_cmdb test_cmdb2],
330
- additional_platforms_content: '
328
+ cmdbs: %i[test_cmdb test_cmdb_2],
329
+ additional_config: <<~'EO_CONFIG'
331
330
  master_cmdbs(
332
- test_cmdb2: :upcase
331
+ test_cmdb_2: :upcase
333
332
  )
334
- '
333
+ EO_CONFIG
335
334
  ) do
336
- expect { test_nodes_handler.get_upcase_of('node1') }.to raise_error 'CMDB test_cmdb2 is configured as a master for property upcase on node node1 but it does not implement the needed API to retrieve it'
335
+ expect { test_nodes_handler.get_upcase_of('node1') }.to raise_error 'CMDB test_cmdb_2 is configured as a master for property upcase on node node1 but it does not implement the needed API to retrieve it'
337
336
  end
338
337
  end
339
338
 
340
339
  it 'continues trying different CMDBs to get a property even if ones already gives it' do
341
- with_cmdb_test_platform(cmdbs: %i[test_cmdb2 test_cmdb]) do
340
+ with_cmdb_test_platform(cmdbs: %i[test_cmdb_2 test_cmdb]) do
342
341
  expect(test_nodes_handler.get_nothing_of('node1')).to eq 'node1 has nothing'
343
342
  # test_cmdb was not even called, as it was registered second
344
343
  expect(cmdb(:test_cmdb).calls).to eq [
345
344
  [:get_nothing, ['node1'], {}]
346
345
  ]
347
- expect(cmdb(:test_cmdb2).calls).to eq [
346
+ expect(cmdb(:test_cmdb_2).calls).to eq [
348
347
  [:get_nothing, ['node1'], {}]
349
348
  ]
350
349
  end
@@ -7,15 +7,15 @@ describe HybridPlatformsConductor::NodesHandler do
7
7
  end
8
8
 
9
9
  it 'initializes with a platform having no node' do
10
- with_test_platform do
10
+ with_test_platform({}) do
11
11
  expect(test_nodes_handler.known_nodes).to eq []
12
12
  end
13
13
  end
14
14
 
15
15
  it 'iterates over defined nodes sequentially' do
16
- with_test_platform(nodes: { 'node1' => {}, 'node2' => {}, 'node3' => {}, 'node4' => {} }) do
16
+ with_test_platform({ nodes: { 'node1' => {}, 'node2' => {}, 'node3' => {}, 'node4' => {} } }) do
17
17
  nodes_iterated = []
18
- test_nodes_handler.for_each_node_in(['node2', 'node3', 'node4']) do |node|
18
+ test_nodes_handler.for_each_node_in(%w[node2 node3 node4]) do |node|
19
19
  nodes_iterated << node
20
20
  end
21
21
  expect(nodes_iterated.sort).to eq %w[node2 node3 node4].sort
@@ -23,18 +23,15 @@ describe HybridPlatformsConductor::NodesHandler do
23
23
  end
24
24
 
25
25
  it 'iterates over defined nodes in parallel' do
26
- with_test_platform(nodes: { 'node1' => {}, 'node2' => {}, 'node3' => {}, 'node4' => {} }) do
26
+ with_test_platform({ nodes: { 'node1' => {}, 'node2' => {}, 'node3' => {}, 'node4' => {} } }) do
27
27
  nodes_iterated = []
28
- test_nodes_handler.for_each_node_in(['node2', 'node3', 'node4'], parallel: true) do |node|
28
+ test_nodes_handler.for_each_node_in(%w[node2 node3 node4], parallel: true) do |node|
29
29
  sleep(
30
- case node
31
- when 'node2'
32
- 2
33
- when 'node3'
34
- 3
35
- when 'node4'
36
- 1
37
- end
30
+ {
31
+ 'node2' => 2,
32
+ 'node3' => 3,
33
+ 'node4' => 1
34
+ }[node]
38
35
  )
39
36
  nodes_iterated << node
40
37
  end
@@ -43,12 +40,12 @@ describe HybridPlatformsConductor::NodesHandler do
43
40
  end
44
41
 
45
42
  it 'iterates over defined nodes in parallel and handle errors correctly' do
46
- with_test_platform(nodes: { 'node1' => {}, 'node2' => {}, 'node3' => {}, 'node4' => {} }) do
43
+ with_test_platform({ nodes: { 'node1' => {}, 'node2' => {}, 'node3' => {}, 'node4' => {} } }) do
47
44
  nodes_iterated = []
48
45
  # Make sure we exit the test case even if the error is not handled correctly by using a timeout
49
46
  Timeout.timeout(5) do
50
47
  expect do
51
- test_nodes_handler.for_each_node_in(['node2', 'node3', 'node4'], parallel: true) do |node|
48
+ test_nodes_handler.for_each_node_in(%w[node2 node3 node4], parallel: true) do |node|
52
49
  case node
53
50
  when 'node2'
54
51
  sleep 2
@@ -68,27 +65,34 @@ describe HybridPlatformsConductor::NodesHandler do
68
65
 
69
66
  it 'selects the correct configurations for a given node' do
70
67
  with_test_platform(
71
- nodes: { 'node1' => {}, 'node2' => {}, 'node3' => {}, 'node4' => {} },
72
- nodes_lists: { 'nodeslist1' => %w[node1 node2], 'nodeslist2' => %w[node3 node4] }
68
+ {
69
+ nodes: { 'node1' => {}, 'node2' => {}, 'node3' => {}, 'node4' => {} },
70
+ nodes_lists: { 'nodeslist1' => %w[node1 node2], 'nodeslist2' => %w[node3 node4] }
71
+ }
73
72
  ) do
74
- expect(test_nodes_handler.select_confs_for_node('node2', [
75
- {
76
- conf: 'conf1',
77
- nodes_selectors_stack: ['/node1/']
78
- },
79
- {
80
- conf: 'conf2',
81
- nodes_selectors_stack: ['/node2/']
82
- },
83
- {
84
- conf: 'conf3',
85
- nodes_selectors_stack: [[{ list: 'nodeslist1' }]]
86
- },
87
- {
88
- conf: 'conf4',
89
- nodes_selectors_stack: [[{ list: 'nodeslist2' }]]
90
- }
91
- ]).map { |config| config[:conf] }.sort).to eq %w[
73
+ expect(
74
+ test_nodes_handler.select_confs_for_node(
75
+ 'node2',
76
+ [
77
+ {
78
+ conf: 'conf1',
79
+ nodes_selectors_stack: ['/node1/']
80
+ },
81
+ {
82
+ conf: 'conf2',
83
+ nodes_selectors_stack: ['/node2/']
84
+ },
85
+ {
86
+ conf: 'conf3',
87
+ nodes_selectors_stack: [[{ list: 'nodeslist1' }]]
88
+ },
89
+ {
90
+ conf: 'conf4',
91
+ nodes_selectors_stack: [[{ list: 'nodeslist2' }]]
92
+ }
93
+ ]
94
+ ).map { |config| config[:conf] }.sort
95
+ ).to eq %w[
92
96
  conf2
93
97
  conf3
94
98
  ].sort
@@ -97,59 +101,65 @@ describe HybridPlatformsConductor::NodesHandler do
97
101
 
98
102
  it 'selects the correct configurations for a given platform' do
99
103
  with_test_platforms(
100
- 'platform1' => { nodes: { 'node11' => {}, 'node12' => {}, 'node13' => {}, 'node14' => {} } },
101
- 'platform2' => { nodes: { 'node21' => {}, 'node22' => {}, 'node23' => {}, 'node24' => {} } }
104
+ {
105
+ 'platform1' => { nodes: { 'node11' => {}, 'node12' => {}, 'node13' => {}, 'node14' => {} } },
106
+ 'platform2' => { nodes: { 'node21' => {}, 'node22' => {}, 'node23' => {}, 'node24' => {} } }
107
+ }
102
108
  ) do
103
- expect(test_nodes_handler.select_confs_for_platform('platform2', [
104
- {
105
- conf: 'conf1',
106
- nodes_selectors_stack: ['/node1/']
107
- },
108
- {
109
- conf: 'conf2',
110
- nodes_selectors_stack: ['/node2/']
111
- },
112
- {
113
- conf: 'conf3',
114
- nodes_selectors_stack: [%w[node11 node13 node21 node22 node23 node24]]
115
- },
116
- {
117
- conf: 'conf4',
118
- nodes_selectors_stack: [%w[node11 node13 node21 node22 node24]]
119
- }
120
- ]).map { |config| config[:conf] }.sort).to eq %w[
109
+ expect(
110
+ test_nodes_handler.select_confs_for_platform(
111
+ 'platform2',
112
+ [
113
+ {
114
+ conf: 'conf1',
115
+ nodes_selectors_stack: ['/node1/']
116
+ },
117
+ {
118
+ conf: 'conf2',
119
+ nodes_selectors_stack: ['/node2/']
120
+ },
121
+ {
122
+ conf: 'conf3',
123
+ nodes_selectors_stack: [%w[node11 node13 node21 node22 node23 node24]]
124
+ },
125
+ {
126
+ conf: 'conf4',
127
+ nodes_selectors_stack: [%w[node11 node13 node21 node22 node24]]
128
+ }
129
+ ]
130
+ ).map { |config| config[:conf] }.sort
131
+ ).to eq %w[
121
132
  conf2
122
133
  conf3
123
134
  ].sort
124
135
  end
125
136
  end
126
137
 
127
- it 'computes the correct sudo for different nodes' do
128
- with_test_platform(
129
- {
130
- nodes: {
131
- 'node1' => {},
132
- 'node2' => {},
133
- 'node3' => {}
134
- }
135
- },
136
- false,
137
- '
138
- for_nodes(%w[node1 node2]) do
139
- sudo_for { |user| "alt_sudo1 -p #{user}" }
140
- end
141
- for_nodes(\'node2\') do
142
- sudo_for { |user| "alt_sudo2 -q #{user}" }
143
- end
144
- '
145
- ) do
146
- expect(test_nodes_handler.sudo_on('node1')).to eq 'alt_sudo1 -p root'
147
- expect(test_nodes_handler.sudo_on('node1', 'test_user')).to eq 'alt_sudo1 -p test_user'
148
- expect(test_nodes_handler.sudo_on('node2')).to eq 'alt_sudo2 -q root'
149
- expect(test_nodes_handler.sudo_on('node2', 'test_user')).to eq 'alt_sudo2 -q test_user'
150
- expect(test_nodes_handler.sudo_on('node3')).to eq 'sudo -u root'
151
- expect(test_nodes_handler.sudo_on('node3', 'test_user')).to eq 'sudo -u test_user'
152
- end
138
+ it 'computes the correct sudo for different nodes' do
139
+ with_test_platform(
140
+ {
141
+ nodes: {
142
+ 'node1' => {},
143
+ 'node2' => {},
144
+ 'node3' => {}
145
+ }
146
+ },
147
+ additional_config: <<~'EO_CONFIG'
148
+ for_nodes(%w[node1 node2]) do
149
+ sudo_for { |user| "alt_sudo1 -p #{user}" }
150
+ end
151
+ for_nodes('node2') do
152
+ sudo_for { |user| "alt_sudo2 -q #{user}" }
153
+ end
154
+ EO_CONFIG
155
+ ) do
156
+ expect(test_nodes_handler.sudo_on('node1')).to eq 'alt_sudo1 -p root'
157
+ expect(test_nodes_handler.sudo_on('node1', 'test_user')).to eq 'alt_sudo1 -p test_user'
158
+ expect(test_nodes_handler.sudo_on('node2')).to eq 'alt_sudo2 -q root'
159
+ expect(test_nodes_handler.sudo_on('node2', 'test_user')).to eq 'alt_sudo2 -q test_user'
160
+ expect(test_nodes_handler.sudo_on('node3')).to eq 'sudo -u root'
161
+ expect(test_nodes_handler.sudo_on('node3', 'test_user')).to eq 'sudo -u test_user'
153
162
  end
163
+ end
154
164
 
155
165
  end