hybrid_platforms_conductor 33.0.1 → 33.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -0
- data/lib/hybrid_platforms_conductor/config.rb +1 -0
- data/lib/hybrid_platforms_conductor/core_extensions/cleanroom/fix_kwargs.rb +116 -0
- data/lib/hybrid_platforms_conductor/version.rb +1 -1
- data/spec/hybrid_platforms_conductor_test/api/actions_executor/actions/bash_spec.rb +4 -2
- 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 +26 -20
- data/spec/hybrid_platforms_conductor_test/api/actions_executor/actions/ruby_spec.rb +39 -31
- 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 +60 -42
- data/spec/hybrid_platforms_conductor_test/api/actions_executor/connection_spec.rb +11 -9
- data/spec/hybrid_platforms_conductor_test/api/actions_executor/connectors/ssh/connections_spec.rb +33 -21
- data/spec/hybrid_platforms_conductor_test/api/actions_executor/logging_spec.rb +91 -81
- data/spec/hybrid_platforms_conductor_test/api/actions_executor/timeout_spec.rb +6 -4
- metadata +136 -135
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 6a281c5f005c18646d519869f181257a5de5e2cb8da38634876a0e62a7c48db7
|
|
4
|
+
data.tar.gz: 9b602696a09232acf361639ebae5764a849f3c69fa7b68c5d30fab3dc623f344
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: c55e4a9bc145c87cde919a8800eed750367de48b539340bc785ff0b7370bb0deb62c5aeea63aa4569bf3c842f9cfca74f15c1d8762803cb17d4ea22c9575fdad
|
|
7
|
+
data.tar.gz: 24fe4e209a118a566ebef1557bcf17155ec7f94f1b3fd6293e9b1f9cf020451a514e27f303d675f5b96dc2490addb98487d14f3cc025da437bff2641c075fd2f
|
data/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
# [v33.0.2](https://github.com/sweet-delights/hybrid-platforms-conductor/compare/v33.0.1...v33.0.2) (2021-06-17 11:15:29)
|
|
2
|
+
|
|
3
|
+
### Patches
|
|
4
|
+
|
|
5
|
+
* [[#49] Corrected warnings to prepare migration to Ruby 3](https://github.com/sweet-delights/hybrid-platforms-conductor/commit/8f3e758a881dcd988540d660b2df8a38fe39d1ca)
|
|
6
|
+
|
|
1
7
|
# [v33.0.1](https://github.com/sweet-delights/hybrid-platforms-conductor/compare/v33.0.0...v33.0.1) (2021-06-16 16:22:41)
|
|
2
8
|
|
|
3
9
|
### Patches
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
# This is a patch of cleanroom Rubygem v1.0.0 that adds kwargs support for Ruby 3.
|
|
2
|
+
# TODO: Remove this patch when the following code will be merged in a new version of cleanroom:
|
|
3
|
+
# https://github.com/sethvargo/cleanroom/compare/master...Muriel-Salvan:handle_kwargs?expand=1
|
|
4
|
+
|
|
5
|
+
module Cleanroom
|
|
6
|
+
|
|
7
|
+
# Add kwargs support
|
|
8
|
+
module ClassMethods
|
|
9
|
+
|
|
10
|
+
#
|
|
11
|
+
# Expose the given method to the DSL.
|
|
12
|
+
#
|
|
13
|
+
# @param [Symbol] name
|
|
14
|
+
#
|
|
15
|
+
def expose(name)
|
|
16
|
+
raise NameError, "undefined method `#{name}' for class `#{self.name}'" unless public_method_defined?(name)
|
|
17
|
+
|
|
18
|
+
exposed_methods_with_kwargs[name] = true if instance_method(name).parameters.any? { |(arg_type, _arg_name)| KWARGS_TYPES.include?(arg_type) }
|
|
19
|
+
exposed_methods[name] = true
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
private
|
|
23
|
+
|
|
24
|
+
# Define the types of argument types that point kwargs arguments.
|
|
25
|
+
# Useful to treat them differently as when defining a method with kwargs, Ruby will pass parameters having a to_hash method differently to such methods:
|
|
26
|
+
#
|
|
27
|
+
# See this example illustrating the difference in treatment with and without kwargs in the method definition:
|
|
28
|
+
# def without_kwargs(*args)
|
|
29
|
+
# p args
|
|
30
|
+
# end
|
|
31
|
+
# def with_kwargs(*args, **kwargs)
|
|
32
|
+
# p args
|
|
33
|
+
# p kwargs
|
|
34
|
+
# end
|
|
35
|
+
# s_without_to_hash = 'Without to_hash'
|
|
36
|
+
# s_with_to_hash = 'With to_hash'
|
|
37
|
+
# s_with_to_hash.define_singleton_method(:to_hash) { { string: self.to_s } }
|
|
38
|
+
# without_kwargs(s_without_to_hash)
|
|
39
|
+
# ["Without to_hash"]
|
|
40
|
+
# without_kwargs(s_with_to_hash)
|
|
41
|
+
# ["With to_hash"]
|
|
42
|
+
# with_kwargs(s_without_to_hash)
|
|
43
|
+
# ["Without to_hash"]
|
|
44
|
+
# {}
|
|
45
|
+
# with_kwargs(s_with_to_hash)
|
|
46
|
+
# []
|
|
47
|
+
# {:string=>"With to_hash"}
|
|
48
|
+
KWARGS_TYPES = %i[key keyreq]
|
|
49
|
+
|
|
50
|
+
#
|
|
51
|
+
# The list of exposed methods with kwargs.
|
|
52
|
+
#
|
|
53
|
+
# @return [Hash]
|
|
54
|
+
#
|
|
55
|
+
def exposed_methods_with_kwargs
|
|
56
|
+
@exposed_methods_with_kwargs ||= from_superclass(:exposed_methods_with_kwargs, {}).dup
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
#
|
|
60
|
+
# The cleanroom instance for this class. This method is intentionally
|
|
61
|
+
# NOT cached!
|
|
62
|
+
#
|
|
63
|
+
# @return [Class]
|
|
64
|
+
#
|
|
65
|
+
def cleanroom
|
|
66
|
+
exposed = exposed_methods.keys
|
|
67
|
+
exposed_with_kwargs = exposed_methods_with_kwargs.keys
|
|
68
|
+
parent = name || 'Anonymous'
|
|
69
|
+
|
|
70
|
+
Class.new(Object) do
|
|
71
|
+
class << self
|
|
72
|
+
|
|
73
|
+
def class_eval
|
|
74
|
+
raise Cleanroom::InaccessibleError.new(:class_eval, self)
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
def instance_eval
|
|
78
|
+
raise Cleanroom::InaccessibleError.new(:instance_eval, self)
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
define_method(:initialize) do |instance|
|
|
84
|
+
define_singleton_method(:__instance__) do
|
|
85
|
+
raise Cleanroom::InaccessibleError.new(:__instance__, self) unless caller[0].include?(__FILE__)
|
|
86
|
+
|
|
87
|
+
instance
|
|
88
|
+
end
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
(exposed - exposed_with_kwargs).each do |exposed_method|
|
|
92
|
+
define_method(exposed_method) do |*args, &block|
|
|
93
|
+
__instance__.public_send(exposed_method, *args, &block)
|
|
94
|
+
end
|
|
95
|
+
end
|
|
96
|
+
|
|
97
|
+
exposed_with_kwargs.each do |exposed_method|
|
|
98
|
+
define_method(exposed_method) do |*args, **kwargs, &block|
|
|
99
|
+
__instance__.public_send(exposed_method, *args, **kwargs, &block)
|
|
100
|
+
end
|
|
101
|
+
end
|
|
102
|
+
|
|
103
|
+
define_method(:class_eval) do
|
|
104
|
+
raise Cleanroom::InaccessibleError.new(:class_eval, self)
|
|
105
|
+
end
|
|
106
|
+
|
|
107
|
+
define_method(:inspect) do
|
|
108
|
+
"#<#{parent} (Cleanroom)>"
|
|
109
|
+
end
|
|
110
|
+
alias_method :to_s, :inspect
|
|
111
|
+
end
|
|
112
|
+
end
|
|
113
|
+
|
|
114
|
+
end
|
|
115
|
+
|
|
116
|
+
end
|
|
@@ -6,8 +6,10 @@ describe HybridPlatformsConductor::ActionsExecutor do
|
|
|
6
6
|
with_test_platform_for_action_plugins do |repository|
|
|
7
7
|
expect(
|
|
8
8
|
test_actions_executor.execute_actions(
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
{
|
|
10
|
+
'node' => {
|
|
11
|
+
bash: "echo TestContent >#{repository}/test_file ; echo TestStdout ; echo TestStderr 1>&2"
|
|
12
|
+
}
|
|
11
13
|
}
|
|
12
14
|
)['node']
|
|
13
15
|
).to eq [0, "TestStdout\n", "TestStderr\n"]
|
|
@@ -4,7 +4,7 @@ describe HybridPlatformsConductor::ActionsExecutor do
|
|
|
4
4
|
|
|
5
5
|
it 'executes remote interactive session' do
|
|
6
6
|
with_test_platform_for_action_plugins do
|
|
7
|
-
test_actions_executor.execute_actions('node' => { interactive: true })
|
|
7
|
+
test_actions_executor.execute_actions({ 'node' => { interactive: true } })
|
|
8
8
|
expect(test_actions_executor.connector(:test_connector).calls).to eq [
|
|
9
9
|
[:connectable_nodes_from, ['node']],
|
|
10
10
|
[:with_connection_to, ['node'], { no_exception: true }],
|
|
@@ -4,7 +4,7 @@ describe HybridPlatformsConductor::ActionsExecutor do
|
|
|
4
4
|
|
|
5
5
|
it 'executes remote Bash code' do
|
|
6
6
|
with_test_platform_for_action_plugins do
|
|
7
|
-
test_actions_executor.execute_actions('node' => { remote_bash: 'remote_bash_cmd.bash' })
|
|
7
|
+
test_actions_executor.execute_actions({ 'node' => { remote_bash: 'remote_bash_cmd.bash' } })
|
|
8
8
|
expect(test_actions_executor.connector(:test_connector).calls).to eq [
|
|
9
9
|
[:connectable_nodes_from, ['node']],
|
|
10
10
|
[:with_connection_to, ['node'], { no_exception: true }],
|
|
@@ -32,7 +32,7 @@ describe HybridPlatformsConductor::ActionsExecutor do
|
|
|
32
32
|
|
|
33
33
|
it 'executes remote Bash code in several lines' do
|
|
34
34
|
with_test_platform_for_action_plugins do
|
|
35
|
-
test_actions_executor.execute_actions('node' => { remote_bash: ['bash_cmd1.bash', 'bash_cmd2.bash', 'bash_cmd3.bash'] })
|
|
35
|
+
test_actions_executor.execute_actions({ 'node' => { remote_bash: ['bash_cmd1.bash', 'bash_cmd2.bash', 'bash_cmd3.bash'] } })
|
|
36
36
|
expect(test_actions_executor.connector(:test_connector).calls).to eq [
|
|
37
37
|
[:connectable_nodes_from, ['node']],
|
|
38
38
|
[:with_connection_to, ['node'], { no_exception: true }],
|
|
@@ -43,7 +43,7 @@ describe HybridPlatformsConductor::ActionsExecutor do
|
|
|
43
43
|
|
|
44
44
|
it 'executes remote Bash code using the commands syntax' do
|
|
45
45
|
with_test_platform_for_action_plugins do
|
|
46
|
-
test_actions_executor.execute_actions('node' => { remote_bash: { commands: 'bash_cmd.bash' } })
|
|
46
|
+
test_actions_executor.execute_actions({ 'node' => { remote_bash: { commands: 'bash_cmd.bash' } } })
|
|
47
47
|
expect(test_actions_executor.connector(:test_connector).calls).to eq [
|
|
48
48
|
[:connectable_nodes_from, ['node']],
|
|
49
49
|
[:with_connection_to, ['node'], { no_exception: true }],
|
|
@@ -55,7 +55,7 @@ describe HybridPlatformsConductor::ActionsExecutor do
|
|
|
55
55
|
it 'executes remote Bash code from a file' do
|
|
56
56
|
with_test_platform_for_action_plugins do |repository|
|
|
57
57
|
File.write("#{repository}/commands.txt", "bash_cmd1.bash\nbash_cmd2.bash")
|
|
58
|
-
test_actions_executor.execute_actions('node' => { remote_bash: { file: "#{repository}/commands.txt" } })
|
|
58
|
+
test_actions_executor.execute_actions({ 'node' => { remote_bash: { file: "#{repository}/commands.txt" } } })
|
|
59
59
|
expect(test_actions_executor.connector(:test_connector).calls).to eq [
|
|
60
60
|
[:connectable_nodes_from, ['node']],
|
|
61
61
|
[:with_connection_to, ['node'], { no_exception: true }],
|
|
@@ -68,10 +68,12 @@ describe HybridPlatformsConductor::ActionsExecutor do
|
|
|
68
68
|
with_test_platform_for_action_plugins do |repository|
|
|
69
69
|
File.write("#{repository}/commands.txt", "bash_cmd3.bash\nbash_cmd4.bash")
|
|
70
70
|
test_actions_executor.execute_actions(
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
71
|
+
{
|
|
72
|
+
'node' => { remote_bash: {
|
|
73
|
+
commands: ['bash_cmd1.bash', 'bash_cmd2.bash'],
|
|
74
|
+
file: "#{repository}/commands.txt"
|
|
75
|
+
} }
|
|
76
|
+
}
|
|
75
77
|
)
|
|
76
78
|
expect(test_actions_executor.connector(:test_connector).calls).to eq [
|
|
77
79
|
[:connectable_nodes_from, ['node']],
|
|
@@ -85,11 +87,13 @@ describe HybridPlatformsConductor::ActionsExecutor do
|
|
|
85
87
|
with_test_platform_for_action_plugins do |repository|
|
|
86
88
|
File.write("#{repository}/commands.txt", "bash_cmd3.bash\nbash_cmd4.bash")
|
|
87
89
|
test_actions_executor.execute_actions(
|
|
88
|
-
|
|
89
|
-
'
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
90
|
+
{
|
|
91
|
+
'node' => { remote_bash: [
|
|
92
|
+
'bash_cmd1.bash',
|
|
93
|
+
'bash_cmd2.bash',
|
|
94
|
+
{ file: "#{repository}/commands.txt" }
|
|
95
|
+
] }
|
|
96
|
+
}
|
|
93
97
|
)
|
|
94
98
|
expect(test_actions_executor.connector(:test_connector).calls).to eq [
|
|
95
99
|
[:connectable_nodes_from, ['node']],
|
|
@@ -102,13 +106,15 @@ describe HybridPlatformsConductor::ActionsExecutor do
|
|
|
102
106
|
it 'executes remote Bash code with environment variables set' do
|
|
103
107
|
with_test_platform_for_action_plugins do
|
|
104
108
|
test_actions_executor.execute_actions(
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
109
|
+
{
|
|
110
|
+
'node' => { remote_bash: {
|
|
111
|
+
commands: 'bash_cmd.bash',
|
|
112
|
+
env: {
|
|
113
|
+
'var1' => 'value1',
|
|
114
|
+
'var2' => 'value2'
|
|
115
|
+
}
|
|
116
|
+
} }
|
|
117
|
+
}
|
|
112
118
|
)
|
|
113
119
|
expect(test_actions_executor.connector(:test_connector).calls).to eq [
|
|
114
120
|
[:connectable_nodes_from, ['node']],
|
|
@@ -7,12 +7,14 @@ describe HybridPlatformsConductor::ActionsExecutor do
|
|
|
7
7
|
executed = false
|
|
8
8
|
expect(
|
|
9
9
|
test_actions_executor.execute_actions(
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
stdout
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
10
|
+
{
|
|
11
|
+
'node' => {
|
|
12
|
+
ruby: proc do |stdout, stderr|
|
|
13
|
+
stdout << 'TestStdout'
|
|
14
|
+
stderr << 'TestStderr'
|
|
15
|
+
executed = true
|
|
16
|
+
end
|
|
17
|
+
}
|
|
16
18
|
}
|
|
17
19
|
)['node']
|
|
18
20
|
).to eq [0, 'TestStdout', 'TestStderr']
|
|
@@ -63,13 +65,15 @@ describe HybridPlatformsConductor::ActionsExecutor do
|
|
|
63
65
|
executed = false
|
|
64
66
|
expect(
|
|
65
67
|
test_actions_executor.execute_actions(
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
68
|
+
{
|
|
69
|
+
'node' => {
|
|
70
|
+
ruby: proc do |stdout, stderr, action|
|
|
71
|
+
expect(action.is_a?(HybridPlatformsConductor::HpcPlugins::Action::Ruby)).to eq true
|
|
72
|
+
stdout << 'TestStdout'
|
|
73
|
+
stderr << 'TestStderr'
|
|
74
|
+
executed = true
|
|
75
|
+
end
|
|
76
|
+
}
|
|
73
77
|
}
|
|
74
78
|
)['node']
|
|
75
79
|
).to eq [0, 'TestStdout', 'TestStderr']
|
|
@@ -82,15 +86,17 @@ describe HybridPlatformsConductor::ActionsExecutor do
|
|
|
82
86
|
executed = false
|
|
83
87
|
expect(
|
|
84
88
|
test_actions_executor.execute_actions(
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
89
|
+
{
|
|
90
|
+
'node' => {
|
|
91
|
+
ruby: {
|
|
92
|
+
code: proc do |stdout, stderr, _action, connector|
|
|
93
|
+
expect(connector.is_a?(HybridPlatformsConductorTest::TestConnector)).to eq true
|
|
94
|
+
stdout << 'TestStdout'
|
|
95
|
+
stderr << 'TestStderr'
|
|
96
|
+
executed = true
|
|
97
|
+
end,
|
|
98
|
+
need_remote: true
|
|
99
|
+
}
|
|
94
100
|
}
|
|
95
101
|
}
|
|
96
102
|
)['node']
|
|
@@ -104,15 +110,17 @@ describe HybridPlatformsConductor::ActionsExecutor do
|
|
|
104
110
|
executed = false
|
|
105
111
|
expect(
|
|
106
112
|
test_actions_executor.execute_actions(
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
113
|
+
{
|
|
114
|
+
'node' => {
|
|
115
|
+
ruby: {
|
|
116
|
+
code: proc do |stdout, stderr, _action, connector|
|
|
117
|
+
expect(connector).to be_nil
|
|
118
|
+
stdout << 'TestStdout'
|
|
119
|
+
stderr << 'TestStderr'
|
|
120
|
+
executed = true
|
|
121
|
+
end,
|
|
122
|
+
need_remote: false
|
|
123
|
+
}
|
|
116
124
|
}
|
|
117
125
|
}
|
|
118
126
|
)['node']
|
|
@@ -4,7 +4,7 @@ describe HybridPlatformsConductor::ActionsExecutor do
|
|
|
4
4
|
|
|
5
5
|
it 'executes remote SCP' do
|
|
6
6
|
with_test_platform_for_action_plugins do
|
|
7
|
-
test_actions_executor.execute_actions('node' => { scp: { 'from' => 'to' } })
|
|
7
|
+
test_actions_executor.execute_actions({ 'node' => { scp: { 'from' => 'to' } } })
|
|
8
8
|
expect(test_actions_executor.connector(:test_connector).calls).to eq [
|
|
9
9
|
[:connectable_nodes_from, ['node']],
|
|
10
10
|
[:with_connection_to, ['node'], { no_exception: true }],
|
|
@@ -33,10 +33,12 @@ describe HybridPlatformsConductor::ActionsExecutor do
|
|
|
33
33
|
it 'executes remote SCP on several files' do
|
|
34
34
|
with_test_platform_for_action_plugins do
|
|
35
35
|
test_actions_executor.execute_actions(
|
|
36
|
-
|
|
37
|
-
'
|
|
38
|
-
|
|
39
|
-
|
|
36
|
+
{
|
|
37
|
+
'node' => { scp: {
|
|
38
|
+
'from1' => 'to1',
|
|
39
|
+
'from2' => 'to2'
|
|
40
|
+
} }
|
|
41
|
+
}
|
|
40
42
|
)
|
|
41
43
|
expect(test_actions_executor.connector(:test_connector).calls).to eq [
|
|
42
44
|
[:connectable_nodes_from, ['node']],
|
|
@@ -50,10 +52,12 @@ describe HybridPlatformsConductor::ActionsExecutor do
|
|
|
50
52
|
it 'executes remote SCP with sudo' do
|
|
51
53
|
with_test_platform_for_action_plugins do
|
|
52
54
|
test_actions_executor.execute_actions(
|
|
53
|
-
|
|
54
|
-
'
|
|
55
|
-
|
|
56
|
-
|
|
55
|
+
{
|
|
56
|
+
'node' => { scp: {
|
|
57
|
+
'from' => 'to',
|
|
58
|
+
sudo: true
|
|
59
|
+
} }
|
|
60
|
+
}
|
|
57
61
|
)
|
|
58
62
|
expect(test_actions_executor.connector(:test_connector).calls).to eq [
|
|
59
63
|
[:connectable_nodes_from, ['node']],
|
|
@@ -66,11 +70,13 @@ describe HybridPlatformsConductor::ActionsExecutor do
|
|
|
66
70
|
it 'executes remote SCP with different owner and group' do
|
|
67
71
|
with_test_platform_for_action_plugins do
|
|
68
72
|
test_actions_executor.execute_actions(
|
|
69
|
-
|
|
70
|
-
'
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
73
|
+
{
|
|
74
|
+
'node' => { scp: {
|
|
75
|
+
'from' => 'to',
|
|
76
|
+
owner: 'new_owner',
|
|
77
|
+
group: 'new_group'
|
|
78
|
+
} }
|
|
79
|
+
}
|
|
74
80
|
)
|
|
75
81
|
expect(test_actions_executor.connector(:test_connector).calls).to eq [
|
|
76
82
|
[:connectable_nodes_from, ['node']],
|
|
@@ -14,20 +14,20 @@ describe HybridPlatformsConductor::ActionsExecutor do
|
|
|
14
14
|
|
|
15
15
|
it 'executes a simple action on 1 node' do
|
|
16
16
|
with_test_platform_for_actions do
|
|
17
|
-
test_actions_executor.execute_actions('node1' => { test_action: 'Action executed' })
|
|
17
|
+
test_actions_executor.execute_actions({ 'node1' => { test_action: 'Action executed' } })
|
|
18
18
|
expect(action_executions).to eq [{ node: 'node1', message: 'Action executed' }]
|
|
19
19
|
end
|
|
20
20
|
end
|
|
21
21
|
|
|
22
22
|
it 'fails to execute an unknown action' do
|
|
23
23
|
with_test_platform_for_actions do
|
|
24
|
-
expect { test_actions_executor.execute_actions('node1' => { unknown_action: 'Action executed' }) }.to raise_error(/Unknown action type unknown_action/)
|
|
24
|
+
expect { test_actions_executor.execute_actions({ 'node1' => { unknown_action: 'Action executed' } }) }.to raise_error(/Unknown action type unknown_action/)
|
|
25
25
|
end
|
|
26
26
|
end
|
|
27
27
|
|
|
28
28
|
it 'executes a simple action on several nodes' do
|
|
29
29
|
with_test_platform_for_actions do
|
|
30
|
-
test_actions_executor.execute_actions(%w[node1 node2 node3] => { test_action: 'Action executed' })
|
|
30
|
+
test_actions_executor.execute_actions({ %w[node1 node2 node3] => { test_action: 'Action executed' } })
|
|
31
31
|
expect(action_executions).to eq [
|
|
32
32
|
{ node: 'node1', message: 'Action executed' },
|
|
33
33
|
{ node: 'node2', message: 'Action executed' },
|
|
@@ -39,11 +39,13 @@ describe HybridPlatformsConductor::ActionsExecutor do
|
|
|
39
39
|
it 'executes several actions on 1 node' do
|
|
40
40
|
with_test_platform_for_actions do
|
|
41
41
|
test_actions_executor.execute_actions(
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
42
|
+
{
|
|
43
|
+
'node1' => [
|
|
44
|
+
{ test_action: 'Action 1 executed' },
|
|
45
|
+
{ test_action: 'Action 2 executed' },
|
|
46
|
+
{ test_action: 'Action 3 executed' }
|
|
47
|
+
]
|
|
48
|
+
}
|
|
47
49
|
)
|
|
48
50
|
expect(action_executions).to eq [
|
|
49
51
|
{ node: 'node1', message: 'Action 1 executed' },
|
|
@@ -56,9 +58,11 @@ describe HybridPlatformsConductor::ActionsExecutor do
|
|
|
56
58
|
it 'executes different actions on several nodes' do
|
|
57
59
|
with_test_platform_for_actions do
|
|
58
60
|
test_actions_executor.execute_actions(
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
61
|
+
{
|
|
62
|
+
'node1' => { test_action: 'Action 1 executed' },
|
|
63
|
+
'node2' => { test_action: 'Action 2 executed' },
|
|
64
|
+
'node3' => { test_action: 'Action 3 executed' }
|
|
65
|
+
}
|
|
62
66
|
)
|
|
63
67
|
expect(action_executions).to eq [
|
|
64
68
|
{ node: 'node1', message: 'Action 1 executed' },
|
|
@@ -73,19 +77,21 @@ describe HybridPlatformsConductor::ActionsExecutor do
|
|
|
73
77
|
actions_executed = []
|
|
74
78
|
expect(
|
|
75
79
|
test_actions_executor.execute_actions(
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
stdout
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
80
|
+
{
|
|
81
|
+
'node1' => [
|
|
82
|
+
{ ruby: proc do |stdout, stderr|
|
|
83
|
+
stdout << 'action1_stdout '
|
|
84
|
+
stderr << 'action1_stderr '
|
|
85
|
+
actions_executed << 'action1'
|
|
86
|
+
end },
|
|
87
|
+
{ bash: 'echo action2_stdout' },
|
|
88
|
+
{ ruby: proc do |stdout, stderr|
|
|
89
|
+
stdout << 'action3_stdout'
|
|
90
|
+
stderr << 'action3_stderr'
|
|
91
|
+
actions_executed << 'action3'
|
|
92
|
+
end }
|
|
93
|
+
]
|
|
94
|
+
}
|
|
89
95
|
)
|
|
90
96
|
).to eq('node1' => [0, "action1_stdout action2_stdout\naction3_stdout", 'action1_stderr action3_stderr'])
|
|
91
97
|
expect(actions_executed).to eq %w[action1 action3]
|
|
@@ -95,8 +101,10 @@ describe HybridPlatformsConductor::ActionsExecutor do
|
|
|
95
101
|
it 'executes several actions on 1 node specified using different selectors' do
|
|
96
102
|
with_test_platform_for_actions do
|
|
97
103
|
test_actions_executor.execute_actions(
|
|
98
|
-
|
|
99
|
-
|
|
104
|
+
{
|
|
105
|
+
'node1' => { test_action: 'Action 1 executed' },
|
|
106
|
+
'/node1/' => { test_action: 'Action 2 executed' }
|
|
107
|
+
}
|
|
100
108
|
)
|
|
101
109
|
expect(action_executions).to eq [
|
|
102
110
|
{ node: 'node1', message: 'Action 1 executed' },
|
|
@@ -107,7 +115,7 @@ describe HybridPlatformsConductor::ActionsExecutor do
|
|
|
107
115
|
|
|
108
116
|
it 'fails to execute an action on an unknown node' do
|
|
109
117
|
with_test_platform_for_actions do
|
|
110
|
-
expect { test_actions_executor.execute_actions('unknown_node' => { test_action: 'Action executed' }) }.to raise_error(RuntimeError, 'Unknown nodes: unknown_node')
|
|
118
|
+
expect { test_actions_executor.execute_actions({ 'unknown_node' => { test_action: 'Action executed' } }) }.to raise_error(RuntimeError, 'Unknown nodes: unknown_node')
|
|
111
119
|
expect(action_executions).to eq []
|
|
112
120
|
end
|
|
113
121
|
end
|
|
@@ -130,9 +138,11 @@ describe HybridPlatformsConductor::ActionsExecutor do
|
|
|
130
138
|
with_test_platform_for_actions do
|
|
131
139
|
expect(
|
|
132
140
|
test_actions_executor.execute_actions(
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
141
|
+
{
|
|
142
|
+
'node1' => { test_action: { code: proc { |stdout| stdout << 'Action 1' } } },
|
|
143
|
+
'node2' => { test_action: { code: proc { raise HybridPlatformsConductor::CmdRunner::UnexpectedExitCodeError, 'Command returned 1' } } },
|
|
144
|
+
'node3' => { test_action: { code: proc { |stdout| stdout << 'Action 3' } } }
|
|
145
|
+
}
|
|
136
146
|
)
|
|
137
147
|
).to eq(
|
|
138
148
|
'node1' => [0, 'Action 1', ''],
|
|
@@ -146,9 +156,11 @@ describe HybridPlatformsConductor::ActionsExecutor do
|
|
|
146
156
|
with_test_platform_for_actions do
|
|
147
157
|
expect(
|
|
148
158
|
test_actions_executor.execute_actions(
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
159
|
+
{
|
|
160
|
+
'node1' => { test_action: { code: proc { |stdout| stdout << 'Action 1' } } },
|
|
161
|
+
'node2' => { test_action: { code: proc { raise HybridPlatformsConductor::CmdRunner::TimeoutError } } },
|
|
162
|
+
'node3' => { test_action: { code: proc { |stdout| stdout << 'Action 3' } } }
|
|
163
|
+
}
|
|
152
164
|
)
|
|
153
165
|
).to eq(
|
|
154
166
|
'node1' => [0, 'Action 1', ''],
|
|
@@ -162,9 +174,11 @@ describe HybridPlatformsConductor::ActionsExecutor do
|
|
|
162
174
|
with_test_platform_for_actions do
|
|
163
175
|
expect(
|
|
164
176
|
test_actions_executor.execute_actions(
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
177
|
+
{
|
|
178
|
+
'node1' => { test_action: { code: proc { |stdout| stdout << 'Action 1' } } },
|
|
179
|
+
'node2' => { test_action: { code: proc { raise HybridPlatformsConductor::ActionsExecutor::ConnectionError, 'Can\'t connect' } } },
|
|
180
|
+
'node3' => { test_action: { code: proc { |stdout| stdout << 'Action 3' } } }
|
|
181
|
+
}
|
|
168
182
|
)
|
|
169
183
|
).to eq(
|
|
170
184
|
'node1' => [0, 'Action 1', ''],
|
|
@@ -178,9 +192,11 @@ describe HybridPlatformsConductor::ActionsExecutor do
|
|
|
178
192
|
with_test_platform_for_actions do
|
|
179
193
|
expect(
|
|
180
194
|
test_actions_executor.execute_actions(
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
195
|
+
{
|
|
196
|
+
'node1' => { test_action: { code: proc { |stdout| stdout << 'Action 1' } } },
|
|
197
|
+
'node2' => { test_action: { code: proc { raise 'Strange error' } } },
|
|
198
|
+
'node3' => { test_action: { code: proc { |stdout| stdout << 'Action 3' } } }
|
|
199
|
+
}
|
|
184
200
|
)
|
|
185
201
|
).to eq(
|
|
186
202
|
'node1' => [0, 'Action 1', ''],
|
|
@@ -195,9 +211,11 @@ describe HybridPlatformsConductor::ActionsExecutor do
|
|
|
195
211
|
test_actions_executor.connector(:test_connector).accept_nodes = %w[node1 node3]
|
|
196
212
|
expect(
|
|
197
213
|
test_actions_executor.execute_actions(
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
214
|
+
{
|
|
215
|
+
'node1' => { test_action: { need_connector: true, code: proc { |stdout| stdout << 'Action 1' } } },
|
|
216
|
+
'node2' => { test_action: { need_connector: true, code: proc { |stdout| stdout << 'Action 2' } } },
|
|
217
|
+
'node3' => { test_action: { need_connector: true, code: proc { |stdout| stdout << 'Action 3' } } }
|
|
218
|
+
}
|
|
201
219
|
)
|
|
202
220
|
).to eq(
|
|
203
221
|
'node1' => [0, 'Action 1', ''],
|