beaker 1.21.0 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (103) hide show
  1. checksums.yaml +8 -8
  2. data/.gitignore +1 -0
  3. data/.rspec +1 -0
  4. data/CONTRIBUTING.md +1 -0
  5. data/HISTORY.md +17288 -2
  6. data/Rakefile +6 -2
  7. data/beaker.gemspec +15 -19
  8. data/lib/beaker.rb +2 -5
  9. data/lib/beaker/answers.rb +2 -0
  10. data/lib/beaker/answers/version34.rb +37 -1
  11. data/lib/beaker/cli.rb +4 -0
  12. data/lib/beaker/command.rb +16 -84
  13. data/lib/beaker/command_factory.rb +13 -2
  14. data/lib/beaker/dsl/assertions.rb +25 -2
  15. data/lib/beaker/dsl/ezbake_utils.rb +2 -2
  16. data/lib/beaker/dsl/helpers.rb +66 -12
  17. data/lib/beaker/dsl/install_utils.rb +128 -66
  18. data/lib/beaker/dsl/wrappers.rb +41 -3
  19. data/lib/beaker/host.rb +42 -6
  20. data/lib/beaker/host/mac.rb +62 -0
  21. data/lib/beaker/host/mac/group.rb +96 -0
  22. data/lib/beaker/host/mac/user.rb +93 -0
  23. data/lib/beaker/host/unix/exec.rb +1 -1
  24. data/lib/beaker/host/unix/pkg.rb +11 -11
  25. data/lib/beaker/host/windows.rb +4 -4
  26. data/lib/beaker/host_prebuilt_steps.rb +194 -58
  27. data/lib/beaker/hypervisor.rb +16 -9
  28. data/lib/beaker/hypervisor/aws_sdk.rb +61 -17
  29. data/lib/beaker/hypervisor/docker.rb +14 -2
  30. data/lib/beaker/hypervisor/ec2_helper.rb +15 -3
  31. data/lib/beaker/hypervisor/vagrant.rb +22 -10
  32. data/lib/beaker/hypervisor/vagrant_libvirt.rb +11 -0
  33. data/lib/beaker/hypervisor/vagrant_virtualbox.rb +1 -1
  34. data/lib/beaker/hypervisor/vcloud_pooled.rb +8 -39
  35. data/lib/beaker/logger.rb +15 -9
  36. data/lib/beaker/network_manager.rb +2 -2
  37. data/lib/beaker/options/command_line_parser.rb +1 -1
  38. data/lib/beaker/options/parser.rb +1 -8
  39. data/lib/beaker/options/presets.rb +70 -45
  40. data/lib/beaker/perf.rb +3 -4
  41. data/lib/beaker/platform.rb +2 -1
  42. data/lib/beaker/result.rb +3 -9
  43. data/lib/beaker/ssh_connection.rb +2 -0
  44. data/lib/beaker/test_case.rb +2 -21
  45. data/lib/beaker/test_suite.rb +21 -25
  46. data/lib/beaker/version.rb +1 -1
  47. data/spec/beaker/answers_spec.rb +36 -0
  48. data/spec/beaker/cli_spec.rb +45 -45
  49. data/spec/beaker/command_spec.rb +25 -36
  50. data/spec/beaker/dsl/assertions_spec.rb +20 -27
  51. data/spec/beaker/dsl/ezbake_utils_spec.rb +5 -5
  52. data/spec/beaker/dsl/helpers_spec.rb +293 -208
  53. data/spec/beaker/dsl/install_utils_spec.rb +310 -189
  54. data/spec/beaker/dsl/outcomes_spec.rb +6 -6
  55. data/spec/beaker/dsl/roles_spec.rb +27 -18
  56. data/spec/beaker/dsl/structure_spec.rb +11 -11
  57. data/spec/beaker/dsl/wrappers_spec.rb +35 -11
  58. data/spec/beaker/host/mac/group_spec.rb +124 -0
  59. data/spec/beaker/host/mac/user_spec.rb +134 -0
  60. data/spec/beaker/host/unix/pkg_spec.rb +40 -24
  61. data/spec/beaker/host/windows/group_spec.rb +1 -1
  62. data/spec/beaker/host_prebuilt_steps_spec.rb +194 -68
  63. data/spec/beaker/host_spec.rb +145 -67
  64. data/spec/beaker/hypervisor/aixer_spec.rb +6 -6
  65. data/spec/beaker/hypervisor/aws_sdk_spec.rb +22 -7
  66. data/spec/beaker/hypervisor/docker_spec.rb +71 -50
  67. data/spec/beaker/hypervisor/ec2_helper_spec.rb +25 -4
  68. data/spec/beaker/hypervisor/fusion_spec.rb +2 -2
  69. data/spec/beaker/hypervisor/hypervisor_spec.rb +20 -27
  70. data/spec/beaker/hypervisor/hypervisor_spec.rb.orig +80 -0
  71. data/spec/beaker/hypervisor/solaris_spec.rb +8 -8
  72. data/spec/beaker/hypervisor/vagrant_fusion_spec.rb +6 -8
  73. data/spec/beaker/hypervisor/vagrant_libvirt_spec.rb +34 -0
  74. data/spec/beaker/hypervisor/vagrant_spec.rb +34 -33
  75. data/spec/beaker/hypervisor/vagrant_virtualbox_spec.rb +18 -8
  76. data/spec/beaker/hypervisor/vagrant_workstation_spec.rb +6 -8
  77. data/spec/beaker/hypervisor/vcloud_pooled_spec.rb +8 -8
  78. data/spec/beaker/hypervisor/vcloud_spec.rb +10 -10
  79. data/spec/beaker/hypervisor/vsphere_helper_spec.rb +8 -8
  80. data/spec/beaker/hypervisor/vsphere_spec.rb +1 -1
  81. data/spec/beaker/logger_spec.rb +45 -31
  82. data/spec/beaker/options/command_line_parser_spec.rb +10 -2
  83. data/spec/beaker/options/hosts_file_parser_spec.rb +9 -2
  84. data/spec/beaker/options/options_hash_spec.rb +2 -2
  85. data/spec/beaker/options/parser_spec.rb +2 -2
  86. data/spec/beaker/options/pe_version_scaper_spec.rb +6 -1
  87. data/spec/beaker/options/presets_spec.rb +11 -1
  88. data/spec/beaker/shared/error_handler_spec.rb +5 -5
  89. data/spec/beaker/shared/host_manager_spec.rb +3 -2
  90. data/spec/beaker/shared/repetition_spec.rb +18 -18
  91. data/spec/beaker/ssh_connection_spec.rb +33 -4
  92. data/spec/beaker/test_case_spec.rb +9 -9
  93. data/spec/beaker/test_suite_spec.rb +14 -14
  94. data/spec/helpers.rb +4 -4
  95. data/spec/matchers.rb +4 -4
  96. data/spec/mocks.rb +5 -1
  97. data/spec/spec_helper.rb +2 -8
  98. metadata +114 -80
  99. data/lib/beaker/hypervisor/blimper.rb +0 -108
  100. data/spec/beaker/hypervisor/blimper_spec.rb +0 -42
  101. data/spec/beaker/options/data/LATEST +0 -1
  102. data/spec/beaker/puppet_command_spec.rb +0 -161
  103. data/spec/mock_blimpy.rb +0 -48
@@ -25,67 +25,83 @@ module Beaker
25
25
 
26
26
  context "check_for_package" do
27
27
 
28
- it "runs the correctly on sles" do
28
+ it "checks correctly on sles" do
29
29
  @opts = {'platform' => 'sles-is-me'}
30
30
  pkg = 'sles_package'
31
- Beaker::Command.should_receive(:new).with("zypper se -i --match-exact #{pkg}").and_return('')
32
- instance.should_receive(:exec).with('', :acceptable_exit_codes => (0...127)).and_return(generate_result("hello", {:exit_code => 0}))
31
+ expect( Beaker::Command ).to receive(:new).with("zypper se -i --match-exact #{pkg}").and_return('')
32
+ expect( instance ).to receive(:exec).with('', :acceptable_exit_codes => (0...127)).and_return(generate_result("hello", {:exit_code => 0}))
33
33
  expect( instance.check_for_package(pkg) ).to be === true
34
34
  end
35
35
 
36
- it "runs the correctly on fedora" do
36
+ it "checks correctly on fedora" do
37
37
  @opts = {'platform' => 'fedora-is-me'}
38
38
  pkg = 'fedora_package'
39
- Beaker::Command.should_receive(:new).with("rpm -q #{pkg}").and_return('')
40
- instance.should_receive(:exec).with('', :acceptable_exit_codes => (0...127)).and_return(generate_result("hello", {:exit_code => 0}))
39
+ expect( Beaker::Command ).to receive(:new).with("rpm -q #{pkg}").and_return('')
40
+ expect( instance ).to receive(:exec).with('', :acceptable_exit_codes => (0...127)).and_return(generate_result("hello", {:exit_code => 0}))
41
41
  expect( instance.check_for_package(pkg) ).to be === true
42
42
  end
43
43
 
44
- it "runs the correctly on centos" do
44
+ it "checks correctly on centos" do
45
45
  @opts = {'platform' => 'centos-is-me'}
46
46
  pkg = 'centos_package'
47
- Beaker::Command.should_receive(:new).with("rpm -q #{pkg}").and_return('')
48
- instance.should_receive(:exec).with('', :acceptable_exit_codes => (0...127)).and_return(generate_result("hello", {:exit_code => 0}))
47
+ expect( Beaker::Command ).to receive(:new).with("rpm -q #{pkg}").and_return('')
48
+ expect( instance ).to receive(:exec).with('', :acceptable_exit_codes => (0...127)).and_return(generate_result("hello", {:exit_code => 0}))
49
49
  expect( instance.check_for_package(pkg) ).to be === true
50
50
  end
51
51
 
52
- it "runs the correctly on el-" do
52
+ it "checks correctly on EOS" do
53
+ @opts = {'platform' => 'eos-is-me'}
54
+ pkg = 'eos-package'
55
+ expect( Beaker::Command ).to receive(:new).with("rpm -q #{pkg}").and_return('')
56
+ expect( instance ).to receive(:exec).with('', :acceptable_exit_codes => (0...127)).and_return(generate_result("hello", {:exit_code => 0}))
57
+ expect( instance.check_for_package(pkg) ).to be === true
58
+ end
59
+
60
+ it "checks correctly on el-" do
53
61
  @opts = {'platform' => 'el-is-me'}
54
62
  pkg = 'el_package'
55
- Beaker::Command.should_receive(:new).with("rpm -q #{pkg}").and_return('')
56
- instance.should_receive(:exec).with('', :acceptable_exit_codes => (0...127)).and_return(generate_result("hello", {:exit_code => 0}))
63
+ expect( Beaker::Command ).to receive(:new).with("rpm -q #{pkg}").and_return('')
64
+ expect( instance ).to receive(:exec).with('', :acceptable_exit_codes => (0...127)).and_return(generate_result("hello", {:exit_code => 0}))
57
65
  expect( instance.check_for_package(pkg) ).to be === true
58
66
  end
59
67
 
60
- it "runs the correctly on debian" do
68
+ it "checks correctly on debian" do
61
69
  @opts = {'platform' => 'debian-is-me'}
62
70
  pkg = 'debian_package'
63
- Beaker::Command.should_receive(:new).with("dpkg -s #{pkg}").and_return('')
64
- instance.should_receive(:exec).with('', :acceptable_exit_codes => (0...127)).and_return(generate_result("hello", {:exit_code => 0}))
71
+ expect( Beaker::Command ).to receive(:new).with("dpkg -s #{pkg}").and_return('')
72
+ expect( instance ).to receive(:exec).with('', :acceptable_exit_codes => (0...127)).and_return(generate_result("hello", {:exit_code => 0}))
65
73
  expect( instance.check_for_package(pkg) ).to be === true
66
74
  end
67
75
 
68
- it "runs the correctly on ubuntu" do
76
+ it "checks correctly on ubuntu" do
69
77
  @opts = {'platform' => 'ubuntu-is-me'}
70
78
  pkg = 'ubuntu_package'
71
- Beaker::Command.should_receive(:new).with("dpkg -s #{pkg}").and_return('')
72
- instance.should_receive(:exec).with('', :acceptable_exit_codes => (0...127)).and_return(generate_result("hello", {:exit_code => 0}))
79
+ expect( Beaker::Command ).to receive(:new).with("dpkg -s #{pkg}").and_return('')
80
+ expect( instance ).to receive(:exec).with('', :acceptable_exit_codes => (0...127)).and_return(generate_result("hello", {:exit_code => 0}))
81
+ expect( instance.check_for_package(pkg) ).to be === true
82
+ end
83
+
84
+ it "checks correctly on cumulus" do
85
+ @opts = {'platform' => 'cumulus-is-me'}
86
+ pkg = 'cumulus_package'
87
+ expect( Beaker::Command ).to receive(:new).with("dpkg -s #{pkg}").and_return('')
88
+ expect( instance ).to receive(:exec).with('', :acceptable_exit_codes => (0...127)).and_return(generate_result("hello", {:exit_code => 0}))
73
89
  expect( instance.check_for_package(pkg) ).to be === true
74
90
  end
75
91
 
76
- it "runs the correctly on solaris-11" do
92
+ it "checks correctly on solaris-11" do
77
93
  @opts = {'platform' => 'solaris-11-is-me'}
78
94
  pkg = 'solaris-11_package'
79
- Beaker::Command.should_receive(:new).with("pkg info #{pkg}").and_return('')
80
- instance.should_receive(:exec).with('', :acceptable_exit_codes => (0...127)).and_return(generate_result("hello", {:exit_code => 0}))
95
+ expect( Beaker::Command ).to receive(:new).with("pkg info #{pkg}").and_return('')
96
+ expect( instance ).to receive(:exec).with('', :acceptable_exit_codes => (0...127)).and_return(generate_result("hello", {:exit_code => 0}))
81
97
  expect( instance.check_for_package(pkg) ).to be === true
82
98
  end
83
99
 
84
- it "runs the correctly on solaris-10" do
100
+ it "checks correctly on solaris-10" do
85
101
  @opts = {'platform' => 'solaris-10-is-me'}
86
102
  pkg = 'solaris-10_package'
87
- Beaker::Command.should_receive(:new).with("pkginfo #{pkg}").and_return('')
88
- instance.should_receive(:exec).with('', :acceptable_exit_codes => (0...127)).and_return(generate_result("hello", {:exit_code => 0}))
103
+ expect( Beaker::Command ).to receive(:new).with("pkginfo #{pkg}").and_return('')
104
+ expect( instance ).to receive(:exec).with('', :acceptable_exit_codes => (0...127)).and_return(generate_result("hello", {:exit_code => 0}))
89
105
  expect( instance.check_for_package(pkg) ).to be === true
90
106
  end
91
107
 
@@ -29,7 +29,7 @@ Name=#{group_name}
29
29
  end
30
30
 
31
31
  before(:each) do
32
- instance.should_receive(:execute).with(/wmic group where/).and_yield(result)
32
+ expect( instance ).to receive(:execute).with(/wmic group where/).and_yield(result)
33
33
  end
34
34
 
35
35
  it "gets a group_list" do
@@ -19,8 +19,7 @@ describe Beaker do
19
19
  hosts[1][:roles] = ['master', 'dashboard', 'agent', 'database']
20
20
  hosts[2][:roles] = ['agent']
21
21
  hosts }
22
- let( :dummy_class ) { Class.new { include Beaker::HostPrebuiltSteps
23
- include Beaker::DSL::Patterns } }
22
+ let( :dummy_class ) { Class.new { include Beaker::HostPrebuiltSteps } }
24
23
 
25
24
  context 'timesync' do
26
25
 
@@ -29,25 +28,25 @@ describe Beaker do
29
28
  it "can sync time on unix hosts" do
30
29
  hosts = make_hosts( { :platform => 'unix' } )
31
30
 
32
- Beaker::Command.should_receive( :new ).with("ntpdate -t 20 #{ntpserver}").exactly( 3 ).times
31
+ expect( Beaker::Command ).to receive( :new ).with("ntpdate -t 20 #{ntpserver}").exactly( 3 ).times
33
32
 
34
33
  subject.timesync( hosts, options )
35
34
  end
36
35
 
37
36
  it "can retry on failure on unix hosts" do
38
37
  hosts = make_hosts( { :platform => 'unix', :exit_code => [1, 0] } )
39
- subject.stub( :sleep ).and_return(true)
38
+ allow( subject ).to receive( :sleep ).and_return(true)
40
39
 
41
- Beaker::Command.should_receive( :new ).with("ntpdate -t 20 #{ntpserver}").exactly( 6 ).times
40
+ expect( Beaker::Command ).to receive( :new ).with("ntpdate -t 20 #{ntpserver}").exactly( 6 ).times
42
41
 
43
42
  subject.timesync( hosts, options )
44
43
  end
45
44
 
46
45
  it "eventually gives up and raises an error when unix hosts can't be synched" do
47
46
  hosts = make_hosts( { :platform => 'unix', :exit_code => 1 } )
48
- subject.stub( :sleep ).and_return(true)
47
+ allow( subject ).to receive( :sleep ).and_return(true)
49
48
 
50
- Beaker::Command.should_receive( :new ).with("ntpdate -t 20 #{ntpserver}").exactly( 5 ).times
49
+ expect( Beaker::Command ).to receive( :new ).with("ntpdate -t 20 #{ntpserver}").exactly( 5 ).times
51
50
 
52
51
  expect{ subject.timesync( hosts, options ) }.to raise_error
53
52
  end
@@ -55,10 +54,10 @@ describe Beaker do
55
54
  it "can sync time on windows hosts" do
56
55
  hosts = make_hosts( { :platform => 'windows' } )
57
56
 
58
- Beaker::Command.should_receive( :new ).with("w32tm /register").exactly( 3 ).times
59
- Beaker::Command.should_receive( :new ).with("net start w32time").exactly( 3 ).times
60
- Beaker::Command.should_receive( :new ).with("w32tm /config /manualpeerlist:#{ntpserver} /syncfromflags:manual /update").exactly( 3 ).times
61
- Beaker::Command.should_receive( :new ).with("w32tm /resync").exactly( 3 ).times
57
+ expect( Beaker::Command ).to receive( :new ).with("w32tm /register").exactly( 3 ).times
58
+ expect( Beaker::Command ).to receive( :new ).with("net start w32time").exactly( 3 ).times
59
+ expect( Beaker::Command ).to receive( :new ).with("w32tm /config /manualpeerlist:#{ntpserver} /syncfromflags:manual /update").exactly( 3 ).times
60
+ expect( Beaker::Command ).to receive( :new ).with("w32tm /resync").exactly( 3 ).times
62
61
 
63
62
  subject.timesync( hosts, options )
64
63
 
@@ -67,7 +66,7 @@ describe Beaker do
67
66
  it "can sync time on Sles hosts" do
68
67
  hosts = make_hosts( { :platform => 'sles-13.1-x64' } )
69
68
 
70
- Beaker::Command.should_receive( :new ).with("sntp #{ntpserver}").exactly( 3 ).times
69
+ expect( Beaker::Command ).to receive( :new ).with("sntp #{ntpserver}").exactly( 3 ).times
71
70
 
72
71
  subject.timesync( hosts, options )
73
72
 
@@ -76,7 +75,7 @@ describe Beaker do
76
75
  it "can set time server on unix hosts" do
77
76
  hosts = make_hosts( { :platform => 'unix' } )
78
77
 
79
- Beaker::Command.should_receive( :new ).with("ntpdate -t 20 #{ntpserver_set}").exactly( 3 ).times
78
+ expect( Beaker::Command ).to receive( :new ).with("ntpdate -t 20 #{ntpserver_set}").exactly( 3 ).times
80
79
 
81
80
  subject.timesync( hosts, options_ntp )
82
81
  end
@@ -84,10 +83,10 @@ describe Beaker do
84
83
  it "can set time server on windows hosts" do
85
84
  hosts = make_hosts( { :platform => 'windows' } )
86
85
 
87
- Beaker::Command.should_receive( :new ).with("w32tm /register").exactly( 3 ).times
88
- Beaker::Command.should_receive( :new ).with("net start w32time").exactly( 3 ).times
89
- Beaker::Command.should_receive( :new ).with("w32tm /config /manualpeerlist:#{ntpserver_set} /syncfromflags:manual /update").exactly( 3 ).times
90
- Beaker::Command.should_receive( :new ).with("w32tm /resync").exactly( 3 ).times
86
+ expect( Beaker::Command ).to receive( :new ).with("w32tm /register").exactly( 3 ).times
87
+ expect( Beaker::Command ).to receive( :new ).with("net start w32time").exactly( 3 ).times
88
+ expect( Beaker::Command ).to receive( :new ).with("w32tm /config /manualpeerlist:#{ntpserver_set} /syncfromflags:manual /update").exactly( 3 ).times
89
+ expect( Beaker::Command ).to receive( :new ).with("w32tm /resync").exactly( 3 ).times
91
90
 
92
91
  subject.timesync( hosts, options_ntp )
93
92
 
@@ -96,7 +95,7 @@ describe Beaker do
96
95
  it "can set time server on Sles hosts" do
97
96
  hosts = make_hosts( { :platform => 'sles-13.1-x64' } )
98
97
 
99
- Beaker::Command.should_receive( :new ).with("sntp #{ntpserver_set}").exactly( 3 ).times
98
+ expect( Beaker::Command ).to receive( :new ).with("sntp #{ntpserver_set}").exactly( 3 ).times
100
99
 
101
100
  subject.timesync( hosts, options_ntp )
102
101
 
@@ -134,7 +133,7 @@ describe Beaker do
134
133
  it "can perform apt-get on ubuntu hosts" do
135
134
  host = make_host( 'testhost', { :platform => 'ubuntu' } )
136
135
 
137
- Beaker::Command.should_receive( :new ).with("apt-get update").once
136
+ expect( Beaker::Command ).to receive( :new ).with("apt-get update").once
138
137
 
139
138
  subject.apt_get_update( host )
140
139
 
@@ -143,16 +142,25 @@ describe Beaker do
143
142
  it "can perform apt-get on debian hosts" do
144
143
  host = make_host( 'testhost', { :platform => 'debian' } )
145
144
 
146
- Beaker::Command.should_receive( :new ).with("apt-get update").once
145
+ expect( Beaker::Command ).to receive( :new ).with("apt-get update").once
147
146
 
148
147
  subject.apt_get_update( host )
149
148
 
150
149
  end
151
150
 
152
- it "does nothing on non debian/ubuntu hosts" do
151
+ it "can perform apt-get on cumulus hosts" do
152
+ host = make_host( 'testhost', { :platform => 'cumulus' } )
153
+
154
+ expect( Beaker::Command ).to receive( :new ).with("apt-get update").once
155
+
156
+ subject.apt_get_update( host )
157
+
158
+ end
159
+
160
+ it "does nothing on non debian/ubuntu/cumulus hosts" do
153
161
  host = make_host( 'testhost', { :platform => 'windows' } )
154
162
 
155
- Beaker::Command.should_receive( :new ).never
163
+ expect( Beaker::Command ).to receive( :new ).never
156
164
 
157
165
  subject.apt_get_update( host )
158
166
 
@@ -169,13 +177,13 @@ describe Beaker do
169
177
  filepath = "/path/to/file"
170
178
  host = make_host( 'testhost', { :platform => 'windows' })
171
179
  tempfile = double( 'tempfile' )
172
- tempfile.stub( :path ).and_return( tempfilepath )
173
- Tempfile.stub( :open ).and_yield( tempfile )
180
+ allow( tempfile ).to receive( :path ).and_return( tempfilepath )
181
+ allow( Tempfile ).to receive( :open ).and_yield( tempfile )
174
182
  file = double( 'file' )
175
- File.stub( :open ).and_yield( file )
183
+ allow( File ).to receive( :open ).and_yield( file )
176
184
 
177
- file.should_receive( :puts ).with( content ).once
178
- host.should_receive( :do_scp_to ).with( tempfilepath, filepath, subject.instance_variable_get( :@options ) ).once
185
+ expect( file ).to receive( :puts ).with( content ).once
186
+ expect( host ).to receive( :do_scp_to ).with( tempfilepath, filepath, subject.instance_variable_get( :@options ) ).once
179
187
 
180
188
  subject.copy_file_to_remote(host, filepath, content)
181
189
 
@@ -189,10 +197,10 @@ describe Beaker do
189
197
  it "correctly configures ubuntu hosts" do
190
198
  hosts = make_hosts( { :platform => 'ubuntu', :exit_code => 1 } )
191
199
 
192
- Beaker::Command.should_receive( :new ).with( "if test -f /etc/apt/apt.conf; then mv /etc/apt/apt.conf /etc/apt/apt.conf.bk; fi" ).exactly( 3 )
200
+ expect( Beaker::Command ).to receive( :new ).with( "if test -f /etc/apt/apt.conf; then mv /etc/apt/apt.conf /etc/apt/apt.conf.bk; fi" ).exactly( 3 )
193
201
  hosts.each do |host|
194
- subject.should_receive( :copy_file_to_remote ).with( host, '/etc/apt/apt.conf', apt_cfg ).once
195
- subject.should_receive( :apt_get_update ).with( host ).once
202
+ expect( subject ).to receive( :copy_file_to_remote ).with( host, '/etc/apt/apt.conf', apt_cfg ).once
203
+ expect( subject ).to receive( :apt_get_update ).with( host ).once
196
204
  end
197
205
 
198
206
  subject.proxy_config( hosts, options )
@@ -202,10 +210,23 @@ describe Beaker do
202
210
  it "correctly configures debian hosts" do
203
211
  hosts = make_hosts( { :platform => 'debian' } )
204
212
 
205
- Beaker::Command.should_receive( :new ).with( "if test -f /etc/apt/apt.conf; then mv /etc/apt/apt.conf /etc/apt/apt.conf.bk; fi" ).exactly( 3 ).times
213
+ expect( Beaker::Command ).to receive( :new ).with( "if test -f /etc/apt/apt.conf; then mv /etc/apt/apt.conf /etc/apt/apt.conf.bk; fi" ).exactly( 3 ).times
214
+ hosts.each do |host|
215
+ expect( subject ).to receive( :copy_file_to_remote ).with( host, '/etc/apt/apt.conf', apt_cfg ).once
216
+ expect( subject ).to receive( :apt_get_update ).with( host ).once
217
+ end
218
+
219
+ subject.proxy_config( hosts, options )
220
+
221
+ end
222
+
223
+ it "correctly configures cumulus hosts" do
224
+ hosts = make_hosts( { :platform => 'cumulus' } )
225
+
226
+ expect( Beaker::Command ).to receive( :new ).with( "if test -f /etc/apt/apt.conf; then mv /etc/apt/apt.conf /etc/apt/apt.conf.bk; fi" ).exactly( 3 ).times
206
227
  hosts.each do |host|
207
- subject.should_receive( :copy_file_to_remote ).with( host, '/etc/apt/apt.conf', apt_cfg ).once
208
- subject.should_receive( :apt_get_update ).with( host ).once
228
+ expect( subject ).to receive( :copy_file_to_remote ).with( host, '/etc/apt/apt.conf', apt_cfg ).once
229
+ expect( subject ).to receive( :apt_get_update ).with( host ).once
209
230
  end
210
231
 
211
232
  subject.proxy_config( hosts, options )
@@ -215,19 +236,19 @@ describe Beaker do
215
236
  it "correctly configures solaris-11 hosts" do
216
237
  hosts = make_hosts( { :platform => 'solaris-11' } )
217
238
 
218
- Beaker::Command.should_receive( :new ).with( "/usr/bin/pkg unset-publisher solaris || :" ).exactly( 3 ).times
239
+ expect( Beaker::Command ).to receive( :new ).with( "/usr/bin/pkg unset-publisher solaris || :" ).exactly( 3 ).times
219
240
  hosts.each do |host|
220
- Beaker::Command.should_receive( :new ).with( "/usr/bin/pkg set-publisher -g %s solaris" % ips_pkg_repo ).once
241
+ expect( Beaker::Command ).to receive( :new ).with( "/usr/bin/pkg set-publisher -g %s solaris" % ips_pkg_repo ).once
221
242
  end
222
243
 
223
244
  subject.proxy_config( hosts, options )
224
245
 
225
246
  end
226
247
 
227
- it "does nothing for non ubuntu/debian/solaris-11 hosts" do
248
+ it "does nothing for non ubuntu/debian/cumulus/solaris-11 hosts" do
228
249
  hosts = make_hosts( { :platform => 'windows' } )
229
-
230
- Beaker::Command.should_receive( :new ).never
250
+
251
+ expect( Beaker::Command ).to receive( :new ).never
231
252
 
232
253
  subject.proxy_config( hosts, options )
233
254
 
@@ -238,16 +259,21 @@ describe Beaker do
238
259
  subject { dummy_class.new }
239
260
 
240
261
  it "add extras for el-5/6 hosts" do
241
- hosts = make_hosts( { :platform => Beaker::Platform.new('el-5-arch'), :exit_code => 1 } )
242
- hosts[0][:platform] = Beaker::Platform.new('el-6-arch')
243
262
 
244
- Beaker::Command.should_receive( :new ).with("rpm -qa | grep epel-release").exactly( 3 ).times
245
- Beaker::Command.should_receive( :new ).with("rpm -i http://mirrors.kernel.org/fedora-epel/6/i386/epel-release-6-8.noarch.rpm").exactly( 1 ).times
246
- Beaker::Command.should_receive( :new ).with("rpm -i http://mirrors.kernel.org/fedora-epel/5/i386/epel-release-5-4.noarch.rpm").exactly( 2 ).times
247
- Beaker::Command.should_receive( :new ).with("sed -i -e 's;#baseurl.*$;baseurl=http://mirrors\\.kernel\\.org/fedora\\-epel/6/$basearch;' /etc/yum.repos.d/epel.repo").exactly( 1 ).times
248
- Beaker::Command.should_receive( :new ).with("sed -i -e 's;#baseurl.*$;baseurl=http://mirrors\\.kernel\\.org/fedora\\-epel/5/$basearch;' /etc/yum.repos.d/epel.repo").exactly( 2 ).times
249
- Beaker::Command.should_receive( :new ).with("sed -i -e '/mirrorlist/d' /etc/yum.repos.d/epel.repo").exactly( 3 ).times
250
- Beaker::Command.should_receive( :new ).with("yum clean all && yum makecache").exactly( 3 ).times
263
+ hosts = make_hosts( { :platform => Beaker::Platform.new('el-5-arch'), :exit_code => 1 }, 6 )
264
+ hosts[0][:platform] = Beaker::Platform.new('el-6-arch')
265
+ hosts[1][:platform] = Beaker::Platform.new('centos-6-arch')
266
+ hosts[2][:platform] = Beaker::Platform.new('scientific-6-arch')
267
+ hosts[3][:platform] = Beaker::Platform.new('redhat-6-arch')
268
+ hosts[4][:platform] = Beaker::Platform.new('oracle-5-arch')
269
+
270
+ expect( Beaker::Command ).to receive( :new ).with("rpm -qa | grep epel-release").exactly( 6 ).times
271
+ expect( Beaker::Command ).to receive( :new ).with("rpm -i http://mirrors.kernel.org/fedora-epel/6/i386/epel-release-6-8.noarch.rpm").exactly( 4 ).times
272
+ expect( Beaker::Command ).to receive( :new ).with("rpm -i http://mirrors.kernel.org/fedora-epel/5/i386/epel-release-5-4.noarch.rpm").exactly( 2 ).times
273
+ expect( Beaker::Command ).to receive( :new ).with("sed -i -e 's;#baseurl.*$;baseurl=http://mirrors\\.kernel\\.org/fedora\\-epel/6/$basearch;' /etc/yum.repos.d/epel.repo").exactly( 4 ).times
274
+ expect( Beaker::Command ).to receive( :new ).with("sed -i -e 's;#baseurl.*$;baseurl=http://mirrors\\.kernel\\.org/fedora\\-epel/5/$basearch;' /etc/yum.repos.d/epel.repo").exactly( 2 ).times
275
+ expect( Beaker::Command ).to receive( :new ).with("sed -i -e '/mirrorlist/d' /etc/yum.repos.d/epel.repo").exactly( 6 ).times
276
+ expect( Beaker::Command ).to receive( :new ).with("yum clean all && yum makecache").exactly( 6 ).times
251
277
 
252
278
  subject.add_el_extras( hosts, options )
253
279
 
@@ -256,7 +282,7 @@ describe Beaker do
256
282
  it "should do nothing for non el-5/6 hosts" do
257
283
  hosts = make_hosts( { :platform => Beaker::Platform.new('windows-version-arch') } )
258
284
 
259
- Beaker::Command.should_receive( :new ).never
285
+ expect( Beaker::Command ).to receive( :new ).never
260
286
 
261
287
  subject.add_el_extras( hosts, options )
262
288
 
@@ -269,7 +295,18 @@ describe Beaker do
269
295
  it "can sync keys on a solaris host" do
270
296
  @platform = 'solaris'
271
297
 
272
- Beaker::Command.should_receive( :new ).with( sync_cmd % "bash" ).exactly( 3 ).times
298
+ expect( Beaker::Command ).to receive( :new ).with( sync_cmd % "| bash" ).exactly( 3 ).times
299
+
300
+ subject.sync_root_keys( hosts, options )
301
+
302
+ end
303
+
304
+ it "can sync keys on an eos host" do
305
+ @platform = 'eos'
306
+
307
+ expect( Beaker::Command ).to receive( :new ).with( sync_cmd % "> manage_root_authorized_keys" ).exactly( 3 ).times
308
+ expect( Beaker::Command ).to receive( :new ).with( "sed -i 's|mv -f $SSH_HOME/authorized_keys.tmp $SSH_HOME/authorized_keys|cp -f $SSH_HOME/authorized_keys.tmp $SSH_HOME/authorized_keys|' manage_root_authorized_keys" ).exactly( 3 ).times
309
+ expect( Beaker::Command ).to receive( :new ).with( "bash manage_root_authorized_keys" ).exactly( 3 ).times
273
310
 
274
311
  subject.sync_root_keys( hosts, options )
275
312
 
@@ -277,7 +314,7 @@ describe Beaker do
277
314
 
278
315
  it "can sync keys on a non-solaris host" do
279
316
 
280
- Beaker::Command.should_receive( :new ).with( sync_cmd % "env PATH=/usr/gnu/bin:$PATH bash" ).exactly( 3 ).times
317
+ expect( Beaker::Command ).to receive( :new ).with( sync_cmd % "| env PATH=/usr/gnu/bin:$PATH bash" ).exactly( 3 ).times
281
318
 
282
319
  subject.sync_root_keys( hosts, options )
283
320
 
@@ -292,8 +329,8 @@ describe Beaker do
292
329
 
293
330
  hosts.each do |host|
294
331
  unix_only_pkgs.each do |pkg|
295
- host.should_receive( :check_for_package ).with( pkg ).once.and_return( false )
296
- host.should_receive( :install_package ).with( pkg ).once
332
+ expect( host ).to receive( :check_for_package ).with( pkg ).once.and_return( false )
333
+ expect( host ).to receive( :install_package ).with( pkg ).once
297
334
  end
298
335
  end
299
336
 
@@ -306,8 +343,8 @@ describe Beaker do
306
343
 
307
344
  hosts.each do |host|
308
345
  windows_pkgs.each do |pkg|
309
- host.should_receive( :check_for_package ).with( pkg ).once.and_return( false )
310
- host.should_receive( :install_package ).with( pkg ).once
346
+ expect( host ).to receive( :check_for_package ).with( pkg ).once.and_return( false )
347
+ expect( host ).to receive( :install_package ).with( pkg ).once
311
348
  end
312
349
  end
313
350
 
@@ -320,8 +357,8 @@ describe Beaker do
320
357
 
321
358
  hosts.each do |host|
322
359
  sles_only_pkgs.each do |pkg|
323
- host.should_receive( :check_for_package).with( pkg ).once.and_return( false )
324
- host.should_receive( :install_package ).with( pkg ).once
360
+ expect( host ).to receive( :check_for_package).with( pkg ).once.and_return( false )
361
+ expect( host ).to receive( :install_package ).with( pkg ).once
325
362
  end
326
363
 
327
364
  end
@@ -337,7 +374,7 @@ describe Beaker do
337
374
  it "can find the domain for a host" do
338
375
  host = make_host('name', { :stdout => "domain labs.lan d.labs.net dc1.labs.net labs.com\nnameserver 10.16.22.10\nnameserver 10.16.22.11" } )
339
376
 
340
- Beaker::Command.should_receive( :new ).with( "cat /etc/resolv.conf" ).once
377
+ expect( Beaker::Command ).to receive( :new ).with( "cat /etc/resolv.conf" ).once
341
378
 
342
379
  expect( subject.get_domain_name( host ) ).to be === "labs.lan"
343
380
 
@@ -346,7 +383,7 @@ describe Beaker do
346
383
  it "can find the search for a host" do
347
384
  host = make_host('name', { :stdout => "search labs.lan d.labs.net dc1.labs.net labs.com\nnameserver 10.16.22.10\nnameserver 10.16.22.11" } )
348
385
 
349
- Beaker::Command.should_receive( :new ).with( "cat /etc/resolv.conf" ).once
386
+ expect( Beaker::Command ).to receive( :new ).with( "cat /etc/resolv.conf" ).once
350
387
 
351
388
  expect( subject.get_domain_name( host ) ).to be === "labs.lan"
352
389
 
@@ -359,7 +396,7 @@ describe Beaker do
359
396
  it "can exec the get_ip command" do
360
397
  host = make_host('name', { :stdout => "192.168.2.130\n" } )
361
398
 
362
- Beaker::Command.should_receive( :new ).with( "ip a|awk '/global/{print$2}' | cut -d/ -f1 | head -1" ).once
399
+ expect( Beaker::Command ).to receive( :new ).with( "ip a|awk '/global/{print$2}' | cut -d/ -f1 | head -1" ).once
363
400
 
364
401
  expect( subject.get_ip( host ) ).to be === "192.168.2.130"
365
402
 
@@ -374,8 +411,8 @@ describe Beaker do
374
411
  host = make_host('name', {})
375
412
  etc_hosts = "127.0.0.1 localhost\n192.168.2.130 pe-ubuntu-lucid\n192.168.2.128 pe-centos6\n192.168.2.131 pe-debian6"
376
413
 
377
- Beaker::Command.should_receive( :new ).with( "echo '#{etc_hosts}' > /etc/hosts" ).once
378
- host.should_receive( :exec ).once
414
+ expect( Beaker::Command ).to receive( :new ).with( "echo '#{etc_hosts}' > /etc/hosts" ).once
415
+ expect( host ).to receive( :exec ).once
379
416
 
380
417
  subject.set_etc_hosts(host, etc_hosts)
381
418
  end
@@ -387,23 +424,112 @@ describe Beaker do
387
424
  subject { dummy_class.new }
388
425
  proxyurl = "http://192.168.2.100:3128"
389
426
 
390
- it "can set proxy config on a debian/ubuntu host" do
391
- host = make_host('name', { :platform => 'ubuntu' } )
427
+ it "can set proxy config on a debian/ubuntu/cumulus host" do
428
+ host = make_host('name', { :platform => 'cumulus' } )
392
429
 
393
- Beaker::Command.should_receive( :new ).with( "echo 'Acquire::http::Proxy \"#{proxyurl}/\";' >> /etc/apt/apt.conf.d/10proxy" ).once
394
- host.should_receive( :exec ).once
430
+ expect( Beaker::Command ).to receive( :new ).with( "echo 'Acquire::http::Proxy \"#{proxyurl}/\";' >> /etc/apt/apt.conf.d/10proxy" ).once
431
+ expect( host ).to receive( :exec ).once
395
432
 
396
433
  subject.package_proxy(host, options.merge( {'package_proxy' => proxyurl}) )
397
434
  end
398
435
 
399
- it "can set proxy config on a redhat/centos host" do
436
+ it "can set proxy config on a centos host" do
400
437
  host = make_host('name', { :platform => 'centos' } )
401
438
 
402
- Beaker::Command.should_receive( :new ).with( "echo 'proxy=#{proxyurl}/' >> /etc/yum.conf" ).once
403
- host.should_receive( :exec ).once
439
+ expect( Beaker::Command ).to receive( :new ).with( "echo 'proxy=#{proxyurl}/' >> /etc/yum.conf" ).once
440
+ expect( host ).to receive( :exec ).once
404
441
 
405
442
  subject.package_proxy(host, options.merge( {'package_proxy' => proxyurl}) )
443
+ end
444
+
445
+ end
446
+
447
+ context "set_env" do
448
+ subject { dummy_class.new }
449
+
450
+ it "can set the environment on a windows host" do
451
+ commands = [
452
+ "echo 'PermitUserEnvironment yes' >> /etc/sshd_config",
453
+ "cygrunsrv -E sshd",
454
+ "cygrunsrv -S sshd"
455
+ ]
456
+ set_env_helper('windows', commands)
457
+ end
458
+
459
+ it "can set the environment on an OS X host" do
460
+ commands = [
461
+ "echo 'PermitUserEnvironment yes' >> /etc/sshd_config",
462
+ "launchctl unload /System/Library/LaunchDaemons/ssh.plist",
463
+ "launchctl load /System/Library/LaunchDaemons/ssh.plist"
464
+ ]
465
+ set_env_helper('osx', commands)
466
+ end
467
+
468
+ it "can set the environment on an ssh-based linux host" do
469
+ commands = [
470
+ "echo 'PermitUserEnvironment yes' >> /etc/ssh/sshd_config",
471
+ "service ssh restart"
472
+ ]
473
+ set_env_helper('ubuntu', commands)
474
+ end
475
+
476
+ it "can set the environment on an sshd-based linux host" do
477
+ commands = [
478
+ "echo 'PermitUserEnvironment yes' >> /etc/ssh/sshd_config",
479
+ "service sshd restart"
480
+ ]
481
+ set_env_helper('eos', commands)
482
+ end
483
+
484
+ it "can set the environment on an sles host" do
485
+ commands = [
486
+ "echo 'PermitUserEnvironment yes' >> /etc/ssh/sshd_config",
487
+ "rcsshd restart"
488
+ ]
489
+ set_env_helper('sles', commands)
490
+ end
491
+
492
+ it "can set the environment on a solaris host" do
493
+ commands = [
494
+ "echo 'PermitUserEnvironment yes' >> /etc/ssh/sshd_config",
495
+ "svcadm restart svc:/network/ssh:default"
496
+ ]
497
+ set_env_helper('solaris', commands)
498
+ end
499
+
500
+ it "can set the environment on an aix host" do
501
+ commands = [
502
+ "echo 'PermitUserEnvironment yes' >> /etc/ssh/sshd_config",
503
+ "stopsrc -g ssh",
504
+ "startsrc -g ssh"
505
+ ]
506
+ set_env_helper('aix', commands)
507
+ end
508
+
509
+ def set_env_helper(platform_name, host_specific_commands_array)
510
+ host = make_host('name', {
511
+ :platform => platform_name,
512
+ :ssh_env_file => 'ssh_env_file'
513
+ } )
514
+ opts = {
515
+ :env1_key => :env1_value,
516
+ :env2_key => :env2_value
517
+ }
518
+
519
+ expect( subject ).to receive( :construct_env ).and_return( opts )
520
+ host_specific_commands_array.each do |command|
521
+ expect( Beaker::Command ).to receive( :new ).with( command ).once
522
+ end
523
+ expect( Beaker::Command ).to receive( :new ).with( "touch #{host[:ssh_env_file]}" ).once
524
+ expect( host ).to receive( :add_env_var ).with( 'RUBYLIB', '$RUBYLIB' ).once
525
+ expect( host ).to receive( :add_env_var ).with( 'PATH', '$PATH' ).once
526
+ opts.each_pair do |key, value|
527
+ expect( host ).to receive( :add_env_var ).with( key, value ).once
528
+ end
529
+ expect( host ).to receive( :add_env_var ).with( 'CYGWIN', 'nodosfilewarning' ).once if platform_name =~ /windows/
530
+ expect( host ).to receive( :exec ).exactly( host_specific_commands_array.length + 1 ).times
406
531
 
532
+ subject.set_env(host, options.merge( opts ))
407
533
  end
408
534
 
409
535
  end