hybrid_platforms_conductor 32.16.4 → 33.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +42 -0
- data/README.md +6 -3
- data/bin/check-node +0 -1
- data/bin/deploy +0 -1
- data/bin/get_impacted_nodes +0 -1
- data/bin/last_deploys +12 -8
- data/bin/nodes_to_deploy +6 -6
- data/bin/setup +6 -6
- data/bin/topograph +1 -1
- data/docs/config_dsl.md +45 -1
- data/docs/executables.md +6 -7
- data/docs/executables/check-node.md +3 -3
- data/docs/executables/deploy.md +3 -3
- data/docs/executables/dump_nodes_json.md +3 -3
- data/docs/executables/test.md +3 -3
- data/docs/executables/topograph.md +3 -3
- data/docs/gen/mermaid/README.md-0.png +0 -0
- data/docs/gen/mermaid/docs/executables/check-node.md-0.png +0 -0
- data/docs/gen/mermaid/docs/executables/deploy.md-0.png +0 -0
- data/docs/gen/mermaid/docs/executables/free_ips.md-0.png +0 -0
- data/docs/gen/mermaid/docs/executables/get_impacted_nodes.md-0.png +0 -0
- data/docs/gen/mermaid/docs/executables/last_deploys.md-0.png +0 -0
- data/docs/gen/mermaid/docs/executables/nodes_to_deploy.md-0.png +0 -0
- data/docs/gen/mermaid/docs/executables/report.md-0.png +0 -0
- data/docs/gen/mermaid/docs/executables/run.md-0.png +0 -0
- data/docs/gen/mermaid/docs/executables/ssh_config.md-0.png +0 -0
- data/docs/gen/mermaid/docs/executables/test.md-0.png +0 -0
- data/docs/plugins.md +47 -0
- data/docs/plugins/connector/ssh.md +1 -1
- data/docs/plugins/log/remote_fs.md +26 -0
- data/docs/plugins/secrets_reader/cli.md +31 -0
- data/docs/plugins/secrets_reader/thycotic.md +46 -0
- data/docs/plugins/test/bitbucket_conf.md +1 -1
- data/docs/plugins/test/check_deploy_and_idempotence.md +1 -1
- data/docs/plugins/test/connection.md +1 -0
- data/docs/plugins/test/deploy_removes_root_access.md +1 -1
- data/docs/plugins/test/file_system.md +1 -0
- data/docs/plugins/test/github_ci.md +48 -0
- data/docs/plugins/test/hostname.md +1 -0
- data/docs/plugins/test/ip.md +1 -0
- data/docs/plugins/test/jenkins_ci_conf.md +1 -1
- data/docs/plugins/test/jenkins_ci_masters_ok.md +1 -1
- data/docs/plugins/test/local_users.md +1 -0
- data/docs/plugins/test/mounts.md +1 -0
- data/docs/plugins/test/orphan_files.md +1 -0
- data/docs/plugins/test/ports.md +1 -0
- data/docs/plugins/test/spectre.md +1 -0
- data/docs/plugins/test/vulnerabilities.md +1 -0
- data/lib/hybrid_platforms_conductor/action.rb +4 -4
- data/lib/hybrid_platforms_conductor/actions_executor.rb +45 -43
- data/lib/hybrid_platforms_conductor/bitbucket.rb +5 -4
- data/lib/hybrid_platforms_conductor/cmd_runner.rb +13 -12
- data/lib/hybrid_platforms_conductor/cmdb.rb +2 -2
- data/lib/hybrid_platforms_conductor/common_config_dsl/bitbucket.rb +2 -1
- data/lib/hybrid_platforms_conductor/common_config_dsl/confluence.rb +2 -1
- data/lib/hybrid_platforms_conductor/common_config_dsl/file_system_tests.rb +5 -4
- data/lib/hybrid_platforms_conductor/common_config_dsl/github.rb +63 -0
- data/lib/hybrid_platforms_conductor/common_config_dsl/idempotence_tests.rb +2 -2
- data/lib/hybrid_platforms_conductor/config.rb +7 -4
- data/lib/hybrid_platforms_conductor/confluence.rb +1 -1
- data/lib/hybrid_platforms_conductor/connector.rb +5 -2
- data/lib/hybrid_platforms_conductor/core_extensions/symbol/zero.rb +24 -0
- data/lib/hybrid_platforms_conductor/credentials.rb +39 -36
- data/lib/hybrid_platforms_conductor/current_dir_monitor.rb +4 -1
- data/lib/hybrid_platforms_conductor/deployer.rb +275 -224
- data/lib/hybrid_platforms_conductor/executable.rb +20 -15
- data/lib/hybrid_platforms_conductor/hpc_plugins/cmdb/config.rb +10 -7
- data/lib/hybrid_platforms_conductor/hpc_plugins/cmdb/host_ip.rb +1 -1
- data/lib/hybrid_platforms_conductor/hpc_plugins/cmdb/host_keys.rb +2 -2
- data/lib/hybrid_platforms_conductor/hpc_plugins/cmdb/platform_handlers.rb +4 -4
- data/lib/hybrid_platforms_conductor/hpc_plugins/connector/local.rb +2 -0
- data/lib/hybrid_platforms_conductor/hpc_plugins/connector/ssh.rb +45 -49
- data/lib/hybrid_platforms_conductor/hpc_plugins/log/my_log_plugin.rb.sample +100 -0
- data/lib/hybrid_platforms_conductor/hpc_plugins/log/remote_fs.rb +180 -0
- data/lib/hybrid_platforms_conductor/hpc_plugins/platform_handler/serverless_chef.rb +68 -66
- data/lib/hybrid_platforms_conductor/hpc_plugins/platform_handler/serverless_chef/dsl_parser.rb +13 -0
- data/lib/hybrid_platforms_conductor/hpc_plugins/platform_handler/serverless_chef/recipes_tree_builder.rb +39 -38
- data/lib/hybrid_platforms_conductor/hpc_plugins/platform_handler/yaml_inventory.rb +5 -4
- data/lib/hybrid_platforms_conductor/hpc_plugins/provisioner/docker.rb +43 -45
- data/lib/hybrid_platforms_conductor/hpc_plugins/provisioner/podman.rb +18 -20
- data/lib/hybrid_platforms_conductor/hpc_plugins/provisioner/proxmox.rb +118 -117
- data/lib/hybrid_platforms_conductor/hpc_plugins/provisioner/proxmox/proxmox_waiter.rb +39 -43
- data/lib/hybrid_platforms_conductor/hpc_plugins/provisioner/proxmox/reserve_proxmox_container +9 -13
- data/lib/hybrid_platforms_conductor/hpc_plugins/report/confluence.rb +2 -2
- data/lib/hybrid_platforms_conductor/hpc_plugins/report/mediawiki.rb +28 -21
- data/lib/hybrid_platforms_conductor/hpc_plugins/report/stdout.rb +26 -22
- data/lib/hybrid_platforms_conductor/hpc_plugins/secrets_reader/cli.rb +77 -0
- data/lib/hybrid_platforms_conductor/hpc_plugins/secrets_reader/my_secrets_reader_plugin.rb.sample +46 -0
- data/lib/hybrid_platforms_conductor/hpc_plugins/secrets_reader/thycotic.rb +90 -0
- data/lib/hybrid_platforms_conductor/hpc_plugins/test/bitbucket_conf.rb +3 -3
- data/lib/hybrid_platforms_conductor/hpc_plugins/test/check_deploy_and_idempotence.rb +4 -2
- data/lib/hybrid_platforms_conductor/hpc_plugins/test/connection.rb +3 -1
- data/lib/hybrid_platforms_conductor/hpc_plugins/test/deploy_freshness.rb +7 -21
- data/lib/hybrid_platforms_conductor/hpc_plugins/test/deploy_removes_root_access.rb +21 -19
- data/lib/hybrid_platforms_conductor/hpc_plugins/test/divergence.rb +2 -2
- data/lib/hybrid_platforms_conductor/hpc_plugins/test/executables.rb +2 -2
- data/lib/hybrid_platforms_conductor/hpc_plugins/test/file_system.rb +21 -22
- data/lib/hybrid_platforms_conductor/hpc_plugins/test/file_system_hdfs.rb +19 -21
- data/lib/hybrid_platforms_conductor/hpc_plugins/test/github_ci.rb +31 -0
- data/lib/hybrid_platforms_conductor/hpc_plugins/test/hostname.rb +3 -1
- data/lib/hybrid_platforms_conductor/hpc_plugins/test/idempotence.rb +2 -2
- data/lib/hybrid_platforms_conductor/hpc_plugins/test/ip.rb +4 -2
- data/lib/hybrid_platforms_conductor/hpc_plugins/test/jenkins_ci_conf.rb +21 -22
- data/lib/hybrid_platforms_conductor/hpc_plugins/test/jenkins_ci_masters_ok.rb +10 -12
- data/lib/hybrid_platforms_conductor/hpc_plugins/test/linear_strategy.rb +9 -9
- data/lib/hybrid_platforms_conductor/hpc_plugins/test/local_users.rb +5 -3
- data/lib/hybrid_platforms_conductor/hpc_plugins/test/mounts.rb +5 -3
- data/lib/hybrid_platforms_conductor/hpc_plugins/test/orphan_files.rb +13 -10
- data/lib/hybrid_platforms_conductor/hpc_plugins/test/ports.rb +5 -3
- data/lib/hybrid_platforms_conductor/hpc_plugins/test/private_ips.rb +5 -5
- data/lib/hybrid_platforms_conductor/hpc_plugins/test/public_ips.rb +5 -5
- data/lib/hybrid_platforms_conductor/hpc_plugins/test/spectre.rb +7 -7
- data/lib/hybrid_platforms_conductor/hpc_plugins/test/veids.rb +3 -3
- data/lib/hybrid_platforms_conductor/hpc_plugins/test/vulnerabilities.rb +27 -25
- data/lib/hybrid_platforms_conductor/hpc_plugins/test_report/confluence.rb +2 -2
- data/lib/hybrid_platforms_conductor/hpc_plugins/test_report/stdout.rb +8 -6
- data/lib/hybrid_platforms_conductor/io_router.rb +14 -13
- data/lib/hybrid_platforms_conductor/json_dumper.rb +2 -2
- data/lib/hybrid_platforms_conductor/log.rb +31 -0
- data/lib/hybrid_platforms_conductor/logger_helpers.rb +19 -16
- data/lib/hybrid_platforms_conductor/nodes_handler.rb +89 -71
- data/lib/hybrid_platforms_conductor/parallel_threads.rb +7 -11
- data/lib/hybrid_platforms_conductor/platform_handler.rb +7 -7
- data/lib/hybrid_platforms_conductor/platforms_handler.rb +5 -3
- data/lib/hybrid_platforms_conductor/plugin.rb +2 -2
- data/lib/hybrid_platforms_conductor/plugins.rb +14 -8
- data/lib/hybrid_platforms_conductor/provisioner.rb +4 -4
- data/lib/hybrid_platforms_conductor/report.rb +2 -2
- data/lib/hybrid_platforms_conductor/reports_handler.rb +3 -2
- data/lib/hybrid_platforms_conductor/secrets_reader.rb +31 -0
- data/lib/hybrid_platforms_conductor/services_handler.rb +32 -29
- data/lib/hybrid_platforms_conductor/test_only_remote_node.rb +18 -0
- data/lib/hybrid_platforms_conductor/test_report.rb +15 -18
- data/lib/hybrid_platforms_conductor/tests_runner.rb +116 -118
- data/lib/hybrid_platforms_conductor/thycotic.rb +28 -19
- data/lib/hybrid_platforms_conductor/topographer.rb +200 -190
- data/lib/hybrid_platforms_conductor/topographer/plugins/graphviz.rb +8 -8
- data/lib/hybrid_platforms_conductor/topographer/plugins/json.rb +4 -4
- data/lib/hybrid_platforms_conductor/version.rb +1 -1
- data/spec/hybrid_platforms_conductor_test.rb +33 -12
- data/spec/hybrid_platforms_conductor_test/api/actions_executor/actions/bash_spec.rb +16 -11
- data/spec/hybrid_platforms_conductor_test/api/actions_executor/actions/interactive_spec.rb +1 -1
- data/spec/hybrid_platforms_conductor_test/api/actions_executor/actions/remote_bash_spec.rb +23 -18
- data/spec/hybrid_platforms_conductor_test/api/actions_executor/actions/ruby_spec.rb +67 -49
- data/spec/hybrid_platforms_conductor_test/api/actions_executor/actions/scp_spec.rb +20 -14
- data/spec/hybrid_platforms_conductor_test/api/actions_executor/actions_spec.rb +63 -50
- data/spec/hybrid_platforms_conductor_test/api/actions_executor/connection_spec.rb +35 -35
- data/spec/hybrid_platforms_conductor_test/api/actions_executor/connectors/local/connectable_nodes_spec.rb +12 -8
- data/spec/hybrid_platforms_conductor_test/api/actions_executor/connectors/local/remote_actions_spec.rb +4 -7
- data/spec/hybrid_platforms_conductor_test/api/actions_executor/connectors/ssh/cli_options_spec.rb +21 -22
- data/spec/hybrid_platforms_conductor_test/api/actions_executor/connectors/ssh/config_dsl_spec.rb +23 -24
- data/spec/hybrid_platforms_conductor_test/api/actions_executor/connectors/ssh/connectable_nodes_spec.rb +10 -6
- data/spec/hybrid_platforms_conductor_test/api/actions_executor/connectors/ssh/connections_spec.rb +73 -54
- data/spec/hybrid_platforms_conductor_test/api/actions_executor/connectors/ssh/global_helpers_spec.rb +145 -126
- data/spec/hybrid_platforms_conductor_test/api/actions_executor/connectors/ssh/node_helpers_spec.rb +3 -3
- data/spec/hybrid_platforms_conductor_test/api/actions_executor/connectors/ssh/remote_actions_spec.rb +29 -25
- data/spec/hybrid_platforms_conductor_test/api/actions_executor/logging_spec.rb +106 -91
- data/spec/hybrid_platforms_conductor_test/api/actions_executor/parallel_spec.rb +272 -244
- data/spec/hybrid_platforms_conductor_test/api/actions_executor/timeout_spec.rb +10 -12
- data/spec/hybrid_platforms_conductor_test/api/cmd_runner_spec.rb +36 -36
- data/spec/hybrid_platforms_conductor_test/api/config_spec.rb +24 -22
- data/spec/hybrid_platforms_conductor_test/api/deployer/check_spec.rb +4 -2
- data/spec/hybrid_platforms_conductor_test/api/deployer/config_dsl_spec.rb +43 -5
- data/spec/hybrid_platforms_conductor_test/api/deployer/deploy_spec.rb +199 -216
- data/spec/hybrid_platforms_conductor_test/api/deployer/log_plugins/remote_fs_spec.rb +223 -0
- data/spec/hybrid_platforms_conductor_test/api/deployer/parse_deploy_output_spec.rb +55 -59
- data/spec/hybrid_platforms_conductor_test/api/deployer/provisioner_spec.rb +36 -62
- data/spec/hybrid_platforms_conductor_test/api/deployer/provisioners/podman_spec.rb +17 -17
- data/spec/hybrid_platforms_conductor_test/api/deployer/provisioners/proxmox/config_dsl_spec.rb +4 -4
- data/spec/hybrid_platforms_conductor_test/api/deployer/provisioners/proxmox/create_spec.rb +44 -51
- data/spec/hybrid_platforms_conductor_test/api/deployer/provisioners/proxmox/destroy_spec.rb +3 -3
- data/spec/hybrid_platforms_conductor_test/api/deployer/provisioners/proxmox/ip_spec.rb +12 -16
- data/spec/hybrid_platforms_conductor_test/api/deployer/provisioners/proxmox/reserve_proxmox_container/destroy_vm_spec.rb +31 -19
- data/spec/hybrid_platforms_conductor_test/api/deployer/provisioners/proxmox/reserve_proxmox_container/expired_containers_spec.rb +324 -266
- data/spec/hybrid_platforms_conductor_test/api/deployer/provisioners/proxmox/reserve_proxmox_container/ips_assignment_spec.rb +89 -61
- data/spec/hybrid_platforms_conductor_test/api/deployer/provisioners/proxmox/reserve_proxmox_container/other_lxc_containers_resources_spec.rb +117 -93
- data/spec/hybrid_platforms_conductor_test/api/deployer/provisioners/proxmox/reserve_proxmox_container/pve_node_resources_spec.rb +71 -54
- data/spec/hybrid_platforms_conductor_test/api/deployer/provisioners/proxmox/reserve_proxmox_container/retries_spec.rb +10 -8
- data/spec/hybrid_platforms_conductor_test/api/deployer/provisioners/proxmox/reserve_proxmox_container/vm_ids_assignment_spec.rb +80 -60
- data/spec/hybrid_platforms_conductor_test/api/deployer/provisioners/proxmox/start_spec.rb +1 -1
- data/spec/hybrid_platforms_conductor_test/api/deployer/provisioners/proxmox/state_spec.rb +1 -1
- data/spec/hybrid_platforms_conductor_test/api/deployer/provisioners/proxmox/stop_spec.rb +1 -1
- data/spec/hybrid_platforms_conductor_test/api/deployer/secrets_reader_plugins/cli_spec.rb +64 -0
- data/spec/hybrid_platforms_conductor_test/api/deployer/secrets_reader_plugins/thycotic_spec.rb +268 -0
- data/spec/hybrid_platforms_conductor_test/api/nodes_handler/cmdbs/config_spec.rb +8 -10
- data/spec/hybrid_platforms_conductor_test/api/nodes_handler/cmdbs/host_ip_spec.rb +33 -24
- data/spec/hybrid_platforms_conductor_test/api/nodes_handler/cmdbs/host_keys_spec.rb +64 -51
- data/spec/hybrid_platforms_conductor_test/api/nodes_handler/cmdbs/platform_handlers_spec.rb +3 -3
- data/spec/hybrid_platforms_conductor_test/api/nodes_handler/cmdbs_plugins_api_spec.rb +50 -51
- data/spec/hybrid_platforms_conductor_test/api/nodes_handler/common_spec.rb +91 -81
- data/spec/hybrid_platforms_conductor_test/api/nodes_handler/config_dsl_spec.rb +14 -16
- data/spec/hybrid_platforms_conductor_test/api/nodes_handler/git_diff_impacts_spec.rb +51 -75
- data/spec/hybrid_platforms_conductor_test/api/nodes_handler/nodes_selectors_spec.rb +35 -26
- data/spec/hybrid_platforms_conductor_test/api/nodes_handler/platform_handlers_plugins_api_spec.rb +24 -16
- data/spec/hybrid_platforms_conductor_test/api/nodes_handler/several_platforms_spec.rb +29 -19
- data/spec/hybrid_platforms_conductor_test/api/platform_handler_spec.rb +4 -4
- data/spec/hybrid_platforms_conductor_test/api/platform_handlers/serverless_chef/config_dsl_spec.rb +2 -2
- data/spec/hybrid_platforms_conductor_test/api/platform_handlers/serverless_chef/deploy_output_parsing_spec.rb +6 -6
- data/spec/hybrid_platforms_conductor_test/api/platform_handlers/serverless_chef/diff_impacts_spec.rb +57 -99
- data/spec/hybrid_platforms_conductor_test/api/platform_handlers/serverless_chef/inventory_spec.rb +4 -4
- data/spec/hybrid_platforms_conductor_test/api/platform_handlers/serverless_chef/packaging_spec.rb +32 -35
- data/spec/hybrid_platforms_conductor_test/api/platform_handlers/serverless_chef/services_deployment_spec.rb +10 -10
- data/spec/hybrid_platforms_conductor_test/api/platforms_handler_spec.rb +38 -27
- data/spec/hybrid_platforms_conductor_test/api/plugins_spec.rb +46 -52
- data/spec/hybrid_platforms_conductor_test/api/reports_handler_spec.rb +2 -2
- data/spec/hybrid_platforms_conductor_test/api/services_handler/actions_to_deploy_spec.rb +90 -58
- data/spec/hybrid_platforms_conductor_test/api/services_handler/deploy_allowed_spec.rb +38 -34
- data/spec/hybrid_platforms_conductor_test/api/services_handler/log_info_spec.rb +11 -9
- data/spec/hybrid_platforms_conductor_test/api/services_handler/package_spec.rb +193 -171
- data/spec/hybrid_platforms_conductor_test/api/services_handler/parse_deploy_output_spec.rb +66 -54
- data/spec/hybrid_platforms_conductor_test/api/services_handler/prepare_for_deploy_spec.rb +147 -133
- data/spec/hybrid_platforms_conductor_test/api/tests_runner/common_spec.rb +69 -49
- data/spec/hybrid_platforms_conductor_test/api/tests_runner/global_spec.rb +5 -4
- data/spec/hybrid_platforms_conductor_test/api/tests_runner/node_check_spec.rb +8 -5
- data/spec/hybrid_platforms_conductor_test/api/tests_runner/node_spec.rb +8 -5
- data/spec/hybrid_platforms_conductor_test/api/tests_runner/node_ssh_spec.rb +30 -27
- data/spec/hybrid_platforms_conductor_test/api/tests_runner/platform_spec.rb +12 -9
- data/spec/hybrid_platforms_conductor_test/api/tests_runner/reports_spec.rb +48 -47
- data/spec/hybrid_platforms_conductor_test/api/tests_runner/test_plugins/bitbucket_conf_spec.rb +5 -5
- data/spec/hybrid_platforms_conductor_test/api/tests_runner/test_plugins/github_ci_spec.rb +72 -0
- data/spec/hybrid_platforms_conductor_test/api/tests_runner/test_reports_plugins/confluence_spec.rb +5 -5
- data/spec/hybrid_platforms_conductor_test/cmdb_plugins/test_cmdb.rb +9 -9
- data/spec/hybrid_platforms_conductor_test/cmdb_plugins/{test_cmdb2.rb → test_cmdb_2.rb} +6 -6
- data/spec/hybrid_platforms_conductor_test/cmdb_plugins/test_cmdb_others.rb +3 -3
- data/spec/hybrid_platforms_conductor_test/cmdb_plugins/{test_cmdb_others2.rb → test_cmdb_others_2.rb} +2 -2
- data/spec/hybrid_platforms_conductor_test/docs_spec.rb +1 -1
- data/spec/hybrid_platforms_conductor_test/executables/{check-node_spec.rb → check_node_spec.rb} +4 -6
- data/spec/hybrid_platforms_conductor_test/executables/deploy_spec.rb +4 -6
- data/spec/hybrid_platforms_conductor_test/executables/get_impacted_nodes_spec.rb +76 -77
- data/spec/hybrid_platforms_conductor_test/executables/last_deploys_spec.rb +159 -113
- data/spec/hybrid_platforms_conductor_test/executables/nodes_to_deploy_spec.rb +299 -160
- data/spec/hybrid_platforms_conductor_test/executables/options/actions_executor_spec.rb +4 -6
- data/spec/hybrid_platforms_conductor_test/executables/options/cmd_runner_spec.rb +3 -5
- data/spec/hybrid_platforms_conductor_test/executables/options/common_spec.rb +8 -8
- data/spec/hybrid_platforms_conductor_test/executables/options/deployer_spec.rb +12 -196
- data/spec/hybrid_platforms_conductor_test/executables/options/nodes_handler_spec.rb +9 -10
- data/spec/hybrid_platforms_conductor_test/executables/options/nodes_selectors_spec.rb +9 -10
- data/spec/hybrid_platforms_conductor_test/executables/options/reports_handler_spec.rb +1 -1
- data/spec/hybrid_platforms_conductor_test/executables/options/tests_runner_spec.rb +22 -22
- data/spec/hybrid_platforms_conductor_test/executables/report_spec.rb +22 -16
- data/spec/hybrid_platforms_conductor_test/executables/run_spec.rb +32 -32
- data/spec/hybrid_platforms_conductor_test/executables/ssh_config_spec.rb +7 -9
- data/spec/hybrid_platforms_conductor_test/executables/test_spec.rb +3 -5
- data/spec/hybrid_platforms_conductor_test/helpers/actions_executor_helpers.rb +2 -2
- data/spec/hybrid_platforms_conductor_test/helpers/cmd_runner_helpers.rb +4 -3
- data/spec/hybrid_platforms_conductor_test/helpers/cmdb_helpers.rb +2 -2
- data/spec/hybrid_platforms_conductor_test/helpers/config_helpers.rb +1 -1
- data/spec/hybrid_platforms_conductor_test/helpers/connector_ssh_helpers.rb +12 -13
- data/spec/hybrid_platforms_conductor_test/helpers/deployer_helpers.rb +245 -56
- data/spec/hybrid_platforms_conductor_test/helpers/executables_helpers.rb +11 -11
- data/spec/hybrid_platforms_conductor_test/helpers/nodes_handler_helpers.rb +1 -1
- data/spec/hybrid_platforms_conductor_test/helpers/platforms_handler_helpers.rb +39 -28
- data/spec/hybrid_platforms_conductor_test/helpers/plugins_helpers.rb +1 -1
- data/spec/hybrid_platforms_conductor_test/helpers/provisioner_proxmox_helpers.rb +86 -111
- data/spec/hybrid_platforms_conductor_test/helpers/reports_handler_helpers.rb +1 -1
- data/spec/hybrid_platforms_conductor_test/helpers/serverless_chef_helpers.rb +3 -3
- data/spec/hybrid_platforms_conductor_test/helpers/services_handler_helpers.rb +1 -1
- data/spec/hybrid_platforms_conductor_test/helpers/tests_runner_helpers.rb +1 -1
- 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
- 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
- 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
- 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
- data/spec/hybrid_platforms_conductor_test/platform_handler_plugins/test.rb +1 -1
- data/spec/hybrid_platforms_conductor_test/platform_handler_plugins/{test2.rb → test_2.rb} +0 -0
- data/spec/hybrid_platforms_conductor_test/rubocop_spec.rb +31 -0
- data/spec/hybrid_platforms_conductor_test/serverless_chef_repositories/1_node/nodes/node.json +3 -3
- data/spec/hybrid_platforms_conductor_test/serverless_chef_repositories/data_bags/nodes/node.json +3 -3
- data/spec/hybrid_platforms_conductor_test/serverless_chef_repositories/recipes/cookbooks/test_cookbook_2/libraries/default.rb +1 -0
- data/spec/hybrid_platforms_conductor_test/serverless_chef_repositories/several_cookbooks/other_cookbooks/test_cookbook_2/libraries/default.rb +1 -0
- data/spec/hybrid_platforms_conductor_test/shared_examples/deployer.rb +952 -0
- data/spec/hybrid_platforms_conductor_test/test_connector.rb +3 -3
- data/spec/hybrid_platforms_conductor_test/test_log_no_read_plugin.rb +84 -0
- data/spec/hybrid_platforms_conductor_test/test_log_plugin.rb +105 -0
- data/spec/hybrid_platforms_conductor_test/test_plugins/global.rb +1 -0
- data/spec/hybrid_platforms_conductor_test/test_plugins/node.rb +1 -0
- data/spec/hybrid_platforms_conductor_test/test_plugins/node_check.rb +1 -0
- data/spec/hybrid_platforms_conductor_test/test_plugins/platform.rb +1 -0
- data/spec/hybrid_platforms_conductor_test/test_plugins/several_checks.rb +2 -2
- data/spec/hybrid_platforms_conductor_test/test_secrets_reader_plugin.rb +45 -0
- data/spec/hybrid_platforms_conductor_test/tests_report_plugin.rb +5 -6
- data/spec/spec_helper.rb +17 -18
- data/tools/check_md +16 -20
- data/tools/generate_mermaid +1 -1
- metadata +82 -13
- data/spec/hybrid_platforms_conductor_test/helpers/deployer_test_helpers.rb +0 -916
@@ -21,12 +21,12 @@ module HybridPlatformsConductorTest
|
|
21
21
|
def register_test_cmdb(cmdb_names = [:test_cmdb])
|
22
22
|
register_plugins(
|
23
23
|
:cmdb,
|
24
|
-
|
24
|
+
cmdb_names.map do |plugin_id|
|
25
25
|
[
|
26
26
|
plugin_id,
|
27
27
|
HybridPlatformsConductorTest::CmdbPlugins.const_get(plugin_id.to_s.split('_').collect(&:capitalize).join.to_sym)
|
28
28
|
]
|
29
|
-
end
|
29
|
+
end.to_h
|
30
30
|
)
|
31
31
|
end
|
32
32
|
|
@@ -9,7 +9,7 @@ module HybridPlatformsConductorTest
|
|
9
9
|
# Result::
|
10
10
|
# * Config: Config on which we can do testing
|
11
11
|
def test_config
|
12
|
-
@config
|
12
|
+
@config ||= HybridPlatformsConductor::Config.new logger: logger, logger_stderr: logger
|
13
13
|
@config
|
14
14
|
end
|
15
15
|
|
@@ -41,30 +41,30 @@ module HybridPlatformsConductorTest
|
|
41
41
|
ssh_commands_per_connection = []
|
42
42
|
if with_strict_host_key_checking
|
43
43
|
ip = node_connection_info[:ip] || node_connection_info[:connection]
|
44
|
-
ssh_commands_once.concat(
|
44
|
+
ssh_commands_once.concat(
|
45
45
|
[
|
46
|
-
|
47
|
-
|
46
|
+
[
|
47
|
+
"ssh-keyscan #{ip}",
|
48
|
+
proc { [0, "#{ip} ssh-rsa fake_host_key_for_#{ip}", ''] }
|
49
|
+
]
|
48
50
|
]
|
49
|
-
|
51
|
+
)
|
50
52
|
end
|
51
53
|
if with_control_master_create
|
52
54
|
control_master_created = false
|
53
55
|
ssh_commands_per_connection << [
|
54
56
|
if with_session_exec
|
55
|
-
|
57
|
+
%r{^.+/ssh #{with_batch_mode ? '-o BatchMode=yes ' : ''}-o ControlMaster=yes -o ControlPersist=yes hpc\.#{Regexp.escape(node)} true$}
|
56
58
|
else
|
57
59
|
unless ENV['hpc_interactive'] == 'false'
|
58
60
|
# Mock the user hitting enter as the Control Master will be created in another thread and the main thread waits for user input.
|
59
61
|
expect($stdin).to receive(:gets) do
|
60
62
|
# We have to wait for the Control Master creation thread to actually create the Control Master before hitting Enter.
|
61
|
-
|
62
|
-
sleep 0.1
|
63
|
-
end
|
63
|
+
sleep 0.1 until control_master_created
|
64
64
|
"\n"
|
65
65
|
end
|
66
66
|
end
|
67
|
-
|
67
|
+
%r{^xterm -e '.+/ssh -o ControlMaster=yes -o ControlPersist=yes hpc\.#{Regexp.escape(node)}'$}
|
68
68
|
end,
|
69
69
|
proc do
|
70
70
|
control_file = test_actions_executor.connector(:ssh).send(:control_master_file, node_connection_info[:connection], '22', node_connection_info[:user])
|
@@ -88,13 +88,13 @@ module HybridPlatformsConductorTest
|
|
88
88
|
end
|
89
89
|
if with_control_master_check
|
90
90
|
ssh_commands_per_connection << [
|
91
|
-
|
91
|
+
%r{^.+/ssh -O check hpc\.#{Regexp.escape(node)}$},
|
92
92
|
proc { [0, '', ''] }
|
93
93
|
]
|
94
94
|
end
|
95
95
|
if with_control_master_destroy
|
96
96
|
ssh_commands_per_connection << [
|
97
|
-
|
97
|
+
%r{^.+/ssh -O exit hpc\.#{Regexp.escape(node)} 2>&1 \| grep -v 'Exit request sent\.'$},
|
98
98
|
proc do
|
99
99
|
# Really mock the control file deletion
|
100
100
|
File.unlink(test_actions_executor.connector(:ssh).send(:control_master_file, node_connection_info[:connection], '22', node_connection_info[:user]))
|
@@ -137,8 +137,7 @@ module HybridPlatformsConductorTest
|
|
137
137
|
)
|
138
138
|
with_test_platform(
|
139
139
|
{ nodes: { 'node' => { meta: { host_ip: '192.168.42.42', ssh_session_exec: session_exec } } } },
|
140
|
-
|
141
|
-
additional_config
|
140
|
+
additional_config: additional_config
|
142
141
|
) do
|
143
142
|
with_cmd_runner_mocked(
|
144
143
|
[
|
@@ -12,7 +12,7 @@ module HybridPlatformsConductorTest
|
|
12
12
|
# * *sudo* (String or nil): sudo supposed to be used, or nil if none [default: 'sudo -u root']
|
13
13
|
def expect_action_to_lock_node(action, node, sudo: 'sudo -u root')
|
14
14
|
expect(action[:scp].size).to eq 1
|
15
|
-
expect(action[:scp].first[0]).to match
|
15
|
+
expect(action[:scp].first[0]).to match(%r{^.+/mutex_dir$})
|
16
16
|
expect(action[:scp].first[1]).to eq '.'
|
17
17
|
expect(action[:remote_bash]).to eq "while ! #{sudo ? "#{sudo} " : ''}./mutex_dir lock /tmp/hybrid_platforms_conductor_deploy_lock \"$(ps -o ppid= -p $$)\"; do echo -e 'Another deployment is running on #{node}. Waiting for it to finish to continue...' ; sleep 5 ; done"
|
18
18
|
end
|
@@ -23,7 +23,7 @@ module HybridPlatformsConductorTest
|
|
23
23
|
# * *action* (Hash<Symbol,Object>): The action to check
|
24
24
|
# * *node* (String): The concerned node
|
25
25
|
# * *sudo* (String or nil): sudo supposed to be used, or nil if none [default: 'sudo -u root']
|
26
|
-
def expect_action_to_unlock_node(action,
|
26
|
+
def expect_action_to_unlock_node(action, _node, sudo: 'sudo -u root')
|
27
27
|
expect(action).to eq(remote_bash: "#{sudo ? "#{sudo} " : ''}./mutex_dir unlock /tmp/hybrid_platforms_conductor_deploy_lock")
|
28
28
|
end
|
29
29
|
|
@@ -40,7 +40,7 @@ module HybridPlatformsConductorTest
|
|
40
40
|
# * Hash<String, [Integer or Symbol, String, String] >: Expected result of those expected actions
|
41
41
|
def expect_actions_to_deploy_on(actions, nodes, check: false, sudo: 'sudo -u root', expected_actions: [], mocked_result: nil)
|
42
42
|
nodes = [nodes] if nodes.is_a?(String)
|
43
|
-
mocked_result =
|
43
|
+
mocked_result = nodes.map { |node| [node, [0, "#{check ? 'Check' : 'Deploy'} successful", '']] }.to_h if mocked_result.nil?
|
44
44
|
expect(actions.size).to eq nodes.size
|
45
45
|
nodes.each do |node|
|
46
46
|
expect(actions.key?(node)).to eq true
|
@@ -65,81 +65,270 @@ module HybridPlatformsConductorTest
|
|
65
65
|
expect(actions.key?(node)).to eq true
|
66
66
|
expect_action_to_unlock_node(actions[node], node, sudo: sudo)
|
67
67
|
end
|
68
|
-
|
68
|
+
nodes.map { |node| [node, [0, 'Release mutex successful', '']] }.to_h
|
69
69
|
end
|
70
70
|
|
71
|
-
# Expect a given set of actions to upload log files on a list of nodes
|
71
|
+
# Expect a given set of actions to upload log files on a list of nodes (using the test_log log plugin)
|
72
72
|
#
|
73
73
|
# Parameters::
|
74
74
|
# * *actions* (Object): Actions
|
75
75
|
# * *nodes* (String or Array<String>): Node (or list of nodes) that should be checked
|
76
|
-
|
77
|
-
def expect_actions_to_upload_logs(actions, nodes, sudo: 'sudo -u root')
|
76
|
+
def expect_actions_to_upload_logs(actions, nodes)
|
78
77
|
nodes = [nodes] if nodes.is_a?(String)
|
79
78
|
expect(actions.size).to eq nodes.size
|
80
79
|
nodes.each do |node|
|
81
80
|
expect(actions.key?(node)).to eq true
|
82
|
-
expect(actions[node]
|
83
|
-
expect(actions[node][:scp].first[1]).to eq '/var/log/deployments'
|
84
|
-
expect(actions[node][:scp][:group]).to eq 'root'
|
85
|
-
expect(actions[node][:scp][:owner]).to eq 'root'
|
86
|
-
expect(actions[node][:scp][:sudo]).to eq (!sudo.nil?)
|
81
|
+
expect(actions[node]).to eq [{ bash: "echo Save test logs to #{node}" }]
|
87
82
|
end
|
88
|
-
|
83
|
+
nodes.map { |node| [node, [0, 'Logs uploaded', '']] }.to_h
|
84
|
+
end
|
85
|
+
|
86
|
+
# Get a test Deployer
|
87
|
+
#
|
88
|
+
# Result::
|
89
|
+
# * Deployer: Deployer on which we can do testing
|
90
|
+
def test_deployer
|
91
|
+
@deployer ||= HybridPlatformsConductor::Deployer.new logger: logger, logger_stderr: logger, config: test_config, cmd_runner: test_cmd_runner, nodes_handler: test_nodes_handler, actions_executor: test_actions_executor, services_handler: test_services_handler
|
92
|
+
@deployer
|
89
93
|
end
|
90
94
|
|
91
|
-
# Expect
|
92
|
-
# Expected logs format:
|
95
|
+
# Expect the test services handler to be called to deploy a given list of services
|
93
96
|
#
|
94
|
-
#
|
95
|
-
#
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
97
|
+
# Parameters::
|
98
|
+
# * *services* (Hash<String, Array<String> >): List of services to be expected, per node name
|
99
|
+
def expect_services_handler_to_deploy(services)
|
100
|
+
expect(test_services_handler).to receive(:deploy_allowed?).with(
|
101
|
+
services: services,
|
102
|
+
local_environment: false
|
103
|
+
).and_return(nil)
|
104
|
+
expect(test_services_handler).to receive(:package).with(
|
105
|
+
services: services,
|
106
|
+
secrets: {},
|
107
|
+
local_environment: false
|
108
|
+
)
|
109
|
+
expect(test_services_handler).to receive(:prepare_for_deploy).with(
|
110
|
+
services: services,
|
111
|
+
secrets: {},
|
112
|
+
local_environment: false,
|
113
|
+
why_run: false
|
114
|
+
)
|
115
|
+
services.each do |node, node_services|
|
116
|
+
expect(test_services_handler).to receive(:actions_to_deploy_on).with(node, node_services, false) do
|
117
|
+
[{ bash: "echo \"Deploying on #{node}\"" }]
|
118
|
+
end
|
119
|
+
expect(test_services_handler).to receive(:log_info_for).with(node, node_services) do
|
120
|
+
{
|
121
|
+
repo_name_0: 'platform',
|
122
|
+
commit_id_0: '123456',
|
123
|
+
commit_message_0: "Test commit for #{node}: #{node_services.join(', ')}"
|
124
|
+
}
|
125
|
+
end
|
126
|
+
end
|
127
|
+
end
|
128
|
+
|
129
|
+
# Get expected actions for a deployment
|
130
|
+
#
|
131
|
+
# Parameters::
|
132
|
+
# * *services* (Hash<String, Array<String> >): Expected nodes that should be deployed, with their corresponding services [default: { 'node' => %w[service] }]
|
133
|
+
# * *sudo* (String or nil): sudo supposed to be used, or nil if none [default: 'sudo -u root']
|
134
|
+
# * *check_mode* (Boolean): Are we testing in check mode? [default: @check_mode]
|
135
|
+
# * *mocked_deploy_result* (Hash or nil): Mocked result of the deployment actions, or nil to use the helper's default [default: nil]
|
136
|
+
# * *additional_expected_actions* (Array): Additional expected actions [default: []]
|
137
|
+
# * *expect_concurrent_actions* (Boolean): Are actions expected to be run in parallel? [default: false]
|
138
|
+
# * *expect_actions_timeout* (Integer or nil): Expected timeout in actions, or nil for none [default: nil]
|
139
|
+
def expected_actions_for_deploy_on(
|
140
|
+
services: { 'node' => %w[service] },
|
141
|
+
sudo: 'sudo -u root',
|
142
|
+
check_mode: @check_mode,
|
143
|
+
mocked_deploy_result: nil,
|
144
|
+
additional_expected_actions: [],
|
145
|
+
expect_concurrent_actions: false,
|
146
|
+
expect_actions_timeout: nil
|
147
|
+
)
|
148
|
+
actions = [
|
149
|
+
# First run, we expect the mutex to be setup, and the deployment actions to be run
|
150
|
+
proc do |actions_per_nodes, timeout: nil, concurrent: false, log_to_dir: 'run_logs', log_to_stdout: true|
|
151
|
+
expect(timeout).to eq expect_actions_timeout
|
152
|
+
expect(concurrent).to eq expect_concurrent_actions
|
153
|
+
expect(log_to_dir).to eq 'run_logs'
|
154
|
+
expect_actions_to_deploy_on(
|
155
|
+
actions_per_nodes,
|
156
|
+
services.keys,
|
157
|
+
check: check_mode,
|
158
|
+
sudo: sudo,
|
159
|
+
mocked_result: mocked_deploy_result,
|
160
|
+
expected_actions: additional_expected_actions
|
161
|
+
)
|
162
|
+
end,
|
163
|
+
# Second run, we expect the mutex to be released
|
164
|
+
proc { |actions_per_nodes| expect_actions_to_unlock(actions_per_nodes, services.keys, sudo: sudo) }
|
165
|
+
]
|
166
|
+
services.each do |node, node_services|
|
167
|
+
expect(test_services_handler).to receive(:actions_to_deploy_on).with(node, node_services, check_mode) do
|
168
|
+
[{ bash: "echo \"#{check_mode ? 'Checking' : 'Deploying'} on #{node}\"" }]
|
169
|
+
end
|
170
|
+
end
|
171
|
+
# Third run, we expect logs to be uploaded on the node (only if not check mode)
|
172
|
+
unless check_mode
|
173
|
+
services.each do |node, node_services|
|
174
|
+
expect(test_services_handler).to receive(:log_info_for).with(node, node_services).and_return(
|
175
|
+
repo_name_0: 'platform',
|
176
|
+
commit_id_0: '123456',
|
177
|
+
commit_message_0: 'Test commit'
|
178
|
+
)
|
179
|
+
end
|
180
|
+
actions << proc { |actions_per_nodes| expect_actions_to_upload_logs(actions_per_nodes, services.keys) }
|
181
|
+
end
|
182
|
+
actions
|
183
|
+
end
|
184
|
+
|
185
|
+
# Prepare a platform ready to test deployments on.
|
104
186
|
#
|
105
187
|
# Parameters::
|
106
|
-
# * *
|
107
|
-
# * *
|
108
|
-
# * *
|
109
|
-
# * *
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
188
|
+
# * *nodes_info* (Hash): Node info to give the platform [default: 1 node having 1 service]
|
189
|
+
# * *expect_services_to_deploy* (Hash<String,Array<String>>): Expected services to be deployed [default: all services from nodes_info]
|
190
|
+
# * *expect_deploy_allowed* (Boolean): Should we expect the call to deploy_allowed? [default: true]
|
191
|
+
# * *expect_package* (Boolean): Should we expect packaging? [default: true]
|
192
|
+
# * *expect_prepare_for_deploy* (Boolean): Should we expect calls to prepare for deploy? [default: true]
|
193
|
+
# * *expect_connections_to_nodes* (Boolean): Should we expect connections to nodes? [default: true]
|
194
|
+
# * *expect_default_actions* (Boolean): Should we expect default actions? [default: true]
|
195
|
+
# * *expect_sudo* (String or nil): Expected sudo command, or nil if none [default: 'sudo -u root']
|
196
|
+
# * *expect_secrets* (Hash): Secrets to be expected during deployment [default: {}]
|
197
|
+
# * *expect_local_environment* (Boolean): Expected local environment flag [default: false]
|
198
|
+
# * *expect_additional_actions* (Array): Additional expected actions [default: []]
|
199
|
+
# * *expect_concurrent_actions* (Boolean): Are actions expected to be run in parallel? [default: false]
|
200
|
+
# * *expect_actions_timeout* (Integer or nil): Expected timeout in actions, or nil for none [default: nil]
|
201
|
+
# * *check_mode* (Boolean): Are we testing in check mode? [default: @check_mode]
|
202
|
+
# * *additional_config* (String): Additional configuration to set [default: '']
|
203
|
+
# * Proc: Code called once the platform is ready for testing the deployer
|
204
|
+
# * Parameters::
|
205
|
+
# * *repository* (String): Path to the repository
|
206
|
+
def with_platform_to_deploy(
|
207
|
+
nodes_info: { nodes: { 'node' => { services: %w[service] } } },
|
208
|
+
expect_services_to_deploy: nodes_info[:nodes].transform_values { |node_info| node_info[:services] },
|
209
|
+
expect_deploy_allowed: true,
|
210
|
+
expect_package: true,
|
211
|
+
expect_prepare_for_deploy: true,
|
212
|
+
expect_connections_to_nodes: true,
|
213
|
+
expect_default_actions: true,
|
214
|
+
expect_sudo: 'sudo -u root',
|
215
|
+
expect_secrets: {},
|
216
|
+
expect_local_environment: false,
|
217
|
+
expect_additional_actions: [],
|
218
|
+
expect_concurrent_actions: false,
|
219
|
+
expect_actions_timeout: nil,
|
220
|
+
check_mode: @check_mode,
|
221
|
+
additional_config: ''
|
222
|
+
)
|
223
|
+
with_test_platform(nodes_info, as_git: !check_mode, additional_config: "#{additional_config}\nsend_logs_to :test_log") do |repository|
|
224
|
+
# Mock the ServicesHandler accesses
|
225
|
+
if !check_mode && expect_deploy_allowed
|
226
|
+
expect(test_services_handler).to receive(:deploy_allowed?).with(
|
227
|
+
services: expect_services_to_deploy,
|
228
|
+
local_environment: expect_local_environment
|
229
|
+
).and_return(nil)
|
230
|
+
end
|
231
|
+
if expect_package
|
232
|
+
expect(test_services_handler).to receive(:package).with(
|
233
|
+
services: expect_services_to_deploy,
|
234
|
+
secrets: expect_secrets,
|
235
|
+
local_environment: expect_local_environment
|
236
|
+
)
|
237
|
+
else
|
238
|
+
expect(test_services_handler).not_to receive(:package)
|
239
|
+
end
|
240
|
+
if expect_prepare_for_deploy
|
241
|
+
expect(test_services_handler).to receive(:prepare_for_deploy).with(
|
242
|
+
services: expect_services_to_deploy,
|
243
|
+
secrets: expect_secrets,
|
244
|
+
local_environment: expect_local_environment,
|
245
|
+
why_run: check_mode
|
246
|
+
)
|
247
|
+
else
|
248
|
+
expect(test_services_handler).not_to receive(:prepare_for_deploy)
|
249
|
+
end
|
250
|
+
test_deployer.use_why_run = true if check_mode
|
251
|
+
if expect_connections_to_nodes
|
252
|
+
with_connections_mocked_on(expect_services_to_deploy.keys) do
|
253
|
+
if expect_default_actions
|
254
|
+
expect_actions_executor_runs(
|
255
|
+
expected_actions_for_deploy_on(
|
256
|
+
services: expect_services_to_deploy,
|
257
|
+
check_mode: check_mode,
|
258
|
+
sudo: expect_sudo,
|
259
|
+
additional_expected_actions: expect_additional_actions,
|
260
|
+
expect_concurrent_actions: expect_concurrent_actions,
|
261
|
+
expect_actions_timeout: expect_actions_timeout
|
262
|
+
)
|
263
|
+
)
|
264
|
+
end
|
265
|
+
yield repository
|
266
|
+
end
|
128
267
|
else
|
129
|
-
|
268
|
+
yield repository
|
130
269
|
end
|
131
270
|
end
|
132
|
-
expect(lines[idx_stdout + 1..idx_stderr - 1].join("\n")).to eq stdout
|
133
|
-
expect(lines[idx_stderr + 1..-1].join("\n")).to eq stderr
|
134
271
|
end
|
135
272
|
|
136
|
-
#
|
273
|
+
# Prepare a directory with certificates
|
137
274
|
#
|
138
|
-
#
|
139
|
-
# *
|
140
|
-
|
141
|
-
|
142
|
-
|
275
|
+
# Parameters::
|
276
|
+
# * Proc: Code called with the directory created with a mocked certificate
|
277
|
+
# * Parameters::
|
278
|
+
# * *certs_dir* (String): Directory containing certificates
|
279
|
+
def with_certs_dir
|
280
|
+
with_repository do |repository|
|
281
|
+
certs_dir = "#{repository}/certificates"
|
282
|
+
FileUtils.mkdir_p certs_dir
|
283
|
+
File.write("#{certs_dir}/test_cert.crt", 'Hello')
|
284
|
+
yield certs_dir
|
285
|
+
end
|
286
|
+
end
|
287
|
+
|
288
|
+
# Prepare a platform ready to test deployments' retries on.
|
289
|
+
#
|
290
|
+
# Parameters::
|
291
|
+
# * *nodes_info* (Hash): Node info to give the platform [default: { nodes: { 'node' => {} } }]
|
292
|
+
# * *block* (Proc): Code called once the platform is ready for testing the deployer
|
293
|
+
# * Parameters::
|
294
|
+
# * *repository* (String): Path to the repository
|
295
|
+
def with_platform_to_retry_deploy(nodes_info: { nodes: { 'node' => { services: %w[service] } } }, &block)
|
296
|
+
with_platform_to_deploy(
|
297
|
+
nodes_info: nodes_info,
|
298
|
+
expect_default_actions: false,
|
299
|
+
additional_config: "
|
300
|
+
for_nodes([#{nodes_info[:nodes].keys.map { |node| "'#{node}'" }.join(', ')}]) do
|
301
|
+
retry_deploy_for_errors_on_stdout [
|
302
|
+
'stdout non-deterministic error'
|
303
|
+
]
|
304
|
+
retry_deploy_for_errors_on_stderr [
|
305
|
+
'stderr non-deterministic error',
|
306
|
+
/stderr regexp error \\d+/
|
307
|
+
]
|
308
|
+
end
|
309
|
+
for_nodes([#{nodes_info[:nodes].keys.map { |node| "'#{node}'" }.join(', ')}]) do
|
310
|
+
retry_deploy_for_errors_on_stdout [
|
311
|
+
/stdout regexp error \\d+/
|
312
|
+
]
|
313
|
+
end
|
314
|
+
",
|
315
|
+
&block
|
316
|
+
)
|
317
|
+
end
|
318
|
+
|
319
|
+
# Mock a sequential list of deployments
|
320
|
+
#
|
321
|
+
# Parameters::
|
322
|
+
# * *statuses* (Array<Hash<String,Status> or Status>)>): List of mocked deployment statuses per node name, or just the status for the default node.
|
323
|
+
# A status is a triplet [Integer or Symbol, String, String]: exit status, stdout and stderr.
|
324
|
+
def mock_deploys_with(statuses)
|
325
|
+
expect_actions_executor_runs(statuses.map do |status|
|
326
|
+
status = { 'node' => status } if status.is_a?(Array)
|
327
|
+
expected_actions_for_deploy_on(
|
328
|
+
services: status.keys.map { |node| [node, %w[service]] }.to_h,
|
329
|
+
mocked_deploy_result: status
|
330
|
+
)
|
331
|
+
end.flatten)
|
143
332
|
end
|
144
333
|
|
145
334
|
end
|
@@ -18,8 +18,8 @@ module HybridPlatformsConductorTest
|
|
18
18
|
stderr_file = "#{Dir.tmpdir}/hpc_test/run.stderr"
|
19
19
|
File.open(stdout_file, 'w') { |f| f.truncate(0) }
|
20
20
|
File.open(stderr_file, 'w') { |f| f.truncate(0) }
|
21
|
-
|
22
|
-
|
21
|
+
test_logger_stdout = Logger.new(stdout_file, level: :info)
|
22
|
+
test_logger_stderr = Logger.new(stderr_file, level: :info)
|
23
23
|
# Mock the Executable creation to redirect stdout and stderr correctly
|
24
24
|
expect(HybridPlatformsConductor::Executable).to receive(:new).once.and_wrap_original do |original_method,
|
25
25
|
check_options: true,
|
@@ -27,8 +27,8 @@ module HybridPlatformsConductorTest
|
|
27
27
|
parallel_options: true,
|
28
28
|
timeout_options: true,
|
29
29
|
deploy_options: true,
|
30
|
-
|
31
|
-
|
30
|
+
_logger: Logger.new($stdout, level: :info),
|
31
|
+
_logger_stderr: Logger.new($stderr, level: :info),
|
32
32
|
&opts_block|
|
33
33
|
original_method.call(
|
34
34
|
check_options: check_options,
|
@@ -36,8 +36,8 @@ module HybridPlatformsConductorTest
|
|
36
36
|
parallel_options: parallel_options,
|
37
37
|
timeout_options: timeout_options,
|
38
38
|
deploy_options: deploy_options,
|
39
|
-
logger:
|
40
|
-
logger_stderr:
|
39
|
+
logger: test_logger_stdout,
|
40
|
+
logger_stderr: test_logger_stderr,
|
41
41
|
&opts_block
|
42
42
|
)
|
43
43
|
end
|
@@ -53,18 +53,18 @@ module HybridPlatformsConductorTest
|
|
53
53
|
HybridPlatformsConductor::TestsRunner => test_tests_runner
|
54
54
|
}
|
55
55
|
# Make sure the tested components use the same loggers as the executable.
|
56
|
-
components_to_mock.
|
56
|
+
components_to_mock.each_value do |component|
|
57
57
|
component.stdout_device = stdout_file
|
58
58
|
component.stderr_device = stderr_file
|
59
59
|
end
|
60
60
|
# Make sure that when the executable creates components it uses ours
|
61
61
|
components_to_mock.each do |component_class, component|
|
62
|
-
allow(component_class).to
|
62
|
+
allow(component_class).to(receive(:new).once { component })
|
63
63
|
end
|
64
64
|
# Run the executable
|
65
65
|
args.concat(['--debug']) if ENV['TEST_DEBUG'] == '1'
|
66
66
|
ARGV.replace(args)
|
67
|
-
|
67
|
+
old_program_name = $PROGRAM_NAME
|
68
68
|
$0 = executable
|
69
69
|
begin
|
70
70
|
exit_code = nil
|
@@ -72,10 +72,10 @@ module HybridPlatformsConductorTest
|
|
72
72
|
load "#{__dir__}/../../../bin/#{executable}"
|
73
73
|
exit_code = 0
|
74
74
|
rescue SystemExit
|
75
|
-
exit_code =
|
75
|
+
exit_code = $ERROR_INFO.status
|
76
76
|
end
|
77
77
|
ensure
|
78
|
-
$0 =
|
78
|
+
$0 = old_program_name
|
79
79
|
end
|
80
80
|
stdout = File.read(stdout_file)
|
81
81
|
stderr = File.read(stderr_file)
|