hybrid_platforms_conductor 32.16.2 → 32.18.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +48 -0
- data/README.md +3 -0
- data/bin/last_deploys +4 -1
- data/bin/nodes_to_deploy +5 -5
- data/docs/config_dsl.md +22 -0
- 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 +26 -0
- data/docs/plugins/connector/ssh.md +1 -1
- data/docs/plugins/log/remote_fs.md +26 -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/actions_executor.rb +8 -1
- data/lib/hybrid_platforms_conductor/common_config_dsl/github.rb +62 -0
- data/lib/hybrid_platforms_conductor/deployer.rb +97 -105
- data/lib/hybrid_platforms_conductor/hpc_plugins/connector/ssh.rb +3 -3
- 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 +179 -0
- data/lib/hybrid_platforms_conductor/hpc_plugins/platform_handler/serverless_chef.rb +2 -2
- data/lib/hybrid_platforms_conductor/hpc_plugins/test/check_deploy_and_idempotence.rb +1 -1
- data/lib/hybrid_platforms_conductor/hpc_plugins/test/connection.rb +3 -1
- data/lib/hybrid_platforms_conductor/hpc_plugins/test/deploy_freshness.rb +7 -20
- data/lib/hybrid_platforms_conductor/hpc_plugins/test/deploy_removes_root_access.rb +1 -1
- data/lib/hybrid_platforms_conductor/hpc_plugins/test/file_system.rb +2 -1
- data/lib/hybrid_platforms_conductor/hpc_plugins/test/github_ci.rb +32 -0
- data/lib/hybrid_platforms_conductor/hpc_plugins/test/hostname.rb +3 -1
- data/lib/hybrid_platforms_conductor/hpc_plugins/test/ip.rb +3 -1
- data/lib/hybrid_platforms_conductor/hpc_plugins/test/local_users.rb +3 -1
- data/lib/hybrid_platforms_conductor/hpc_plugins/test/mounts.rb +3 -1
- data/lib/hybrid_platforms_conductor/hpc_plugins/test/orphan_files.rb +3 -1
- data/lib/hybrid_platforms_conductor/hpc_plugins/test/ports.rb +3 -1
- data/lib/hybrid_platforms_conductor/hpc_plugins/test/spectre.rb +3 -1
- data/lib/hybrid_platforms_conductor/hpc_plugins/test/vulnerabilities.rb +2 -1
- data/lib/hybrid_platforms_conductor/log.rb +31 -0
- data/lib/hybrid_platforms_conductor/test_only_remote_node.rb +18 -0
- data/lib/hybrid_platforms_conductor/version.rb +1 -1
- data/spec/hybrid_platforms_conductor_test.rb +22 -6
- data/spec/hybrid_platforms_conductor_test/api/actions_executor/connectors/ssh/connections_spec.rb +3 -3
- data/spec/hybrid_platforms_conductor_test/api/deployer/config_dsl_spec.rb +24 -4
- data/spec/hybrid_platforms_conductor_test/api/deployer/deploy_spec.rb +187 -212
- data/spec/hybrid_platforms_conductor_test/api/deployer/log_plugins/remote_fs_spec.rb +223 -0
- data/spec/hybrid_platforms_conductor_test/api/deployer/provisioner_spec.rb +4 -4
- data/spec/hybrid_platforms_conductor_test/api/platform_handlers/serverless_chef/packaging_spec.rb +2 -2
- data/spec/hybrid_platforms_conductor_test/api/tests_runner/global_spec.rb +1 -1
- data/spec/hybrid_platforms_conductor_test/api/tests_runner/test_plugins/github_ci_spec.rb +72 -0
- data/spec/hybrid_platforms_conductor_test/executables/last_deploys_spec.rb +146 -98
- data/spec/hybrid_platforms_conductor_test/executables/nodes_to_deploy_spec.rb +240 -83
- data/spec/hybrid_platforms_conductor_test/executables/options/common_spec.rb +2 -1
- data/spec/hybrid_platforms_conductor_test/helpers/connector_ssh_helpers.rb +1 -1
- data/spec/hybrid_platforms_conductor_test/helpers/deployer_helpers.rb +40 -53
- data/spec/hybrid_platforms_conductor_test/helpers/deployer_test_helpers.rb +2 -2
- data/spec/hybrid_platforms_conductor_test/test_log_no_read_plugin.rb +82 -0
- data/spec/hybrid_platforms_conductor_test/test_log_plugin.rb +103 -0
- metadata +30 -2
@@ -0,0 +1,18 @@
|
|
1
|
+
module HybridPlatformsConductor
|
2
|
+
|
3
|
+
# Ancestor for all tests that should be run just on remote nodes
|
4
|
+
class TestOnlyRemoteNode < Test
|
5
|
+
|
6
|
+
# Limit the list of nodes for these tests.
|
7
|
+
#
|
8
|
+
# Result::
|
9
|
+
# * Array<String or Regex> or nil: List of nodes allowed for this test, or nil for all. Regular expressions matching node names can also be used.
|
10
|
+
def self.only_on_nodes
|
11
|
+
# Just 1 node per service and platform
|
12
|
+
Test.nodes_handler.prefetch_metadata_of Test.nodes_handler.known_nodes, :local_node
|
13
|
+
Test.nodes_handler.known_nodes.select { |node| !Test.nodes_handler.get_local_node_of(node) }
|
14
|
+
end
|
15
|
+
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
@@ -5,6 +5,7 @@ require 'hybrid_platforms_conductor/platforms_handler'
|
|
5
5
|
require 'hybrid_platforms_conductor/actions_executor'
|
6
6
|
require 'hybrid_platforms_conductor/cmd_runner'
|
7
7
|
require 'hybrid_platforms_conductor/deployer'
|
8
|
+
require 'hybrid_platforms_conductor/log'
|
8
9
|
require 'hybrid_platforms_conductor/nodes_handler'
|
9
10
|
require 'hybrid_platforms_conductor/platform_handler'
|
10
11
|
require 'hybrid_platforms_conductor/provisioner'
|
@@ -43,6 +44,8 @@ require 'hybrid_platforms_conductor_test/platform_handler_plugins/test2'
|
|
43
44
|
require 'hybrid_platforms_conductor_test/report_plugin'
|
44
45
|
require 'hybrid_platforms_conductor_test/test_action'
|
45
46
|
require 'hybrid_platforms_conductor_test/test_connector'
|
47
|
+
require 'hybrid_platforms_conductor_test/test_log_plugin'
|
48
|
+
require 'hybrid_platforms_conductor_test/test_log_no_read_plugin'
|
46
49
|
require 'hybrid_platforms_conductor_test/test_plugins/global'
|
47
50
|
require 'hybrid_platforms_conductor_test/test_plugins/node'
|
48
51
|
require 'hybrid_platforms_conductor_test/test_plugins/node_check'
|
@@ -128,16 +131,29 @@ module HybridPlatformsConductorTest
|
|
128
131
|
HybridPlatformsConductorTest::TestPlugins::NodeCheck.only_on_platform_types = nil
|
129
132
|
HybridPlatformsConductorTest::TestPlugins::NodeCheck.only_on_nodes = nil
|
130
133
|
HybridPlatformsConductorTest::TestPlugins::SeveralChecks.runs = []
|
134
|
+
HybridPlatformsConductorTest::TestLogPlugin.calls = []
|
135
|
+
HybridPlatformsConductorTest::TestLogNoReadPlugin.calls = []
|
131
136
|
FileUtils.rm_rf './run_logs'
|
132
137
|
FileUtils.rm_rf './testadmin.key.pub'
|
133
138
|
FileUtils.rm_rf '/tmp/hpc_ssh'
|
139
|
+
register_plugins(
|
140
|
+
:log,
|
141
|
+
{
|
142
|
+
test_log: HybridPlatformsConductorTest::TestLogPlugin,
|
143
|
+
test_log_no_read: HybridPlatformsConductorTest::TestLogNoReadPlugin
|
144
|
+
},
|
145
|
+
replace: false
|
146
|
+
)
|
134
147
|
# Make sure CMDB plugin classes loaded by test framework are not added automatically
|
135
|
-
register_plugins(
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
148
|
+
register_plugins(
|
149
|
+
:cmdb,
|
150
|
+
{
|
151
|
+
config: HybridPlatformsConductor::HpcPlugins::Cmdb::Config,
|
152
|
+
host_ip: HybridPlatformsConductor::HpcPlugins::Cmdb::HostIp,
|
153
|
+
host_keys: HybridPlatformsConductor::HpcPlugins::Cmdb::HostKeys,
|
154
|
+
platform_handlers: HybridPlatformsConductor::HpcPlugins::Cmdb::PlatformHandlers
|
155
|
+
}
|
156
|
+
)
|
141
157
|
end
|
142
158
|
end
|
143
159
|
|
data/spec/hybrid_platforms_conductor_test/api/actions_executor/connectors/ssh/connections_spec.rb
CHANGED
@@ -29,7 +29,7 @@ describe HybridPlatformsConductor::ActionsExecutor do
|
|
29
29
|
end
|
30
30
|
|
31
31
|
it 'creates an SSH master to 1 node not having Session Exec capabilities' do
|
32
|
-
with_test_platform(nodes: { 'node' => { meta: { host_ip: '192.168.42.42', ssh_session_exec:
|
32
|
+
with_test_platform(nodes: { 'node' => { meta: { host_ip: '192.168.42.42', ssh_session_exec: false } } }) do
|
33
33
|
with_cmd_runner_mocked(
|
34
34
|
[
|
35
35
|
['which env', proc { [0, "/usr/bin/env\n", ''] }],
|
@@ -45,7 +45,7 @@ describe HybridPlatformsConductor::ActionsExecutor do
|
|
45
45
|
end
|
46
46
|
|
47
47
|
it 'can\'t create an SSH master to 1 node not having Session Exec capabilities when hpc_interactive is false' do
|
48
|
-
with_test_platform(nodes: { 'node' => { meta: { host_ip: '192.168.42.42', ssh_session_exec:
|
48
|
+
with_test_platform(nodes: { 'node' => { meta: { host_ip: '192.168.42.42', ssh_session_exec: false } } }) do
|
49
49
|
ENV['hpc_interactive'] = 'false'
|
50
50
|
with_cmd_runner_mocked(
|
51
51
|
[
|
@@ -69,7 +69,7 @@ describe HybridPlatformsConductor::ActionsExecutor do
|
|
69
69
|
it 'fails without creating exception when creating an SSH master to 1 node not having Session Exec capabilities when hpc_interactive is false and we use no_exception' do
|
70
70
|
with_test_platform(nodes: {
|
71
71
|
'node1' => { meta: { host_ip: '192.168.42.1' } },
|
72
|
-
'node2' => { meta: { host_ip: '192.168.42.2', ssh_session_exec:
|
72
|
+
'node2' => { meta: { host_ip: '192.168.42.2', ssh_session_exec: false } },
|
73
73
|
'node3' => { meta: { host_ip: '192.168.42.3' } }
|
74
74
|
}) do
|
75
75
|
ENV['hpc_interactive'] = 'false'
|
@@ -3,10 +3,30 @@ describe HybridPlatformsConductor::Deployer do
|
|
3
3
|
context 'checking deployer specific config DSL' do
|
4
4
|
|
5
5
|
it 'declares a packaging timeout' do
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
6
|
+
with_platforms('packaging_timeout 666') do
|
7
|
+
expect(test_config.packaging_timeout_secs).to eq 666
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
it 'declares log plugins to be used' do
|
12
|
+
with_test_platforms(
|
13
|
+
{ nodes: { 'node1' => {}, 'node2' => {} } },
|
14
|
+
false,
|
15
|
+
<<~EOS
|
16
|
+
send_logs_to %i[log_plugin_1 log_plugin_2]
|
17
|
+
for_nodes('node2') { send_logs_to :log_plugin_3 }
|
18
|
+
EOS
|
19
|
+
) do
|
20
|
+
expect(test_config.deployment_logs).to eq [
|
21
|
+
{
|
22
|
+
nodes_selectors_stack: [],
|
23
|
+
log_plugins: %i[log_plugin_1 log_plugin_2]
|
24
|
+
},
|
25
|
+
{
|
26
|
+
nodes_selectors_stack: %w[node2],
|
27
|
+
log_plugins: %i[log_plugin_3]
|
28
|
+
}
|
29
|
+
]
|
10
30
|
end
|
11
31
|
end
|
12
32
|
|
@@ -4,238 +4,213 @@ describe HybridPlatformsConductor::Deployer do
|
|
4
4
|
|
5
5
|
deploy_specs_for(check_mode: false)
|
6
6
|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
end
|
19
|
-
expect(test_services_handler).to receive(:package).with(
|
20
|
-
services: services,
|
21
|
-
secrets: {},
|
22
|
-
local_environment: false
|
23
|
-
)
|
24
|
-
expect(test_services_handler).to receive(:prepare_for_deploy).with(
|
25
|
-
services: services,
|
26
|
-
secrets: {},
|
27
|
-
local_environment: false,
|
28
|
-
why_run: false
|
29
|
-
)
|
30
|
-
services.each do |node, services|
|
31
|
-
expect(test_services_handler).to receive(:actions_to_deploy_on).with(node, services, false) do
|
32
|
-
[{ bash: "echo \"Deploying on #{node}\"" }]
|
7
|
+
context 'checking log plugins usage' do
|
8
|
+
|
9
|
+
# Prepare the test platform with test log plugins
|
10
|
+
#
|
11
|
+
# Parameters::
|
12
|
+
# * *platforms_info* (Hash): The platforms info [default = {}]
|
13
|
+
# * *as_git* (Boolean): As a git repository? [default = false]
|
14
|
+
# * *additional_config* (String): Additional config [default = 'send_logs_to :test_log']
|
15
|
+
def with_test_platform_for_deploy_tests(platforms_info = {}, as_git = false, additional_config = 'send_logs_to :test_log')
|
16
|
+
with_test_platform(platforms_info, false, additional_config) do
|
17
|
+
yield
|
33
18
|
end
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
19
|
+
end
|
20
|
+
|
21
|
+
it 'deploys correct logs information on 1 node' do
|
22
|
+
with_test_platform_for_deploy_tests({ nodes: { 'node' => { services: %w[service1 service2] } } }, true) do
|
23
|
+
with_connections_mocked_on ['node'] do
|
24
|
+
test_actions_executor.connector(:ssh).ssh_user = 'test_user'
|
25
|
+
expect_services_handler_to_deploy('node' => %w[service1 service2])
|
26
|
+
expect_actions_executor_runs([
|
27
|
+
# First run, we expect the mutex to be setup, and the deployment actions to be run
|
28
|
+
proc { |actions_per_nodes| expect_actions_to_deploy_on(actions_per_nodes, 'node') },
|
29
|
+
# Second run, we expect the mutex to be released
|
30
|
+
proc { |actions_per_nodes| expect_actions_to_unlock(actions_per_nodes, 'node') },
|
31
|
+
# Third run, we expect logs to be uploaded on the node
|
32
|
+
proc { |actions_per_nodes| expect(actions_per_nodes).to eq('node' => [{ bash: 'echo Save test logs to node' }]) }
|
33
|
+
])
|
34
|
+
expect(test_deployer.deploy_on('node')).to eq('node' => [0, 'Deploy successful', ''])
|
35
|
+
expect(HybridPlatformsConductorTest::TestLogPlugin.calls).to eq [
|
36
|
+
{
|
37
|
+
method: :actions_to_save_logs,
|
38
|
+
node: 'node',
|
39
|
+
services: %w[service1 service2],
|
40
|
+
deployment_info: {
|
41
|
+
repo_name_0: 'platform',
|
42
|
+
commit_id_0: '123456',
|
43
|
+
commit_message_0: 'Test commit for node: service1, service2',
|
44
|
+
user: 'test_user'
|
45
|
+
},
|
46
|
+
exit_status: 0,
|
47
|
+
stdout: 'Deploy successful',
|
48
|
+
stderr: ''
|
49
|
+
}
|
50
|
+
]
|
51
|
+
end
|
40
52
|
end
|
41
53
|
end
|
42
|
-
end
|
43
54
|
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
#
|
57
|
-
|
58
|
-
expect
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
55
|
+
it 'deploys correct logs information on several nodes' do
|
56
|
+
with_test_platform_for_deploy_tests({ nodes: {
|
57
|
+
'node1' => { services: %w[service1] },
|
58
|
+
'node2' => { services: %w[service2] }
|
59
|
+
} }, true) do
|
60
|
+
with_connections_mocked_on %w[node1 node2] do
|
61
|
+
test_actions_executor.connector(:ssh).ssh_user = 'test_user'
|
62
|
+
expect_services_handler_to_deploy(
|
63
|
+
'node1' => %w[service1],
|
64
|
+
'node2' => %w[service2]
|
65
|
+
)
|
66
|
+
expect_actions_executor_runs([
|
67
|
+
# First run, we expect the mutex to be setup, and the deployment actions to be run
|
68
|
+
proc { |actions_per_nodes| expect_actions_to_deploy_on(actions_per_nodes, %w[node1 node2]) },
|
69
|
+
# Second run, we expect the mutex to be released
|
70
|
+
proc { |actions_per_nodes| expect_actions_to_unlock(actions_per_nodes, %w[node1 node2]) },
|
71
|
+
# Third run, we expect logs to be uploaded on the node
|
72
|
+
proc do |actions_per_nodes|
|
73
|
+
expect(actions_per_nodes).to eq(
|
74
|
+
'node1' => [{ bash: 'echo Save test logs to node1' }],
|
75
|
+
'node2' => [{ bash: 'echo Save test logs to node2' }]
|
76
|
+
)
|
77
|
+
end
|
78
|
+
])
|
79
|
+
expect(test_deployer.deploy_on(%w[node1 node2])).to eq(
|
80
|
+
'node1' => [0, 'Deploy successful', ''],
|
81
|
+
'node2' => [0, 'Deploy successful', '']
|
82
|
+
)
|
83
|
+
expect(HybridPlatformsConductorTest::TestLogPlugin.calls).to eq [
|
84
|
+
{
|
85
|
+
method: :actions_to_save_logs,
|
86
|
+
node: 'node1',
|
87
|
+
services: %w[service1],
|
88
|
+
deployment_info: {
|
89
|
+
repo_name_0: 'platform',
|
90
|
+
commit_id_0: '123456',
|
91
|
+
commit_message_0: 'Test commit for node1: service1',
|
92
|
+
user: 'test_user'
|
93
|
+
},
|
94
|
+
exit_status: 0,
|
95
|
+
stdout: 'Deploy successful',
|
96
|
+
stderr: ''
|
97
|
+
},
|
98
|
+
{
|
99
|
+
method: :actions_to_save_logs,
|
100
|
+
node: 'node2',
|
101
|
+
services: %w[service2],
|
102
|
+
deployment_info: {
|
103
|
+
repo_name_0: 'platform',
|
104
|
+
commit_id_0: '123456',
|
105
|
+
commit_message_0: 'Test commit for node2: service2',
|
106
|
+
user: 'test_user'
|
107
|
+
},
|
108
|
+
exit_status: 0,
|
109
|
+
stdout: 'Deploy successful',
|
110
|
+
stderr: ''
|
111
|
+
}
|
112
|
+
]
|
113
|
+
end
|
73
114
|
end
|
74
115
|
end
|
75
|
-
end
|
76
116
|
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
repo_name_0: 'platform',
|
115
|
-
commit_id_0: '123456',
|
116
|
-
commit_message_0: 'Test commit for node2: service2',
|
117
|
-
services: 'service2',
|
118
|
-
exit_status: '0'
|
119
|
-
)
|
120
|
-
expect_actions_to_upload_logs(actions_per_nodes, %w[node1 node2])
|
121
|
-
end
|
122
|
-
])
|
123
|
-
expect(test_deployer.deploy_on(%w[node1 node2])).to eq(
|
124
|
-
'node1' => [0, 'Deploy successful', ''],
|
125
|
-
'node2' => [0, 'Deploy successful', '']
|
126
|
-
)
|
117
|
+
it 'deploys correct logs information on 1 node even when there is a failing deploy' do
|
118
|
+
with_test_platform_for_deploy_tests({ nodes: { 'node' => { services: %w[service1 service2] } } }, true) do
|
119
|
+
with_connections_mocked_on ['node'] do
|
120
|
+
test_actions_executor.connector(:ssh).ssh_user = 'test_user'
|
121
|
+
expect_services_handler_to_deploy('node' => %w[service1 service2])
|
122
|
+
expect_actions_executor_runs([
|
123
|
+
# First run, we expect the mutex to be setup, and the deployment actions to be run
|
124
|
+
proc do |actions_per_nodes|
|
125
|
+
expect_actions_to_deploy_on(
|
126
|
+
actions_per_nodes,
|
127
|
+
'node',
|
128
|
+
mocked_result: { 'node' => [:failed_action, 'Failed deploy stdout', 'Failed deploy stderr'] }
|
129
|
+
)
|
130
|
+
end,
|
131
|
+
# Second run, we expect the mutex to be released
|
132
|
+
proc { |actions_per_nodes| expect_actions_to_unlock(actions_per_nodes, 'node') },
|
133
|
+
# Third run, we expect logs to be uploaded on the node
|
134
|
+
proc { |actions_per_nodes| expect(actions_per_nodes).to eq('node' => [{ bash: 'echo Save test logs to node' }]) }
|
135
|
+
])
|
136
|
+
expect(test_deployer.deploy_on('node')).to eq('node' => [:failed_action, 'Failed deploy stdout', 'Failed deploy stderr'])
|
137
|
+
expect(HybridPlatformsConductorTest::TestLogPlugin.calls).to eq [
|
138
|
+
{
|
139
|
+
method: :actions_to_save_logs,
|
140
|
+
node: 'node',
|
141
|
+
services: %w[service1 service2],
|
142
|
+
deployment_info: {
|
143
|
+
repo_name_0: 'platform',
|
144
|
+
commit_id_0: '123456',
|
145
|
+
commit_message_0: 'Test commit for node: service1, service2',
|
146
|
+
user: 'test_user'
|
147
|
+
},
|
148
|
+
exit_status: :failed_action,
|
149
|
+
stdout: 'Failed deploy stdout',
|
150
|
+
stderr: 'Failed deploy stderr'
|
151
|
+
}
|
152
|
+
]
|
153
|
+
end
|
127
154
|
end
|
128
155
|
end
|
129
|
-
end
|
130
156
|
|
131
|
-
|
132
|
-
|
133
|
-
with_connections_mocked_on ['node'] do
|
134
|
-
test_actions_executor.connector(:ssh).ssh_user = 'test_user'
|
135
|
-
expect_services_handler_to_deploy('node' => %w[service1 service2])
|
157
|
+
it 'gets deployment info from log plugins' do
|
158
|
+
with_test_platform_for_deploy_tests({ nodes: { 'node' => {} } }) do |repository|
|
136
159
|
expect_actions_executor_runs([
|
137
|
-
#
|
160
|
+
# Expect the actions to get log files
|
138
161
|
proc do |actions_per_nodes|
|
139
|
-
|
140
|
-
|
141
|
-
'node',
|
142
|
-
mocked_result: { 'node' => [:failed_action, "Failed deploy stdout\n", "Failed deploy stderr\n"] }
|
143
|
-
)
|
144
|
-
end,
|
145
|
-
# Second run, we expect the mutex to be released
|
146
|
-
proc { |actions_per_nodes| expect_actions_to_unlock(actions_per_nodes, 'node') },
|
147
|
-
# Third run, we expect logs to be uploaded on the node
|
148
|
-
proc do |actions_per_nodes|
|
149
|
-
# Check logs content
|
150
|
-
local_log_file = actions_per_nodes['node'][:scp].first[0]
|
151
|
-
expect(File.exist?(local_log_file)).to eq true
|
152
|
-
expect_logs_to_be(File.read(local_log_file), "Failed deploy stdout\n", 'Failed deploy stderr',
|
153
|
-
date: /\d\d\d\d-\d\d-\d\d \d\d:\d\d:\d\d/,
|
154
|
-
user: 'test_user',
|
155
|
-
debug: 'No',
|
156
|
-
repo_name_0: 'platform',
|
157
|
-
commit_id_0: '123456',
|
158
|
-
commit_message_0: 'Test commit for node: service1, service2',
|
159
|
-
services: 'service1, service2',
|
160
|
-
exit_status: 'failed_action'
|
161
|
-
)
|
162
|
-
expect_actions_to_upload_logs(actions_per_nodes, 'node')
|
162
|
+
expect(actions_per_nodes).to eq('node' => [{ bash: 'echo Read logs for node' }])
|
163
|
+
{ 'node' => [42, 'Log files read stdout', 'Log files read stderr'] }
|
163
164
|
end
|
164
165
|
])
|
165
|
-
expect(test_deployer.
|
166
|
+
expect(test_deployer.deployment_info_from('node')).to eq(
|
167
|
+
'node' => {
|
168
|
+
deployment_info: { user: 'test_user' },
|
169
|
+
exit_status: 666,
|
170
|
+
services: %w[unknown],
|
171
|
+
stderr: 'Deployment test stderr',
|
172
|
+
stdout: 'Deployment test stdout'
|
173
|
+
}
|
174
|
+
)
|
175
|
+
expect(HybridPlatformsConductorTest::TestLogPlugin.calls).to eq [
|
176
|
+
{
|
177
|
+
method: :actions_to_read_logs,
|
178
|
+
node: 'node'
|
179
|
+
},
|
180
|
+
{
|
181
|
+
method: :logs_for,
|
182
|
+
node: 'node',
|
183
|
+
exit_status: 42,
|
184
|
+
stdout: 'Log files read stdout',
|
185
|
+
stderr: 'Log files read stderr'
|
186
|
+
}
|
187
|
+
]
|
166
188
|
end
|
167
189
|
end
|
168
|
-
end
|
169
|
-
|
170
|
-
it 'gets deployment info from log files' do
|
171
|
-
with_test_platform({ nodes: { 'node' => {} } }) do |repository|
|
172
|
-
expect_actions_executor_runs([
|
173
|
-
# Expect the actions to get log files
|
174
|
-
proc do |actions_per_nodes|
|
175
|
-
expect(actions_per_nodes).to eq('node' => { remote_bash: 'cd /var/log/deployments && ls -t | head -1 | xargs sed \'/===== STDOUT =====/q\'' })
|
176
|
-
{ 'node' => [0, "Property1: Value1\nProperty2: Value2", ''] }
|
177
|
-
end
|
178
|
-
])
|
179
|
-
expect(test_deployer.deployment_info_from('node')).to eq(
|
180
|
-
'node' => {
|
181
|
-
Property1: 'Value1',
|
182
|
-
Property2: 'Value2'
|
183
|
-
}
|
184
|
-
)
|
185
|
-
end
|
186
|
-
end
|
187
190
|
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
end
|
201
|
-
])
|
202
|
-
expect(test_deployer.deployment_info_from('node')).to eq(
|
203
|
-
'node' => {
|
204
|
-
date: Time.parse('2017-11-23 18:43:01 UTC'),
|
205
|
-
debug: true,
|
206
|
-
diff_files_0: %w[file1 file2 file3],
|
207
|
-
services: %w[service1 service2 service3]
|
208
|
-
}
|
209
|
-
)
|
210
|
-
end
|
211
|
-
end
|
212
|
-
|
213
|
-
it 'gets deployment info from several log files' do
|
214
|
-
with_test_platform({ nodes: { 'node1' => {}, 'node2' => {} } }) do |repository|
|
215
|
-
expect_actions_executor_runs([
|
216
|
-
# Expect the actions to get log files
|
217
|
-
proc do |actions_per_nodes|
|
218
|
-
expect(actions_per_nodes).to eq(
|
219
|
-
'node1' => { remote_bash: 'cd /var/log/deployments && ls -t | head -1 | xargs sed \'/===== STDOUT =====/q\'' },
|
220
|
-
'node2' => { remote_bash: 'cd /var/log/deployments && ls -t | head -1 | xargs sed \'/===== STDOUT =====/q\'' }
|
221
|
-
)
|
191
|
+
it 'gets deployment info from log plugins not having actions_to_read_logs' do
|
192
|
+
with_test_platform_for_deploy_tests({ nodes: { 'node' => {} } }, false, 'send_logs_to :test_log_no_read') do |repository|
|
193
|
+
expect(test_deployer.deployment_info_from('node')).to eq(
|
194
|
+
'node' => {
|
195
|
+
deployment_info: { user: 'test_user' },
|
196
|
+
exit_status: 666,
|
197
|
+
services: %w[unknown],
|
198
|
+
stderr: 'Deployment test stderr',
|
199
|
+
stdout: 'Deployment test stdout'
|
200
|
+
}
|
201
|
+
)
|
202
|
+
expect(HybridPlatformsConductorTest::TestLogNoReadPlugin.calls).to eq [
|
222
203
|
{
|
223
|
-
|
224
|
-
|
204
|
+
method: :logs_for,
|
205
|
+
node: 'node',
|
206
|
+
exit_status: nil,
|
207
|
+
stdout: nil,
|
208
|
+
stderr: nil
|
225
209
|
}
|
226
|
-
|
227
|
-
|
228
|
-
expect(test_deployer.deployment_info_from(%w[node1 node2])).to eq(
|
229
|
-
'node1' => {
|
230
|
-
Property1: 'Value1',
|
231
|
-
Property2: 'Value2'
|
232
|
-
},
|
233
|
-
'node2' => {
|
234
|
-
Property3: 'Value3',
|
235
|
-
Property4: 'Value4'
|
236
|
-
}
|
237
|
-
)
|
210
|
+
]
|
211
|
+
end
|
238
212
|
end
|
213
|
+
|
239
214
|
end
|
240
215
|
|
241
216
|
end
|