hybrid_platforms_conductor 32.3.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (244) hide show
  1. checksums.yaml +7 -0
  2. data/bin/check-node +24 -0
  3. data/bin/deploy +12 -0
  4. data/bin/dump_nodes_json +12 -0
  5. data/bin/free_ips +23 -0
  6. data/bin/free_veids +17 -0
  7. data/bin/get_impacted_nodes +43 -0
  8. data/bin/last_deploys +56 -0
  9. data/bin/nodes_to_deploy +104 -0
  10. data/bin/report +10 -0
  11. data/bin/run +39 -0
  12. data/bin/setup +11 -0
  13. data/bin/ssh_config +14 -0
  14. data/bin/test +13 -0
  15. data/bin/topograph +54 -0
  16. data/lib/hybrid_platforms_conductor/action.rb +82 -0
  17. data/lib/hybrid_platforms_conductor/actions_executor.rb +307 -0
  18. data/lib/hybrid_platforms_conductor/bitbucket.rb +123 -0
  19. data/lib/hybrid_platforms_conductor/cmd_runner.rb +188 -0
  20. data/lib/hybrid_platforms_conductor/cmdb.rb +34 -0
  21. data/lib/hybrid_platforms_conductor/common_config_dsl/bitbucket.rb +78 -0
  22. data/lib/hybrid_platforms_conductor/common_config_dsl/confluence.rb +43 -0
  23. data/lib/hybrid_platforms_conductor/common_config_dsl/file_system_tests.rb +110 -0
  24. data/lib/hybrid_platforms_conductor/common_config_dsl/idempotence_tests.rb +38 -0
  25. data/lib/hybrid_platforms_conductor/config.rb +263 -0
  26. data/lib/hybrid_platforms_conductor/confluence.rb +119 -0
  27. data/lib/hybrid_platforms_conductor/connector.rb +84 -0
  28. data/lib/hybrid_platforms_conductor/credentials.rb +127 -0
  29. data/lib/hybrid_platforms_conductor/current_dir_monitor.rb +42 -0
  30. data/lib/hybrid_platforms_conductor/deployer.rb +598 -0
  31. data/lib/hybrid_platforms_conductor/executable.rb +145 -0
  32. data/lib/hybrid_platforms_conductor/hpc_plugins/action/bash.rb +44 -0
  33. data/lib/hybrid_platforms_conductor/hpc_plugins/action/interactive.rb +44 -0
  34. data/lib/hybrid_platforms_conductor/hpc_plugins/action/my_action.rb.sample +79 -0
  35. data/lib/hybrid_platforms_conductor/hpc_plugins/action/remote_bash.rb +63 -0
  36. data/lib/hybrid_platforms_conductor/hpc_plugins/action/ruby.rb +69 -0
  37. data/lib/hybrid_platforms_conductor/hpc_plugins/action/scp.rb +61 -0
  38. data/lib/hybrid_platforms_conductor/hpc_plugins/cmdb/config.rb +78 -0
  39. data/lib/hybrid_platforms_conductor/hpc_plugins/cmdb/host_ip.rb +104 -0
  40. data/lib/hybrid_platforms_conductor/hpc_plugins/cmdb/host_keys.rb +114 -0
  41. data/lib/hybrid_platforms_conductor/hpc_plugins/cmdb/my_cmdb.rb.sample +129 -0
  42. data/lib/hybrid_platforms_conductor/hpc_plugins/cmdb/platform_handlers.rb +66 -0
  43. data/lib/hybrid_platforms_conductor/hpc_plugins/connector/my_connector.rb.sample +156 -0
  44. data/lib/hybrid_platforms_conductor/hpc_plugins/connector/ssh.rb +702 -0
  45. data/lib/hybrid_platforms_conductor/hpc_plugins/platform_handler/platform_handler_plugin.rb.sample +292 -0
  46. data/lib/hybrid_platforms_conductor/hpc_plugins/provisioner/docker.rb +148 -0
  47. data/lib/hybrid_platforms_conductor/hpc_plugins/provisioner/my_provisioner.rb.sample +103 -0
  48. data/lib/hybrid_platforms_conductor/hpc_plugins/provisioner/podman.rb +125 -0
  49. data/lib/hybrid_platforms_conductor/hpc_plugins/provisioner/proxmox.rb +522 -0
  50. data/lib/hybrid_platforms_conductor/hpc_plugins/provisioner/proxmox/proxmox_waiter.rb +707 -0
  51. data/lib/hybrid_platforms_conductor/hpc_plugins/provisioner/proxmox/reserve_proxmox_container +122 -0
  52. data/lib/hybrid_platforms_conductor/hpc_plugins/report/confluence.rb +69 -0
  53. data/lib/hybrid_platforms_conductor/hpc_plugins/report/mediawiki.rb +164 -0
  54. data/lib/hybrid_platforms_conductor/hpc_plugins/report/my_report_plugin.rb.sample +88 -0
  55. data/lib/hybrid_platforms_conductor/hpc_plugins/report/stdout.rb +61 -0
  56. data/lib/hybrid_platforms_conductor/hpc_plugins/report/templates/confluence_inventory.html.erb +33 -0
  57. data/lib/hybrid_platforms_conductor/hpc_plugins/test/bitbucket_conf.rb +137 -0
  58. data/lib/hybrid_platforms_conductor/hpc_plugins/test/can_be_checked.rb +21 -0
  59. data/lib/hybrid_platforms_conductor/hpc_plugins/test/check_deploy_and_idempotence.rb +112 -0
  60. data/lib/hybrid_platforms_conductor/hpc_plugins/test/check_from_scratch.rb +35 -0
  61. data/lib/hybrid_platforms_conductor/hpc_plugins/test/connection.rb +28 -0
  62. data/lib/hybrid_platforms_conductor/hpc_plugins/test/deploy_freshness.rb +44 -0
  63. data/lib/hybrid_platforms_conductor/hpc_plugins/test/deploy_from_scratch.rb +36 -0
  64. data/lib/hybrid_platforms_conductor/hpc_plugins/test/deploy_removes_root_access.rb +49 -0
  65. data/lib/hybrid_platforms_conductor/hpc_plugins/test/divergence.rb +25 -0
  66. data/lib/hybrid_platforms_conductor/hpc_plugins/test/executables.rb +46 -0
  67. data/lib/hybrid_platforms_conductor/hpc_plugins/test/file_system.rb +45 -0
  68. data/lib/hybrid_platforms_conductor/hpc_plugins/test/file_system_hdfs.rb +45 -0
  69. data/lib/hybrid_platforms_conductor/hpc_plugins/test/hostname.rb +25 -0
  70. data/lib/hybrid_platforms_conductor/hpc_plugins/test/idempotence.rb +77 -0
  71. data/lib/hybrid_platforms_conductor/hpc_plugins/test/ip.rb +38 -0
  72. data/lib/hybrid_platforms_conductor/hpc_plugins/test/jenkins_ci_conf.rb +56 -0
  73. data/lib/hybrid_platforms_conductor/hpc_plugins/test/jenkins_ci_masters_ok.rb +54 -0
  74. data/lib/hybrid_platforms_conductor/hpc_plugins/test/linear_strategy.rb +47 -0
  75. data/lib/hybrid_platforms_conductor/hpc_plugins/test/local_users.rb +82 -0
  76. data/lib/hybrid_platforms_conductor/hpc_plugins/test/mounts.rb +120 -0
  77. data/lib/hybrid_platforms_conductor/hpc_plugins/test/my_test_plugin.rb.sample +143 -0
  78. data/lib/hybrid_platforms_conductor/hpc_plugins/test/orphan_files.rb +74 -0
  79. data/lib/hybrid_platforms_conductor/hpc_plugins/test/ports.rb +85 -0
  80. data/lib/hybrid_platforms_conductor/hpc_plugins/test/private_ips.rb +38 -0
  81. data/lib/hybrid_platforms_conductor/hpc_plugins/test/public_ips.rb +38 -0
  82. data/lib/hybrid_platforms_conductor/hpc_plugins/test/spectre-meltdown-checker.sh +1930 -0
  83. data/lib/hybrid_platforms_conductor/hpc_plugins/test/spectre.rb +56 -0
  84. data/lib/hybrid_platforms_conductor/hpc_plugins/test/veids.rb +31 -0
  85. data/lib/hybrid_platforms_conductor/hpc_plugins/test/vulnerabilities.rb +159 -0
  86. data/lib/hybrid_platforms_conductor/hpc_plugins/test_report/confluence.rb +122 -0
  87. data/lib/hybrid_platforms_conductor/hpc_plugins/test_report/my_test_report.rb.sample +48 -0
  88. data/lib/hybrid_platforms_conductor/hpc_plugins/test_report/stdout.rb +120 -0
  89. data/lib/hybrid_platforms_conductor/hpc_plugins/test_report/templates/_confluence_errors_status.html.erb +46 -0
  90. data/lib/hybrid_platforms_conductor/hpc_plugins/test_report/templates/_confluence_gauge.html.erb +49 -0
  91. data/lib/hybrid_platforms_conductor/hpc_plugins/test_report/templates/confluence.html.erb +242 -0
  92. data/lib/hybrid_platforms_conductor/io_router.rb +70 -0
  93. data/lib/hybrid_platforms_conductor/json_dumper.rb +88 -0
  94. data/lib/hybrid_platforms_conductor/logger_helpers.rb +319 -0
  95. data/lib/hybrid_platforms_conductor/mutex_dir +76 -0
  96. data/lib/hybrid_platforms_conductor/nodes_handler.rb +597 -0
  97. data/lib/hybrid_platforms_conductor/parallel_threads.rb +97 -0
  98. data/lib/hybrid_platforms_conductor/platform_handler.rb +188 -0
  99. data/lib/hybrid_platforms_conductor/platforms_handler.rb +118 -0
  100. data/lib/hybrid_platforms_conductor/plugin.rb +53 -0
  101. data/lib/hybrid_platforms_conductor/plugins.rb +101 -0
  102. data/lib/hybrid_platforms_conductor/provisioner.rb +181 -0
  103. data/lib/hybrid_platforms_conductor/report.rb +31 -0
  104. data/lib/hybrid_platforms_conductor/reports_handler.rb +84 -0
  105. data/lib/hybrid_platforms_conductor/services_handler.rb +274 -0
  106. data/lib/hybrid_platforms_conductor/test.rb +141 -0
  107. data/lib/hybrid_platforms_conductor/test_by_service.rb +22 -0
  108. data/lib/hybrid_platforms_conductor/test_report.rb +282 -0
  109. data/lib/hybrid_platforms_conductor/tests_runner.rb +590 -0
  110. data/lib/hybrid_platforms_conductor/thycotic.rb +92 -0
  111. data/lib/hybrid_platforms_conductor/topographer.rb +859 -0
  112. data/lib/hybrid_platforms_conductor/topographer/plugin.rb +20 -0
  113. data/lib/hybrid_platforms_conductor/topographer/plugins/graphviz.rb +127 -0
  114. data/lib/hybrid_platforms_conductor/topographer/plugins/json.rb +72 -0
  115. data/lib/hybrid_platforms_conductor/topographer/plugins/my_topographer_output_plugin.rb.sample +37 -0
  116. data/lib/hybrid_platforms_conductor/topographer/plugins/svg.rb +30 -0
  117. data/lib/hybrid_platforms_conductor/version.rb +5 -0
  118. data/spec/hybrid_platforms_conductor_test.rb +159 -0
  119. data/spec/hybrid_platforms_conductor_test/api/actions_executor/actions/bash_spec.rb +43 -0
  120. data/spec/hybrid_platforms_conductor_test/api/actions_executor/actions/interactive_spec.rb +18 -0
  121. data/spec/hybrid_platforms_conductor_test/api/actions_executor/actions/remote_bash_spec.rb +102 -0
  122. data/spec/hybrid_platforms_conductor_test/api/actions_executor/actions/ruby_spec.rb +108 -0
  123. data/spec/hybrid_platforms_conductor_test/api/actions_executor/actions/scp_spec.rb +79 -0
  124. data/spec/hybrid_platforms_conductor_test/api/actions_executor/actions_spec.rb +199 -0
  125. data/spec/hybrid_platforms_conductor_test/api/actions_executor/connection_spec.rb +212 -0
  126. data/spec/hybrid_platforms_conductor_test/api/actions_executor/connectors/ssh/cli_options_spec.rb +125 -0
  127. data/spec/hybrid_platforms_conductor_test/api/actions_executor/connectors/ssh/config_dsl_spec.rb +50 -0
  128. data/spec/hybrid_platforms_conductor_test/api/actions_executor/connectors/ssh/connectable_nodes_spec.rb +28 -0
  129. data/spec/hybrid_platforms_conductor_test/api/actions_executor/connectors/ssh/connections_spec.rb +448 -0
  130. data/spec/hybrid_platforms_conductor_test/api/actions_executor/connectors/ssh/global_helpers_spec.rb +313 -0
  131. data/spec/hybrid_platforms_conductor_test/api/actions_executor/connectors/ssh/node_helpers_spec.rb +32 -0
  132. data/spec/hybrid_platforms_conductor_test/api/actions_executor/connectors/ssh/remote_actions_spec.rb +134 -0
  133. data/spec/hybrid_platforms_conductor_test/api/actions_executor/logging_spec.rb +256 -0
  134. data/spec/hybrid_platforms_conductor_test/api/actions_executor/parallel_spec.rb +338 -0
  135. data/spec/hybrid_platforms_conductor_test/api/actions_executor/timeout_spec.rb +101 -0
  136. data/spec/hybrid_platforms_conductor_test/api/cmd_runner_spec.rb +165 -0
  137. data/spec/hybrid_platforms_conductor_test/api/config_spec.rb +238 -0
  138. data/spec/hybrid_platforms_conductor_test/api/deployer/check_spec.rb +9 -0
  139. data/spec/hybrid_platforms_conductor_test/api/deployer/deploy_spec.rb +243 -0
  140. data/spec/hybrid_platforms_conductor_test/api/deployer/parse_deploy_output_spec.rb +104 -0
  141. data/spec/hybrid_platforms_conductor_test/api/deployer/provisioner_spec.rb +131 -0
  142. data/spec/hybrid_platforms_conductor_test/api/deployer/provisioners/docker/Dockerfile +10 -0
  143. data/spec/hybrid_platforms_conductor_test/api/deployer/provisioners/docker_spec.rb +123 -0
  144. data/spec/hybrid_platforms_conductor_test/api/deployer/provisioners/podman_spec.rb +211 -0
  145. data/spec/hybrid_platforms_conductor_test/api/deployer/provisioners/proxmox/config_dsl_spec.rb +126 -0
  146. data/spec/hybrid_platforms_conductor_test/api/deployer/provisioners/proxmox/create_spec.rb +290 -0
  147. data/spec/hybrid_platforms_conductor_test/api/deployer/provisioners/proxmox/destroy_spec.rb +43 -0
  148. data/spec/hybrid_platforms_conductor_test/api/deployer/provisioners/proxmox/ip_spec.rb +60 -0
  149. data/spec/hybrid_platforms_conductor_test/api/deployer/provisioners/proxmox/proxmox.json +3 -0
  150. data/spec/hybrid_platforms_conductor_test/api/deployer/provisioners/proxmox/reserve_proxmox_container/destroy_vm_spec.rb +82 -0
  151. data/spec/hybrid_platforms_conductor_test/api/deployer/provisioners/proxmox/reserve_proxmox_container/expired_containers_spec.rb +786 -0
  152. data/spec/hybrid_platforms_conductor_test/api/deployer/provisioners/proxmox/reserve_proxmox_container/ips_assignment_spec.rb +112 -0
  153. data/spec/hybrid_platforms_conductor_test/api/deployer/provisioners/proxmox/reserve_proxmox_container/other_lxc_containers_resources_spec.rb +190 -0
  154. data/spec/hybrid_platforms_conductor_test/api/deployer/provisioners/proxmox/reserve_proxmox_container/pve_node_resources_spec.rb +200 -0
  155. data/spec/hybrid_platforms_conductor_test/api/deployer/provisioners/proxmox/reserve_proxmox_container/retries_spec.rb +35 -0
  156. data/spec/hybrid_platforms_conductor_test/api/deployer/provisioners/proxmox/reserve_proxmox_container/vm_ids_assignment_spec.rb +67 -0
  157. data/spec/hybrid_platforms_conductor_test/api/deployer/provisioners/proxmox/start_spec.rb +79 -0
  158. data/spec/hybrid_platforms_conductor_test/api/deployer/provisioners/proxmox/state_spec.rb +28 -0
  159. data/spec/hybrid_platforms_conductor_test/api/deployer/provisioners/proxmox/stop_spec.rb +41 -0
  160. data/spec/hybrid_platforms_conductor_test/api/nodes_handler/cmdbs/config_spec.rb +33 -0
  161. data/spec/hybrid_platforms_conductor_test/api/nodes_handler/cmdbs/host_ip_spec.rb +64 -0
  162. data/spec/hybrid_platforms_conductor_test/api/nodes_handler/cmdbs/host_keys_spec.rb +133 -0
  163. data/spec/hybrid_platforms_conductor_test/api/nodes_handler/cmdbs/platform_handlers_spec.rb +19 -0
  164. data/spec/hybrid_platforms_conductor_test/api/nodes_handler/cmdbs_plugins_api_spec.rb +446 -0
  165. data/spec/hybrid_platforms_conductor_test/api/nodes_handler/common_spec.rb +127 -0
  166. data/spec/hybrid_platforms_conductor_test/api/nodes_handler/git_diff_impacts_spec.rb +318 -0
  167. data/spec/hybrid_platforms_conductor_test/api/nodes_handler/nodes_selectors_spec.rb +132 -0
  168. data/spec/hybrid_platforms_conductor_test/api/nodes_handler/platform_handlers_plugins_api_spec.rb +60 -0
  169. data/spec/hybrid_platforms_conductor_test/api/nodes_handler/several_platforms_spec.rb +58 -0
  170. data/spec/hybrid_platforms_conductor_test/api/platform_handler_spec.rb +97 -0
  171. data/spec/hybrid_platforms_conductor_test/api/platforms_handler_spec.rb +104 -0
  172. data/spec/hybrid_platforms_conductor_test/api/plugins_spec.rb +243 -0
  173. data/spec/hybrid_platforms_conductor_test/api/reports_handler_spec.rb +44 -0
  174. data/spec/hybrid_platforms_conductor_test/api/services_handler/actions_to_deploy_spec.rb +121 -0
  175. data/spec/hybrid_platforms_conductor_test/api/services_handler/deploy_allowed_spec.rb +142 -0
  176. data/spec/hybrid_platforms_conductor_test/api/services_handler/log_info_spec.rb +101 -0
  177. data/spec/hybrid_platforms_conductor_test/api/services_handler/package_spec.rb +388 -0
  178. data/spec/hybrid_platforms_conductor_test/api/services_handler/parse_deploy_output_spec.rb +274 -0
  179. data/spec/hybrid_platforms_conductor_test/api/services_handler/prepare_for_deploy_spec.rb +264 -0
  180. data/spec/hybrid_platforms_conductor_test/api/tests_runner/common_spec.rb +194 -0
  181. data/spec/hybrid_platforms_conductor_test/api/tests_runner/global_spec.rb +37 -0
  182. data/spec/hybrid_platforms_conductor_test/api/tests_runner/node_check_spec.rb +194 -0
  183. data/spec/hybrid_platforms_conductor_test/api/tests_runner/node_spec.rb +137 -0
  184. data/spec/hybrid_platforms_conductor_test/api/tests_runner/node_ssh_spec.rb +257 -0
  185. data/spec/hybrid_platforms_conductor_test/api/tests_runner/platform_spec.rb +110 -0
  186. data/spec/hybrid_platforms_conductor_test/api/tests_runner/reports_spec.rb +367 -0
  187. data/spec/hybrid_platforms_conductor_test/api/tests_runner/test_plugins/bitbucket_conf_spec.rb +111 -0
  188. data/spec/hybrid_platforms_conductor_test/api/tests_runner/test_reports_plugins/confluence_spec.rb +29 -0
  189. data/spec/hybrid_platforms_conductor_test/cmdb_plugins/test_cmdb.rb +166 -0
  190. data/spec/hybrid_platforms_conductor_test/cmdb_plugins/test_cmdb2.rb +93 -0
  191. data/spec/hybrid_platforms_conductor_test/cmdb_plugins/test_cmdb_others.rb +60 -0
  192. data/spec/hybrid_platforms_conductor_test/cmdb_plugins/test_cmdb_others2.rb +58 -0
  193. data/spec/hybrid_platforms_conductor_test/executables/check-node_spec.rb +35 -0
  194. data/spec/hybrid_platforms_conductor_test/executables/deploy_spec.rb +35 -0
  195. data/spec/hybrid_platforms_conductor_test/executables/get_impacted_nodes_spec.rb +158 -0
  196. data/spec/hybrid_platforms_conductor_test/executables/last_deploys_spec.rb +173 -0
  197. data/spec/hybrid_platforms_conductor_test/executables/nodes_to_deploy_spec.rb +283 -0
  198. data/spec/hybrid_platforms_conductor_test/executables/options/actions_executor_spec.rb +28 -0
  199. data/spec/hybrid_platforms_conductor_test/executables/options/cmd_runner_spec.rb +28 -0
  200. data/spec/hybrid_platforms_conductor_test/executables/options/common_spec.rb +67 -0
  201. data/spec/hybrid_platforms_conductor_test/executables/options/deployer_spec.rb +251 -0
  202. data/spec/hybrid_platforms_conductor_test/executables/options/nodes_handler_spec.rb +111 -0
  203. data/spec/hybrid_platforms_conductor_test/executables/options/nodes_selectors_spec.rb +71 -0
  204. data/spec/hybrid_platforms_conductor_test/executables/options/reports_handler_spec.rb +54 -0
  205. data/spec/hybrid_platforms_conductor_test/executables/options/tests_runner_spec.rb +139 -0
  206. data/spec/hybrid_platforms_conductor_test/executables/report_spec.rb +60 -0
  207. data/spec/hybrid_platforms_conductor_test/executables/run_spec.rb +173 -0
  208. data/spec/hybrid_platforms_conductor_test/executables/ssh_config_spec.rb +35 -0
  209. data/spec/hybrid_platforms_conductor_test/executables/test_spec.rb +41 -0
  210. data/spec/hybrid_platforms_conductor_test/helpers/actions_executor_helpers.rb +98 -0
  211. data/spec/hybrid_platforms_conductor_test/helpers/cmd_runner_helpers.rb +92 -0
  212. data/spec/hybrid_platforms_conductor_test/helpers/cmdb_helpers.rb +37 -0
  213. data/spec/hybrid_platforms_conductor_test/helpers/config_helpers.rb +20 -0
  214. data/spec/hybrid_platforms_conductor_test/helpers/connector_ssh_helpers.rb +130 -0
  215. data/spec/hybrid_platforms_conductor_test/helpers/deployer_helpers.rb +149 -0
  216. data/spec/hybrid_platforms_conductor_test/helpers/deployer_test_helpers.rb +812 -0
  217. data/spec/hybrid_platforms_conductor_test/helpers/executables_helpers.rb +96 -0
  218. data/spec/hybrid_platforms_conductor_test/helpers/nodes_handler_helpers.rb +20 -0
  219. data/spec/hybrid_platforms_conductor_test/helpers/platform_handler_helpers.rb +35 -0
  220. data/spec/hybrid_platforms_conductor_test/helpers/platforms_handler_helpers.rb +127 -0
  221. data/spec/hybrid_platforms_conductor_test/helpers/plugins_helpers.rb +48 -0
  222. data/spec/hybrid_platforms_conductor_test/helpers/provisioner_proxmox_helpers.rb +789 -0
  223. data/spec/hybrid_platforms_conductor_test/helpers/reports_handler_helpers.rb +29 -0
  224. data/spec/hybrid_platforms_conductor_test/helpers/services_handler_helpers.rb +20 -0
  225. data/spec/hybrid_platforms_conductor_test/helpers/tests_runner_helpers.rb +38 -0
  226. data/spec/hybrid_platforms_conductor_test/mocked_lib/my_test_gem/hpc_plugins/test_plugin_type/test_plugin_id1.rb +22 -0
  227. data/spec/hybrid_platforms_conductor_test/mocked_lib/my_test_gem/hpc_plugins/test_plugin_type/test_plugin_id2.rb +22 -0
  228. data/spec/hybrid_platforms_conductor_test/mocked_lib/my_test_gem2/sub_dir/hpc_plugins/test_plugin_type/test_plugin_id3.rb +26 -0
  229. data/spec/hybrid_platforms_conductor_test/mocked_lib/my_test_gem2/sub_dir/hpc_plugins/test_plugin_type2/test_plugin_id4.rb +26 -0
  230. data/spec/hybrid_platforms_conductor_test/platform_handler_plugins/test.rb +225 -0
  231. data/spec/hybrid_platforms_conductor_test/platform_handler_plugins/test2.rb +11 -0
  232. data/spec/hybrid_platforms_conductor_test/report_plugin.rb +35 -0
  233. data/spec/hybrid_platforms_conductor_test/test_action.rb +66 -0
  234. data/spec/hybrid_platforms_conductor_test/test_connector.rb +151 -0
  235. data/spec/hybrid_platforms_conductor_test/test_plugins/global.rb +30 -0
  236. data/spec/hybrid_platforms_conductor_test/test_plugins/node.rb +53 -0
  237. data/spec/hybrid_platforms_conductor_test/test_plugins/node_check.rb +47 -0
  238. data/spec/hybrid_platforms_conductor_test/test_plugins/node_ssh.rb +42 -0
  239. data/spec/hybrid_platforms_conductor_test/test_plugins/platform.rb +50 -0
  240. data/spec/hybrid_platforms_conductor_test/test_plugins/several_checks.rb +50 -0
  241. data/spec/hybrid_platforms_conductor_test/test_provisioner.rb +95 -0
  242. data/spec/hybrid_platforms_conductor_test/tests_report_plugin.rb +49 -0
  243. data/spec/spec_helper.rb +111 -0
  244. metadata +566 -0
@@ -0,0 +1,283 @@
1
+ describe 'nodes_to_deploy executable' do
2
+
3
+ # Setup a platform for nodes_to_deploy tests
4
+ #
5
+ # Parameters::
6
+ # * *additional_platforms_content* (String): Additional platforms content to be added [default = '']
7
+ # * Proc: Code called when the platform is setup
8
+ # * Parameters::
9
+ # * *repository* (String): Platform's repository
10
+ def with_test_platform_for_nodes_to_deploy(additional_platforms_content: '')
11
+ with_test_platform({ nodes: { 'node1' => {}, 'node2' => {} } }, false, additional_platforms_content) do |repository|
12
+ yield repository
13
+ end
14
+ end
15
+
16
+ it 'returns all nodes by default' do
17
+ with_test_platform_for_nodes_to_deploy do
18
+ expect_actions_executor_runs([proc do |actions|
19
+ expect(actions).to eq(
20
+ 'node1' => { remote_bash: "cd /var/log/deployments && ls -t | head -1 | xargs sed '/===== STDOUT =====/q'" },
21
+ 'node2' => { remote_bash: "cd /var/log/deployments && ls -t | head -1 | xargs sed '/===== STDOUT =====/q'" }
22
+ )
23
+ {
24
+ 'node1' => [0, "repo_name_0: platform\nexit_status: 0\ncommit_id_0: abcdef1", ''],
25
+ 'node2' => [0, "repo_name_0: platform\nexit_status: 0\ncommit_id_0: abcdef2", '']
26
+ }
27
+ end])
28
+ expect(test_nodes_handler).to receive(:impacted_nodes_from_git_diff).with('platform', from_commit: 'abcdef1', to_commit: 'master') { [%w[node1 node2], [], [], false] }
29
+ expect(test_nodes_handler).to receive(:impacted_nodes_from_git_diff).with('platform', from_commit: 'abcdef2', to_commit: 'master') { [%w[node1 node2], [], [], false] }
30
+ exit_code, stdout, stderr = run 'nodes_to_deploy'
31
+ expect(exit_code).to eq 0
32
+ expect(stdout).to eq <<~EOS
33
+ ===== Nodes to deploy =====
34
+ node1
35
+ node2
36
+ EOS
37
+ expect(stderr).to match /\[ node1 \] - No deployment schedule defined./
38
+ expect(stderr).to match /\[ node2 \] - No deployment schedule defined./
39
+ end
40
+ end
41
+
42
+ it 'can filter nodes' do
43
+ with_test_platform_for_nodes_to_deploy do
44
+ expect_actions_executor_runs([proc do |actions|
45
+ expect(actions).to eq(
46
+ 'node2' => { remote_bash: "cd /var/log/deployments && ls -t | head -1 | xargs sed '/===== STDOUT =====/q'" }
47
+ )
48
+ {
49
+ 'node2' => [0, "repo_name_0: platform\nexit_status: 0\ncommit_id_0: abcdef2", '']
50
+ }
51
+ end])
52
+ expect(test_nodes_handler).to receive(:impacted_nodes_from_git_diff).with('platform', from_commit: 'abcdef2', to_commit: 'master') { [%w[node1 node2], [], [], false] }
53
+ exit_code, stdout, stderr = run 'nodes_to_deploy', '--node', 'node2'
54
+ expect(exit_code).to eq 0
55
+ expect(stdout).to eq <<~EOS
56
+ ===== Nodes to deploy =====
57
+ node2
58
+ EOS
59
+ expect(stderr).not_to match /\[ node1 \] - No deployment schedule defined./
60
+ expect(stderr).to match /\[ node2 \] - No deployment schedule defined./
61
+ end
62
+ end
63
+
64
+ it 'does not return nodes that have no impact' do
65
+ with_test_platform_for_nodes_to_deploy do
66
+ expect_actions_executor_runs([proc do |actions|
67
+ expect(actions).to eq(
68
+ 'node1' => { remote_bash: "cd /var/log/deployments && ls -t | head -1 | xargs sed '/===== STDOUT =====/q'" },
69
+ 'node2' => { remote_bash: "cd /var/log/deployments && ls -t | head -1 | xargs sed '/===== STDOUT =====/q'" }
70
+ )
71
+ {
72
+ 'node1' => [0, "repo_name_0: platform\nexit_status: 0\ncommit_id_0: abcdef1", ''],
73
+ 'node2' => [0, "repo_name_0: platform\nexit_status: 0\ncommit_id_0: abcdef2", '']
74
+ }
75
+ end])
76
+ expect(test_nodes_handler).to receive(:impacted_nodes_from_git_diff).with('platform', from_commit: 'abcdef1', to_commit: 'master') { [%w[node1], [], [], false] }
77
+ expect(test_nodes_handler).to receive(:impacted_nodes_from_git_diff).with('platform', from_commit: 'abcdef2', to_commit: 'master') { [%w[], [], [], false] }
78
+ exit_code, stdout, stderr = run 'nodes_to_deploy'
79
+ expect(exit_code).to eq 0
80
+ expect(stdout).to eq <<~EOS
81
+ ===== Nodes to deploy =====
82
+ node1
83
+ EOS
84
+ end
85
+ end
86
+
87
+ it 'considers nodes having no repository info in their logs to be deployed' do
88
+ with_test_platform_for_nodes_to_deploy do
89
+ expect_actions_executor_runs([proc do |actions|
90
+ expect(actions).to eq(
91
+ 'node1' => { remote_bash: "cd /var/log/deployments && ls -t | head -1 | xargs sed '/===== STDOUT =====/q'" },
92
+ 'node2' => { remote_bash: "cd /var/log/deployments && ls -t | head -1 | xargs sed '/===== STDOUT =====/q'" }
93
+ )
94
+ {
95
+ 'node1' => [0, "exit_status: 0\n", ''],
96
+ 'node2' => [0, "repo_name_0: platform\nexit_status: 0\ncommit_id_0: abcdef2", '']
97
+ }
98
+ end])
99
+ expect(test_nodes_handler).to receive(:impacted_nodes_from_git_diff).with('platform', from_commit: 'abcdef2', to_commit: 'master') { [%w[], [], [], false] }
100
+ exit_code, stdout, stderr = run 'nodes_to_deploy'
101
+ expect(exit_code).to eq 0
102
+ expect(stdout).to eq <<~EOS
103
+ ===== Nodes to deploy =====
104
+ node1
105
+ EOS
106
+ end
107
+ end
108
+
109
+ it 'ignores impacts if asked' do
110
+ with_test_platform_for_nodes_to_deploy do
111
+ exit_code, stdout, stderr = run 'nodes_to_deploy', '--ignore-deployed-info'
112
+ expect(exit_code).to eq 0
113
+ expect(stdout).to eq <<~EOS
114
+ ===== Nodes to deploy =====
115
+ node1
116
+ node2
117
+ EOS
118
+ end
119
+ end
120
+
121
+ it 'does not return nodes that are outside the schedule' do
122
+ with_test_platform_for_nodes_to_deploy(additional_platforms_content: '
123
+ for_nodes(\'node1\') { deployment_schedule(IceCube::Schedule.new(Time.now.utc - 120, duration: 60)) }
124
+ for_nodes(\'node2\') { deployment_schedule(IceCube::Schedule.new(Time.now.utc - 60, duration: 120)) }
125
+ ') do
126
+ expect_actions_executor_runs([proc do |actions|
127
+ expect(actions).to eq(
128
+ 'node2' => { remote_bash: "cd /var/log/deployments && ls -t | head -1 | xargs sed '/===== STDOUT =====/q'" }
129
+ )
130
+ {
131
+ 'node2' => [0, "repo_name_0: platform\nexit_status: 0\ncommit_id_0: abcdef2", '']
132
+ }
133
+ end])
134
+ expect(test_nodes_handler).to receive(:impacted_nodes_from_git_diff).with('platform', from_commit: 'abcdef2', to_commit: 'master') { [%w[node1 node2], [], [], false] }
135
+ exit_code, stdout, stderr = run 'nodes_to_deploy'
136
+ expect(exit_code).to eq 0
137
+ expect(stdout).to eq <<~EOS
138
+ ===== Nodes to deploy =====
139
+ node2
140
+ EOS
141
+ expect(stderr).to eq ''
142
+ end
143
+ end
144
+
145
+ it 'does not return nodes that are outside the schedule when using a different deployment time' do
146
+ with_test_platform_for_nodes_to_deploy(additional_platforms_content: '
147
+ for_nodes(\'node1\') { deployment_schedule(IceCube::Schedule.new(Time.now.utc - 120, duration: 60)) }
148
+ for_nodes(\'node2\') { deployment_schedule(IceCube::Schedule.new(Time.now.utc - 60, duration: 120)) }
149
+ ') do
150
+ expect_actions_executor_runs([proc do |actions|
151
+ expect(actions).to eq(
152
+ 'node1' => { remote_bash: "cd /var/log/deployments && ls -t | head -1 | xargs sed '/===== STDOUT =====/q'" }
153
+ )
154
+ {
155
+ 'node1' => [0, "repo_name_0: platform\nexit_status: 0\ncommit_id_0: abcdef1", '']
156
+ }
157
+ end])
158
+ expect(test_nodes_handler).to receive(:impacted_nodes_from_git_diff).with('platform', from_commit: 'abcdef1', to_commit: 'master') { [%w[node1 node2], [], [], false] }
159
+ # 90 seconds before now, the schedule should match only node1
160
+ exit_code, stdout, stderr = run 'nodes_to_deploy', '--deployment-time', (Time.now.utc - 90).strftime('%F %T')
161
+ expect(exit_code).to eq 0
162
+ expect(stdout).to eq <<~EOS
163
+ ===== Nodes to deploy =====
164
+ node1
165
+ EOS
166
+ expect(stderr).to eq ''
167
+ end
168
+ end
169
+
170
+ it 'returns nodes that are outside the schedule when ignoring the schedule' do
171
+ with_test_platform_for_nodes_to_deploy(additional_platforms_content: '
172
+ for_nodes(\'node1\') { deployment_schedule(IceCube::Schedule.new(Time.now.utc - 120, duration: 60)) }
173
+ for_nodes(\'node2\') { deployment_schedule(IceCube::Schedule.new(Time.now.utc - 60, duration: 120)) }
174
+ ') do
175
+ expect_actions_executor_runs([proc do |actions|
176
+ expect(actions).to eq(
177
+ 'node1' => { remote_bash: "cd /var/log/deployments && ls -t | head -1 | xargs sed '/===== STDOUT =====/q'" },
178
+ 'node2' => { remote_bash: "cd /var/log/deployments && ls -t | head -1 | xargs sed '/===== STDOUT =====/q'" }
179
+ )
180
+ {
181
+ 'node1' => [0, "repo_name_0: platform\nexit_status: 0\ncommit_id_0: abcdef1", ''],
182
+ 'node2' => [0, "repo_name_0: platform\nexit_status: 0\ncommit_id_0: abcdef2", '']
183
+ }
184
+ end])
185
+ expect(test_nodes_handler).to receive(:impacted_nodes_from_git_diff).with('platform', from_commit: 'abcdef1', to_commit: 'master') { [%w[node1 node2], [], [], false] }
186
+ expect(test_nodes_handler).to receive(:impacted_nodes_from_git_diff).with('platform', from_commit: 'abcdef2', to_commit: 'master') { [%w[node1 node2], [], [], false] }
187
+ exit_code, stdout, stderr = run 'nodes_to_deploy', '--ignore-schedule'
188
+ expect(exit_code).to eq 0
189
+ expect(stdout).to eq <<~EOS
190
+ ===== Nodes to deploy =====
191
+ node1
192
+ node2
193
+ EOS
194
+ expect(stderr).to eq ''
195
+ end
196
+ end
197
+
198
+ it 'considers impacts from several repositories' do
199
+ with_test_platforms(
200
+ 'platform1' => { nodes: { 'node1' => {}, 'node2' => {} } },
201
+ 'platform2' => { nodes: {} }
202
+ ) do
203
+ expect_actions_executor_runs([proc do |actions|
204
+ expect(actions).to eq(
205
+ 'node1' => { remote_bash: "cd /var/log/deployments && ls -t | head -1 | xargs sed '/===== STDOUT =====/q'" },
206
+ 'node2' => { remote_bash: "cd /var/log/deployments && ls -t | head -1 | xargs sed '/===== STDOUT =====/q'" }
207
+ )
208
+ {
209
+ 'node1' => [0, "repo_name_0: platform1\nexit_status: 0\ncommit_id_0: abcdef1", ''],
210
+ 'node2' => [0, "repo_name_0: platform2\nexit_status: 0\ncommit_id_0: abcdef2", '']
211
+ }
212
+ end])
213
+ expect(test_nodes_handler).to receive(:impacted_nodes_from_git_diff).with('platform1', from_commit: 'abcdef1', to_commit: 'master') { [%w[node1], [], [], false] }
214
+ expect(test_nodes_handler).to receive(:impacted_nodes_from_git_diff).with('platform2', from_commit: 'abcdef2', to_commit: 'master') { [%w[node2], [], [], false] }
215
+ exit_code, stdout, stderr = run 'nodes_to_deploy'
216
+ expect(exit_code).to eq 0
217
+ expect(stdout).to eq <<~EOS
218
+ ===== Nodes to deploy =====
219
+ node1
220
+ node2
221
+ EOS
222
+ end
223
+ end
224
+
225
+ it 'considers impacts from several repositories for the same node as different services for different platforms might be deployed' do
226
+ with_test_platforms(
227
+ 'platform1' => { nodes: { 'node1' => {}, 'node2' => {} } },
228
+ 'platform2' => { nodes: {} },
229
+ 'platform3' => { nodes: {} }
230
+ ) do
231
+ expect_actions_executor_runs([proc do |actions|
232
+ expect(actions).to eq(
233
+ 'node1' => { remote_bash: "cd /var/log/deployments && ls -t | head -1 | xargs sed '/===== STDOUT =====/q'" },
234
+ 'node2' => { remote_bash: "cd /var/log/deployments && ls -t | head -1 | xargs sed '/===== STDOUT =====/q'" }
235
+ )
236
+ {
237
+ 'node1' => [0, "exit_status: 0\nrepo_name_0: platform1\ncommit_id_0: abcdef1\nrepo_name_1: platform2\ncommit_id_1: 1234567", ''],
238
+ 'node2' => [0, "exit_status: 0\nrepo_name_0: platform2\ncommit_id_0: abcdef2\nrepo_name_1: platform3\ncommit_id_1: 2345678", '']
239
+ }
240
+ end])
241
+ expect(test_nodes_handler).to receive(:impacted_nodes_from_git_diff).with('platform1', from_commit: 'abcdef1', to_commit: 'master') { [%w[], [], [], false] }
242
+ expect(test_nodes_handler).to receive(:impacted_nodes_from_git_diff).with('platform2', from_commit: '1234567', to_commit: 'master') { [%w[node1], [], [], false] }
243
+ expect(test_nodes_handler).to receive(:impacted_nodes_from_git_diff).with('platform2', from_commit: 'abcdef2', to_commit: 'master') { [%w[], [], [], false] }
244
+ expect(test_nodes_handler).to receive(:impacted_nodes_from_git_diff).with('platform3', from_commit: '2345678', to_commit: 'master') { [%w[node2], [], [], false] }
245
+ exit_code, stdout, stderr = run 'nodes_to_deploy'
246
+ expect(exit_code).to eq 0
247
+ expect(stdout).to eq <<~EOS
248
+ ===== Nodes to deploy =====
249
+ node1
250
+ node2
251
+ EOS
252
+ end
253
+ end
254
+
255
+ it 'considers impacts from several repositories for the same node but does not query diffs for the nodes we already know need deployment' do
256
+ with_test_platforms(
257
+ 'platform1' => { nodes: { 'node1' => {}, 'node2' => {} } },
258
+ 'platform2' => { nodes: {} },
259
+ 'platform3' => { nodes: {} }
260
+ ) do
261
+ expect_actions_executor_runs([proc do |actions|
262
+ expect(actions).to eq(
263
+ 'node1' => { remote_bash: "cd /var/log/deployments && ls -t | head -1 | xargs sed '/===== STDOUT =====/q'" },
264
+ 'node2' => { remote_bash: "cd /var/log/deployments && ls -t | head -1 | xargs sed '/===== STDOUT =====/q'" }
265
+ )
266
+ {
267
+ 'node1' => [0, "exit_status: 0\nrepo_name_0: platform1\ncommit_id_0: abcdef1\nrepo_name_1: platform2\ncommit_id_1: 1234567", ''],
268
+ 'node2' => [0, "exit_status: 0\nrepo_name_0: platform2\ncommit_id_0: abcdef2\nrepo_name_1: platform3\ncommit_id_1: 2345678", '']
269
+ }
270
+ end])
271
+ expect(test_nodes_handler).to receive(:impacted_nodes_from_git_diff).with('platform1', from_commit: 'abcdef1', to_commit: 'master') { [%w[node1], [], [], false] }
272
+ expect(test_nodes_handler).to receive(:impacted_nodes_from_git_diff).with('platform2', from_commit: 'abcdef2', to_commit: 'master') { [%w[node2], [], [], false] }
273
+ exit_code, stdout, stderr = run 'nodes_to_deploy'
274
+ expect(exit_code).to eq 0
275
+ expect(stdout).to eq <<~EOS
276
+ ===== Nodes to deploy =====
277
+ node1
278
+ node2
279
+ EOS
280
+ end
281
+ end
282
+
283
+ end
@@ -0,0 +1,28 @@
1
+ describe 'executables\' Actions Executor options' do
2
+
3
+ # Setup a platform for tests
4
+ #
5
+ # Parameters::
6
+ # * Proc: Code called when the platform is setup
7
+ # * Parameters::
8
+ # * *repository* (String): Platform's repository
9
+ def with_test_platform_for_actions_executor_options
10
+ with_test_platform({ nodes: { 'node' => {} } }) do |repository|
11
+ yield repository
12
+ end
13
+ end
14
+
15
+ it 'drives the maximum number of threads' do
16
+ with_test_platform_for_actions_executor_options do
17
+ expect_actions_executor_runs([proc do |actions, timeout: nil, concurrent: false, log_to_dir: 'run_logs', log_to_stdout: true|
18
+ expect(test_actions_executor.max_threads).to eq 5
19
+ {}
20
+ end])
21
+ exit_code, stdout, stderr = run 'run', '--node', 'node', '--command', 'echo Hello', '--max-threads', '5'
22
+ expect(exit_code).to eq 0
23
+ expect(stdout).to eq ''
24
+ expect(stderr).to eq ''
25
+ end
26
+ end
27
+
28
+ end
@@ -0,0 +1,28 @@
1
+ describe 'executables\' Cmd Runner options' do
2
+
3
+ # Setup a platform for tests
4
+ #
5
+ # Parameters::
6
+ # * Proc: Code called when the platform is setup
7
+ # * Parameters::
8
+ # * *repository* (String): Platform's repository
9
+ def with_test_platform_for_cmd_runner_options
10
+ with_test_platform({ nodes: { 'node' => {} } }) do |repository|
11
+ yield repository
12
+ end
13
+ end
14
+
15
+ it 'displays commands instead of running them' do
16
+ with_test_platform_for_cmd_runner_options do
17
+ expect_actions_executor_runs([proc do
18
+ expect(test_cmd_runner.dry_run).to eq true
19
+ {}
20
+ end])
21
+ exit_code, stdout, stderr = run 'run', '--node', 'node', '--command', 'echo Hello', '--show-commands'
22
+ expect(exit_code).to eq 0
23
+ expect(stdout).to eq ''
24
+ expect(stderr).to eq ''
25
+ end
26
+ end
27
+
28
+ end
@@ -0,0 +1,67 @@
1
+ describe 'executables\' common options' do
2
+
3
+ # Setup a platform for tests
4
+ #
5
+ # Parameters::
6
+ # * Proc: Code called when the platform is setup
7
+ # * Parameters::
8
+ # * *repository* (String): Platform's repository
9
+ def with_test_platform_for_common_options
10
+ with_test_platform(
11
+ {
12
+ nodes: { 'node1' => { meta: { host_ip: '192.168.42.42' }, services: ['node1_service'] } },
13
+ deployable_services: %w[node1_service]
14
+ },
15
+ true
16
+ ) do |repository|
17
+ yield repository
18
+ end
19
+ end
20
+
21
+ # List of executables for which we test the common options, along with options to try that should do nothing
22
+ {
23
+ 'check-node' => ['--node', 'node1', '--show-commands', '--ssh-no-control-master'],
24
+ 'deploy' => ['--node', 'node1', '--show-commands', '--why-run', '--ssh-no-control-master'],
25
+ 'dump_nodes_json' => ['--help'],
26
+ 'free_ips' => [],
27
+ 'free_veids' => [],
28
+ 'last_deploys' => ['--node', 'node1', '--show-commands', '--ssh-no-control-master'],
29
+ 'report' => ['--node', 'node1', '--format', 'stdout'],
30
+ 'setup' => ['--help'],
31
+ 'ssh_config' => [],
32
+ 'run' => ['--node', 'node1', '--show-commands', '--interactive', '--ssh-no-control-master'],
33
+ 'test' => ['--help']
34
+ # TODO: Add topograph in the tests suite
35
+ # 'topograph' => ['--from', '--node node1', '--to', '--node node1', '--skip-run', '--output', 'graphviz:graph.gv'],
36
+ }.each do |executable, default_options|
37
+
38
+ context "checking common options for #{executable}" do
39
+
40
+ it 'displays its help' do
41
+ with_test_platform_for_common_options do
42
+ exit_code, stdout, stderr = run executable, '--help'
43
+ expect(exit_code).to eq 0
44
+ expect(stdout).to match /Usage: .*#{executable}/
45
+ expect(stderr).to eq ''
46
+ end
47
+ end
48
+
49
+ it 'accepts the debug mode switch' do
50
+ with_test_platform_for_common_options do
51
+ exit_code, stdout, stderr = run executable, *(['--debug'] + default_options)
52
+ expect(exit_code).to eq 0
53
+ expect(stderr).to eq ''
54
+ end
55
+ end
56
+
57
+ it 'fails in case of an unknown option' do
58
+ with_test_platform_for_common_options do
59
+ expect { run executable, '--invalid_option' }.to raise_error(RuntimeError, 'invalid option: --invalid_option')
60
+ end
61
+ end
62
+
63
+ end
64
+
65
+ end
66
+
67
+ end
@@ -0,0 +1,251 @@
1
+ describe 'executables\' Deployer options' do
2
+
3
+ # Setup a platform for tests
4
+ #
5
+ # Parameters::
6
+ # * Proc: Code called when the platform is setup
7
+ # * Parameters::
8
+ # * *repository* (String): Platform's repository
9
+ def with_test_platform_for_deployer_options
10
+ with_test_platform({ nodes: { 'node' => {} } }) do |repository|
11
+ yield repository
12
+ end
13
+ end
14
+
15
+ # Mock calls being made to a Thycotic SOAP API using Savon
16
+ #
17
+ # Parameters::
18
+ # * *url* (String): Mocked URL
19
+ # * *secret_id* (String): The mocked secret ID
20
+ # * *mocked_secrets_file* (String or nil): The mocked secrets file stored in Thycotic, or nil to mock a missing secret
21
+ # * *user* (String or nil): The user to be expected, or nil if it should be read from netrc [default: nil]
22
+ # * *password* (String or nil): The password to be expected, or nil if it should be read from netrc [default: nil]
23
+ def mock_thycotic_file_download_on(url, secret_id, mocked_secrets_file, user: nil, password: nil)
24
+ if user.nil?
25
+ user = 'thycotic_user_from_netrc'
26
+ password = 'thycotic_password_from_netrc'
27
+ expect(HybridPlatformsConductor::Credentials).to receive(:with_credentials_for) do |id, _logger, _logger_stderr, url: nil, &client_code|
28
+ expect(id).to eq :thycotic
29
+ expect(url).to eq url
30
+ client_code.call user, password
31
+ end
32
+ end
33
+ # Mock the Savon calls
34
+ mocked_savon_client = double 'Mocked Savon client'
35
+ expect(Savon).to receive(:client) do |params|
36
+ expect(params[:wsdl]).to eq "#{url}/webservices/SSWebservice.asmx?wsdl"
37
+ expect(params[:ssl_verify_mode]).to eq :none
38
+ mocked_savon_client
39
+ end
40
+ expect(mocked_savon_client).to receive(:call).with(
41
+ :authenticate,
42
+ message: {
43
+ username: user,
44
+ password: password,
45
+ domain: 'thycotic_auth_domain'
46
+ }
47
+ ) do
48
+ { authenticate_response: { authenticate_result: { token: 'soap_token' } } }
49
+ end
50
+ expect(mocked_savon_client).to receive(:call).with(
51
+ :get_secret,
52
+ message: {
53
+ token: 'soap_token',
54
+ secretId: secret_id
55
+ }
56
+ ) do
57
+ {
58
+ get_secret_response: {
59
+ get_secret_result:
60
+ if mocked_secrets_file
61
+ { secret: { items: { secret_item: { id: '4242' } } } }
62
+ else
63
+ { errors: { string: 'Access Denied'}, secret_error: { error_code: 'LOAD', error_message: 'Access Denied', allows_response: false } }
64
+ end
65
+ }
66
+ }
67
+ end
68
+ if mocked_secrets_file
69
+ expect(mocked_savon_client).to receive(:call).with(
70
+ :download_file_attachment_by_item_id,
71
+ message: {
72
+ token: 'soap_token',
73
+ secretId: secret_id,
74
+ secretItemId: '4242'
75
+ }
76
+ ) do
77
+ {
78
+ download_file_attachment_by_item_id_response: {
79
+ download_file_attachment_by_item_id_result: {
80
+ file_attachment: Base64.encode64(mocked_secrets_file)
81
+ }
82
+ }
83
+ }
84
+ end
85
+ end
86
+ ENV['hpc_domain_for_thycotic'] = 'thycotic_auth_domain'
87
+ end
88
+
89
+ it 'gets secrets from a file' do
90
+ with_test_platform_for_deployer_options do |repository|
91
+ secrets_file = "#{repository}/my_secrets.json"
92
+ File.write(secrets_file, '{ "secret_name": "secret_value" }')
93
+ expect(test_deployer).to receive(:deploy_on).with(['node']) do
94
+ expect(test_deployer.secrets).to eq [{ 'secret_name' => 'secret_value' }]
95
+ {}
96
+ end
97
+ exit_code, stdout, stderr = run 'deploy', '--node', 'node', '--secrets', secrets_file
98
+ expect(exit_code).to eq 0
99
+ expect(stderr).to eq ''
100
+ end
101
+ end
102
+
103
+ it 'gets secrets from several files' do
104
+ with_test_platform_for_deployer_options do |repository|
105
+ secrets_file1 = "#{repository}/my_secrets1.json"
106
+ File.write(secrets_file1, '{ "secret1": "value1" }')
107
+ secrets_file2 = "#{repository}/my_secrets2.json"
108
+ File.write(secrets_file2, '{ "secret2": "value2" }')
109
+ expect(test_deployer).to receive(:deploy_on).with(['node']) do
110
+ expect(test_deployer.secrets).to eq [{ 'secret1' => 'value1' }, { 'secret2' => 'value2' }]
111
+ {}
112
+ end
113
+ exit_code, stdout, stderr = run 'deploy', '--node', 'node', '--secrets', secrets_file1, '--secrets', secrets_file2
114
+ expect(exit_code).to eq 0
115
+ expect(stderr).to eq ''
116
+ end
117
+ end
118
+
119
+ it 'fails to get secrets from a missing file' do
120
+ with_test_platform_for_deployer_options do
121
+ expect do
122
+ run 'deploy', '--node', 'node', '--secrets', 'unknown_file.json'
123
+ end.to raise_error 'Missing secret file: unknown_file.json'
124
+ end
125
+ end
126
+
127
+ it 'gets secrets from a Thycotic Secret Server' do
128
+ with_test_platform_for_deployer_options do
129
+ expect(test_deployer).to receive(:deploy_on).with(['node']) do
130
+ expect(test_deployer.secrets).to eq [{ 'secret_name' => 'secret_value' }]
131
+ {}
132
+ end
133
+ mock_thycotic_file_download_on('https://my_thycotic.domain.com/SecretServer', '1107', '{ "secret_name": "secret_value" }')
134
+ exit_code, stdout, stderr = run 'deploy', '--node', 'node', '--secrets', 'https://my_thycotic.domain.com/SecretServer:1107'
135
+ expect(exit_code).to eq 0
136
+ expect(stderr).to eq ''
137
+ end
138
+ end
139
+
140
+ it 'gets secrets from a Thycotic Secret Server using env variables' do
141
+ with_test_platform_for_deployer_options do
142
+ expect(test_deployer).to receive(:deploy_on).with(['node']) do
143
+ expect(test_deployer.secrets).to eq [{ 'secret_name' => 'secret_value' }]
144
+ {}
145
+ end
146
+ mock_thycotic_file_download_on(
147
+ 'https://my_thycotic.domain.com/SecretServer',
148
+ '1107',
149
+ '{ "secret_name": "secret_value" }',
150
+ user: 'thycotic_user_from_env',
151
+ password: 'thycotic_password_from_env'
152
+ )
153
+ ENV['hpc_user_for_thycotic'] = 'thycotic_user_from_env'
154
+ ENV['hpc_password_for_thycotic'] = 'thycotic_password_from_env'
155
+ exit_code, stdout, stderr = run 'deploy', '--node', 'node', '--secrets', 'https://my_thycotic.domain.com/SecretServer:1107'
156
+ expect(exit_code).to eq 0
157
+ expect(stderr).to eq ''
158
+ end
159
+ end
160
+
161
+ it 'gets secrets from several Thycotic Secret Servers and files' do
162
+ with_test_platform_for_deployer_options do |repository|
163
+ secrets_file1 = "#{repository}/my_secrets1.json"
164
+ File.write(secrets_file1, '{ "secret1": "value1" }')
165
+ secrets_file3 = "#{repository}/my_secrets3.json"
166
+ File.write(secrets_file3, '{ "secret3": "value3" }')
167
+ expect(test_deployer).to receive(:deploy_on).with(['node']) do
168
+ expect(test_deployer.secrets).to eq [
169
+ { 'secret1' => 'value1' },
170
+ { 'secret2' => 'value2' },
171
+ { 'secret3' => 'value3' },
172
+ { 'secret4' => 'value4' }
173
+ ]
174
+ {}
175
+ end
176
+ mock_thycotic_file_download_on('https://my_thycotic2.domain.com/SecretServer', '110702', '{ "secret2": "value2" }')
177
+ mock_thycotic_file_download_on('https://my_thycotic4.domain.com/SecretServer', '110704', '{ "secret4": "value4" }')
178
+ exit_code, stdout, stderr = run 'deploy', '--node', 'node',
179
+ '--secrets', secrets_file1,
180
+ '--secrets', 'https://my_thycotic2.domain.com/SecretServer:110702',
181
+ '--secrets', secrets_file3,
182
+ '--secrets', 'https://my_thycotic4.domain.com/SecretServer:110704'
183
+ expect(exit_code).to eq 0
184
+ expect(stderr).to eq ''
185
+ end
186
+ end
187
+
188
+ it 'fails to get secrets from a missing Thycotic Secret Server' do
189
+ with_test_platform_for_deployer_options do
190
+ mock_thycotic_file_download_on('https://my_thycotic.domain.com/SecretServer', '1107', nil)
191
+ expect do
192
+ run 'deploy', '--node', 'node', '--secrets', 'https://my_thycotic.domain.com/SecretServer:1107'
193
+ end.to raise_error 'Unable to fetch secret file ID https://my_thycotic.domain.com/SecretServer:1107'
194
+ end
195
+ end
196
+
197
+ it 'uses parallel mode' do
198
+ with_test_platform_for_deployer_options do |repository|
199
+ expect(test_deployer).to receive(:deploy_on).with(['node']) do
200
+ expect(test_deployer.concurrent_execution).to eq true
201
+ {}
202
+ end
203
+ exit_code, stdout, stderr = run 'deploy', '--node', 'node', '--parallel'
204
+ expect(exit_code).to eq 0
205
+ expect(stderr).to eq ''
206
+ end
207
+ end
208
+
209
+ it 'uses why-run' do
210
+ with_test_platform_for_deployer_options do |repository|
211
+ expect(test_deployer).to receive(:deploy_on).with(['node']) do
212
+ expect(test_deployer.use_why_run).to eq true
213
+ {}
214
+ end
215
+ exit_code, stdout, stderr = run 'deploy', '--node', 'node', '--why-run'
216
+ expect(exit_code).to eq 0
217
+ expect(stderr).to eq ''
218
+ end
219
+ end
220
+
221
+ it 'uses timeout with why-run' do
222
+ with_test_platform_for_deployer_options do |repository|
223
+ expect(test_deployer).to receive(:deploy_on).with(['node']) do
224
+ expect(test_deployer.timeout).to eq 5
225
+ {}
226
+ end
227
+ exit_code, stdout, stderr = run 'deploy', '--node', 'node', '--why-run', '--timeout', '5'
228
+ expect(exit_code).to eq 0
229
+ expect(stderr).to eq ''
230
+ end
231
+ end
232
+
233
+ it 'fails to use timeout without why-run' do
234
+ with_test_platform_for_deployer_options do |repository|
235
+ expect { run 'deploy', '--node', 'node', '--timeout', '5' }.to raise_error(RuntimeError, 'Can\'t have a timeout unless why-run mode. Please don\'t use --timeout without --why-run.')
236
+ end
237
+ end
238
+
239
+ it 'uses retries on errors' do
240
+ with_test_platform_for_deployer_options do |repository|
241
+ expect(test_deployer).to receive(:deploy_on).with(['node']) do
242
+ expect(test_deployer.nbr_retries_on_error).to eq 42
243
+ {}
244
+ end
245
+ exit_code, stdout, stderr = run 'deploy', '--node', 'node', '--retries-on-error', '42'
246
+ expect(exit_code).to eq 0
247
+ expect(stderr).to eq ''
248
+ end
249
+ end
250
+
251
+ end