hybrid_platforms_conductor 32.15.0 → 32.16.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c01fcd515c7641751b265f34747561465570795cb75fb0287a75c61915055a2c
4
- data.tar.gz: c249eb8d612bdc9b6a09467f195c71c607619e9aea278df4ff5b2bf061b968ed
3
+ metadata.gz: 45e61d4a95176f285aaf24fdd34a78440dd7db0decf1c138a9f42f028afc09b4
4
+ data.tar.gz: fc142e6e71ac4f3240d42cb42079a7b05ae811d4da4f1f0508dd2ac5541285d1
5
5
  SHA512:
6
- metadata.gz: 571f2e0effa2d3489eb8c948f90bcf23cc8890ac71a0e6bc4b2ec805dea5d9bd74a608de3d5f6a8d327015058f6c2adf8a23f07aea4f82f1c6445b4b943cd3bd
7
- data.tar.gz: 749df7363532aec2976b1b070462288ee8bed7596fe419d1871390022e337ad0472570fe98a513661f95e47366bd4df3a72d022ec0595cdc73ac051ff000dbb3
6
+ metadata.gz: ac9b4f7a7aa937fcdd18042880fec76a5ea567d3cdeb15135f8f9cfa12652ca0adfc3dffbc115f59ea793fd6a06f567e8081c10c8a6080d51a8ac58db56708b4
7
+ data.tar.gz: ba302151aca73a94f4492774b6ddf32524b02351c3265591430b689e713e2de39af352fbee8d7f09c4e58667f5a960a8ec8027f583c13e3c929d0e59cd381ca3
data/CHANGELOG.md CHANGED
@@ -1,3 +1,15 @@
1
+ # [v32.16.0](https://github.com/sweet-delights/hybrid-platforms-conductor/compare/v32.15.0...v32.16.0) (2021-05-31 17:55:49)
2
+
3
+ ## Global changes
4
+ ### Patches
5
+
6
+ * [[Feature(cmd_runner)] Add option to force bash usage in run_cmd](https://github.com/sweet-delights/hybrid-platforms-conductor/commit/0711f1f33fc8f282b925726e0631ae78bf1337b5)
7
+
8
+ ## Changes for cmd_runner
9
+ ### Features
10
+
11
+ * [[Feature(cmd_runner)] Add option to force bash usage in run_cmd](https://github.com/sweet-delights/hybrid-platforms-conductor/commit/0711f1f33fc8f282b925726e0631ae78bf1337b5)
12
+
1
13
  # [v32.15.0](https://github.com/sweet-delights/hybrid-platforms-conductor/compare/v32.14.0...v32.15.0) (2021-05-31 14:43:32)
2
14
 
3
15
  ## Global changes
@@ -1,4 +1,5 @@
1
1
  require 'logger'
2
+ require 'tempfile'
2
3
  require 'tty-command'
3
4
  require 'hybrid_platforms_conductor/logger_helpers'
4
5
  require 'hybrid_platforms_conductor/io_router'
@@ -66,6 +67,7 @@ module HybridPlatformsConductor
66
67
  # * *timeout*: The command ended in timeout
67
68
  # * *timeout* (Integer or nil): Timeout to apply for the command to be run, or nil for no timeout [default: nil]
68
69
  # * *no_exception* (Boolean): If true, don't throw exception in case of error [default: false]
70
+ # * *force_bash* (Boolean): If true, then make sure command is invoked with bash instead of sh [default: false]
69
71
  # Result::
70
72
  # * Integer or Symbol: Exit status of the command, or Symbol in case of error. In case of dry-run mode the expected code is returned without executing anything.
71
73
  # * String: Standard output of the command
@@ -78,7 +80,8 @@ module HybridPlatformsConductor
78
80
  log_stderr_to_io: nil,
79
81
  expected_code: 0,
80
82
  timeout: nil,
81
- no_exception: false
83
+ no_exception: false,
84
+ force_bash: false
82
85
  )
83
86
  expected_code = [expected_code] unless expected_code.is_a?(Array)
84
87
  if @dry_run
@@ -101,6 +104,14 @@ module HybridPlatformsConductor
101
104
  nil
102
105
  end
103
106
  start_time = Time.now if log_debug?
107
+ bash_file = nil
108
+ if force_bash
109
+ bash_file = Tempfile.new('hpc_bash')
110
+ bash_file.write(cmd)
111
+ bash_file.chmod 0700
112
+ bash_file.close
113
+ cmd = "/bin/bash -c #{bash_file.path}"
114
+ end
104
115
  begin
105
116
  # Make sure we keep a trace of stdout and stderr, even if it was not asked, just to use it in case of exceptions raised
106
117
  cmd_result_stdout = ''
@@ -141,6 +152,7 @@ module HybridPlatformsConductor
141
152
  cmd_stderr = "#{cmd_result_stderr.empty? ? '' : "#{cmd_result_stderr}\n"}#{$!}\n#{$!.backtrace.join("\n")}"
142
153
  ensure
143
154
  file_output.close unless file_output.nil?
155
+ bash_file.unlink unless bash_file.nil?
144
156
  end
145
157
  if log_debug?
146
158
  elapsed = Time.now - start_time
@@ -65,17 +65,19 @@ module HybridPlatformsConductor
65
65
  #
66
66
  # Parameters::
67
67
  # * *cmd* (String): The command to be run
68
+ # * *force_bash* (Boolean): If true, then make sure command is invoked with bash instead of sh [default: false]
68
69
  # Result::
69
70
  # * Integer: Exit code
70
71
  # * String: Standard output
71
72
  # * String: Error output
72
- def run_cmd(cmd)
73
+ def run_cmd(cmd, force_bash: false)
73
74
  @cmd_runner.run_cmd(
74
75
  cmd,
75
76
  timeout: @timeout,
76
77
  log_to_stdout: false,
77
78
  log_stdout_to_io: @stdout_io,
78
- log_stderr_to_io: @stderr_io
79
+ log_stderr_to_io: @stderr_io,
80
+ force_bash: force_bash
79
81
  )
80
82
  end
81
83
 
@@ -37,7 +37,7 @@ module HybridPlatformsConductor
37
37
  # Parameters::
38
38
  # * *bash_cmds* (String): Bash commands to execute
39
39
  def remote_bash(bash_cmds)
40
- run_cmd "cd #{workspace_for(@node)} ; #{bash_cmds}"
40
+ run_cmd "cd #{workspace_for(@node)} ; #{bash_cmds}", force_bash: true
41
41
  end
42
42
 
43
43
  # Execute an interactive shell on the remote node
@@ -1,5 +1,5 @@
1
1
  module HybridPlatformsConductor
2
2
 
3
- VERSION = '32.15.0'
3
+ VERSION = '32.16.0'
4
4
 
5
5
  end
@@ -13,6 +13,13 @@ describe HybridPlatformsConductor::CmdRunner do
13
13
  end
14
14
  end
15
15
 
16
+ it 'runs a simple bash command and forces usage of bash' do
17
+ with_repository do |repository|
18
+ # Use set -o pipefail that does not work in /bin/sh
19
+ expect(test_cmd_runner.run_cmd "set -o pipefail ; echo TestStderr 1>&2 ; echo TestStdout", force_bash: true).to eq [0, "TestStdout\n", "TestStderr\n"]
20
+ end
21
+ end
22
+
16
23
  it 'runs a simple bash command and logs stdout and stderr to a file' do
17
24
  with_repository do |repository|
18
25
  test_cmd_runner.run_cmd "echo TestStderr 1>&2 ; sleep 1 ; echo TestStdout", log_to_file: "#{repository}/test_file"
@@ -31,7 +31,7 @@ module HybridPlatformsConductorTest
31
31
  end
32
32
  # We need to protect the access to this array as the mocked commands can be called by competing threads
33
33
  remaining_expected_commands_mutex = Mutex.new
34
- allow(cmd_runner).to receive(:run_cmd) do |cmd, log_to_file: nil, log_to_stdout: true, log_stdout_to_io: nil, log_stderr_to_io: nil, expected_code: 0, timeout: nil, no_exception: false|
34
+ allow(cmd_runner).to receive(:run_cmd) do |cmd, log_to_file: nil, log_to_stdout: true, log_stdout_to_io: nil, log_stderr_to_io: nil, expected_code: 0, timeout: nil, no_exception: false, force_bash: false|
35
35
  # Check the remaining expected commands
36
36
  found_command = nil
37
37
  found_command_code = nil
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hybrid_platforms_conductor
3
3
  version: !ruby/object:Gem::Version
4
- version: 32.15.0
4
+ version: 32.16.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Muriel Salvan