beaker 2.33.0 → 2.34.0

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.
Files changed (44) hide show
  1. checksums.yaml +8 -8
  2. data/HISTORY.md +173 -2
  3. data/README.md +5 -0
  4. data/acceptance/tests/base/dsl/helpers/host_helpers/check_for_package_test.rb +0 -5
  5. data/acceptance/tests/base/dsl/helpers/host_helpers/install_package_test.rb +0 -4
  6. data/acceptance/tests/base/dsl/helpers/host_helpers/upgrade_package_test.rb +0 -4
  7. data/docs/Beaker-Libraries.md +8 -0
  8. data/docs/Beaker-Recipes.md +13 -0
  9. data/docs/Docker-Support.md +19 -0
  10. data/docs/README.md +2 -0
  11. data/docs/hosts/cisco.md +60 -0
  12. data/docs/hosts/eos.md +2 -2
  13. data/lib/beaker/command.rb +4 -45
  14. data/lib/beaker/dsl/helpers/host_helpers.rb +14 -9
  15. data/lib/beaker/dsl/install_utils/foss_utils.rb +32 -32
  16. data/lib/beaker/host.rb +7 -3
  17. data/lib/beaker/host/cisco.rb +124 -0
  18. data/lib/beaker/host/pswindows/exec.rb +11 -0
  19. data/lib/beaker/host/pswindows/user.rb +1 -1
  20. data/lib/beaker/host/unix.rb +9 -2
  21. data/lib/beaker/host/unix/exec.rb +43 -0
  22. data/lib/beaker/host/unix/file.rb +19 -4
  23. data/lib/beaker/host/windows/exec.rb +13 -0
  24. data/lib/beaker/host/windows/user.rb +1 -1
  25. data/lib/beaker/hypervisor/docker.rb +9 -0
  26. data/lib/beaker/network_manager.rb +3 -1
  27. data/lib/beaker/test_case.rb +2 -0
  28. data/lib/beaker/version.rb +1 -1
  29. data/spec/beaker/command_spec.rb +17 -27
  30. data/spec/beaker/dsl/helpers/host_helpers_spec.rb +13 -1
  31. data/spec/beaker/dsl/install_utils/foss_utils_spec.rb +24 -15
  32. data/spec/beaker/dsl/install_utils/module_utils_spec.rb +2 -1
  33. data/spec/beaker/host/cisco_spec.rb +182 -0
  34. data/spec/beaker/host/pswindows/exec_spec.rb +54 -0
  35. data/spec/beaker/host/pswindows/user_spec.rb +70 -0
  36. data/spec/beaker/host/unix/exec_spec.rb +30 -0
  37. data/spec/beaker/host/unix/file_spec.rb +11 -4
  38. data/spec/beaker/host/unix/pkg_spec.rb +0 -1
  39. data/spec/beaker/host/unix_spec.rb +9 -0
  40. data/spec/beaker/host/windows/exec_spec.rb +17 -24
  41. data/spec/beaker/host/windows/user_spec.rb +70 -0
  42. data/spec/beaker/host_spec.rb +21 -0
  43. data/spec/beaker/hypervisor/docker_spec.rb +35 -0
  44. metadata +10 -2
@@ -0,0 +1,54 @@
1
+ require 'spec_helper'
2
+
3
+ module Beaker
4
+ describe PSWindows::Exec do
5
+ class PSWindowsExecTest
6
+ include PSWindows::Exec
7
+
8
+ def initialize(hash, logger)
9
+ @hash = hash
10
+ @logger = logger
11
+ end
12
+
13
+ def [](k)
14
+ @hash[k]
15
+ end
16
+
17
+ def to_s
18
+ "me"
19
+ end
20
+
21
+ end
22
+
23
+ let (:opts) { @opts || {} }
24
+ let (:logger) { double( 'logger' ).as_null_object }
25
+ let (:instance) { PSWindowsExecTest.new(opts, logger) }
26
+
27
+ context "rm" do
28
+
29
+ it "deletes" do
30
+ path = '/path/to/delete'
31
+ corrected_path = '\\path\\to\\delete'
32
+ expect( instance ).to receive(:execute).with("del /s /q #{corrected_path}").and_return(0)
33
+ expect( instance.rm_rf(path) ).to be === 0
34
+ end
35
+ end
36
+
37
+ context 'mv' do
38
+ let(:origin) { '/origin/path/of/content' }
39
+ let(:destination) { '/destination/path/of/content' }
40
+
41
+ it 'rm first' do
42
+ expect( instance ).to receive(:execute).with("del /s /q #{destination.gsub(/\//, '\\')}").and_return(0)
43
+ expect( instance ).to receive(:execute).with("move /y #{origin.gsub(/\//, '\\')} #{destination.gsub(/\//, '\\')}").and_return(0)
44
+ expect( instance.mv(origin, destination) ).to be === 0
45
+
46
+ end
47
+
48
+ it 'does not rm' do
49
+ expect( instance ).to receive(:execute).with("move /y #{origin.gsub(/\//, '\\')} #{destination.gsub(/\//, '\\')}").and_return(0)
50
+ expect( instance.mv(origin, destination, false) ).to be === 0
51
+ end
52
+ end
53
+ end
54
+ end
@@ -0,0 +1,70 @@
1
+ require 'spec_helper'
2
+
3
+ class PSWindowsUserTest
4
+ include PSWindows::User
5
+ end
6
+
7
+ describe PSWindowsUserTest do
8
+ let( :wmic_output ) do <<-EOS
9
+
10
+
11
+
12
+
13
+ Name=Administrator
14
+
15
+
16
+
17
+
18
+
19
+ Name=bob foo
20
+
21
+
22
+
23
+
24
+
25
+ Name=bob-dash
26
+
27
+
28
+
29
+
30
+
31
+ Name=bob.foo
32
+
33
+
34
+
35
+
36
+
37
+ Name=cyg_server
38
+
39
+
40
+
41
+
42
+
43
+
44
+
45
+
46
+ EOS
47
+ end
48
+ let( :command ) { 'cmd /c echo "" | wmic useraccount where localaccount="true" get name /format:value' }
49
+ let( :host ) { double.as_null_object }
50
+ let( :result ) { Beaker::Result.new( host, command ) }
51
+
52
+ describe '#user_list' do
53
+
54
+ it 'returns user names list correctly' do
55
+ result.stdout = wmic_output
56
+ expect( subject ).to receive( :execute ).with( command ).and_yield(result)
57
+ expect( subject.user_list ).to be === ['Administrator', 'bob foo', 'bob-dash', 'bob.foo', 'cyg_server']
58
+ end
59
+
60
+ it 'yields correctly with the result object' do
61
+ result.stdout = wmic_output
62
+ expect( subject ).to receive( :execute ).and_yield(result)
63
+ subject.user_list { |result|
64
+ expect( result.stdout ).to be === wmic_output
65
+ }
66
+ end
67
+
68
+ end
69
+
70
+ end
@@ -50,6 +50,25 @@ module Beaker
50
50
  end
51
51
  end
52
52
 
53
+ describe '#environment_string' do
54
+ let(:host) { {'pathseparator' => ':'} }
55
+
56
+ it 'returns a blank string if theres no env' do
57
+ expect( instance ).to receive( :is_powershell? ).never
58
+ expect( instance.environment_string( {} ) ).to be == ''
59
+ end
60
+
61
+ it 'takes an env hash with var_name/value pairs' do
62
+ expect( instance.environment_string( {:HOME => '/'} ) ).
63
+ to be == "env HOME=\"/\""
64
+ end
65
+
66
+ it 'takes an env hash with var_name/value[Array] pairs' do
67
+ expect( instance.environment_string( {:LD_PATH => ['/', '/tmp']}) ).
68
+ to be == "env LD_PATH=\"/:/tmp\""
69
+ end
70
+ end
71
+
53
72
  describe '#ssh_permit_user_environment' do
54
73
  it 'raises an error on unsupported platforms' do
55
74
  opts['platform'] = 'notarealthing01-parts-arch'
@@ -67,5 +86,16 @@ module Beaker
67
86
  }.to raise_error( ArgumentError, /#{opts['platform']}/ )
68
87
  end
69
88
  end
89
+
90
+ describe '#prepend_commands' do
91
+
92
+ it 'returns the pc parameter unchanged for non-cisco platforms' do
93
+ allow( instance ).to receive( :[] ).with( :platform ).and_return( 'notcisco' )
94
+ answer_prepend_commands = 'pc_param_unchanged_13579'
95
+ answer_test = instance.prepend_commands( 'fake_cmd', answer_prepend_commands )
96
+ expect( answer_test ).to be === answer_prepend_commands
97
+ end
98
+
99
+ end
70
100
  end
71
101
  end
@@ -102,18 +102,25 @@ module Beaker
102
102
 
103
103
  it 'builds the filename correctly for debian-based platforms' do
104
104
  @platform = 'debian-8-x86_64'
105
- filename = instance.repo_filename( 'pkg_name', 'pkg_version9' )
106
- correct = 'pl-pkg_name-pkg_version9-jessie.list'
105
+ filename = instance.repo_filename( 'pkg_name', 'pkg_version10' )
106
+ correct = 'pl-pkg_name-pkg_version10-jessie.list'
107
107
  expect( filename ).to be === correct
108
108
  end
109
109
 
110
110
  it 'uses the variant for the codename on the cumulus platform' do
111
111
  @platform = 'cumulus-2.5-x86_64'
112
- filename = instance.repo_filename( 'pkg_name', 'pkg_version10' )
113
- correct = 'pl-pkg_name-pkg_version10-cumulus.list'
112
+ filename = instance.repo_filename( 'pkg_name', 'pkg_version11' )
113
+ correct = 'pl-pkg_name-pkg_version11-cumulus.list'
114
114
  expect( filename ).to be === correct
115
115
  end
116
116
 
117
+ it 'adds wrlinux to variant on cisco platforms' do
118
+ @platform = 'cisco-5-x86_64'
119
+ allow( instance ).to receive( :is_pe? ) { false }
120
+ filename = instance.repo_filename( 'pkg_name', 'pkg_version12' )
121
+ expect( filename ).to match( /sion12\-cisco\-wrlinux\-/ )
122
+ end
123
+
117
124
  it 'errors for non-el or debian-based platforms' do
118
125
  @platform = 'freebsd-22-x86_64'
119
126
  expect {
@@ -142,7 +142,6 @@ module Beaker
142
142
  expect( instance ).to receive(:exec).with('', {}).and_return(generate_result("hello", {:exit_code => 0}))
143
143
  expect( instance.install_package(pkg) ).to be == "hello"
144
144
  end
145
-
146
145
  end
147
146
 
148
147
  context "install_package_with_rpm" do
@@ -204,5 +204,14 @@ module Unix
204
204
  expect( host.determine_ssh_server ).to be === :openssh
205
205
  end
206
206
  end
207
+
208
+ describe '#validate_setup' do
209
+
210
+ it 'does nothing for non cisco-5 platforms' do
211
+ @platform = 'el-7-x86_64'
212
+ validate_test = host.validate_setup
213
+ expect( validate_test ).to be_nil
214
+ end
215
+ end
207
216
  end
208
217
  end
@@ -1,9 +1,9 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  module Beaker
4
- describe PSWindows::Exec do
5
- class PSWindowsExecTest
6
- include PSWindows::Exec
4
+ describe Windows::Exec do
5
+ class WindowsExecTest
6
+ include Windows::Exec
7
7
 
8
8
  def initialize(hash, logger)
9
9
  @hash = hash
@@ -22,32 +22,25 @@ module Beaker
22
22
 
23
23
  let (:opts) { @opts || {} }
24
24
  let (:logger) { double( 'logger' ).as_null_object }
25
- let (:instance) { PSWindowsExecTest.new(opts, logger) }
25
+ let (:instance) { WindowsExecTest.new(opts, logger) }
26
26
 
27
- context "rm" do
28
-
29
- it "deletes" do
30
- path = '/path/to/delete'
31
- corrected_path = '\\path\\to\\delete'
32
- expect( instance ).to receive(:execute).with("del /s /q #{corrected_path}").and_return(0)
33
- expect( instance.rm_rf(path) ).to be === 0
27
+ describe '#prepend_commands' do
28
+ it 'sets spacing correctly if both parts are defined' do
29
+ allow( instance ).to receive( :is_cygwin? ).and_return( true )
30
+ command_str = instance.prepend_commands( 'command', 'pants', { :cmd_exe => true } )
31
+ expect( command_str ).to be === 'cmd.exe /c pants'
34
32
  end
35
- end
36
-
37
- context 'mv' do
38
- let(:origin) { '/origin/path/of/content' }
39
- let(:destination) { '/destination/path/of/content' }
40
-
41
- it 'rm first' do
42
- expect( instance ).to receive(:execute).with("del /s /q #{destination.gsub(/\//, '\\')}").and_return(0)
43
- expect( instance ).to receive(:execute).with("move /y #{origin.gsub(/\//, '\\')} #{destination.gsub(/\//, '\\')}").and_return(0)
44
- expect( instance.mv(origin, destination) ).to be === 0
45
33
 
34
+ it 'sets spacing empty if one is not supplied' do
35
+ allow( instance ).to receive( :is_cygwin? ).and_return( true )
36
+ command_str = instance.prepend_commands( 'command', 'pants' )
37
+ expect( command_str ).to be === 'pants'
46
38
  end
47
39
 
48
- it 'does not rm' do
49
- expect( instance ).to receive(:execute).with("move /y #{origin.gsub(/\//, '\\')} #{destination.gsub(/\//, '\\')}").and_return(0)
50
- expect( instance.mv(origin, destination, false) ).to be === 0
40
+ it 'does not use cmd.exe by default' do
41
+ allow( instance ).to receive( :is_cygwin? ).and_return( true )
42
+ command_str = instance.prepend_commands( 'pants' )
43
+ expect( command_str ).not_to match( /cmd\.exe/ )
51
44
  end
52
45
  end
53
46
  end
@@ -0,0 +1,70 @@
1
+ require 'spec_helper'
2
+
3
+ class WindowsUserTest
4
+ include Windows::User
5
+ end
6
+
7
+ describe WindowsUserTest do
8
+ let( :wmic_output ) do <<-EOS
9
+
10
+
11
+
12
+
13
+ Name=Administrator
14
+
15
+
16
+
17
+
18
+
19
+ Name=bob foo
20
+
21
+
22
+
23
+
24
+
25
+ Name=bob-dash
26
+
27
+
28
+
29
+
30
+
31
+ Name=bob.foo
32
+
33
+
34
+
35
+
36
+
37
+ Name=cyg_server
38
+
39
+
40
+
41
+
42
+
43
+
44
+
45
+
46
+ EOS
47
+ end
48
+ let( :command ) { 'cmd /c echo "" | wmic useraccount where localaccount="true" get name /format:value' }
49
+ let( :host ) { double.as_null_object }
50
+ let( :result ) { Beaker::Result.new( host, command ) }
51
+
52
+ describe '#user_list' do
53
+
54
+ it 'returns user names list correctly' do
55
+ result.stdout = wmic_output
56
+ expect( subject ).to receive( :execute ).with( command ).and_yield(result)
57
+ expect( subject.user_list ).to be === ['Administrator', 'bob foo', 'bob-dash', 'bob.foo', 'cyg_server']
58
+ end
59
+
60
+ it 'yields correctly with the result object' do
61
+ result.stdout = wmic_output
62
+ expect( subject ).to receive( :execute ).and_yield(result)
63
+ subject.user_list { |result|
64
+ expect( result.stdout ).to be === wmic_output
65
+ }
66
+ end
67
+
68
+ end
69
+
70
+ end
@@ -423,6 +423,27 @@ module Beaker
423
423
  host.do_scp_to *args
424
424
  end
425
425
 
426
+ it 'calls for host scp post operations after SCPing happens' do
427
+ create_files(['source'])
428
+ logger = host[:logger]
429
+ conn = double(:connection)
430
+ @options = { :logger => logger }
431
+ host.instance_variable_set :@connection, conn
432
+ args = [ '/source', 'target', {} ]
433
+ conn_args = args + [ nil ]
434
+
435
+ allow( logger ).to receive(:trace)
436
+ expect( conn ).to receive(:scp_to).ordered.with(
437
+ *conn_args
438
+ ).and_return(Beaker::Result.new(host, 'output!'))
439
+ allow( conn ).to receive(:ip).and_return(host['ip'])
440
+ allow( conn ).to receive(:vmhostname).and_return(host['vmhostname'])
441
+ allow( conn ).to receive(:hostname).and_return(host.name)
442
+ expect( host ).to receive( :scp_post_operations ).ordered
443
+
444
+ host.do_scp_to *args
445
+ end
446
+
426
447
  it 'throws an IOError when the file given doesn\'t exist' do
427
448
  expect { host.do_scp_to "/does/not/exist", "does/not/exist/over/there", {} }.to raise_error(IOError)
428
449
  end
@@ -203,6 +203,41 @@ module Beaker
203
203
  docker.provision
204
204
  end
205
205
 
206
+ it 'should create a container with volumes bound' do
207
+ hosts.each_with_index do |host, index|
208
+ host['mount_folders'] = {
209
+ 'mount1' => {
210
+ 'host_path' => '/source_folder',
211
+ 'container_path' => '/mount_point',
212
+ },
213
+ 'mount2' => {
214
+ 'host_path' => '/another_folder',
215
+ 'container_path' => '/another_mount',
216
+ 'opts' => 'ro',
217
+ },
218
+ 'mount3' => {
219
+ 'host_path' => '/different_folder',
220
+ 'container_path' => '/different_mount',
221
+ 'opts' => 'rw',
222
+ },
223
+ }
224
+
225
+ expect( ::Docker::Container ).to receive(:create).with({
226
+ 'Image' => image.id,
227
+ 'Hostname' => host.name,
228
+ 'HostConfig' => {
229
+ 'Binds' => [
230
+ '/source_folder:/mount_point',
231
+ '/another_folder:/another_mount:ro',
232
+ '/different_folder:/different_mount:rw',
233
+ ]
234
+ }
235
+ })
236
+ end
237
+
238
+ docker.provision
239
+ end
240
+
206
241
  it 'should start the container' do
207
242
  expect( container ).to receive(:start).with({'PublishAllPorts' => true, 'Privileged' => true})
208
243
 
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: 2.33.0
4
+ version: 2.34.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Puppetlabs
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-01-27 00:00:00.000000000 Z
11
+ date: 2016-02-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec
@@ -535,7 +535,9 @@ files:
535
535
  - docs/Access-the-Live-Test-Console-with-Pry.md
536
536
  - docs/Argument-Processing-and-Precedence.md
537
537
  - docs/Beaker-Installation.md
538
+ - docs/Beaker-Libraries.md
538
539
  - docs/Beaker-Owners-and-Reviewers.md
540
+ - docs/Beaker-Recipes.md
539
541
  - docs/Beaker-Test-Tagging.md
540
542
  - docs/Beaker-with-Masterless-Puppet.md
541
543
  - docs/Creating-A-Test-Environment.md
@@ -561,6 +563,7 @@ files:
561
563
  - docs/Vagrant-Support.md
562
564
  - docs/beaker-vs.-beaker-rspec.md
563
565
  - docs/hosts/README.md
566
+ - docs/hosts/cisco.md
564
567
  - docs/hosts/eos.md
565
568
  - docs/hypervisors/README.md
566
569
  - docs/hypervisors/aws.md
@@ -601,6 +604,7 @@ files:
601
604
  - lib/beaker/host/aix/file.rb
602
605
  - lib/beaker/host/aix/group.rb
603
606
  - lib/beaker/host/aix/user.rb
607
+ - lib/beaker/host/cisco.rb
604
608
  - lib/beaker/host/eos.rb
605
609
  - lib/beaker/host/freebsd.rb
606
610
  - lib/beaker/host/freebsd/exec.rb
@@ -699,12 +703,15 @@ files:
699
703
  - spec/beaker/dsl/structure_spec.rb
700
704
  - spec/beaker/dsl/wrappers_spec.rb
701
705
  - spec/beaker/host/aix_spec.rb
706
+ - spec/beaker/host/cisco_spec.rb
702
707
  - spec/beaker/host/eos_spec.rb
703
708
  - spec/beaker/host/freebsd/exec_spec.rb
704
709
  - spec/beaker/host/freebsd/pkg_spec.rb
705
710
  - spec/beaker/host/mac/group_spec.rb
706
711
  - spec/beaker/host/mac/user_spec.rb
707
712
  - spec/beaker/host/mac_spec.rb
713
+ - spec/beaker/host/pswindows/exec_spec.rb
714
+ - spec/beaker/host/pswindows/user_spec.rb
708
715
  - spec/beaker/host/pswindows_spec.rb
709
716
  - spec/beaker/host/unix/exec_spec.rb
710
717
  - spec/beaker/host/unix/file_spec.rb
@@ -713,6 +720,7 @@ files:
713
720
  - spec/beaker/host/windows/exec_spec.rb
714
721
  - spec/beaker/host/windows/group_spec.rb
715
722
  - spec/beaker/host/windows/pkg_spec.rb
723
+ - spec/beaker/host/windows/user_spec.rb
716
724
  - spec/beaker/host/windows_spec.rb
717
725
  - spec/beaker/host_prebuilt_steps_spec.rb
718
726
  - spec/beaker/host_spec.rb