hybrid_platforms_conductor 32.3.6

Sign up to get free protection for your applications and to get access to all the features.
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,111 @@
1
+ describe 'executables\' Nodes Handler 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_nodes_handler_options
10
+ with_test_platforms(
11
+ {
12
+ 'platform_1' => {
13
+ nodes: {
14
+ 'node11' => {
15
+ meta: { host_ip: '192.168.42.11' },
16
+ services: ['service1']
17
+ },
18
+ 'node12' => {
19
+ meta: {
20
+ host_ip: '192.168.42.12',
21
+ description: 'Node12 description'
22
+ },
23
+ services: ['service1']
24
+ },
25
+ 'node13' => {
26
+ meta: { host_ip: '192.168.42.13' },
27
+ services: ['service2']
28
+ },
29
+ 'node14' => {
30
+ meta: { private_ips: ['192.168.42.14', '172.16.42.14'] }
31
+ },
32
+ 'node15' => {
33
+ meta: {
34
+ hostname: 'my_host15.my_domain'
35
+ }
36
+ },
37
+ 'node16' => {
38
+ meta: {
39
+ host_ip: '192.168.42.16',
40
+ hostname: 'my_host16.my_domain'
41
+ }
42
+ }
43
+ },
44
+ nodes_lists: { 'my_list' => ['node11', 'node13'] }
45
+ },
46
+ 'platform_2' => {
47
+ nodes: {
48
+ 'node21' => {
49
+ meta: { host_ip: '192.168.42.21' },
50
+ services: ['service2', 'service3']
51
+ },
52
+ 'node22' => {
53
+ meta: { host_ip: '192.168.42.22' },
54
+ services: ['service1']
55
+ }
56
+ }
57
+ }
58
+ }
59
+ ) do |repository|
60
+ yield repository
61
+ end
62
+ end
63
+
64
+ it 'displays info about nodes' do
65
+ with_test_platform_for_nodes_handler_options do
66
+ with_cmd_runner_mocked [
67
+ ['getent hosts my_host15.my_domain', proc { [0, '192.168.42.15 my_host16.my_domain', ''] }],
68
+ ['getent hosts my_host16.my_domain', proc { [0, '192.168.42.16 my_host16.my_domain', ''] }]
69
+ ] do
70
+ exit_code, stdout, stderr = run 'run', '--show-nodes'
71
+ expect(exit_code).to eq 0
72
+ expect(stdout).to eq <<~EOS
73
+ * Known platforms:
74
+ platform_1 - Type: test - Location: /tmp/hpc_test/platform_1
75
+ platform_2 - Type: test - Location: /tmp/hpc_test/platform_2
76
+
77
+ * Known nodes lists:
78
+ my_list
79
+
80
+ * Known services:
81
+ service1
82
+ service2
83
+ service3
84
+
85
+ * Known nodes:
86
+ node11
87
+ node12
88
+ node13
89
+ node14
90
+ node15
91
+ node16
92
+ node21
93
+ node22
94
+
95
+ * Known nodes with description:
96
+ node11 (192.168.42.11) - service1 -
97
+ node12 (192.168.42.12) - service1 - Node12 description
98
+ node13 (192.168.42.13) - service2 -
99
+ node14 (192.168.42.14) - -
100
+ node15 (my_host15.my_domain) - -
101
+ node16 (my_host16.my_domain) - -
102
+ node21 (192.168.42.21) - service2, service3 -
103
+ node22 (192.168.42.22) - service1 -
104
+
105
+ EOS
106
+ expect(stderr).to eq ''
107
+ end
108
+ end
109
+ end
110
+
111
+ end
@@ -0,0 +1,71 @@
1
+ describe 'executables\' nodes selection 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_nodes_selector_options
10
+ with_test_platforms(
11
+ {
12
+ 'platform_1' => {
13
+ nodes: {
14
+ 'node11' => { services: ['service1'] },
15
+ 'node12' => { services: ['service3', 'service1'] },
16
+ 'node13' => { services: ['service2'] }
17
+ },
18
+ nodes_lists: { 'my_list' => ['node11', 'node13'] }
19
+ },
20
+ 'platform_2' => {
21
+ nodes: {
22
+ 'node21' => { services: ['service2'] },
23
+ 'node22' => { services: ['service1'] }
24
+ }
25
+ }
26
+ }
27
+ ) do |repository|
28
+ yield repository
29
+ end
30
+ end
31
+
32
+ # Enumerate all command-line selectors to test, and the corresponding nodes list
33
+ {
34
+ ['--all-nodes'] => [{ all: true }],
35
+ ['--node', 'node11'] => ['node11'],
36
+ ['--node', '/node1.+/'] => [/node1.+/],
37
+ ['--nodes-list', 'my_list'] => [{ list: 'my_list' }],
38
+ ['--nodes-platform', 'platform_2'] => [{ platform: 'platform_2' }],
39
+ ['--nodes-service', 'service1'] => [{ service: 'service1' }],
40
+ ['--node', 'node11', '--node', 'node12'] => %w[node11 node12],
41
+ ['--nodes-service', 'service1', '--nodes-platform', 'platform_2'] => [{ service: 'service1' }, { platform: 'platform_2' }],
42
+ ['--nodes-git-impact', 'platform_2'] => [{ git_diff: { platform: 'platform_2' } }],
43
+ ['--nodes-git-impact', 'platform_2:from_commit'] => [
44
+ { git_diff: { platform: 'platform_2', from_commit: 'from_commit' } }
45
+ ],
46
+ ['--nodes-git-impact', 'platform_2:from_commit:to_commit'] => [
47
+ { git_diff: { platform: 'platform_2', from_commit: 'from_commit', to_commit: 'to_commit' } }
48
+ ],
49
+ ['--nodes-git-impact', 'platform_2:from_commit:to_commit:min'] => [
50
+ { git_diff: { platform: 'platform_2', from_commit: 'from_commit', to_commit: 'to_commit', smallest_set: true } }
51
+ ],
52
+ ['--nodes-git-impact', 'platform_2::to_commit:min'] => [
53
+ { git_diff: { platform: 'platform_2', to_commit: 'to_commit', smallest_set: true } }
54
+ ],
55
+ ['--nodes-git-impact', 'platform_2:::min'] => [
56
+ { git_diff: { platform: 'platform_2', smallest_set: true } }
57
+ ]
58
+ }.each do |args, expected_nodes|
59
+
60
+ it "resolves '#{args.join(' ')}' into #{expected_nodes.join(', ')}" do
61
+ with_test_platform_for_nodes_selector_options do
62
+ expect(test_deployer).to receive(:deploy_on).with(expected_nodes) { {} }
63
+ exit_code, stdout, stderr = run 'deploy', *args
64
+ expect(exit_code).to eq 0
65
+ expect(stderr).to eq ''
66
+ end
67
+ end
68
+
69
+ end
70
+
71
+ end
@@ -0,0 +1,54 @@
1
+ describe 'executables\' Reports Handler 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_reports_handler_options
10
+ with_test_platform do |repository|
11
+ register_report_plugins(test_reports_handler, report_format: HybridPlatformsConductorTest::ReportPlugin)
12
+ yield repository
13
+ end
14
+ end
15
+
16
+ it 'uses a given format' do
17
+ with_test_platform_for_reports_handler_options do
18
+ expect(test_reports_handler).to receive(:produce_report_for).with([{ all: true }]) do
19
+ expect(test_reports_handler.format).to eq :report_format
20
+ {}
21
+ end
22
+ exit_code, stdout, stderr = run 'report', '--format', 'report_format'
23
+ expect(exit_code).to eq 0
24
+ expect(stdout).to eq ''
25
+ expect(stderr).to eq ''
26
+ end
27
+ end
28
+
29
+ it 'fails to use an unknown format' do
30
+ with_test_platform_for_reports_handler_options do
31
+ expect { run 'report', '--format', 'unknown_format' }.to raise_error(RuntimeError, 'Unknown format: unknown_format')
32
+ end
33
+ end
34
+
35
+ it 'uses a given locale' do
36
+ with_test_platform_for_reports_handler_options do
37
+ expect(test_reports_handler).to receive(:produce_report_for).with([{ all: true }]) do
38
+ expect(test_reports_handler.locale).to eq :fr
39
+ {}
40
+ end
41
+ exit_code, stdout, stderr = run 'report', '--format', 'report_format', '--locale', 'fr'
42
+ expect(exit_code).to eq 0
43
+ expect(stdout).to eq ''
44
+ expect(stderr).to eq ''
45
+ end
46
+ end
47
+
48
+ it 'fails to use an unknown locale' do
49
+ with_test_platform_for_reports_handler_options do
50
+ expect { run 'report', '--format', 'report_format', '--locale', 'unknown_locale' }.to raise_error(RuntimeError, 'Unknown locale for format report_format: unknown_locale')
51
+ end
52
+ end
53
+
54
+ end
@@ -0,0 +1,139 @@
1
+ describe 'executables\' Tests Runner options' do
2
+
3
+ it 'specifies a given test to execute' do
4
+ with_test_platform do
5
+ expect(test_tests_runner).to receive(:run_tests).with([]) do
6
+ expect(test_tests_runner.tests.sort).to eq %i[my_test]
7
+ 0
8
+ end
9
+ exit_code, stdout, stderr = run 'test', '--test', 'my_test'
10
+ expect(exit_code).to eq 0
11
+ expect(stdout).to eq ''
12
+ expect(stderr).to eq ''
13
+ end
14
+ end
15
+
16
+ it 'specifies several tests to execute' do
17
+ with_test_platform do
18
+ expect(test_tests_runner).to receive(:run_tests).with([]) do
19
+ expect(test_tests_runner.tests.sort).to eq %i[my_test1 my_test2]
20
+ 0
21
+ end
22
+ exit_code, stdout, stderr = run 'test', '--test', 'my_test1', '--test', 'my_test2'
23
+ expect(exit_code).to eq 0
24
+ expect(stdout).to eq ''
25
+ expect(stderr).to eq ''
26
+ end
27
+ end
28
+
29
+ it 'specifies a tests file to execute' do
30
+ with_test_platform do |repository|
31
+ tests_file = "#{repository}/my_tests.txt"
32
+ File.write(tests_file, "my_test1\n# Comment to ignore\nmy_test2\n")
33
+ expect(test_tests_runner).to receive(:run_tests).with([]) do
34
+ expect(test_tests_runner.tests.sort).to eq %i[my_test1 my_test2]
35
+ 0
36
+ end
37
+ exit_code, stdout, stderr = run 'test', '--tests-list', tests_file
38
+ expect(exit_code).to eq 0
39
+ expect(stdout).to eq ''
40
+ expect(stderr).to eq ''
41
+ end
42
+ end
43
+
44
+ it 'specifies a mix of tests files and test names to execute' do
45
+ with_test_platform do |repository|
46
+ tests_file1 = "#{repository}/my_tests1.txt"
47
+ File.write(tests_file1, "my_test1\n# Comment to ignore\nmy_test2\n")
48
+ tests_file2 = "#{repository}/my_tests2.txt"
49
+ File.write(tests_file2, "my_test4\n# Comment to ignore\nmy_test5\n")
50
+ expect(test_tests_runner).to receive(:run_tests).with([]) do
51
+ expect(test_tests_runner.tests.sort).to eq %i[my_test1 my_test2 my_test3 my_test4 my_test5 my_test6]
52
+ 0
53
+ end
54
+ exit_code, stdout, stderr = run 'test', '--tests-list', tests_file1, '--test', 'my_test3', '--tests-list', tests_file2, '--test', 'my_test6'
55
+ expect(exit_code).to eq 0
56
+ expect(stdout).to eq ''
57
+ expect(stderr).to eq ''
58
+ end
59
+ end
60
+
61
+ it 'uses current run_logs instead of executing new check-nodes' do
62
+ with_test_platform do
63
+ expect(test_tests_runner).to receive(:run_tests).with([]) do
64
+ expect(test_tests_runner.skip_run).to eq true
65
+ 0
66
+ end
67
+ exit_code, stdout, stderr = run 'test', '--test', 'my_test', '--skip-run'
68
+ expect(exit_code).to eq 0
69
+ expect(stdout).to eq ''
70
+ expect(stderr).to eq ''
71
+ end
72
+ end
73
+
74
+ it 'reports into a given format' do
75
+ with_test_platform do
76
+ expect(test_tests_runner).to receive(:run_tests).with([]) do
77
+ expect(test_tests_runner.reports).to eq %i[my_report]
78
+ 0
79
+ end
80
+ exit_code, stdout, stderr = run 'test', '--report', 'my_report'
81
+ expect(exit_code).to eq 0
82
+ expect(stdout).to eq ''
83
+ expect(stderr).to eq ''
84
+ end
85
+ end
86
+
87
+ it 'reports into several formats' do
88
+ with_test_platform do
89
+ expect(test_tests_runner).to receive(:run_tests).with([]) do
90
+ expect(test_tests_runner.reports.sort).to eq %i[my_report1 my_report2].sort
91
+ 0
92
+ end
93
+ exit_code, stdout, stderr = run 'test', '--report', 'my_report1', '--report', 'my_report2'
94
+ expect(exit_code).to eq 0
95
+ expect(stdout).to eq ''
96
+ expect(stderr).to eq ''
97
+ end
98
+ end
99
+
100
+ it 'specifies the number of max threads for connections to nodes' do
101
+ with_test_platform do
102
+ expect(test_tests_runner).to receive(:run_tests).with([]) do
103
+ expect(test_tests_runner.max_threads_connection_on_nodes).to eq 43
104
+ 0
105
+ end
106
+ exit_code, stdout, stderr = run 'test', '--max-threads-connections', '43'
107
+ expect(exit_code).to eq 0
108
+ expect(stdout).to eq ''
109
+ expect(stderr).to eq ''
110
+ end
111
+ end
112
+
113
+ it 'specifies the number of max threads for node tests' do
114
+ with_test_platform do
115
+ expect(test_tests_runner).to receive(:run_tests).with([]) do
116
+ expect(test_tests_runner.max_threads_nodes).to eq 43
117
+ 0
118
+ end
119
+ exit_code, stdout, stderr = run 'test', '--max-threads-nodes', '43'
120
+ expect(exit_code).to eq 0
121
+ expect(stdout).to eq ''
122
+ expect(stderr).to eq ''
123
+ end
124
+ end
125
+
126
+ it 'specifies the number of max threads for platform tests' do
127
+ with_test_platform do
128
+ expect(test_tests_runner).to receive(:run_tests).with([]) do
129
+ expect(test_tests_runner.max_threads_platforms).to eq 43
130
+ 0
131
+ end
132
+ exit_code, stdout, stderr = run 'test', '--max-threads-platforms', '43'
133
+ expect(exit_code).to eq 0
134
+ expect(stdout).to eq ''
135
+ expect(stderr).to eq ''
136
+ end
137
+ end
138
+
139
+ end
@@ -0,0 +1,60 @@
1
+ describe 'report executable' do
2
+
3
+ it 'reports by default on all nodes' do
4
+ with_test_platform(nodes: { 'node1' => { services: ['node1_service'] }, 'node2' => { services: ['node2_service'] } }) do
5
+ exit_code, stdout, stderr = run 'report'
6
+ expect(exit_code).to eq 0
7
+ expect(stdout).to eq <<~EOS
8
+ +-------+----------+-----------+----+-----------+----+-------------+---------------+
9
+ | Node | Platform | Host name | IP | Physical? | OS | Description | Services |
10
+ +-------+----------+-----------+----+-----------+----+-------------+---------------+
11
+ | node1 | platform | | | No | | | node1_service |
12
+ | node2 | platform | | | No | | | node2_service |
13
+ +-------+----------+-----------+----+-----------+----+-------------+---------------+
14
+ EOS
15
+ expect(stderr).to eq ''
16
+ end
17
+ end
18
+
19
+ it 'reports on given nodes only' do
20
+ with_test_platform(nodes: { 'node1' => { services: ['node1_service'] }, 'node2' => { services: ['node2_service'] } }) do
21
+ exit_code, stdout, stderr = run 'report', '--node', 'node2'
22
+ expect(exit_code).to eq 0
23
+ expect(stdout).to eq <<~EOS
24
+ +-------+----------+-----------+----+-----------+----+-------------+---------------+
25
+ | Node | Platform | Host name | IP | Physical? | OS | Description | Services |
26
+ +-------+----------+-----------+----+-----------+----+-------------+---------------+
27
+ | node2 | platform | | | No | | | node2_service |
28
+ +-------+----------+-----------+----+-----------+----+-------------+---------------+
29
+ EOS
30
+ expect(stderr).to eq ''
31
+ end
32
+ end
33
+
34
+ it 'reports info from metadata' do
35
+ with_test_platform(nodes: { 'node' => {
36
+ meta: {
37
+ hostname: 'node.domain.com',
38
+ image: 'debian_10',
39
+ description: 'A great server'
40
+ },
41
+ services: ['node_service1', 'node_service2']
42
+ } }) do
43
+ with_cmd_runner_mocked [
44
+ ['getent hosts node.domain.com', proc { [0, '192.168.0.1 node.domain.com', ''] }]
45
+ ] do
46
+ exit_code, stdout, stderr = run 'report', '--node', 'node'
47
+ expect(exit_code).to eq 0
48
+ expect(stdout).to eq <<~EOS
49
+ +------+----------+-----------------+-------------+-----------+-----------+----------------+------------------------------+
50
+ | Node | Platform | Host name | IP | Physical? | OS | Description | Services |
51
+ +------+----------+-----------------+-------------+-----------+-----------+----------------+------------------------------+
52
+ | node | platform | node.domain.com | 192.168.0.1 | No | debian_10 | A great server | node_service1, node_service2 |
53
+ +------+----------+-----------------+-------------+-----------+-----------+----------------+------------------------------+
54
+ EOS
55
+ expect(stderr).to eq ''
56
+ end
57
+ end
58
+ end
59
+
60
+ end
@@ -0,0 +1,173 @@
1
+ describe 'run executable' do
2
+
3
+ # Setup a platform for run 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_run
10
+ with_test_platform({ nodes: { 'node1' => {}, 'node2' => {} } }) do |repository|
11
+ yield repository
12
+ end
13
+ end
14
+
15
+ it 'executes a single command on a node' do
16
+ with_test_platform_for_run do
17
+ expect_actions_executor_runs([proc do |actions, timeout: nil, concurrent: false, log_to_dir: 'run_logs', log_to_stdout: true|
18
+ expect(actions).to eq(['node1'] => [{ remote_bash: ['echo Hello'] }])
19
+ test_actions_executor.stdout_device << "Hello\n"
20
+ { 'node1' => [0, "Hello\n", ''] }
21
+ end])
22
+ exit_code, stdout, stderr = run 'run', '--node', 'node1', '--command', 'echo Hello'
23
+ expect(exit_code).to eq 0
24
+ expect(stdout).to match /Hello/
25
+ expect(stderr).to eq ''
26
+ end
27
+ end
28
+
29
+ it 'executes a command file on a node' do
30
+ with_test_platform_for_run do |repository|
31
+ commands_file = "#{repository}/commands.txt"
32
+ File.write(commands_file, "echo Hello1\necho Hello2\n")
33
+ expect_actions_executor_runs([proc do |actions, timeout: nil, concurrent: false, log_to_dir: 'run_logs', log_to_stdout: true|
34
+ expect(actions).to eq(['node1'] => [{ remote_bash: [{ file: commands_file }] }])
35
+ test_actions_executor.stdout_device << "Hello1\nHello2\n"
36
+ { 'node1' => [0, "Hello1\nHello2\n", ''] }
37
+ end])
38
+ exit_code, stdout, stderr = run 'run', '--node', 'node1', '--command-file', commands_file
39
+ expect(exit_code).to eq 0
40
+ expect(stdout).to match /Hello1/
41
+ expect(stdout).to match /Hello2/
42
+ expect(stderr).to eq ''
43
+ end
44
+ end
45
+
46
+ it 'executes a single command on a node with timeout' do
47
+ with_test_platform_for_run do
48
+ expect_actions_executor_runs([proc do |actions, timeout: nil, concurrent: false, log_to_dir: 'run_logs', log_to_stdout: true|
49
+ expect(timeout).to eq 5
50
+ expect(actions).to eq(['node1'] => [{ remote_bash: ['echo Hello'] }])
51
+ test_actions_executor.stdout_device << "Hello\n"
52
+ { 'node1' => [0, "Hello\n", ''] }
53
+ end])
54
+ exit_code, stdout, stderr = run 'run', '--node', 'node1', '--command', 'echo Hello', '--timeout', '5'
55
+ expect(exit_code).to eq 0
56
+ expect(stdout).to match /Hello/
57
+ expect(stderr).to eq ''
58
+ end
59
+ end
60
+
61
+ it 'executes a single command on a node and captures stderr correctly' do
62
+ with_test_platform_for_run do
63
+ expect_actions_executor_runs([proc do |actions, timeout: nil, concurrent: false, log_to_dir: 'run_logs', log_to_stdout: true|
64
+ expect(actions).to eq(['node1'] => [{ remote_bash: ['echo Hello 2>&1'] }])
65
+ test_actions_executor.stderr_device << "Hello\n"
66
+ { 'node1' => [0, '', "Hello\n"] }
67
+ end])
68
+ exit_code, stdout, stderr = run 'run', '--node', 'node1', '--command', 'echo Hello 2>&1'
69
+ expect(exit_code).to eq 0
70
+ expect(stdout).to eq ''
71
+ expect(stderr).to match /Hello/
72
+ end
73
+ end
74
+
75
+ it 'executes a single command on several nodes' do
76
+ with_test_platform_for_run do
77
+ expect_actions_executor_runs([proc do |actions, timeout: nil, concurrent: false, log_to_dir: 'run_logs', log_to_stdout: true|
78
+ expect(concurrent).to eq false
79
+ expect(actions).to eq(%w[node1 node2] => [{ remote_bash: ['echo Hello'] }])
80
+ test_actions_executor.stdout_device << "Hello\nHello\n"
81
+ { 'node1' => [0, "Hello\nHello\n", ''] }
82
+ end])
83
+ exit_code, stdout, stderr = run 'run', '--node', 'node1', '--node', 'node2', '--command', 'echo Hello'
84
+ expect(exit_code).to eq 0
85
+ expect(stdout).to match /Hello/
86
+ expect(stderr).to eq ''
87
+ end
88
+ end
89
+
90
+ it 'executes several commands' do
91
+ with_test_platform_for_run do
92
+ expect_actions_executor_runs([proc do |actions, timeout: nil, concurrent: false, log_to_dir: 'run_logs', log_to_stdout: true|
93
+ expect(actions).to eq(['node1'] => [{ remote_bash: ['echo Hello1', 'echo Hello2'] }])
94
+ test_actions_executor.stdout_device << "Hello1\nHello2\n"
95
+ { 'node1' => [0, "Hello1\nHello2\n", ''] }
96
+ end])
97
+ exit_code, stdout, stderr = run 'run', '--node', 'node1', '--command', 'echo Hello1', '--command', 'echo Hello2'
98
+ expect(exit_code).to eq 0
99
+ expect(stdout).to match /Hello1/
100
+ expect(stdout).to match /Hello2/
101
+ expect(stderr).to eq ''
102
+ end
103
+ end
104
+
105
+ it 'executes several commands and commands files ordered by arguments' do
106
+ with_test_platform_for_run do |repository|
107
+ commands_file_1 = "#{repository}/commands1.txt"
108
+ File.write(commands_file_1, "echo Hello1\necho Hello2\n")
109
+ commands_file_2 = "#{repository}/commands2.txt"
110
+ File.write(commands_file_1, "echo Hello4\necho Hello5\n")
111
+ expect_actions_executor_runs([proc do |actions, timeout: nil, concurrent: false, log_to_dir: 'run_logs', log_to_stdout: true|
112
+ expect(actions).to eq(['node1'] => [{ remote_bash: [
113
+ { file: commands_file_1 },
114
+ 'echo Hello3',
115
+ { file: commands_file_2 },
116
+ 'echo Hello6'
117
+ ] }])
118
+ test_actions_executor.stdout_device << "Hello1\nHello2\nHello3\nHello4\nHello5\nHello6\n"
119
+ { 'node1' => [0, "Hello1\nHello2\nHello3\nHello4\nHello5\nHello6\n", ''] }
120
+ end])
121
+ exit_code, stdout, stderr = run 'run', '--node', 'node1', '--commands-file', commands_file_1, '--command', 'echo Hello3', '--commands-file', commands_file_2, '--command', 'echo Hello6'
122
+ expect(exit_code).to eq 0
123
+ expect(stdout).to match /Hello1/
124
+ expect(stdout).to match /Hello2/
125
+ expect(stdout).to match /Hello3/
126
+ expect(stdout).to match /Hello4/
127
+ expect(stdout).to match /Hello5/
128
+ expect(stdout).to match /Hello6/
129
+ expect(stderr).to eq ''
130
+ end
131
+ end
132
+
133
+ it 'executes in parallel' do
134
+ with_test_platform_for_run do
135
+ expect_actions_executor_runs([proc do |actions, timeout: nil, concurrent: false, log_to_dir: 'run_logs', log_to_stdout: true|
136
+ expect(concurrent).to eq true
137
+ expect(actions).to eq(%w[node1 node2] => [{ remote_bash: ['echo Hello'] }])
138
+ test_actions_executor.stdout_device << "Hello\nHello\n"
139
+ { 'node1' => [0, "Hello\nHello\n", ''] }
140
+ end])
141
+ exit_code, stdout, stderr = run 'run', '--node', 'node1', '--node', 'node2', '--command', 'echo Hello', '--parallel'
142
+ expect(exit_code).to eq 0
143
+ expect(stdout).to match /Hello/
144
+ expect(stderr).to eq ''
145
+ end
146
+ end
147
+
148
+ it 'executes an interactive session on a node' do
149
+ with_test_platform_for_run do
150
+ expect_actions_executor_runs([proc do |actions, timeout: nil, concurrent: false, log_to_dir: 'run_logs', log_to_stdout: true|
151
+ expect(actions).to eq(['node1'] => [{ interactive: true }])
152
+ { 'node1' => [0, '', ''] }
153
+ end])
154
+ exit_code, stdout, stderr = run 'run', '--node', 'node1', '--interactive'
155
+ expect(exit_code).to eq 0
156
+ expect(stdout).to eq ''
157
+ expect(stderr).to eq ''
158
+ end
159
+ end
160
+
161
+ it 'fails when neither commands nor interactive session are present' do
162
+ with_test_platform_for_run do
163
+ expect { run 'run', '--node', 'node1' }.to raise_error(RuntimeError, '--interactive or --command options have to be present')
164
+ end
165
+ end
166
+
167
+ it 'fails when no node is specified' do
168
+ with_test_platform_for_run do
169
+ expect { run 'run', '--command', 'echo Hello' }.to raise_error(RuntimeError, 'No node selected. Please use --node option to set at least one.')
170
+ end
171
+ end
172
+
173
+ end