beaker 4.24.0 → 4.28.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -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.24.0
4
+ version: 4.28.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Puppet
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-06-05 00:00:00.000000000 Z
11
+ date: 2020-12-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec
@@ -44,20 +44,14 @@ dependencies:
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '0.6'
48
- - - "<"
49
- - !ruby/object:Gem::Version
50
- version: 0.14.0
47
+ version: '1.0'
51
48
  type: :development
52
49
  prerelease: false
53
50
  version_requirements: !ruby/object:Gem::Requirement
54
51
  requirements:
55
52
  - - "~>"
56
53
  - !ruby/object:Gem::Version
57
- version: '0.6'
58
- - - "<"
59
- - !ruby/object:Gem::Version
60
- version: 0.14.0
54
+ version: '1.0'
61
55
  - !ruby/object:Gem::Dependency
62
56
  name: simplecov
63
57
  requirement: !ruby/object:Gem::Requirement
@@ -78,14 +72,14 @@ dependencies:
78
72
  requirements:
79
73
  - - "~>"
80
74
  - !ruby/object:Gem::Version
81
- version: '12.0'
75
+ version: '13.0'
82
76
  type: :development
83
77
  prerelease: false
84
78
  version_requirements: !ruby/object:Gem::Requirement
85
79
  requirements:
86
80
  - - "~>"
87
81
  - !ruby/object:Gem::Version
88
- version: '12.0'
82
+ version: '13.0'
89
83
  - !ruby/object:Gem::Dependency
90
84
  name: beaker-aws
91
85
  requirement: !ruby/object:Gem::Requirement
@@ -176,14 +170,14 @@ dependencies:
176
170
  requirements:
177
171
  - - "~>"
178
172
  - !ruby/object:Gem::Version
179
- version: '3.6'
173
+ version: '3.9'
180
174
  type: :runtime
181
175
  prerelease: false
182
176
  version_requirements: !ruby/object:Gem::Requirement
183
177
  requirements:
184
178
  - - "~>"
185
179
  - !ruby/object:Gem::Version
186
- version: '3.6'
180
+ version: '3.9'
187
181
  - !ruby/object:Gem::Dependency
188
182
  name: rb-readline
189
183
  requirement: !ruby/object:Gem::Requirement
@@ -230,16 +224,22 @@ dependencies:
230
224
  name: net-scp
231
225
  requirement: !ruby/object:Gem::Requirement
232
226
  requirements:
233
- - - "~>"
227
+ - - ">="
234
228
  - !ruby/object:Gem::Version
235
229
  version: '1.2'
230
+ - - "<"
231
+ - !ruby/object:Gem::Version
232
+ version: '4.0'
236
233
  type: :runtime
237
234
  prerelease: false
238
235
  version_requirements: !ruby/object:Gem::Requirement
239
236
  requirements:
240
- - - "~>"
237
+ - - ">="
241
238
  - !ruby/object:Gem::Version
242
239
  version: '1.2'
240
+ - - "<"
241
+ - !ruby/object:Gem::Version
242
+ version: '4.0'
243
243
  - !ruby/object:Gem::Dependency
244
244
  name: inifile
245
245
  requirement: !ruby/object:Gem::Requirement
@@ -346,16 +346,18 @@ dependencies:
346
346
  version: '0'
347
347
  description: Puppet's accceptance testing harness
348
348
  email:
349
- - delivery@puppet.com
349
+ - voxpupuli@groups.io
350
350
  executables:
351
351
  - beaker
352
352
  extensions: []
353
353
  extra_rdoc_files: []
354
354
  files:
355
+ - ".github/dependabot.yml"
356
+ - ".github/workflows/release.yml"
357
+ - ".github/workflows/test.yml"
355
358
  - ".gitignore"
356
359
  - ".rspec"
357
360
  - ".simplecov"
358
- - ".travis.yml"
359
361
  - CHANGELOG.md
360
362
  - CODEOWNERS
361
363
  - CONTRIBUTING.md
@@ -576,6 +578,7 @@ files:
576
578
  - lib/beaker/hypervisor.rb
577
579
  - lib/beaker/hypervisor/noop.rb
578
580
  - lib/beaker/junit.xsl
581
+ - lib/beaker/local_connection.rb
579
582
  - lib/beaker/logger.rb
580
583
  - lib/beaker/logger_junit.rb
581
584
  - lib/beaker/network_manager.rb
@@ -646,6 +649,7 @@ files:
646
649
  - spec/beaker/host_prebuilt_steps_spec.rb
647
650
  - spec/beaker/host_spec.rb
648
651
  - spec/beaker/hypervisor/hypervisor_spec.rb
652
+ - spec/beaker/localhost_connection_spec.rb
649
653
  - spec/beaker/logger_junit_spec.rb
650
654
  - spec/beaker/logger_spec.rb
651
655
  - spec/beaker/network_manager_spec.rb
@@ -680,9 +684,9 @@ files:
680
684
  - spec/mock_vsphere_helper.rb
681
685
  - spec/mocks.rb
682
686
  - spec/spec_helper.rb
683
- homepage: https://github.com/puppetlabs/beaker
687
+ homepage: https://github.com/voxpupuli/beaker
684
688
  licenses:
685
- - Apache2
689
+ - Apache-2.0
686
690
  metadata: {}
687
691
  post_install_message:
688
692
  rdoc_options: []
@@ -692,14 +696,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
692
696
  requirements:
693
697
  - - ">="
694
698
  - !ruby/object:Gem::Version
695
- version: 2.1.8
699
+ version: '2.4'
696
700
  required_rubygems_version: !ruby/object:Gem::Requirement
697
701
  requirements:
698
702
  - - ">="
699
703
  - !ruby/object:Gem::Version
700
704
  version: '0'
701
705
  requirements: []
702
- rubygems_version: 3.0.6
706
+ rubygems_version: 3.1.4
703
707
  signing_key:
704
708
  specification_version: 4
705
709
  summary: Let's test Puppet!
@@ -1,12 +0,0 @@
1
- before_install:
2
- - gem update --system 2.2.1
3
- - gem --version
4
- language: ruby
5
- script: "bundle exec rake travis"
6
- notifications:
7
- email: false
8
- rvm:
9
- - 2.6
10
- - 2.0.0
11
- - 1.9.3
12
- - 1.8.7-p374