hybrid_platforms_conductor 32.18.0 → 33.0.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (255) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +36 -0
  3. data/README.md +3 -3
  4. data/bin/check-node +0 -1
  5. data/bin/deploy +0 -1
  6. data/bin/get_impacted_nodes +0 -1
  7. data/bin/last_deploys +8 -7
  8. data/bin/nodes_to_deploy +2 -2
  9. data/bin/setup +6 -6
  10. data/bin/topograph +1 -1
  11. data/docs/config_dsl.md +23 -1
  12. data/docs/executables.md +6 -7
  13. data/docs/executables/check-node.md +3 -3
  14. data/docs/executables/deploy.md +3 -3
  15. data/docs/executables/dump_nodes_json.md +3 -3
  16. data/docs/executables/test.md +3 -3
  17. data/docs/executables/topograph.md +3 -3
  18. data/docs/plugins.md +21 -0
  19. data/docs/plugins/secrets_reader/cli.md +31 -0
  20. data/docs/plugins/secrets_reader/thycotic.md +46 -0
  21. data/lib/hybrid_platforms_conductor/action.rb +4 -4
  22. data/lib/hybrid_platforms_conductor/actions_executor.rb +37 -42
  23. data/lib/hybrid_platforms_conductor/bitbucket.rb +5 -4
  24. data/lib/hybrid_platforms_conductor/cmd_runner.rb +26 -23
  25. data/lib/hybrid_platforms_conductor/cmdb.rb +2 -2
  26. data/lib/hybrid_platforms_conductor/common_config_dsl/bitbucket.rb +2 -1
  27. data/lib/hybrid_platforms_conductor/common_config_dsl/confluence.rb +2 -1
  28. data/lib/hybrid_platforms_conductor/common_config_dsl/file_system_tests.rb +5 -4
  29. data/lib/hybrid_platforms_conductor/common_config_dsl/github.rb +4 -3
  30. data/lib/hybrid_platforms_conductor/common_config_dsl/idempotence_tests.rb +2 -2
  31. data/lib/hybrid_platforms_conductor/config.rb +8 -4
  32. data/lib/hybrid_platforms_conductor/confluence.rb +1 -1
  33. data/lib/hybrid_platforms_conductor/connector.rb +5 -2
  34. data/lib/hybrid_platforms_conductor/core_extensions/cleanroom/fix_kwargs.rb +116 -0
  35. data/lib/hybrid_platforms_conductor/core_extensions/symbol/zero.rb +24 -0
  36. data/lib/hybrid_platforms_conductor/credentials.rb +39 -36
  37. data/lib/hybrid_platforms_conductor/current_dir_monitor.rb +4 -1
  38. data/lib/hybrid_platforms_conductor/deployer.rb +185 -127
  39. data/lib/hybrid_platforms_conductor/executable.rb +20 -15
  40. data/lib/hybrid_platforms_conductor/hpc_plugins/cmdb/config.rb +10 -7
  41. data/lib/hybrid_platforms_conductor/hpc_plugins/cmdb/host_ip.rb +1 -1
  42. data/lib/hybrid_platforms_conductor/hpc_plugins/cmdb/host_keys.rb +2 -2
  43. data/lib/hybrid_platforms_conductor/hpc_plugins/cmdb/platform_handlers.rb +4 -4
  44. data/lib/hybrid_platforms_conductor/hpc_plugins/connector/local.rb +5 -1
  45. data/lib/hybrid_platforms_conductor/hpc_plugins/connector/ssh.rb +45 -49
  46. data/lib/hybrid_platforms_conductor/hpc_plugins/log/remote_fs.rb +6 -5
  47. data/lib/hybrid_platforms_conductor/hpc_plugins/platform_handler/serverless_chef.rb +77 -79
  48. data/lib/hybrid_platforms_conductor/hpc_plugins/platform_handler/serverless_chef/dsl_parser.rb +13 -0
  49. data/lib/hybrid_platforms_conductor/hpc_plugins/platform_handler/serverless_chef/recipes_tree_builder.rb +39 -38
  50. data/lib/hybrid_platforms_conductor/hpc_plugins/platform_handler/yaml_inventory.rb +5 -4
  51. data/lib/hybrid_platforms_conductor/hpc_plugins/provisioner/docker.rb +43 -45
  52. data/lib/hybrid_platforms_conductor/hpc_plugins/provisioner/podman.rb +18 -20
  53. data/lib/hybrid_platforms_conductor/hpc_plugins/provisioner/proxmox.rb +119 -118
  54. data/lib/hybrid_platforms_conductor/hpc_plugins/provisioner/proxmox/proxmox_waiter.rb +39 -43
  55. data/lib/hybrid_platforms_conductor/hpc_plugins/provisioner/proxmox/reserve_proxmox_container +9 -13
  56. data/lib/hybrid_platforms_conductor/hpc_plugins/report/confluence.rb +2 -2
  57. data/lib/hybrid_platforms_conductor/hpc_plugins/report/mediawiki.rb +28 -21
  58. data/lib/hybrid_platforms_conductor/hpc_plugins/report/stdout.rb +26 -22
  59. data/lib/hybrid_platforms_conductor/hpc_plugins/secrets_reader/cli.rb +77 -0
  60. data/lib/hybrid_platforms_conductor/hpc_plugins/secrets_reader/my_secrets_reader_plugin.rb.sample +46 -0
  61. data/lib/hybrid_platforms_conductor/hpc_plugins/secrets_reader/thycotic.rb +90 -0
  62. data/lib/hybrid_platforms_conductor/hpc_plugins/test/bitbucket_conf.rb +3 -3
  63. data/lib/hybrid_platforms_conductor/hpc_plugins/test/check_deploy_and_idempotence.rb +4 -2
  64. data/lib/hybrid_platforms_conductor/hpc_plugins/test/deploy_freshness.rb +0 -1
  65. data/lib/hybrid_platforms_conductor/hpc_plugins/test/deploy_removes_root_access.rb +21 -19
  66. data/lib/hybrid_platforms_conductor/hpc_plugins/test/divergence.rb +2 -2
  67. data/lib/hybrid_platforms_conductor/hpc_plugins/test/executables.rb +2 -2
  68. data/lib/hybrid_platforms_conductor/hpc_plugins/test/file_system.rb +19 -21
  69. data/lib/hybrid_platforms_conductor/hpc_plugins/test/file_system_hdfs.rb +19 -21
  70. data/lib/hybrid_platforms_conductor/hpc_plugins/test/github_ci.rb +2 -3
  71. data/lib/hybrid_platforms_conductor/hpc_plugins/test/idempotence.rb +2 -2
  72. data/lib/hybrid_platforms_conductor/hpc_plugins/test/ip.rb +1 -1
  73. data/lib/hybrid_platforms_conductor/hpc_plugins/test/jenkins_ci_conf.rb +21 -22
  74. data/lib/hybrid_platforms_conductor/hpc_plugins/test/jenkins_ci_masters_ok.rb +10 -12
  75. data/lib/hybrid_platforms_conductor/hpc_plugins/test/linear_strategy.rb +9 -9
  76. data/lib/hybrid_platforms_conductor/hpc_plugins/test/local_users.rb +2 -2
  77. data/lib/hybrid_platforms_conductor/hpc_plugins/test/mounts.rb +2 -2
  78. data/lib/hybrid_platforms_conductor/hpc_plugins/test/orphan_files.rb +10 -9
  79. data/lib/hybrid_platforms_conductor/hpc_plugins/test/ports.rb +2 -2
  80. data/lib/hybrid_platforms_conductor/hpc_plugins/test/private_ips.rb +5 -5
  81. data/lib/hybrid_platforms_conductor/hpc_plugins/test/public_ips.rb +5 -5
  82. data/lib/hybrid_platforms_conductor/hpc_plugins/test/spectre.rb +4 -6
  83. data/lib/hybrid_platforms_conductor/hpc_plugins/test/veids.rb +3 -3
  84. data/lib/hybrid_platforms_conductor/hpc_plugins/test/vulnerabilities.rb +25 -24
  85. data/lib/hybrid_platforms_conductor/hpc_plugins/test_report/confluence.rb +2 -2
  86. data/lib/hybrid_platforms_conductor/hpc_plugins/test_report/stdout.rb +8 -6
  87. data/lib/hybrid_platforms_conductor/io_router.rb +14 -13
  88. data/lib/hybrid_platforms_conductor/json_dumper.rb +2 -2
  89. data/lib/hybrid_platforms_conductor/log.rb +2 -2
  90. data/lib/hybrid_platforms_conductor/logger_helpers.rb +19 -16
  91. data/lib/hybrid_platforms_conductor/nodes_handler.rb +89 -71
  92. data/lib/hybrid_platforms_conductor/parallel_threads.rb +7 -11
  93. data/lib/hybrid_platforms_conductor/platform_handler.rb +7 -7
  94. data/lib/hybrid_platforms_conductor/platforms_handler.rb +5 -3
  95. data/lib/hybrid_platforms_conductor/plugin.rb +2 -2
  96. data/lib/hybrid_platforms_conductor/plugins.rb +14 -8
  97. data/lib/hybrid_platforms_conductor/provisioner.rb +4 -4
  98. data/lib/hybrid_platforms_conductor/report.rb +2 -2
  99. data/lib/hybrid_platforms_conductor/reports_handler.rb +3 -2
  100. data/lib/hybrid_platforms_conductor/secrets_reader.rb +31 -0
  101. data/lib/hybrid_platforms_conductor/services_handler.rb +32 -29
  102. data/lib/hybrid_platforms_conductor/test_only_remote_node.rb +1 -1
  103. data/lib/hybrid_platforms_conductor/test_report.rb +15 -18
  104. data/lib/hybrid_platforms_conductor/tests_runner.rb +116 -118
  105. data/lib/hybrid_platforms_conductor/thycotic.rb +28 -19
  106. data/lib/hybrid_platforms_conductor/topographer.rb +200 -190
  107. data/lib/hybrid_platforms_conductor/topographer/plugins/graphviz.rb +8 -8
  108. data/lib/hybrid_platforms_conductor/topographer/plugins/json.rb +4 -4
  109. data/lib/hybrid_platforms_conductor/version.rb +1 -1
  110. data/spec/hybrid_platforms_conductor_test.rb +29 -6
  111. data/spec/hybrid_platforms_conductor_test/api/actions_executor/actions/bash_spec.rb +18 -11
  112. data/spec/hybrid_platforms_conductor_test/api/actions_executor/actions/interactive_spec.rb +2 -2
  113. data/spec/hybrid_platforms_conductor_test/api/actions_executor/actions/remote_bash_spec.rb +32 -21
  114. data/spec/hybrid_platforms_conductor_test/api/actions_executor/actions/ruby_spec.rb +75 -49
  115. data/spec/hybrid_platforms_conductor_test/api/actions_executor/actions/scp_spec.rb +27 -15
  116. data/spec/hybrid_platforms_conductor_test/api/actions_executor/actions_spec.rb +90 -59
  117. data/spec/hybrid_platforms_conductor_test/api/actions_executor/connection_spec.rb +46 -44
  118. data/spec/hybrid_platforms_conductor_test/api/actions_executor/connectors/local/connectable_nodes_spec.rb +12 -8
  119. data/spec/hybrid_platforms_conductor_test/api/actions_executor/connectors/local/remote_actions_spec.rb +4 -7
  120. data/spec/hybrid_platforms_conductor_test/api/actions_executor/connectors/ssh/cli_options_spec.rb +21 -22
  121. data/spec/hybrid_platforms_conductor_test/api/actions_executor/connectors/ssh/config_dsl_spec.rb +23 -24
  122. data/spec/hybrid_platforms_conductor_test/api/actions_executor/connectors/ssh/connectable_nodes_spec.rb +10 -6
  123. data/spec/hybrid_platforms_conductor_test/api/actions_executor/connectors/ssh/connections_spec.rb +106 -75
  124. data/spec/hybrid_platforms_conductor_test/api/actions_executor/connectors/ssh/global_helpers_spec.rb +145 -126
  125. data/spec/hybrid_platforms_conductor_test/api/actions_executor/connectors/ssh/node_helpers_spec.rb +3 -3
  126. data/spec/hybrid_platforms_conductor_test/api/actions_executor/connectors/ssh/remote_actions_spec.rb +29 -25
  127. data/spec/hybrid_platforms_conductor_test/api/actions_executor/logging_spec.rb +167 -142
  128. data/spec/hybrid_platforms_conductor_test/api/actions_executor/parallel_spec.rb +272 -244
  129. data/spec/hybrid_platforms_conductor_test/api/actions_executor/timeout_spec.rb +16 -16
  130. data/spec/hybrid_platforms_conductor_test/api/cmd_runner_spec.rb +42 -36
  131. data/spec/hybrid_platforms_conductor_test/api/config_spec.rb +24 -22
  132. data/spec/hybrid_platforms_conductor_test/api/deployer/check_spec.rb +4 -2
  133. data/spec/hybrid_platforms_conductor_test/api/deployer/config_dsl_spec.rb +24 -6
  134. data/spec/hybrid_platforms_conductor_test/api/deployer/deploy_spec.rb +34 -26
  135. data/spec/hybrid_platforms_conductor_test/api/deployer/log_plugins/remote_fs_spec.rb +21 -21
  136. data/spec/hybrid_platforms_conductor_test/api/deployer/parse_deploy_output_spec.rb +55 -59
  137. data/spec/hybrid_platforms_conductor_test/api/deployer/provisioner_spec.rb +36 -62
  138. data/spec/hybrid_platforms_conductor_test/api/deployer/provisioners/podman_spec.rb +17 -17
  139. data/spec/hybrid_platforms_conductor_test/api/deployer/provisioners/proxmox/config_dsl_spec.rb +4 -4
  140. data/spec/hybrid_platforms_conductor_test/api/deployer/provisioners/proxmox/create_spec.rb +44 -51
  141. data/spec/hybrid_platforms_conductor_test/api/deployer/provisioners/proxmox/destroy_spec.rb +3 -3
  142. data/spec/hybrid_platforms_conductor_test/api/deployer/provisioners/proxmox/ip_spec.rb +12 -16
  143. data/spec/hybrid_platforms_conductor_test/api/deployer/provisioners/proxmox/reserve_proxmox_container/destroy_vm_spec.rb +31 -19
  144. data/spec/hybrid_platforms_conductor_test/api/deployer/provisioners/proxmox/reserve_proxmox_container/expired_containers_spec.rb +324 -266
  145. data/spec/hybrid_platforms_conductor_test/api/deployer/provisioners/proxmox/reserve_proxmox_container/ips_assignment_spec.rb +89 -61
  146. data/spec/hybrid_platforms_conductor_test/api/deployer/provisioners/proxmox/reserve_proxmox_container/other_lxc_containers_resources_spec.rb +117 -93
  147. data/spec/hybrid_platforms_conductor_test/api/deployer/provisioners/proxmox/reserve_proxmox_container/pve_node_resources_spec.rb +71 -54
  148. data/spec/hybrid_platforms_conductor_test/api/deployer/provisioners/proxmox/reserve_proxmox_container/retries_spec.rb +10 -8
  149. data/spec/hybrid_platforms_conductor_test/api/deployer/provisioners/proxmox/reserve_proxmox_container/vm_ids_assignment_spec.rb +80 -60
  150. data/spec/hybrid_platforms_conductor_test/api/deployer/provisioners/proxmox/start_spec.rb +1 -1
  151. data/spec/hybrid_platforms_conductor_test/api/deployer/provisioners/proxmox/state_spec.rb +1 -1
  152. data/spec/hybrid_platforms_conductor_test/api/deployer/provisioners/proxmox/stop_spec.rb +1 -1
  153. data/spec/hybrid_platforms_conductor_test/api/deployer/secrets_reader_plugins/cli_spec.rb +64 -0
  154. data/spec/hybrid_platforms_conductor_test/api/deployer/secrets_reader_plugins/thycotic_spec.rb +268 -0
  155. data/spec/hybrid_platforms_conductor_test/api/nodes_handler/cmdbs/config_spec.rb +8 -10
  156. data/spec/hybrid_platforms_conductor_test/api/nodes_handler/cmdbs/host_ip_spec.rb +33 -24
  157. data/spec/hybrid_platforms_conductor_test/api/nodes_handler/cmdbs/host_keys_spec.rb +64 -51
  158. data/spec/hybrid_platforms_conductor_test/api/nodes_handler/cmdbs/platform_handlers_spec.rb +3 -3
  159. data/spec/hybrid_platforms_conductor_test/api/nodes_handler/cmdbs_plugins_api_spec.rb +50 -51
  160. data/spec/hybrid_platforms_conductor_test/api/nodes_handler/common_spec.rb +91 -81
  161. data/spec/hybrid_platforms_conductor_test/api/nodes_handler/config_dsl_spec.rb +14 -16
  162. data/spec/hybrid_platforms_conductor_test/api/nodes_handler/git_diff_impacts_spec.rb +51 -75
  163. data/spec/hybrid_platforms_conductor_test/api/nodes_handler/nodes_selectors_spec.rb +35 -26
  164. data/spec/hybrid_platforms_conductor_test/api/nodes_handler/platform_handlers_plugins_api_spec.rb +24 -16
  165. data/spec/hybrid_platforms_conductor_test/api/nodes_handler/several_platforms_spec.rb +29 -19
  166. data/spec/hybrid_platforms_conductor_test/api/platform_handler_spec.rb +4 -4
  167. data/spec/hybrid_platforms_conductor_test/api/platform_handlers/serverless_chef/config_dsl_spec.rb +2 -2
  168. data/spec/hybrid_platforms_conductor_test/api/platform_handlers/serverless_chef/deploy_output_parsing_spec.rb +6 -6
  169. data/spec/hybrid_platforms_conductor_test/api/platform_handlers/serverless_chef/diff_impacts_spec.rb +57 -99
  170. data/spec/hybrid_platforms_conductor_test/api/platform_handlers/serverless_chef/inventory_spec.rb +4 -4
  171. data/spec/hybrid_platforms_conductor_test/api/platform_handlers/serverless_chef/packaging_spec.rb +32 -35
  172. data/spec/hybrid_platforms_conductor_test/api/platform_handlers/serverless_chef/services_deployment_spec.rb +10 -10
  173. data/spec/hybrid_platforms_conductor_test/api/platforms_handler_spec.rb +38 -27
  174. data/spec/hybrid_platforms_conductor_test/api/plugins_spec.rb +46 -52
  175. data/spec/hybrid_platforms_conductor_test/api/reports_handler_spec.rb +2 -2
  176. data/spec/hybrid_platforms_conductor_test/api/services_handler/actions_to_deploy_spec.rb +90 -58
  177. data/spec/hybrid_platforms_conductor_test/api/services_handler/deploy_allowed_spec.rb +38 -34
  178. data/spec/hybrid_platforms_conductor_test/api/services_handler/log_info_spec.rb +11 -9
  179. data/spec/hybrid_platforms_conductor_test/api/services_handler/package_spec.rb +193 -171
  180. data/spec/hybrid_platforms_conductor_test/api/services_handler/parse_deploy_output_spec.rb +66 -54
  181. data/spec/hybrid_platforms_conductor_test/api/services_handler/prepare_for_deploy_spec.rb +147 -133
  182. data/spec/hybrid_platforms_conductor_test/api/tests_runner/common_spec.rb +69 -49
  183. data/spec/hybrid_platforms_conductor_test/api/tests_runner/global_spec.rb +4 -3
  184. data/spec/hybrid_platforms_conductor_test/api/tests_runner/node_check_spec.rb +8 -5
  185. data/spec/hybrid_platforms_conductor_test/api/tests_runner/node_spec.rb +8 -5
  186. data/spec/hybrid_platforms_conductor_test/api/tests_runner/node_ssh_spec.rb +30 -27
  187. data/spec/hybrid_platforms_conductor_test/api/tests_runner/platform_spec.rb +12 -9
  188. data/spec/hybrid_platforms_conductor_test/api/tests_runner/reports_spec.rb +48 -47
  189. data/spec/hybrid_platforms_conductor_test/api/tests_runner/test_plugins/bitbucket_conf_spec.rb +5 -5
  190. data/spec/hybrid_platforms_conductor_test/api/tests_runner/test_plugins/github_ci_spec.rb +5 -5
  191. data/spec/hybrid_platforms_conductor_test/api/tests_runner/test_reports_plugins/confluence_spec.rb +5 -5
  192. data/spec/hybrid_platforms_conductor_test/cmdb_plugins/test_cmdb.rb +9 -9
  193. data/spec/hybrid_platforms_conductor_test/cmdb_plugins/{test_cmdb2.rb → test_cmdb_2.rb} +6 -6
  194. data/spec/hybrid_platforms_conductor_test/cmdb_plugins/test_cmdb_others.rb +3 -3
  195. data/spec/hybrid_platforms_conductor_test/cmdb_plugins/{test_cmdb_others2.rb → test_cmdb_others_2.rb} +2 -2
  196. data/spec/hybrid_platforms_conductor_test/docs_spec.rb +1 -1
  197. data/spec/hybrid_platforms_conductor_test/executables/{check-node_spec.rb → check_node_spec.rb} +4 -6
  198. data/spec/hybrid_platforms_conductor_test/executables/deploy_spec.rb +4 -6
  199. data/spec/hybrid_platforms_conductor_test/executables/get_impacted_nodes_spec.rb +76 -77
  200. data/spec/hybrid_platforms_conductor_test/executables/last_deploys_spec.rb +13 -15
  201. data/spec/hybrid_platforms_conductor_test/executables/nodes_to_deploy_spec.rb +289 -307
  202. data/spec/hybrid_platforms_conductor_test/executables/options/actions_executor_spec.rb +4 -6
  203. data/spec/hybrid_platforms_conductor_test/executables/options/cmd_runner_spec.rb +3 -5
  204. data/spec/hybrid_platforms_conductor_test/executables/options/common_spec.rb +8 -9
  205. data/spec/hybrid_platforms_conductor_test/executables/options/deployer_spec.rb +12 -196
  206. data/spec/hybrid_platforms_conductor_test/executables/options/nodes_handler_spec.rb +9 -10
  207. data/spec/hybrid_platforms_conductor_test/executables/options/nodes_selectors_spec.rb +9 -10
  208. data/spec/hybrid_platforms_conductor_test/executables/options/reports_handler_spec.rb +1 -1
  209. data/spec/hybrid_platforms_conductor_test/executables/options/tests_runner_spec.rb +22 -22
  210. data/spec/hybrid_platforms_conductor_test/executables/report_spec.rb +22 -16
  211. data/spec/hybrid_platforms_conductor_test/executables/run_spec.rb +32 -32
  212. data/spec/hybrid_platforms_conductor_test/executables/ssh_config_spec.rb +7 -9
  213. data/spec/hybrid_platforms_conductor_test/executables/test_spec.rb +3 -5
  214. data/spec/hybrid_platforms_conductor_test/helpers/actions_executor_helpers.rb +2 -2
  215. data/spec/hybrid_platforms_conductor_test/helpers/cmd_runner_helpers.rb +4 -3
  216. data/spec/hybrid_platforms_conductor_test/helpers/cmdb_helpers.rb +2 -2
  217. data/spec/hybrid_platforms_conductor_test/helpers/config_helpers.rb +1 -1
  218. data/spec/hybrid_platforms_conductor_test/helpers/connector_ssh_helpers.rb +12 -13
  219. data/spec/hybrid_platforms_conductor_test/helpers/deployer_helpers.rb +216 -14
  220. data/spec/hybrid_platforms_conductor_test/helpers/executables_helpers.rb +11 -11
  221. data/spec/hybrid_platforms_conductor_test/helpers/nodes_handler_helpers.rb +1 -1
  222. data/spec/hybrid_platforms_conductor_test/helpers/platforms_handler_helpers.rb +39 -28
  223. data/spec/hybrid_platforms_conductor_test/helpers/plugins_helpers.rb +1 -1
  224. data/spec/hybrid_platforms_conductor_test/helpers/provisioner_proxmox_helpers.rb +86 -111
  225. data/spec/hybrid_platforms_conductor_test/helpers/reports_handler_helpers.rb +1 -1
  226. data/spec/hybrid_platforms_conductor_test/helpers/serverless_chef_helpers.rb +3 -3
  227. data/spec/hybrid_platforms_conductor_test/helpers/services_handler_helpers.rb +1 -1
  228. data/spec/hybrid_platforms_conductor_test/helpers/tests_runner_helpers.rb +1 -1
  229. data/spec/hybrid_platforms_conductor_test/mocked_lib/my_test_gem/hpc_plugins/test_plugin_type/{test_plugin_id1.rb → test_plugin_id_1.rb} +0 -0
  230. data/spec/hybrid_platforms_conductor_test/mocked_lib/my_test_gem/hpc_plugins/test_plugin_type/{test_plugin_id2.rb → test_plugin_id_2.rb} +0 -0
  231. data/spec/hybrid_platforms_conductor_test/mocked_lib/my_test_gem2/sub_dir/hpc_plugins/test_plugin_type/{test_plugin_id3.rb → test_plugin_id_3.rb} +0 -0
  232. data/spec/hybrid_platforms_conductor_test/mocked_lib/my_test_gem2/sub_dir/hpc_plugins/{test_plugin_type2/test_plugin_id4.rb → test_plugin_type_2/test_plugin_id_4.rb} +0 -0
  233. data/spec/hybrid_platforms_conductor_test/platform_handler_plugins/test.rb +1 -1
  234. data/spec/hybrid_platforms_conductor_test/platform_handler_plugins/{test2.rb → test_2.rb} +0 -0
  235. data/spec/hybrid_platforms_conductor_test/rubocop_spec.rb +31 -0
  236. data/spec/hybrid_platforms_conductor_test/serverless_chef_repositories/1_node/nodes/node.json +3 -3
  237. data/spec/hybrid_platforms_conductor_test/serverless_chef_repositories/data_bags/nodes/node.json +3 -3
  238. data/spec/hybrid_platforms_conductor_test/serverless_chef_repositories/recipes/cookbooks/test_cookbook_2/libraries/default.rb +1 -0
  239. data/spec/hybrid_platforms_conductor_test/serverless_chef_repositories/several_cookbooks/other_cookbooks/test_cookbook_2/libraries/default.rb +1 -0
  240. data/spec/hybrid_platforms_conductor_test/shared_examples/deployer.rb +952 -0
  241. data/spec/hybrid_platforms_conductor_test/test_connector.rb +4 -3
  242. data/spec/hybrid_platforms_conductor_test/test_log_no_read_plugin.rb +3 -1
  243. data/spec/hybrid_platforms_conductor_test/test_log_plugin.rb +3 -1
  244. data/spec/hybrid_platforms_conductor_test/test_plugins/global.rb +1 -0
  245. data/spec/hybrid_platforms_conductor_test/test_plugins/node.rb +1 -0
  246. data/spec/hybrid_platforms_conductor_test/test_plugins/node_check.rb +1 -0
  247. data/spec/hybrid_platforms_conductor_test/test_plugins/platform.rb +1 -0
  248. data/spec/hybrid_platforms_conductor_test/test_plugins/several_checks.rb +2 -2
  249. data/spec/hybrid_platforms_conductor_test/test_secrets_reader_plugin.rb +45 -0
  250. data/spec/hybrid_platforms_conductor_test/tests_report_plugin.rb +5 -6
  251. data/spec/spec_helper.rb +17 -18
  252. data/tools/check_md +16 -20
  253. data/tools/generate_mermaid +1 -1
  254. metadata +186 -144
  255. data/spec/hybrid_platforms_conductor_test/helpers/deployer_test_helpers.rb +0 -916
@@ -0,0 +1,46 @@
1
+ require 'hybrid_platforms_conductor/secrets_reader'
2
+
3
+ module HybridPlatformsConductor
4
+
5
+ module HpcPlugins
6
+
7
+ module SecretsReader
8
+
9
+ # Read secrets from a secrets source
10
+ class MySecretsReaderPlugin < HybridPlatformsConductor::SecretsReader
11
+
12
+ # Complete an option parser with options meant to control this secrets reader
13
+ # [API] - This method is optional
14
+ #
15
+ # Parameters::
16
+ # * *options_parser* (OptionParser): The option parser to complete
17
+ def options_parse(options_parser)
18
+ @key_file = nil
19
+ options_parser.on('--key-file FILE', 'Key file decrypting a secret vault.') do |file|
20
+ @key_file = file
21
+ end
22
+ end
23
+
24
+ # Return secrets for a given service to be deployed on a node.
25
+ # [API] - This method is mandatory
26
+ # [API] - The following API components are accessible:
27
+ # * *@config* (Config): Main configuration API.
28
+ # * *@cmd_runner* (CmdRunner): Command Runner API.
29
+ # * *@nodes_handler* (NodesHandler): Nodes handler API.
30
+ #
31
+ # Parameters::
32
+ # * *node* (String): Node to be deployed
33
+ # * *service* (String): Service to be deployed
34
+ # Result::
35
+ # * Hash: The secrets
36
+ def secrets_for(node, service)
37
+ JSON.parse(Vault.decrypt("/path/to/#{node}_#{service}.vault", key: @key_file))
38
+ end
39
+
40
+ end
41
+
42
+ end
43
+
44
+ end
45
+
46
+ end
@@ -0,0 +1,90 @@
1
+ require 'hybrid_platforms_conductor/secrets_reader'
2
+ require 'hybrid_platforms_conductor/thycotic'
3
+
4
+ module HybridPlatformsConductor
5
+
6
+ module HpcPlugins
7
+
8
+ module SecretsReader
9
+
10
+ # Get secrets from a Thycotic secrets server
11
+ class Thycotic < HybridPlatformsConductor::SecretsReader
12
+
13
+ # Extend the Config DSL
14
+ module ConfigDSLExtension
15
+
16
+ # List of defined Thycotic secrets. Each info has the following properties:
17
+ # * *nodes_selectors_stack* (Array<Object>): Stack of nodes selectors impacted by this rule.
18
+ # * *thycotic_url* (String): Thycotic URL.
19
+ # * *secret_id* (Integer): Thycotic secret ID.
20
+ # Array< Hash<Symbol, Object> >
21
+ attr_reader :thycotic_secrets
22
+
23
+ # Mixin initializer
24
+ def init_thycotic_config
25
+ @thycotic_secrets = []
26
+ end
27
+
28
+ # Set a Thycotic secret server configuration
29
+ #
30
+ # Parameters::
31
+ # * *thycotic_url* (String): The Thycotic server URL.
32
+ # * *secret_id* (Integer): The Thycotic secret ID containing the secrets file to be used as secrets.
33
+ def secrets_from_thycotic(thycotic_url:, secret_id:)
34
+ @thycotic_secrets << {
35
+ nodes_selectors_stack: current_nodes_selectors_stack,
36
+ thycotic_url: thycotic_url,
37
+ secret_id: secret_id
38
+ }
39
+ end
40
+
41
+ end
42
+
43
+ Config.extend_config_dsl_with ConfigDSLExtension, :init_thycotic_config
44
+
45
+ # Return secrets for a given service to be deployed on a node.
46
+ # [API] - This method is mandatory
47
+ # [API] - The following API components are accessible:
48
+ # * *@config* (Config): Main configuration API.
49
+ # * *@cmd_runner* (CmdRunner): Command Runner API.
50
+ # * *@nodes_handler* (NodesHandler): Nodes handler API.
51
+ #
52
+ # Parameters::
53
+ # * *node* (String): Node to be deployed
54
+ # * *service* (String): Service to be deployed
55
+ # Result::
56
+ # * Hash: The secrets
57
+ def secrets_for(node, _service)
58
+ secrets = {}
59
+ # As we are dealing with global secrets, cache the reading for performance between nodes and services.
60
+ # Keep secrets cache grouped by URL/ID
61
+ @secrets = {} unless defined?(@secrets)
62
+ @nodes_handler.select_confs_for_node(node, @config.thycotic_secrets).each do |thycotic_secrets_info|
63
+ server_id = "#{thycotic_secrets_info[:thycotic_url]}:#{thycotic_secrets_info[:secret_id]}"
64
+ unless @secrets.key?(server_id)
65
+ HybridPlatformsConductor::Thycotic.with_thycotic(thycotic_secrets_info[:thycotic_url], @logger, @logger_stderr) do |thycotic|
66
+ secret_file_item_id = thycotic.get_secret(thycotic_secrets_info[:secret_id]).dig(:secret, :items, :secret_item, :id)
67
+ raise "Unable to fetch secret file ID #{thycotic_secrets_info[:secret_id]} from #{thycotic_secrets_info[:thycotic_url]}" if secret_file_item_id.nil?
68
+
69
+ secret = thycotic.download_file_attachment_by_item_id(thycotic_secrets_info[:secret_id], secret_file_item_id)
70
+ raise "Unable to fetch secret file attachment from secret ID #{thycotic_secrets_info[:secret_id]} from #{thycotic_secrets_info[:thycotic_url]}" if secret.nil?
71
+
72
+ @secrets[server_id] = JSON.parse(secret)
73
+ end
74
+ end
75
+ secrets.merge!(@secrets[server_id]) do |key, value_1, value_2|
76
+ raise "Thycotic secret #{key} served by #{thycotic_secrets_info[:thycotic_url]} from secret ID #{thycotic_secrets_info[:secret_id]} has conflicting values between different secrets." if value_1 != value_2
77
+
78
+ value_1
79
+ end
80
+ end
81
+ secrets
82
+ end
83
+
84
+ end
85
+
86
+ end
87
+
88
+ end
89
+
90
+ end
@@ -10,7 +10,7 @@ module HybridPlatformsConductor
10
10
  # Check that all repositories in Bitbucket have a consistent dev workflow.
11
11
  class BitbucketConf < HybridPlatformsConductor::Test
12
12
 
13
- self.extend_config_dsl_with CommonConfigDsl::Bitbucket, :init_bitbucket
13
+ extend_config_dsl_with CommonConfigDsl::Bitbucket, :init_bitbucket
14
14
 
15
15
  # Check my_test_plugin.rb.sample documentation for signature details.
16
16
  def test
@@ -107,12 +107,12 @@ module HybridPlatformsConductor
107
107
  mandatory_default_reviewers = repo_info.dig(*%i[checks pr_settings mandatory_default_reviewers])
108
108
  if mandatory_default_reviewers
109
109
  reviewers_found = default_reviewers.any? do |condition_info|
110
- reviewers = condition_info.dig('reviewers')
110
+ reviewers = condition_info['reviewers']
111
111
  condition_info.dig('sourceRefMatcher', 'id') == 'ANY_REF_MATCHER_ID' &&
112
112
  condition_info.dig('targetRefMatcher', 'id') == 'ANY_REF_MATCHER_ID' &&
113
113
  !reviewers.nil? &&
114
114
  (mandatory_default_reviewers - reviewers.map { |reviewer_info| reviewer_info['name'] }).empty? &&
115
- (required_approvers.nil? || condition_info.dig('requiredApprovals') == required_approvers)
115
+ (required_approvers.nil? || condition_info['requiredApprovals'] == required_approvers)
116
116
  end
117
117
  assert_equal(
118
118
  reviewers_found,
@@ -18,7 +18,7 @@ module HybridPlatformsConductor
18
18
  # Don't forget to add the testadmin private key in your SSH agent if you run this test locally.
19
19
  class CheckDeployAndIdempotence < TestByService
20
20
 
21
- self.extend_config_dsl_with CommonConfigDsl::IdempotenceTests, :init_idempotence_tests
21
+ extend_config_dsl_with CommonConfigDsl::IdempotenceTests, :init_idempotence_tests
22
22
 
23
23
  # Check my_test_plugin.rb.sample documentation for signature details.
24
24
  def test_for_node
@@ -30,6 +30,7 @@ module HybridPlatformsConductor
30
30
  ssh_ok = ssh.exec!('echo Works').strip == 'Works'
31
31
  end
32
32
  rescue
33
+ nil
33
34
  end
34
35
  assert_equal ssh_ok, true, 'Root does not have access from the empty image'
35
36
 
@@ -46,7 +47,7 @@ module HybridPlatformsConductor
46
47
  deployer.nbr_retries_on_error = 3
47
48
  exit_status, _stdout, _stderr = deployer.deploy_on(@node)[@node]
48
49
  assert_equal exit_status, 0, "Deploy from scratch returned error code #{exit_status}", log_debug? ? nil : deployer.stdouts_to_s
49
- if exit_status == 0
50
+ if exit_status.zero?
50
51
  # As it's possible sshd has to be restarted because of a change in its conf, restart the container.
51
52
  # Otherwise you'll get the following error upon reconnection:
52
53
  # System is booting up. See pam_nologin(8)
@@ -63,6 +64,7 @@ module HybridPlatformsConductor
63
64
  ssh_ok = ssh.exec!('echo Works').strip == 'Works'
64
65
  end
65
66
  rescue
67
+ nil
66
68
  end
67
69
  assert_equal ssh_ok, false, 'Root can still connect on the image after deployment'
68
70
  # Even if we can connect using root, run the idempotence test
@@ -13,7 +13,6 @@ module HybridPlatformsConductor
13
13
 
14
14
  # Check my_test_plugin.rb.sample documentation for signature details.
15
15
  def test_for_node
16
- now = Time.now
17
16
  deploy_info = @deployer.deployment_info_from(@node)[@node]
18
17
  if deploy_info.key?(:error)
19
18
  error "Error while getting deployment info: #{deploy_info[:error]}"
@@ -12,32 +12,34 @@ module HybridPlatformsConductor
12
12
 
13
13
  # Check my_test_plugin.rb.sample documentation for signature details.
14
14
  def test_for_node
15
- unless @nodes_handler.get_root_access_allowed_of(@node)
16
- @deployer.with_test_provisioned_instance(@config.tests_provisioner_id, @node, environment: 'deploy_removes_root_access', reuse_instance: log_debug?) do |deployer, instance|
17
- # Check that we can connect with root
15
+ return if @nodes_handler.get_root_access_allowed_of(@node)
16
+
17
+ @deployer.with_test_provisioned_instance(@config.tests_provisioner_id, @node, environment: 'deploy_removes_root_access', reuse_instance: log_debug?) do |deployer, instance|
18
+ # Check that we can connect with root
19
+ ssh_ok = false
20
+ begin
21
+ Net::SSH.start(instance.ip, 'root', password: 'root_pwd', auth_methods: ['password'], verify_host_key: :never) do |ssh|
22
+ ssh_ok = ssh.exec!('echo Works').strip == 'Works'
23
+ end
24
+ rescue
25
+ nil
26
+ end
27
+ assert_equal ssh_ok, true, 'Root does not have access from the empty image'
28
+ if ssh_ok
29
+ deployer.nbr_retries_on_error = 3
30
+ deployer.deploy_on @node
31
+ # As sshd is certainly being restarted, start and stop the container to reload it.
32
+ deployer.restart @node
33
+ # Check that we can't connect with root
18
34
  ssh_ok = false
19
35
  begin
20
36
  Net::SSH.start(instance.ip, 'root', password: 'root_pwd', auth_methods: ['password'], verify_host_key: :never) do |ssh|
21
37
  ssh_ok = ssh.exec!('echo Works').strip == 'Works'
22
38
  end
23
39
  rescue
40
+ nil
24
41
  end
25
- assert_equal ssh_ok, true, 'Root does not have access from the empty image'
26
- if ssh_ok
27
- deployer.nbr_retries_on_error = 3
28
- deployer.deploy_on @node
29
- # As sshd is certainly being restarted, start and stop the container to reload it.
30
- deployer.restart @node
31
- # Check that we can't connect with root
32
- ssh_ok = false
33
- begin
34
- Net::SSH.start(instance.ip, 'root', password: 'root_pwd', auth_methods: ['password'], verify_host_key: :never) do |ssh|
35
- ssh_ok = ssh.exec!('echo Works').strip == 'Works'
36
- end
37
- rescue
38
- end
39
- assert_equal ssh_ok, false, 'Root can still connect on the image after deployment'
40
- end
42
+ assert_equal ssh_ok, false, 'Root can still connect on the image after deployment'
41
43
  end
42
44
  end
43
45
  end
@@ -10,10 +10,10 @@ module HybridPlatformsConductor
10
10
  # Test that the node has not diverged since last deployment
11
11
  class Divergence < HybridPlatformsConductor::Test
12
12
 
13
- self.extend_config_dsl_with CommonConfigDsl::IdempotenceTests, :init_idempotence_tests
13
+ extend_config_dsl_with CommonConfigDsl::IdempotenceTests, :init_idempotence_tests
14
14
 
15
15
  # Check my_test_plugin.rb.sample documentation for signature details.
16
- def test_on_check_node(stdout, stderr, exit_status)
16
+ def test_on_check_node(stdout, stderr, _exit_status)
17
17
  # Check that the output of the check-node returns no changes.
18
18
  ignored_tasks = @nodes_handler.select_confs_for_node(@node, @config.ignored_divergent_tasks).inject({}) do |merged_ignored_tasks, conf|
19
19
  merged_ignored_tasks.merge(conf[:ignored_tasks])
@@ -27,7 +27,7 @@ module HybridPlatformsConductor
27
27
  ).known_platforms.first
28
28
  unless example_platform.nil?
29
29
  tests.concat [
30
- "#{CmdRunner.executables_prefix}get_impacted_nodes --platform #{example_platform.name} --show-commands",
30
+ "#{CmdRunner.executables_prefix}get_impacted_nodes --platform #{example_platform.name} --show-commands"
31
31
  ]
32
32
  example_node = example_platform.known_nodes.first
33
33
  unless example_node.nil?
@@ -42,7 +42,7 @@ module HybridPlatformsConductor
42
42
  ]
43
43
  end
44
44
  end
45
- tests.sort.each do |cmd|
45
+ tests.sort.each do |cmd|
46
46
  log_debug "Testing #{cmd}"
47
47
  exit_status, stdout, _stderr = @cmd_runner.run_cmd "#{cmd} 2>&1", no_exception: true, log_to_stdout: log_debug?
48
48
  assert_equal(exit_status, 0, "Command #{cmd} returned code #{exit_status}:\n#{stdout}")
@@ -10,31 +10,29 @@ module HybridPlatformsConductor
10
10
  # Perform various tests on a node's file system
11
11
  class FileSystem < TestOnlyRemoteNode
12
12
 
13
- self.extend_config_dsl_with CommonConfigDsl::FileSystemTests, :init_file_system_tests
13
+ extend_config_dsl_with CommonConfigDsl::FileSystemTests, :init_file_system_tests
14
14
 
15
15
  # Check my_test_plugin.rb.sample documentation for signature details.
16
16
  def test_on_node
17
17
  # Flatten the paths rules so that we can spot inconsistencies in configuration
18
- Hash[
19
- @config.aggregate_files_rules(@nodes_handler, @node).map do |path, rule_info|
20
- [
21
- "if #{@nodes_handler.sudo_on(@node)} /bin/bash -c '[[ -d \"#{path}\" ]]' ; then echo 1 ; else echo 0 ; fi",
22
- {
23
- validator: proc do |stdout, stderr|
24
- case stdout.last
25
- when '1'
26
- error "Path found that should be absent: #{path}" if rule_info[:state] == :absent
27
- when '0'
28
- error "Path not found that should be present: #{path}" if rule_info[:state] == :present
29
- else
30
- error "Could not check for existence of path #{path}", "----- STDOUT:\n#{stdout.join("\n")}----- STDERR:\n#{stderr.join("\n")}"
31
- end
32
- end,
33
- timeout: 2
34
- }
35
- ]
36
- end
37
- ]
18
+ @config.aggregate_files_rules(@nodes_handler, @node).map do |path, rule_info|
19
+ [
20
+ "if #{@nodes_handler.sudo_on(@node)} /bin/bash -c '[[ -d \"#{path}\" ]]' ; then echo 1 ; else echo 0 ; fi",
21
+ {
22
+ validator: proc do |stdout, stderr|
23
+ case stdout.last
24
+ when '1'
25
+ error "Path found that should be absent: #{path}" if rule_info[:state] == :absent
26
+ when '0'
27
+ error "Path not found that should be present: #{path}" if rule_info[:state] == :present
28
+ else
29
+ error "Could not check for existence of path #{path}", "----- STDOUT:\n#{stdout.join("\n")}----- STDERR:\n#{stderr.join("\n")}"
30
+ end
31
+ end,
32
+ timeout: 2
33
+ }
34
+ ]
35
+ end.to_h
38
36
  end
39
37
 
40
38
  end
@@ -9,31 +9,29 @@ module HybridPlatformsConductor
9
9
  # Perform various tests on a HDFS's file system
10
10
  class FileSystemHdfs < HybridPlatformsConductor::Test
11
11
 
12
- self.extend_config_dsl_with CommonConfigDsl::FileSystemTests, :init_file_system_tests
12
+ extend_config_dsl_with CommonConfigDsl::FileSystemTests, :init_file_system_tests
13
13
 
14
14
  # Check my_test_plugin.rb.sample documentation for signature details.
15
15
  def test_on_node
16
16
  # Flatten the paths rules so that we can spot inconsistencies in configuration
17
- Hash[
18
- @config.aggregate_files_rules(@nodes_handler, @node, file_system_type: :hdfs).map do |path, rule_info|
19
- [
20
- "if sudo#{rule_info[:context][:sudo_user] ? " -u #{rule_info[:context][:sudo_user]}" : ''} hdfs dfs -ls \"#{path}\" ; then echo 1 ; else echo 0 ; fi",
21
- {
22
- validator: proc do |stdout, stderr|
23
- case stdout.last
24
- when '1'
25
- error "HDFS path found that should be absent: #{path}" if rule_info[:state] == :absent
26
- when '0'
27
- error "HDFS path not found that should be present: #{path}" if rule_info[:state] == :present
28
- else
29
- error "Could not check for existence of HDFS path #{path}", "----- STDOUT:\n#{stdout.join("\n")}----- STDERR:\n#{stderr.join("\n")}"
30
- end
31
- end,
32
- timeout: 5
33
- }
34
- ]
35
- end
36
- ]
17
+ @config.aggregate_files_rules(@nodes_handler, @node, file_system_type: :hdfs).map do |path, rule_info|
18
+ [
19
+ "if sudo#{rule_info[:context][:sudo_user] ? " -u #{rule_info[:context][:sudo_user]}" : ''} hdfs dfs -ls \"#{path}\" ; then echo 1 ; else echo 0 ; fi",
20
+ {
21
+ validator: proc do |stdout, stderr|
22
+ case stdout.last
23
+ when '1'
24
+ error "HDFS path found that should be absent: #{path}" if rule_info[:state] == :absent
25
+ when '0'
26
+ error "HDFS path not found that should be present: #{path}" if rule_info[:state] == :present
27
+ else
28
+ error "Could not check for existence of HDFS path #{path}", "----- STDOUT:\n#{stdout.join("\n")}----- STDERR:\n#{stderr.join("\n")}"
29
+ end
30
+ end,
31
+ timeout: 5
32
+ }
33
+ ]
34
+ end.to_h
37
35
  end
38
36
 
39
37
  end
@@ -9,7 +9,7 @@ module HybridPlatformsConductor
9
9
  # Check that all repositories have a successful Github CI
10
10
  class GithubCi < HybridPlatformsConductor::Test
11
11
 
12
- self.extend_config_dsl_with CommonConfigDsl::Github, :init_github
12
+ extend_config_dsl_with CommonConfigDsl::Github, :init_github
13
13
 
14
14
  # Check my_test_plugin.rb.sample documentation for signature details.
15
15
  def test
@@ -17,8 +17,7 @@ module HybridPlatformsConductor
17
17
  log_debug "Checking CI for Github repository #{repo_info[:slug]}"
18
18
  last_status = client.repository_workflow_runs(repo_info[:slug])[:workflow_runs].
19
19
  select { |run| run[:head_branch] == 'master' }.
20
- sort_by { |run| run[:created_at] }.
21
- last[:conclusion]
20
+ max_by { |run| run[:created_at] }[:conclusion]
22
21
  error "Last workflow status for repository #{repo_info[:slug]} is #{last_status}" unless last_status == 'success'
23
22
  end
24
23
  end
@@ -13,7 +13,7 @@ module HybridPlatformsConductor
13
13
  # Don't forget to add the testadmin private key in your SSH agent if you run this test locally.
14
14
  class Idempotence < TestByService
15
15
 
16
- self.extend_config_dsl_with CommonConfigDsl::IdempotenceTests, :init_idempotence_tests
16
+ extend_config_dsl_with CommonConfigDsl::IdempotenceTests, :init_idempotence_tests
17
17
 
18
18
  # Check my_test_plugin.rb.sample documentation for signature details.
19
19
  def test_for_node
@@ -21,7 +21,7 @@ module HybridPlatformsConductor
21
21
  # First deploy as root
22
22
  deployer.nbr_retries_on_error = 3
23
23
  exit_status, _stdout, _stderr = deployer.deploy_on(@node)[@node]
24
- if exit_status == 0
24
+ if exit_status.zero?
25
25
  # As it's possible sshd has to be restarted because of a change in its conf, restart the container.
26
26
  # Otherwise you'll get the following error upon reconnection:
27
27
  # System is booting up. See pam_nologin(8)
@@ -19,7 +19,7 @@ module HybridPlatformsConductor
19
19
  else
20
20
  private_ips = @nodes_handler.get_private_ips_of @node
21
21
  if private_ips
22
- host_ips = stdout.first.split(' ').select { |ip| ip =~ /^172\.16\.\d+\.\d+$/ }.sort
22
+ host_ips = stdout.first.split.select { |ip| ip =~ /^172\.16\.\d+\.\d+$/ }.sort
23
23
  ref_ips = private_ips.sort
24
24
  assert_equal(
25
25
  host_ips,
@@ -1,3 +1,4 @@
1
+ require 'open-uri'
1
2
  require 'nokogiri'
2
3
  require 'hybrid_platforms_conductor/credentials'
3
4
  require 'hybrid_platforms_conductor/common_config_dsl/bitbucket'
@@ -11,7 +12,7 @@ module HybridPlatformsConductor
11
12
  # Check that all repositories have a correct Jenkins CI configuration.
12
13
  class JenkinsCiConf < HybridPlatformsConductor::Test
13
14
 
14
- self.extend_config_dsl_with CommonConfigDsl::Bitbucket, :init_bitbucket
15
+ extend_config_dsl_with CommonConfigDsl::Bitbucket, :init_bitbucket
15
16
 
16
17
  # Check my_test_plugin.rb.sample documentation for signature details.
17
18
  def test
@@ -21,27 +22,25 @@ module HybridPlatformsConductor
21
22
  else
22
23
  Credentials.with_credentials_for(:jenkins_ci, @logger, @logger_stderr, url: repo_info[:jenkins_ci_url]) do |jenkins_user, jenkins_password|
23
24
  # Get its config
24
- begin
25
- doc = Nokogiri::XML(open("#{repo_info[:jenkins_ci_url]}/config.xml", http_basic_authentication: [jenkins_user, jenkins_password]).read)
26
- # Check that this job builds the correct Bitbucket repository
27
- assert_equal(
28
- doc.xpath('/org.jenkinsci.plugins.workflow.multibranch.WorkflowMultiBranchProject/sources/data/jenkins.branch.BranchSource/source/serverUrl').text,
29
- bitbucket.bitbucket_url,
30
- "Job #{repo_info[:jenkins_ci_url]} does not build repository from Bitbucket"
31
- )
32
- assert_equal(
33
- doc.xpath('/org.jenkinsci.plugins.workflow.multibranch.WorkflowMultiBranchProject/sources/data/jenkins.branch.BranchSource/source/repoOwner').text.downcase,
34
- repo_info[:project].downcase,
35
- "Job #{repo_info[:jenkins_ci_url]} does not build repository from project #{repo_info[:project]}"
36
- )
37
- assert_equal(
38
- doc.xpath('/org.jenkinsci.plugins.workflow.multibranch.WorkflowMultiBranchProject/sources/data/jenkins.branch.BranchSource/source/repository').text,
39
- repo_info[:name],
40
- "Job #{repo_info[:jenkins_ci_url]} does not build repository named #{repo_info[:name]}"
41
- )
42
- rescue
43
- error "Error while checking Jenkins CI job for #{repo_info[:project]}/#{repo_info[:name]} from URL #{repo_info[:jenkins_ci_url]}: #{$!}"
44
- end
25
+ doc = Nokogiri::XML(URI.parse("#{repo_info[:jenkins_ci_url]}/config.xml").open(http_basic_authentication: [jenkins_user, jenkins_password]).read)
26
+ # Check that this job builds the correct Bitbucket repository
27
+ assert_equal(
28
+ doc.xpath('/org.jenkinsci.plugins.workflow.multibranch.WorkflowMultiBranchProject/sources/data/jenkins.branch.BranchSource/source/serverUrl').text,
29
+ bitbucket.bitbucket_url,
30
+ "Job #{repo_info[:jenkins_ci_url]} does not build repository from Bitbucket"
31
+ )
32
+ assert_equal(
33
+ doc.xpath('/org.jenkinsci.plugins.workflow.multibranch.WorkflowMultiBranchProject/sources/data/jenkins.branch.BranchSource/source/repoOwner').text.downcase,
34
+ repo_info[:project].downcase,
35
+ "Job #{repo_info[:jenkins_ci_url]} does not build repository from project #{repo_info[:project]}"
36
+ )
37
+ assert_equal(
38
+ doc.xpath('/org.jenkinsci.plugins.workflow.multibranch.WorkflowMultiBranchProject/sources/data/jenkins.branch.BranchSource/source/repository').text,
39
+ repo_info[:name],
40
+ "Job #{repo_info[:jenkins_ci_url]} does not build repository named #{repo_info[:name]}"
41
+ )
42
+ rescue
43
+ error "Error while checking Jenkins CI job for #{repo_info[:project]}/#{repo_info[:name]} from URL #{repo_info[:jenkins_ci_url]}: #{$ERROR_INFO}"
45
44
  end
46
45
  end
47
46
  end