beaker 2.34.0 → 2.35.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -162,11 +162,6 @@ module Beaker
162
162
  stderr_callback = stdout_callback
163
163
 
164
164
  result = Result.new(@hostname, command)
165
- # why are we getting to this point on a dry run anyways?
166
- # also... the host creates connections through the class method,
167
- # which automatically connects, so you can't do a dry run unless you also
168
- # can connect to your hosts?
169
- return result if options[:dry_run]
170
165
 
171
166
  @ssh.open_channel do |channel|
172
167
  request_terminal_for( channel, command ) if options[:pty]
@@ -267,8 +262,7 @@ module Beaker
267
262
  channel.eof!
268
263
  end
269
264
 
270
- def scp_to source, target, options = {}, dry_run = false
271
- return if dry_run
265
+ def scp_to source, target, options = {}
272
266
 
273
267
  local_opts = options.dup
274
268
  if local_opts[:recursive].nil?
@@ -278,10 +272,10 @@ module Beaker
278
272
 
279
273
  result = Result.new(@hostname, [source, target])
280
274
  result.stdout = "\n"
275
+
281
276
  @ssh.scp.upload! source, target, local_opts do |ch, name, sent, total|
282
277
  result.stdout << "\tcopying %s: %10d/%d\n" % [name, sent, total]
283
278
  end
284
-
285
279
  # Setting these values allows reporting via result.log(test_name)
286
280
  result.stdout << " SCP'ed file #{source} to #{@hostname}:#{target}"
287
281
 
@@ -292,8 +286,7 @@ module Beaker
292
286
  return result
293
287
  end
294
288
 
295
- def scp_from source, target, options = {}, dry_run = false
296
- return if dry_run
289
+ def scp_from source, target, options = {}
297
290
 
298
291
  local_opts = options.dup
299
292
  if local_opts[:recursive].nil?
@@ -303,10 +296,10 @@ module Beaker
303
296
 
304
297
  result = Result.new(@hostname, [source, target])
305
298
  result.stdout = "\n"
299
+
306
300
  @ssh.scp.download! source, target, local_opts do |ch, name, sent, total|
307
301
  result.stdout << "\tcopying %s: %10d/%d\n" % [name, sent, total]
308
302
  end
309
-
310
303
  # Setting these values allows reporting via result.log(test_name)
311
304
  result.stdout << " SCP'ed file #{@hostname}:#{source} to #{target}"
312
305
 
@@ -1,5 +1,5 @@
1
1
  module Beaker
2
2
  module Version
3
- STRING = '2.34.0'
3
+ STRING = '2.35.0'
4
4
  end
5
5
  end
@@ -805,35 +805,7 @@ describe ClassMixedWithDSLInstallUtils do
805
805
 
806
806
  describe '#install_puppet_agent_pe_promoted_repo_on' do
807
807
 
808
- it 'splits the platform string version correctly to get ubuntu puppet-agent packages (format 9999)' do
809
- platform = Object.new()
810
- allow(platform).to receive(:to_array) { ['ubuntu', '9999', 'x42']}
811
- host = basic_hosts.first
812
- host['platform'] = platform
813
-
814
- expect(subject).to receive(:fetch_http_file).once.with(/\/puppet-agent\//, "puppet-agent-ubuntu-99.99-x42.tar.gz", /ubuntu/)
815
- expect(subject).to receive(:scp_to).once.with(host, /-ubuntu-99.99-x42\./, "/root")
816
- expect(subject).to receive(:on).ordered.with(host, /^tar.*-ubuntu-99.99-x42/)
817
- expect(subject).to receive(:on).ordered.with(host, /dpkg\ -i\ --force-all/)
818
- expect(subject).to receive(:on).ordered.with(host, /apt-get\ update/)
819
-
820
- subject.install_puppet_agent_pe_promoted_repo_on( host, {} )
821
- end
822
-
823
- it 'doesn\'t split the platform string version correctly to get ubuntu puppet-agent packages when unnecessary (format 99.99)' do
824
- platform = Object.new()
825
- allow(platform).to receive(:to_array) { ['ubuntu', '99.99', 'x42']}
826
- host = basic_hosts.first
827
- host['platform'] = platform
828
808
 
829
- expect(subject).to receive(:fetch_http_file).once.with(/\/puppet-agent\//, "puppet-agent-ubuntu-99.99-x42.tar.gz", /ubuntu/)
830
- expect(subject).to receive(:scp_to).once.with(host, /-ubuntu-99.99-x42\./, "/root")
831
- expect(subject).to receive(:on).ordered.with(host, /^tar.*-ubuntu-99.99-x42/)
832
- expect(subject).to receive(:on).ordered.with(host, /dpkg\ -i\ --force-all/)
833
- expect(subject).to receive(:on).ordered.with(host, /apt-get\ update/)
834
-
835
- subject.install_puppet_agent_pe_promoted_repo_on( host, {} )
836
- end
837
809
 
838
810
  end
839
811
 
@@ -1003,12 +975,7 @@ describe ClassMixedWithDSLInstallUtils do
1003
975
  expect( subject ).to receive( :scp_to ).once.with(
1004
976
  host, /#{release_file}$/, anything )
1005
977
 
1006
- noask_text = 'blablabla noask solaris 10 text'
1007
- allow( host ).to receive( :noask_file_text ).and_return( noask_text )
1008
- expect( subject ).to receive( :create_remote_file ).with(
1009
- host, /noask$/, noask_text )
1010
- expect( subject ).to receive( :on ).with(
1011
- host, /^gunzip.*#{release_file}.*pkgadd.*noask.*all$/ )
978
+ expect( host ).to receive( :solaris_install_local_package )
1012
979
 
1013
980
  allow( subject ).to receive( :configure_type_defaults_on )
1014
981
  subject.install_puppet_agent_dev_repo_on( host, opts )
@@ -1098,13 +1065,11 @@ describe ClassMixedWithDSLInstallUtils do
1098
1065
  it 'calls fetch_http_file with no ending slash' do
1099
1066
  test_fetch_http_file_no_ending_slash( 'windows-7-x86_64' )
1100
1067
  end
1101
-
1102
1068
  end
1103
1069
 
1104
1070
  it 'calls fetch_http_file with no ending slash' do
1105
1071
  test_fetch_http_file_no_ending_slash( 'debian-5-x86_64' )
1106
1072
  end
1107
-
1108
1073
  end
1109
1074
 
1110
1075
  describe '#remove_puppet_on' do
@@ -186,6 +186,93 @@ module Beaker
186
186
 
187
187
  end
188
188
 
189
+ context '#pe_puppet_agent_promoted_package_install' do
190
+ context 'on solaris platforms' do
191
+ before :each do
192
+ allow( subject ).to receive( :fetch_http_file )
193
+ allow( subject ).to receive( :scp_to )
194
+ allow( subject ).to receive( :configure_type_defaults_on )
195
+ end
196
+
197
+ context 'version support' do
198
+ (7..17).each do |version|
199
+ supported_version = version == 10 || version == 11
200
+ supported_str = ( supported_version ? '' : 'not ')
201
+ test_title = "does #{supported_str}support version #{version}"
202
+
203
+ it "#{test_title}" do
204
+ solaris_platform = Beaker::Platform.new("solaris-#{version}-x86_64")
205
+ @opts = {'platform' => solaris_platform}
206
+ allow( instance ).to receive( :execute )
207
+ allow( instance ).to receive( :exec )
208
+ if supported_version
209
+ if version == 10
210
+ allow( instance ).to receive( :noask_file_text )
211
+ allow( instance ).to receive( :create_remote_file )
212
+ end
213
+ # only expect diff in the last line: .not_to vs .to raise_error
214
+ expect{
215
+ instance.pe_puppet_agent_promoted_package_install(
216
+ 'oh_cp_base', 'oh_cp_dl', 'oh_cp_fl', 'dl_fl', {}
217
+ )
218
+ }.not_to raise_error
219
+ else
220
+ expect{
221
+ instance.pe_puppet_agent_promoted_package_install(
222
+ 'oh_cp_base', 'oh_cp_dl', 'oh_cp_fl', 'dl_fl', {}
223
+ )
224
+ }.to raise_error(ArgumentError, /^Solaris #{version} is not supported/ )
225
+ end
226
+ end
227
+ end
228
+
229
+ end
230
+
231
+ context 'on solaris 10' do
232
+ before :each do
233
+ solaris_platform = Beaker::Platform.new('solaris-10-x86_64')
234
+ @opts = {'platform' => solaris_platform}
235
+ end
236
+
237
+ it 'sets a noask file' do
238
+ allow( instance ).to receive( :execute )
239
+ allow( instance ).to receive( :exec )
240
+ expect( instance ).to receive( :noask_file_text )
241
+ expect( instance ).to receive( :create_remote_file )
242
+ instance.pe_puppet_agent_promoted_package_install('', '', '', '', {})
243
+ end
244
+
245
+ it 'calls the correct install command' do
246
+ allow( instance ).to receive( :noask_file_text )
247
+ allow( instance ).to receive( :create_remote_file )
248
+ # a number of `execute` calls before the one we're looking for
249
+ allow( instance ).to receive( :execute )
250
+ allow( instance ).to receive( :exec )
251
+ # actual gunzip call to
252
+ expect( Beaker::Command ).to receive( :new ).with( /^gunzip\ \-c\ / )
253
+ instance.pe_puppet_agent_promoted_package_install(
254
+ 'oh_cp_base', 'oh_cp_dl', 'oh_cp_fl', 'dl_fl', {}
255
+ )
256
+ end
257
+ end
258
+
259
+ context 'on solaris 11' do
260
+ before :each do
261
+ solaris_platform = Beaker::Platform.new('solaris-11-x86_64')
262
+ @opts = {'platform' => solaris_platform}
263
+ end
264
+
265
+ it 'calls the correct install command' do
266
+ allow( instance ).to receive( :execute )
267
+ allow( instance ).to receive( :exec )
268
+ expect( Beaker::Command ).to receive( :new ).with( /^pkg\ install\ \-g / )
269
+ instance.pe_puppet_agent_promoted_package_install(
270
+ 'oh_cp_base', 'oh_cp_dl', 'oh_cp_fl', 'dl_fl', {}
271
+ )
272
+ end
273
+ end
274
+ end
275
+ end
189
276
  end
190
277
  end
191
278
 
@@ -179,6 +179,26 @@ module Unix
179
179
  end
180
180
  end
181
181
 
182
+ describe '#pe_puppet_agent_promoted_package_info' do
183
+ context 'on ubuntu platforms' do
184
+ it 'splits the platform string version to get puppet-agent packages (format 9999)' do
185
+ @platform = 'ubuntu-9999-x42'
186
+ _, _, download_file = host.pe_puppet_agent_promoted_package_info(
187
+ 'pa_collection'
188
+ )
189
+ expect( download_file ).to match( /-ubuntu-99\.99-x42/ )
190
+ end
191
+
192
+ it 'skips splitting the platform string version to get puppet-agent packages when unnecessary (format 99.99)' do
193
+ @platform = 'ubuntu-88.88-x63'
194
+ _, _, download_file = host.pe_puppet_agent_promoted_package_info(
195
+ 'pa_collection'
196
+ )
197
+ expect( download_file ).to match( /-ubuntu-88\.88-x63/ )
198
+ end
199
+ end
200
+ end
201
+
182
202
  describe '#external_copy_base' do
183
203
 
184
204
  it 'returns /root in general' do
@@ -412,7 +412,7 @@ module Beaker
412
412
  @options = { :logger => logger }
413
413
  host.instance_variable_set :@connection, conn
414
414
  args = [ '/source', 'target', {} ]
415
- conn_args = args + [ nil ]
415
+ conn_args = args
416
416
 
417
417
  expect( logger ).to receive(:trace)
418
418
  expect( conn ).to receive(:scp_to).with( *conn_args ).and_return(Beaker::Result.new(host, 'output!'))
@@ -430,7 +430,7 @@ module Beaker
430
430
  @options = { :logger => logger }
431
431
  host.instance_variable_set :@connection, conn
432
432
  args = [ '/source', 'target', {} ]
433
- conn_args = args + [ nil ]
433
+ conn_args = args
434
434
 
435
435
  allow( logger ).to receive(:trace)
436
436
  expect( conn ).to receive(:scp_to).ordered.with(
@@ -488,7 +488,7 @@ module Beaker
488
488
  conn = double(:connection)
489
489
  @options = { :logger => logger }
490
490
  host.instance_variable_set :@connection, conn
491
- args = [ source_path, target_path, {:ignore => [exclude_file]} ]
491
+ args = [ source_path, target_path, {:ignore => [exclude_file], :dry_run => false} ]
492
492
 
493
493
  allow( Dir ).to receive( :glob ).and_return( @fileset1 + @fileset2 )
494
494
 
@@ -498,12 +498,12 @@ module Beaker
498
498
 
499
499
  (@fileset1 + @fileset2).each do |file|
500
500
  if file !~ /#{exclude_file}/
501
- file_args = [ file, File.join(created_target_path, File.dirname(file).gsub(source_path,'')), {:ignore => [exclude_file]} ]
502
- conn_args = file_args + [ nil ]
501
+ file_args = [ file, File.join(created_target_path, File.dirname(file).gsub(source_path,'')), {:ignore => [exclude_file], :dry_run => false} ]
502
+ conn_args = file_args
503
503
  expect( conn ).to receive(:scp_to).with( *conn_args ).and_return(Beaker::Result.new(host, 'output!'))
504
504
  else
505
- file_args = [ file, File.join(created_target_path, File.dirname(file).gsub(source_path,'')), {:ignore => [exclude_file]} ]
506
- conn_args = file_args + [ nil ]
505
+ file_args = [ file, File.join(created_target_path, File.dirname(file).gsub(source_path,'')), {:ignore => [exclude_file], :dry_run => false} ]
506
+ conn_args = file_args
507
507
  expect( conn ).to_not receive(:scp_to).with( *conn_args )
508
508
  end
509
509
  end
@@ -553,7 +553,7 @@ module Beaker
553
553
  conn = double(:connection)
554
554
  @options = { :logger => logger }
555
555
  host.instance_variable_set :@connection, conn
556
- args = [ 'tmp', 'target', {:ignore => [exclude_file]} ]
556
+ args = [ 'tmp', 'target', {:ignore => [exclude_file], :dry_run => false} ]
557
557
 
558
558
  allow( Dir ).to receive( :glob ).and_return( @fileset1 + @fileset2 )
559
559
 
@@ -562,19 +562,18 @@ module Beaker
562
562
  expect( host ).to receive( :mkdir_p ).with('target/tmp/tests2')
563
563
  (@fileset1 + @fileset2).each do |file|
564
564
  if file !~ /#{exclude_file}/
565
- file_args = [ file, File.join('target', File.dirname(file)), {:ignore => [exclude_file]} ]
566
- conn_args = file_args + [ nil ]
565
+ file_args = [ file, File.join('target', File.dirname(file)), {:ignore => [exclude_file], :dry_run => false} ]
566
+ conn_args = file_args
567
567
  expect( conn ).to receive(:scp_to).with( *conn_args ).and_return(Beaker::Result.new(host, 'output!'))
568
568
  else
569
- file_args = [ file, File.join('target', File.dirname(file)), {:ignore => [exclude_file]} ]
570
- conn_args = file_args + [ nil ]
569
+ file_args = [ file, File.join('target', File.dirname(file)), {:ignore => [exclude_file], :dry_run => false} ]
570
+ conn_args = file_args
571
571
  expect( conn ).to_not receive(:scp_to).with( *conn_args )
572
572
  end
573
573
  end
574
574
  allow( conn ).to receive(:ip).and_return(host['ip'])
575
575
  allow( conn ).to receive(:vmhostname).and_return(host['vmhostname'])
576
576
  allow( conn ).to receive(:hostname).and_return(host.name)
577
-
578
577
  host.do_scp_to *args
579
578
  end
580
579
 
@@ -584,7 +583,7 @@ module Beaker
584
583
  conn = double(:connection)
585
584
  @options = { :logger => logger }
586
585
  host.instance_variable_set :@connection, conn
587
- args = [ 'tmp', 'target', {:ignore => [exclude_file]} ]
586
+ args = [ 'tmp', 'target', {:ignore => [exclude_file], :dry_run => false} ]
588
587
 
589
588
  allow( Dir ).to receive( :glob ).and_return( @fileset1 + @fileset2 )
590
589
 
@@ -592,13 +591,13 @@ module Beaker
592
591
  expect( host ).to_not receive( :mkdir_p ).with('target/tmp/tests')
593
592
  expect( host ).to receive( :mkdir_p ).with('target/tmp/tests2')
594
593
  (@fileset1).each do |file|
595
- file_args = [ file, File.join('target', File.dirname(file)), {:ignore => [exclude_file]} ]
596
- conn_args = file_args + [ nil ]
594
+ file_args = [ file, File.join('target', File.dirname(file)), {:ignore => [exclude_file], :dry_run => false} ]
595
+ conn_args = file_args
597
596
  expect( conn ).to_not receive(:scp_to).with( *conn_args )
598
597
  end
599
598
  (@fileset2).each do |file|
600
- file_args = [ file, File.join('target', File.dirname(file)), {:ignore => [exclude_file]} ]
601
- conn_args = file_args + [ nil ]
599
+ file_args = [ file, File.join('target', File.dirname(file)), {:ignore => [exclude_file], :dry_run => false} ]
600
+ conn_args = file_args
602
601
  expect( conn ).to receive(:scp_to).with( *conn_args ).and_return(Beaker::Result.new(host, 'output!'))
603
602
  end
604
603
 
@@ -617,7 +616,7 @@ module Beaker
617
616
  @options = { :logger => logger }
618
617
  host.instance_variable_set :@connection, conn
619
618
  args = [ 'source', 'target', {} ]
620
- conn_args = args + [ nil ]
619
+ conn_args = args
621
620
 
622
621
  expect( logger ).to receive(:debug)
623
622
  expect( conn ).to receive(:scp_from).with( *conn_args ).and_return(Beaker::Result.new(host, 'output!'))
@@ -220,6 +220,14 @@ module Beaker
220
220
  'container_path' => '/different_mount',
221
221
  'opts' => 'rw',
222
222
  },
223
+ 'mount4' => {
224
+ 'host_path' => './',
225
+ 'container_path' => '/relative_mount',
226
+ },
227
+ 'mount5' => {
228
+ 'host_path' => 'local_folder',
229
+ 'container_path' => '/another_relative_mount',
230
+ }
223
231
  }
224
232
 
225
233
  expect( ::Docker::Container ).to receive(:create).with({
@@ -230,6 +238,8 @@ module Beaker
230
238
  '/source_folder:/mount_point',
231
239
  '/another_folder:/another_mount:ro',
232
240
  '/different_folder:/different_mount:rw',
241
+ "#{File.expand_path('./')}:/relative_mount",
242
+ "#{File.expand_path('local_folder')}:/another_relative_mount",
233
243
  ]
234
244
  }
235
245
  })
@@ -73,6 +73,25 @@ module Beaker
73
73
  let( :hosts ) { make_hosts( { :platform => 'el-5' } ) }
74
74
  let( :hypervisor ) { Beaker::Hypervisor.new( hosts, options ) }
75
75
 
76
+ context 'if :timesync option set true on host' do
77
+ it 'does call timesync for host' do
78
+ hosts[0][:timesync] = true
79
+ allow( hypervisor ).to receive( :set_env )
80
+ expect( hypervisor ).to receive( :timesync ).once
81
+ hypervisor.configure
82
+ end
83
+ end
84
+
85
+ context 'if :timesync option set true but false on host' do
86
+ it 'does not call timesync for host' do
87
+ options[:timesync] = true
88
+ hosts[0][:timesync] = false
89
+ allow( hypervisor ).to receive( :set_env )
90
+ expect( hypervisor ).to_not receive( :timesync )
91
+ hypervisor.configure
92
+ end
93
+ end
94
+
76
95
  context "if :disable_iptables option set false" do
77
96
  it "does not call disable_iptables" do
78
97
  options[:disable_iptables] = false
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.34.0
4
+ version: 2.35.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-02-10 00:00:00.000000000 Z
11
+ date: 2016-02-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec