beaker 4.23.2 → 4.27.1
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/.github/dependabot.yml +8 -0
- data/.rspec +1 -0
- data/.travis.yml +2 -4
- data/CHANGELOG.md +56 -2
- data/CODEOWNERS +0 -2
- data/Rakefile +1 -4
- data/beaker.gemspec +5 -5
- data/lib/beaker/host.rb +7 -1
- data/lib/beaker/host/pswindows/exec.rb +19 -4
- data/lib/beaker/host/pswindows/file.rb +3 -3
- data/lib/beaker/host/unix/exec.rb +86 -58
- data/lib/beaker/local_connection.rb +86 -0
- data/lib/beaker/ssh_connection.rb +6 -1
- data/lib/beaker/version.rb +1 -1
- data/spec/beaker/host/pswindows/exec_spec.rb +59 -6
- data/spec/beaker/host/pswindows/file_spec.rb +23 -4
- data/spec/beaker/host/unix/exec_spec.rb +175 -113
- data/spec/beaker/host_spec.rb +7 -1
- data/spec/beaker/localhost_connection_spec.rb +106 -0
- metadata +22 -13
data/spec/beaker/host_spec.rb
CHANGED
@@ -349,7 +349,13 @@ module Beaker
|
|
349
349
|
allow( result ).to receive( :exit_code ).and_return( 0 )
|
350
350
|
allow( host ).to receive( :exec ).and_return( result )
|
351
351
|
|
352
|
-
expect( Beaker::Command ).to receive(:new).
|
352
|
+
expect( Beaker::Command ).to receive(:new).
|
353
|
+
with("powershell.exe", ["-ExecutionPolicy Bypass",
|
354
|
+
"-InputFormat None",
|
355
|
+
"-NoLogo",
|
356
|
+
"-NoProfile",
|
357
|
+
"-NonInteractive",
|
358
|
+
"-Command New-Item -Path 'test\\test\\test' -ItemType 'directory'"])
|
353
359
|
expect( host.mkdir_p('test/test/test') ).to be == true
|
354
360
|
|
355
361
|
end
|
@@ -0,0 +1,106 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'net/ssh'
|
3
|
+
|
4
|
+
module Beaker
|
5
|
+
describe LocalConnection do
|
6
|
+
let( :options ) { { :logger => double('logger').as_null_object, :ssh_env_file => '/path/to/ssh/file'} }
|
7
|
+
subject(:connection) { LocalConnection.new(options) }
|
8
|
+
|
9
|
+
before :each do
|
10
|
+
allow( subject ).to receive(:sleep)
|
11
|
+
end
|
12
|
+
|
13
|
+
describe '#self.connect' do
|
14
|
+
it 'loggs message' do
|
15
|
+
expect(options[:logger]).to receive(:debug).with('Local connection, no connection to start')
|
16
|
+
connection_constructor = LocalConnection.connect(options)
|
17
|
+
expect( connection_constructor ).to be_a_kind_of LocalConnection
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
describe '#close' do
|
22
|
+
it 'logs message' do
|
23
|
+
expect(options[:logger]).to receive(:debug).with('Local connection, no connection to close')
|
24
|
+
connection.close
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
describe '#with_env' do
|
29
|
+
it 'sets envs temporarily' do
|
30
|
+
connection.connect
|
31
|
+
connection.with_env({'my_env' => 'my_env_value'}) do
|
32
|
+
expect(ENV.to_hash).to include({'my_env' => 'my_env_value'})
|
33
|
+
end
|
34
|
+
expect(ENV.to_hash).not_to include({'my_env' => 'my_env_value'})
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
describe '#execute' do
|
39
|
+
it 'calls open3' do
|
40
|
+
expect( Open3 ).to receive( :capture3 ).with({}, 'my_command')
|
41
|
+
connection.connect
|
42
|
+
expect(connection.execute('my_command')).to be_a_kind_of Result
|
43
|
+
end
|
44
|
+
|
45
|
+
it 'sets stdout, stderr and exitcode' do
|
46
|
+
allow(Open3).to receive(:capture3).and_return(['stdout', 'stderr', double({exitstatus: 0})])
|
47
|
+
connection.connect
|
48
|
+
result = connection.execute('my_command')
|
49
|
+
expect(result.exit_code).to eq(0)
|
50
|
+
expect(result.stdout).to eq('stdout')
|
51
|
+
expect(result.stderr).to eq('stderr')
|
52
|
+
end
|
53
|
+
|
54
|
+
it 'sets logger last_result' do
|
55
|
+
allow(Open3).to receive(:capture3).and_return(['stdout', 'stderr', double({exitstatus: 0})])
|
56
|
+
expect(options[:logger]).to receive(:last_result=).with(an_instance_of(Result))
|
57
|
+
connection.connect
|
58
|
+
connection.execute('my_command')
|
59
|
+
end
|
60
|
+
|
61
|
+
it 'sets exitcode to 1, when Open3 raises exeception' do
|
62
|
+
allow(Open3).to receive(:capture3).and_raise Errno::ENOENT
|
63
|
+
connection.connect
|
64
|
+
result = connection.execute('my_failing_command')
|
65
|
+
expect(result.exit_code).to eq(1)
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
describe '#scp_to' do
|
70
|
+
let(:source) { '/source/path' }
|
71
|
+
let(:dest) { '/dest/path' }
|
72
|
+
|
73
|
+
it 'calls FileUtils.cp_r' do
|
74
|
+
connection.connect
|
75
|
+
expect(FileUtils).to receive(:cp_r).with(source, dest)
|
76
|
+
connection.scp_to(source, dest)
|
77
|
+
end
|
78
|
+
|
79
|
+
it 'returns and Result object' do
|
80
|
+
expect(FileUtils).to receive(:cp_r).and_return(true)
|
81
|
+
connection.connect
|
82
|
+
result = connection.scp_to(source, dest)
|
83
|
+
expect(result.exit_code).to eq(0)
|
84
|
+
expect(result.stdout).to eq(" CP'ed file #{source} to #{dest}")
|
85
|
+
end
|
86
|
+
|
87
|
+
it 'catches exception and logs warning message' do
|
88
|
+
allow(FileUtils).to receive(:cp_r).and_raise Errno::ENOENT
|
89
|
+
expect(options[:logger]).to receive(:warn).with("Errno::ENOENT error in cp'ing. Forcing the connection to close, which should raise an error.")
|
90
|
+
connection.connect
|
91
|
+
connection.scp_to(source, dest)
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
describe '#scp_from' do
|
96
|
+
let(:source) { '/source/path' }
|
97
|
+
let(:dest) { '/dest/path' }
|
98
|
+
|
99
|
+
it 'callse scp_to with reversed params' do
|
100
|
+
expect(connection).to receive(:scp_to).with(dest, source, {})
|
101
|
+
connection.connect
|
102
|
+
connection.scp_from(source, dest)
|
103
|
+
end
|
104
|
+
end
|
105
|
+
end
|
106
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: beaker
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.
|
4
|
+
version: 4.27.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Puppet
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-09-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|
@@ -44,20 +44,20 @@ dependencies:
|
|
44
44
|
requirements:
|
45
45
|
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: '
|
47
|
+
version: '1.2'
|
48
48
|
- - "<"
|
49
49
|
- !ruby/object:Gem::Version
|
50
|
-
version:
|
50
|
+
version: 1.3.0
|
51
51
|
type: :development
|
52
52
|
prerelease: false
|
53
53
|
version_requirements: !ruby/object:Gem::Requirement
|
54
54
|
requirements:
|
55
55
|
- - "~>"
|
56
56
|
- !ruby/object:Gem::Version
|
57
|
-
version: '
|
57
|
+
version: '1.2'
|
58
58
|
- - "<"
|
59
59
|
- !ruby/object:Gem::Version
|
60
|
-
version:
|
60
|
+
version: 1.3.0
|
61
61
|
- !ruby/object:Gem::Dependency
|
62
62
|
name: simplecov
|
63
63
|
requirement: !ruby/object:Gem::Requirement
|
@@ -78,14 +78,14 @@ dependencies:
|
|
78
78
|
requirements:
|
79
79
|
- - "~>"
|
80
80
|
- !ruby/object:Gem::Version
|
81
|
-
version: '
|
81
|
+
version: '13.0'
|
82
82
|
type: :development
|
83
83
|
prerelease: false
|
84
84
|
version_requirements: !ruby/object:Gem::Requirement
|
85
85
|
requirements:
|
86
86
|
- - "~>"
|
87
87
|
- !ruby/object:Gem::Version
|
88
|
-
version: '
|
88
|
+
version: '13.0'
|
89
89
|
- !ruby/object:Gem::Dependency
|
90
90
|
name: beaker-aws
|
91
91
|
requirement: !ruby/object:Gem::Requirement
|
@@ -176,14 +176,14 @@ dependencies:
|
|
176
176
|
requirements:
|
177
177
|
- - "~>"
|
178
178
|
- !ruby/object:Gem::Version
|
179
|
-
version: '3.
|
179
|
+
version: '3.9'
|
180
180
|
type: :runtime
|
181
181
|
prerelease: false
|
182
182
|
version_requirements: !ruby/object:Gem::Requirement
|
183
183
|
requirements:
|
184
184
|
- - "~>"
|
185
185
|
- !ruby/object:Gem::Version
|
186
|
-
version: '3.
|
186
|
+
version: '3.9'
|
187
187
|
- !ruby/object:Gem::Dependency
|
188
188
|
name: rb-readline
|
189
189
|
requirement: !ruby/object:Gem::Requirement
|
@@ -230,16 +230,22 @@ dependencies:
|
|
230
230
|
name: net-scp
|
231
231
|
requirement: !ruby/object:Gem::Requirement
|
232
232
|
requirements:
|
233
|
-
- - "
|
233
|
+
- - ">="
|
234
234
|
- !ruby/object:Gem::Version
|
235
235
|
version: '1.2'
|
236
|
+
- - "<"
|
237
|
+
- !ruby/object:Gem::Version
|
238
|
+
version: '4.0'
|
236
239
|
type: :runtime
|
237
240
|
prerelease: false
|
238
241
|
version_requirements: !ruby/object:Gem::Requirement
|
239
242
|
requirements:
|
240
|
-
- - "
|
243
|
+
- - ">="
|
241
244
|
- !ruby/object:Gem::Version
|
242
245
|
version: '1.2'
|
246
|
+
- - "<"
|
247
|
+
- !ruby/object:Gem::Version
|
248
|
+
version: '4.0'
|
243
249
|
- !ruby/object:Gem::Dependency
|
244
250
|
name: inifile
|
245
251
|
requirement: !ruby/object:Gem::Requirement
|
@@ -352,6 +358,7 @@ executables:
|
|
352
358
|
extensions: []
|
353
359
|
extra_rdoc_files: []
|
354
360
|
files:
|
361
|
+
- ".github/dependabot.yml"
|
355
362
|
- ".gitignore"
|
356
363
|
- ".rspec"
|
357
364
|
- ".simplecov"
|
@@ -576,6 +583,7 @@ files:
|
|
576
583
|
- lib/beaker/hypervisor.rb
|
577
584
|
- lib/beaker/hypervisor/noop.rb
|
578
585
|
- lib/beaker/junit.xsl
|
586
|
+
- lib/beaker/local_connection.rb
|
579
587
|
- lib/beaker/logger.rb
|
580
588
|
- lib/beaker/logger_junit.rb
|
581
589
|
- lib/beaker/network_manager.rb
|
@@ -646,6 +654,7 @@ files:
|
|
646
654
|
- spec/beaker/host_prebuilt_steps_spec.rb
|
647
655
|
- spec/beaker/host_spec.rb
|
648
656
|
- spec/beaker/hypervisor/hypervisor_spec.rb
|
657
|
+
- spec/beaker/localhost_connection_spec.rb
|
649
658
|
- spec/beaker/logger_junit_spec.rb
|
650
659
|
- spec/beaker/logger_spec.rb
|
651
660
|
- spec/beaker/network_manager_spec.rb
|
@@ -692,7 +701,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
692
701
|
requirements:
|
693
702
|
- - ">="
|
694
703
|
- !ruby/object:Gem::Version
|
695
|
-
version: 2.
|
704
|
+
version: '2.4'
|
696
705
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
697
706
|
requirements:
|
698
707
|
- - ">="
|