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
@@ -9,7 +9,7 @@ module HybridPlatformsConductorTest
|
|
9
9
|
# Result::
|
10
10
|
# * NodesHandler: NodesHandler on which we can do testing
|
11
11
|
def test_nodes_handler
|
12
|
-
@nodes_handler
|
12
|
+
@nodes_handler ||= HybridPlatformsConductor::NodesHandler.new logger: logger, logger_stderr: logger, config: test_config, cmd_runner: test_cmd_runner, platforms_handler: test_platforms_handler
|
13
13
|
@nodes_handler
|
14
14
|
end
|
15
15
|
|
@@ -14,24 +14,24 @@ module HybridPlatformsConductorTest
|
|
14
14
|
# * Parameters::
|
15
15
|
# * *repositories* (Hash<String,String>): Path to the repositories, per repository name
|
16
16
|
def with_repositories(names = [], as_git: false)
|
17
|
-
repositories =
|
18
|
-
repositories.
|
17
|
+
repositories = names.map { |name| [name, "#{Dir.tmpdir}/hpc_test/#{name}"] }.to_h
|
18
|
+
repositories.each_value do |dir|
|
19
19
|
FileUtils.rm_rf dir
|
20
20
|
FileUtils.mkdir_p dir
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
21
|
+
next unless as_git
|
22
|
+
|
23
|
+
git = Git.init(dir)
|
24
|
+
FileUtils.touch("#{dir}/test_file")
|
25
|
+
git.add('test_file')
|
26
|
+
git.config('user.name', 'Thats Me')
|
27
|
+
git.config('user.email', 'email@email.com')
|
28
|
+
git.commit('Test commit')
|
29
|
+
git.add_remote('origin', "https://my_remote.com/path/to/#{File.basename(dir)}.git")
|
30
30
|
end
|
31
31
|
begin
|
32
32
|
yield repositories
|
33
33
|
ensure
|
34
|
-
repositories.
|
34
|
+
repositories.each_value do |dir|
|
35
35
|
FileUtils.rm_rf dir
|
36
36
|
end
|
37
37
|
end
|
@@ -73,21 +73,28 @@ module HybridPlatformsConductorTest
|
|
73
73
|
# Clean-up at the end.
|
74
74
|
#
|
75
75
|
# Parameters::
|
76
|
-
# * *platforms_info* (Hash<String,Object>): Platforms info for the test platform
|
77
|
-
# * *as_git* (Boolean): Do we initialize those repositories as Git repositories? [default
|
78
|
-
# * *
|
76
|
+
# * *platforms_info* (Hash<String,Object>): Platforms info for the test platform
|
77
|
+
# * *as_git* (Boolean): Do we initialize those repositories as Git repositories? [default: false]
|
78
|
+
# * *additional_config* (String): Additional config to be added [default: '']
|
79
79
|
# * Proc: Code called with the environment ready
|
80
80
|
# * Parameters::
|
81
81
|
# * *repositories* (Hash<String,String>): Path to the repositories, per repository name
|
82
|
-
def with_test_platforms(platforms_info
|
82
|
+
def with_test_platforms(platforms_info, as_git: false, additional_config: '')
|
83
83
|
with_repositories(platforms_info.keys, as_git: as_git) do |repositories|
|
84
84
|
platform_types = []
|
85
|
-
with_platforms(
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
85
|
+
with_platforms(
|
86
|
+
repositories.map do |platform, dir|
|
87
|
+
platform_type = platforms_info[platform].key?(:platform_type) ? platforms_info[platform][:platform_type] : :test
|
88
|
+
platform_types << platform_type unless platform_types.include?(platform_type)
|
89
|
+
"#{platform_type}_platform path: '#{dir}'"
|
90
|
+
end.join("\n") + "\n#{additional_config}"
|
91
|
+
) do
|
92
|
+
register_platform_handlers(platform_types.map do |platform_type|
|
93
|
+
[
|
94
|
+
platform_type,
|
95
|
+
HybridPlatformsConductorTest::PlatformHandlerPlugins.const_get(platform_type.to_s.split('_').collect(&:capitalize).join.to_sym)
|
96
|
+
]
|
97
|
+
end.to_h)
|
91
98
|
self.test_platforms_info = platforms_info
|
92
99
|
yield repositories
|
93
100
|
end
|
@@ -98,15 +105,19 @@ module HybridPlatformsConductorTest
|
|
98
105
|
# Clean-up at the end.
|
99
106
|
#
|
100
107
|
# Parameters::
|
101
|
-
# * *platform_info* (Hash<Symbol,Object>): Platform info for the test platform
|
102
|
-
# * *as_git* (Boolean): Do we initialize those repositories as Git repositories? [default
|
103
|
-
# * *
|
108
|
+
# * *platform_info* (Hash<Symbol,Object>): Platform info for the test platform
|
109
|
+
# * *as_git* (Boolean): Do we initialize those repositories as Git repositories? [default: false]
|
110
|
+
# * *additional_config* (String): Additional config to be added [default: '']
|
104
111
|
# * Proc: Code called with the environment ready
|
105
112
|
# * Parameters::
|
106
113
|
# * *repository* (String): Path to the repository
|
107
|
-
def with_test_platform(platform_info
|
114
|
+
def with_test_platform(platform_info, as_git: false, additional_config: '')
|
108
115
|
platform_name = as_git ? 'my_remote_platform' : 'platform'
|
109
|
-
with_test_platforms(
|
116
|
+
with_test_platforms(
|
117
|
+
{ platform_name => platform_info },
|
118
|
+
as_git: as_git,
|
119
|
+
additional_config: additional_config
|
120
|
+
) do |repositories|
|
110
121
|
yield repositories[platform_name]
|
111
122
|
end
|
112
123
|
end
|
@@ -116,7 +127,7 @@ module HybridPlatformsConductorTest
|
|
116
127
|
# Result::
|
117
128
|
# * PlatformsHandler: PlatformsHandler on which we can do testing
|
118
129
|
def test_platforms_handler
|
119
|
-
@platforms_handler
|
130
|
+
@platforms_handler ||= HybridPlatformsConductor::PlatformsHandler.new logger: logger, logger_stderr: logger, config: test_config, cmd_runner: test_cmd_runner
|
120
131
|
@platforms_handler
|
121
132
|
end
|
122
133
|
|
@@ -18,7 +18,7 @@ module HybridPlatformsConductorTest
|
|
18
18
|
# * *replace* (Boolean): Should we replace the plugins or add them?
|
19
19
|
# Hash< Symbol, Hash<Symbol, Object> >
|
20
20
|
@plugins_to_mock = {}
|
21
|
-
allow(HybridPlatformsConductor::Plugins).to receive(:new).and_wrap_original do |original_new, plugins_type, init_plugin: nil, parse_gems: true, logger: Logger.new(
|
21
|
+
allow(HybridPlatformsConductor::Plugins).to receive(:new).and_wrap_original do |original_new, plugins_type, init_plugin: nil, parse_gems: true, logger: Logger.new($stdout), logger_stderr: Logger.new($stderr)|
|
22
22
|
# If this plugin type is to be mocked, then don't parse gems and provide the mocked plugins instead
|
23
23
|
mocked_plugins = original_new.call(
|
24
24
|
plugins_type,
|
@@ -98,21 +98,17 @@ module HybridPlatformsConductorTest
|
|
98
98
|
expect(password).to eq proxmox_password
|
99
99
|
expect(realm).to eq proxmox_realm
|
100
100
|
expect(options[:verify_ssl]).to eq false
|
101
|
-
proxmox =
|
101
|
+
proxmox = instance_double ::Proxmox::Proxmox
|
102
102
|
# Mock initialization
|
103
|
-
expect(proxmox).to receive(:logger=)
|
104
|
-
|
105
|
-
end
|
106
|
-
expect(proxmox).to receive(:logger_stderr=) do
|
107
|
-
# Nothing
|
108
|
-
end
|
103
|
+
expect(proxmox).to receive(:logger=).and_return(nil)
|
104
|
+
expect(proxmox).to receive(:logger_stderr=).and_return(nil)
|
109
105
|
# Mock checking existing nodes
|
110
106
|
idx_try = 0
|
111
107
|
expect(proxmox).to receive(:get).exactly(nbr_api_errors + 1).times.with('nodes') do
|
112
108
|
idx_try += 1
|
113
109
|
idx_try <= nbr_api_errors ? 'NOK: error code = 500' : nodes_info
|
114
110
|
end
|
115
|
-
extra_expects
|
111
|
+
extra_expects&.call(proxmox)
|
116
112
|
proxmox
|
117
113
|
end
|
118
114
|
end
|
@@ -142,14 +138,10 @@ module HybridPlatformsConductorTest
|
|
142
138
|
expect(password).to eq proxmox_password
|
143
139
|
expect(realm).to eq 'pam'
|
144
140
|
expect(options[:verify_ssl]).to eq false
|
145
|
-
proxmox =
|
141
|
+
proxmox = instance_double ::Proxmox::Proxmox
|
146
142
|
# Mock initialization
|
147
|
-
expect(proxmox).to receive(:logger=)
|
148
|
-
|
149
|
-
end
|
150
|
-
expect(proxmox).to receive(:logger_stderr=) do
|
151
|
-
# Nothing
|
152
|
-
end
|
143
|
+
expect(proxmox).to receive(:logger=).and_return(nil)
|
144
|
+
expect(proxmox).to receive(:logger_stderr=).and_return(nil)
|
153
145
|
# Mock start a container
|
154
146
|
idx_try = 0
|
155
147
|
expect(proxmox).to receive(:post).exactly(nbr_api_errors + (task_status.nil? ? 0 : 1)).times.with('nodes/pve_node_name/lxc/1024/status/start') do
|
@@ -189,18 +181,12 @@ module HybridPlatformsConductorTest
|
|
189
181
|
expect(password).to eq proxmox_password
|
190
182
|
expect(realm).to eq 'pam'
|
191
183
|
expect(options[:verify_ssl]).to eq false
|
192
|
-
proxmox =
|
184
|
+
proxmox = instance_double ::Proxmox::Proxmox
|
193
185
|
# Mock initialization
|
194
|
-
expect(proxmox).to receive(:logger=)
|
195
|
-
|
196
|
-
end
|
197
|
-
expect(proxmox).to receive(:logger_stderr=) do
|
198
|
-
# Nothing
|
199
|
-
end
|
186
|
+
expect(proxmox).to receive(:logger=).and_return(nil)
|
187
|
+
expect(proxmox).to receive(:logger_stderr=).and_return(nil)
|
200
188
|
# Mock start a container
|
201
|
-
expect(proxmox).to receive(:post).with('nodes/pve_node_name/lxc/1024/status/stop')
|
202
|
-
'UPID:pve_node_name:0000A504:6DEABF24:5F44669B:stop::root@pam:'
|
203
|
-
end
|
189
|
+
expect(proxmox).to receive(:post).with('nodes/pve_node_name/lxc/1024/status/stop').and_return('UPID:pve_node_name:0000A504:6DEABF24:5F44669B:stop::root@pam:')
|
204
190
|
# Mock checking task status
|
205
191
|
expect(proxmox).to receive(:get).with('nodes/pve_node_name/tasks/UPID:pve_node_name:0000A504:6DEABF24:5F44669B:stop::root@pam:/status') do
|
206
192
|
{ 'status' => task_status }
|
@@ -230,18 +216,12 @@ module HybridPlatformsConductorTest
|
|
230
216
|
expect(password).to eq proxmox_password
|
231
217
|
expect(realm).to eq 'pam'
|
232
218
|
expect(options[:verify_ssl]).to eq false
|
233
|
-
proxmox =
|
219
|
+
proxmox = instance_double ::Proxmox::Proxmox
|
234
220
|
# Mock initialization
|
235
|
-
expect(proxmox).to receive(:logger=)
|
236
|
-
|
237
|
-
end
|
238
|
-
expect(proxmox).to receive(:logger_stderr=) do
|
239
|
-
# Nothing
|
240
|
-
end
|
221
|
+
expect(proxmox).to receive(:logger=).and_return(nil)
|
222
|
+
expect(proxmox).to receive(:logger_stderr=).and_return(nil)
|
241
223
|
# Mock start a container
|
242
|
-
expect(proxmox).to receive(:delete).with('nodes/pve_node_name/lxc/1024')
|
243
|
-
'UPID:pve_node_name:0000A504:6DEABF24:5F44669B:destroy::root@pam:'
|
244
|
-
end
|
224
|
+
expect(proxmox).to receive(:delete).with('nodes/pve_node_name/lxc/1024').and_return('UPID:pve_node_name:0000A504:6DEABF24:5F44669B:destroy::root@pam:')
|
245
225
|
# Mock checking task status
|
246
226
|
expect(proxmox).to receive(:get).with('nodes/pve_node_name/tasks/UPID:pve_node_name:0000A504:6DEABF24:5F44669B:destroy::root@pam:/status') do
|
247
227
|
{ 'status' => task_status }
|
@@ -273,14 +253,10 @@ module HybridPlatformsConductorTest
|
|
273
253
|
expect(password).to eq proxmox_password
|
274
254
|
expect(realm).to eq 'pam'
|
275
255
|
expect(options[:verify_ssl]).to eq false
|
276
|
-
proxmox =
|
256
|
+
proxmox = instance_double ::Proxmox::Proxmox
|
277
257
|
# Mock initialization
|
278
|
-
expect(proxmox).to receive(:logger=)
|
279
|
-
|
280
|
-
end
|
281
|
-
expect(proxmox).to receive(:logger_stderr=) do
|
282
|
-
# Nothing
|
283
|
-
end
|
258
|
+
expect(proxmox).to receive(:logger=).and_return(nil)
|
259
|
+
expect(proxmox).to receive(:logger_stderr=).and_return(nil)
|
284
260
|
# Mock getting status of a container
|
285
261
|
idx_try = 0
|
286
262
|
expect(proxmox).to receive(:get).exactly(nbr_api_errors + (status.nil? ? 0 : 1)).times.with('nodes/pve_node_name/lxc') do
|
@@ -307,6 +283,9 @@ module HybridPlatformsConductorTest
|
|
307
283
|
end
|
308
284
|
end
|
309
285
|
|
286
|
+
# Give access to the actions that have been called on the mocked Proxmox instances
|
287
|
+
attr_reader(*%i[proxmox_actions proxmox_create_options proxmox_destroy_options])
|
288
|
+
|
310
289
|
# Mock a call to the reserve_proxmox_container sync node
|
311
290
|
#
|
312
291
|
# Parameters::
|
@@ -334,24 +313,24 @@ module HybridPlatformsConductorTest
|
|
334
313
|
expect(actions['node'].size).to eq 4
|
335
314
|
# First action should be to copy the reserve_proxmox_container code
|
336
315
|
expect(actions['node'][0].keys).to eq [:scp]
|
337
|
-
expect(actions['node'][0][:scp].first[0]).to match
|
316
|
+
expect(actions['node'][0][:scp].first[0]).to match(%r{^.+/hpc_plugins/provisioner/proxmox/$})
|
338
317
|
expect(actions['node'][0][:scp].first[1]).to eq '.'
|
339
318
|
# Second action should be to create directories
|
340
|
-
expect(actions['node'][1]).to eq(
|
319
|
+
expect(actions['node'][1]).to eq(
|
341
320
|
remote_bash: "mkdir -p ./proxmox/config\nmkdir -p ./proxmox/create"
|
342
|
-
|
321
|
+
)
|
343
322
|
# Next actions should be to copy the config/create/destroy files
|
344
323
|
expect(actions['node'][2].keys).to eq [:scp]
|
345
|
-
expect(actions['node'][2][:scp].first[0]).to match
|
324
|
+
expect(actions['node'][2][:scp].first[0]).to match(%r{^.+/create_#{Regexp.escape(expected_file_id)}\.json$})
|
346
325
|
expect(actions['node'][2][:scp].first[1]).to eq './proxmox/create'
|
347
326
|
expect(actions['node'][3].keys).to eq [:scp]
|
348
|
-
expect(actions['node'][3][:scp].first[0]).to match
|
327
|
+
expect(actions['node'][3][:scp].first[0]).to match(%r{^.+/config_#{Regexp.escape(expected_file_id)}\.json$})
|
349
328
|
expect(actions['node'][3][:scp].first[1]).to eq './proxmox/config'
|
350
329
|
@proxmox_create_options = JSON.parse(File.read(actions['node'][2][:scp].first[0]))
|
351
330
|
{ 'node' => [0, '', ''] }
|
352
331
|
end,
|
353
332
|
proc do |actions|
|
354
|
-
expect(actions).to eq(
|
333
|
+
expect(actions).to eq(
|
355
334
|
'node' => {
|
356
335
|
remote_bash: {
|
357
336
|
commands: "#{expected_sudo ? 'sudo -u root -E ' : ''}./proxmox/reserve_proxmox_container --create ./proxmox/create/create_#{expected_file_id}.json --config ./proxmox/config/config_#{expected_file_id}.json",
|
@@ -362,7 +341,7 @@ module HybridPlatformsConductorTest
|
|
362
341
|
}
|
363
342
|
}
|
364
343
|
}
|
365
|
-
|
344
|
+
)
|
366
345
|
result =
|
367
346
|
if error_on_create
|
368
347
|
{ error: error_on_create }
|
@@ -373,10 +352,10 @@ module HybridPlatformsConductorTest
|
|
373
352
|
vm_ip: '192.168.0.100'
|
374
353
|
}
|
375
354
|
end
|
376
|
-
{ 'node' => [0, <<~
|
355
|
+
{ 'node' => [0, <<~EO_STDOUT, ''] }
|
377
356
|
===== JSON =====
|
378
357
|
#{JSON.pretty_generate(result)}
|
379
|
-
|
358
|
+
EO_STDOUT
|
380
359
|
end
|
381
360
|
]
|
382
361
|
if destroy_vm
|
@@ -386,24 +365,24 @@ module HybridPlatformsConductorTest
|
|
386
365
|
expect(actions['node'].size).to eq 4
|
387
366
|
# First action should be to copy the reserve_proxmox_container code
|
388
367
|
expect(actions['node'][0].keys).to eq [:scp]
|
389
|
-
expect(actions['node'][0][:scp].first[0]).to match
|
368
|
+
expect(actions['node'][0][:scp].first[0]).to match(%r{^.+/hpc_plugins/provisioner/proxmox/$})
|
390
369
|
expect(actions['node'][0][:scp].first[1]).to eq '.'
|
391
370
|
# Second action should be to create directories
|
392
|
-
expect(actions['node'][1]).to eq(
|
371
|
+
expect(actions['node'][1]).to eq(
|
393
372
|
remote_bash: "mkdir -p ./proxmox/config\nmkdir -p ./proxmox/destroy"
|
394
|
-
|
373
|
+
)
|
395
374
|
# Next actions should be to copy the config/create/destroy files
|
396
375
|
expect(actions['node'][2].keys).to eq [:scp]
|
397
|
-
expect(actions['node'][2][:scp].first[0]).to match
|
376
|
+
expect(actions['node'][2][:scp].first[0]).to match(%r{^.+/destroy_#{Regexp.escape(expected_file_id)}\.json$})
|
398
377
|
expect(actions['node'][2][:scp].first[1]).to eq './proxmox/destroy'
|
399
378
|
expect(actions['node'][3].keys).to eq [:scp]
|
400
|
-
expect(actions['node'][3][:scp].first[0]).to match
|
379
|
+
expect(actions['node'][3][:scp].first[0]).to match(%r{^.+/config_#{Regexp.escape(expected_file_id)}\.json$})
|
401
380
|
expect(actions['node'][3][:scp].first[1]).to eq './proxmox/config'
|
402
381
|
@proxmox_destroy_options = JSON.parse(File.read(actions['node'][2][:scp].first[0]))
|
403
382
|
{ 'node' => [0, '', ''] }
|
404
383
|
end,
|
405
384
|
proc do |actions|
|
406
|
-
expect(actions).to eq(
|
385
|
+
expect(actions).to eq(
|
407
386
|
'node' => {
|
408
387
|
remote_bash: {
|
409
388
|
commands: "#{expected_sudo ? 'sudo -u root -E ' : ''}./proxmox/reserve_proxmox_container --destroy ./proxmox/destroy/destroy_#{expected_file_id}.json --config ./proxmox/config/config_#{expected_file_id}.json",
|
@@ -414,7 +393,7 @@ module HybridPlatformsConductorTest
|
|
414
393
|
}
|
415
394
|
}
|
416
395
|
}
|
417
|
-
|
396
|
+
)
|
418
397
|
result =
|
419
398
|
if error_on_destroy
|
420
399
|
{ error: error_on_destroy }
|
@@ -425,10 +404,10 @@ module HybridPlatformsConductorTest
|
|
425
404
|
vm_ip: '192.168.0.100'
|
426
405
|
}
|
427
406
|
end
|
428
|
-
{ 'node' => [0, <<~
|
407
|
+
{ 'node' => [0, <<~EO_STDOUT, ''] }
|
429
408
|
===== JSON =====
|
430
409
|
#{JSON.pretty_generate(result)}
|
431
|
-
|
410
|
+
EO_STDOUT
|
432
411
|
end
|
433
412
|
]
|
434
413
|
end
|
@@ -515,8 +494,8 @@ module HybridPlatformsConductorTest
|
|
515
494
|
mock_proxmox_calls_with(
|
516
495
|
mocked_pve_nodes.map do |pve_nodes|
|
517
496
|
# Complete pve_nodes with default values
|
518
|
-
pve_nodes =
|
519
|
-
pve_node_info[:lxc_containers] =
|
497
|
+
pve_nodes = pve_nodes.map do |pve_node_name, pve_node_info|
|
498
|
+
pve_node_info[:lxc_containers] = (pve_node_info.key?(:lxc_containers) ? pve_node_info[:lxc_containers] : {}).map do |vm_id, vm_info|
|
520
499
|
[
|
521
500
|
vm_id,
|
522
501
|
{
|
@@ -531,7 +510,7 @@ module HybridPlatformsConductorTest
|
|
531
510
|
environment: 'test_env'
|
532
511
|
}.merge(vm_info)
|
533
512
|
]
|
534
|
-
end
|
513
|
+
end.to_h
|
535
514
|
[
|
536
515
|
pve_node_name,
|
537
516
|
{
|
@@ -540,7 +519,7 @@ module HybridPlatformsConductorTest
|
|
540
519
|
storage_total: 100 * 1024 * 1024 * 1024
|
541
520
|
}.merge(pve_node_info)
|
542
521
|
]
|
543
|
-
end
|
522
|
+
end.to_h
|
544
523
|
proc do |url, pve_node, user, password, realm, options|
|
545
524
|
expect(url).to eq 'https://my-proxmox.my-domain.com:8006/api2/json/'
|
546
525
|
expect(pve_node).to eq 'my-proxmox'
|
@@ -548,30 +527,30 @@ module HybridPlatformsConductorTest
|
|
548
527
|
expect(password).to eq proxmox_password
|
549
528
|
expect(realm).to eq proxmox_realm
|
550
529
|
expect(options[:verify_ssl]).to eq false
|
551
|
-
proxmox =
|
530
|
+
proxmox = instance_double ::Proxmox::Proxmox
|
552
531
|
# Mock getting status of a container
|
553
532
|
allow(proxmox).to receive(:get) do |path|
|
554
533
|
case path
|
555
534
|
when 'nodes'
|
556
535
|
pve_nodes.keys.map { |pve_node_name| { 'node' => pve_node_name } }
|
557
|
-
when
|
558
|
-
pve_node_name =
|
536
|
+
when %r{^nodes/([^/]+)/status$}
|
537
|
+
pve_node_name = Regexp.last_match(1)
|
559
538
|
{
|
560
539
|
'loadavg' => pve_nodes[pve_node_name][:loadavg].map(&:to_s),
|
561
540
|
'memory' => {
|
562
541
|
'total' => pve_nodes[pve_node_name][:memory_total]
|
563
542
|
}
|
564
543
|
}
|
565
|
-
when
|
566
|
-
pve_node_name =
|
544
|
+
when %r{^nodes/([^/]+)/storage$}
|
545
|
+
pve_node_name = Regexp.last_match(1)
|
567
546
|
[
|
568
547
|
{
|
569
548
|
'storage' => 'local-lvm',
|
570
549
|
'total' => pve_nodes[pve_node_name][:storage_total]
|
571
550
|
}
|
572
551
|
]
|
573
|
-
when
|
574
|
-
pve_node_name =
|
552
|
+
when %r{^nodes/([^/]+)/lxc$}
|
553
|
+
pve_node_name = Regexp.last_match(1)
|
575
554
|
if pve_nodes[pve_node_name][:error_strings].nil? || pve_nodes[pve_node_name][:error_strings].empty?
|
576
555
|
pve_nodes[pve_node_name][:lxc_containers].map do |vm_id, vm_info|
|
577
556
|
{
|
@@ -584,28 +563,26 @@ module HybridPlatformsConductorTest
|
|
584
563
|
else
|
585
564
|
pve_nodes[pve_node_name][:error_strings].shift
|
586
565
|
end
|
587
|
-
when
|
588
|
-
pve_node_name =
|
589
|
-
vmid =
|
566
|
+
when %r{^nodes/([^/]+)/lxc/([^/]+)/config$}
|
567
|
+
pve_node_name = Regexp.last_match(1)
|
568
|
+
vmid = Regexp.last_match(2)
|
590
569
|
{
|
591
570
|
'net0' => "ip=#{pve_nodes[pve_node_name][:lxc_containers][Integer(vmid)][:ip]}/32",
|
592
|
-
'description' => <<~
|
571
|
+
'description' => <<~EO_DESCRIPTION
|
593
572
|
===== HPC info =====
|
594
573
|
node: #{pve_nodes[pve_node_name][:lxc_containers][Integer(vmid)][:node]}
|
595
574
|
environment: #{pve_nodes[pve_node_name][:lxc_containers][Integer(vmid)][:environment]}
|
596
575
|
debug: #{pve_nodes[pve_node_name][:lxc_containers][Integer(vmid)][:debug] ? 'true' : 'false'}
|
597
576
|
creation_date: #{pve_nodes[pve_node_name][:lxc_containers][Integer(vmid)][:creation_date].strftime('%FT%T')}
|
598
|
-
|
577
|
+
EO_DESCRIPTION
|
599
578
|
}
|
600
|
-
when
|
601
|
-
pve_node_name =
|
602
|
-
vmid =
|
579
|
+
when %r{^nodes/([^/]+)/lxc/([^/]+)/status/current$}
|
580
|
+
pve_node_name = Regexp.last_match(1)
|
581
|
+
vmid = Regexp.last_match(2)
|
603
582
|
{
|
604
583
|
'status' => pve_nodes[pve_node_name][:lxc_containers][Integer(vmid)][:status]
|
605
584
|
}
|
606
|
-
when
|
607
|
-
pve_node_name = $1
|
608
|
-
task = $2
|
585
|
+
when %r{^nodes/[^/]+/tasks/[^/]+/status$}
|
609
586
|
# Mock tasks completion
|
610
587
|
{
|
611
588
|
'status' => 'OK'
|
@@ -618,12 +595,12 @@ module HybridPlatformsConductorTest
|
|
618
595
|
allow(proxmox).to receive(:post) do |path, args|
|
619
596
|
@proxmox_actions << [:post, path, args].compact
|
620
597
|
case path
|
621
|
-
when
|
622
|
-
pve_node_name =
|
598
|
+
when %r{^nodes/([^/]+)/lxc$}
|
599
|
+
pve_node_name = Regexp.last_match(1)
|
623
600
|
"UPID:#{pve_node_name}:0000A504:6DEABF24:5F44669B:create::root@pam:"
|
624
|
-
when
|
625
|
-
pve_node_name =
|
626
|
-
vmid =
|
601
|
+
when %r{^nodes/([^/]+)/lxc/([^/]+)/status/stop$}
|
602
|
+
pve_node_name = Regexp.last_match(1)
|
603
|
+
vmid = Regexp.last_match(2)
|
627
604
|
"UPID:#{pve_node_name}:0000A504:6DEABF24:5F44669B:stop_#{vmid}::root@pam:"
|
628
605
|
else
|
629
606
|
raise "Unknown Proxmox API post call: #{path}. Please adapt the test framework."
|
@@ -633,9 +610,9 @@ module HybridPlatformsConductorTest
|
|
633
610
|
allow(proxmox).to receive(:delete) do |path|
|
634
611
|
@proxmox_actions << [:delete, path]
|
635
612
|
case path
|
636
|
-
when
|
637
|
-
pve_node_name =
|
638
|
-
vmid =
|
613
|
+
when %r{^nodes/([^/]+)/lxc/([^/]+)$}
|
614
|
+
pve_node_name = Regexp.last_match(1)
|
615
|
+
vmid = Regexp.last_match(2)
|
639
616
|
# Make sure we delete the mocked information as well
|
640
617
|
pve_nodes[pve_node_name][:lxc_containers].delete(Integer(vmid))
|
641
618
|
"UPID:#{pve_node_name}:0000A504:6DEABF24:5F44669B:destroy_#{vmid}::root@pam:"
|
@@ -668,9 +645,9 @@ module HybridPlatformsConductorTest
|
|
668
645
|
case dir
|
669
646
|
when '/sys/fs/cgroup/*/lxc/*'
|
670
647
|
block.nil? ? remaining_leftovers : remaining_leftovers.each(&block)
|
671
|
-
when
|
672
|
-
vm_id_str =
|
673
|
-
file_pattern =
|
648
|
+
when %r{^/sys/fs/cgroup/\*/lxc/(.+)$}
|
649
|
+
vm_id_str = Regexp.last_match(1)
|
650
|
+
file_pattern = %r{^/sys/fs/cgroup/.+/lxc/#{Regexp.escape(vm_id_str)}$}
|
674
651
|
matched_files = remaining_leftovers.select { |file| file =~ file_pattern }
|
675
652
|
block.nil? ? matched_files : matched_files.each(&block)
|
676
653
|
else
|
@@ -760,17 +737,15 @@ module HybridPlatformsConductorTest
|
|
760
737
|
$stdout = StringIO.new unless logger.debug?
|
761
738
|
begin
|
762
739
|
load "#{@repository}/proxmox/reserve_proxmox_container"
|
763
|
-
if logger.debug?
|
764
|
-
|
765
|
-
|
766
|
-
@stdout = $stdout.string
|
767
|
-
end
|
740
|
+
raise 'This test can\'t run in debug mode.' if logger.debug?
|
741
|
+
|
742
|
+
@stdout = $stdout.string
|
768
743
|
ensure
|
769
744
|
ARGV.replace old_argv
|
770
745
|
$stdout = old_stdout
|
771
746
|
end
|
772
747
|
stdout_lines = @stdout.split("\n")
|
773
|
-
JSON.parse(stdout_lines[stdout_lines.index('===== JSON =====') + 1
|
748
|
+
JSON.parse(stdout_lines[stdout_lines.index('===== JSON =====') + 1..].join("\n")).transform_keys(&:to_sym)
|
774
749
|
end
|
775
750
|
|
776
751
|
# Call the reserve_proxmox_container script and get its result as JSON.
|
@@ -839,26 +814,26 @@ module HybridPlatformsConductorTest
|
|
839
814
|
# Parameters::
|
840
815
|
# * *expected_proxmox_actions* (Array<Array>): Expected Proxmox actions
|
841
816
|
def expect_proxmox_actions_to_be(expected_proxmox_actions)
|
842
|
-
expect(@proxmox_actions.size).to eq(expected_proxmox_actions.size), <<~
|
817
|
+
expect(@proxmox_actions.size).to eq(expected_proxmox_actions.size), <<~EO_ERROR_MESSAGE
|
843
818
|
Expected #{expected_proxmox_actions.size} Proxmox actions, but got #{@proxmox_actions.size} instead:
|
844
819
|
----- Received:
|
845
820
|
#{@proxmox_actions.map(&:inspect).join("\n")}
|
846
821
|
----- Expected:
|
847
822
|
#{expected_proxmox_actions.map(&:inspect).join("\n")}
|
848
|
-
|
823
|
+
EO_ERROR_MESSAGE
|
849
824
|
@proxmox_actions.zip(expected_proxmox_actions).each do |proxmox_action, expected_proxmox_action|
|
850
825
|
expect(proxmox_action.size).to eq expected_proxmox_action.size
|
851
826
|
expect(proxmox_action[0..1]).to eq expected_proxmox_action[0..1]
|
852
|
-
if proxmox_action.size
|
853
|
-
|
854
|
-
|
855
|
-
|
856
|
-
|
857
|
-
|
858
|
-
|
859
|
-
|
860
|
-
|
861
|
-
|
827
|
+
next if proxmox_action.size < 3
|
828
|
+
|
829
|
+
# The third argument is a Hash that might have Regexp in the expectation
|
830
|
+
expect(proxmox_action[2].keys.sort).to eq expected_proxmox_action[2].keys.sort
|
831
|
+
proxmox_action[2].each do |property, value|
|
832
|
+
expected_value = expected_proxmox_action[2][property]
|
833
|
+
if expected_value.is_a?(Regexp)
|
834
|
+
expect(value).to match expected_value
|
835
|
+
else
|
836
|
+
expect(value).to eq expected_value
|
862
837
|
end
|
863
838
|
end
|
864
839
|
end
|