beaker 1.6.2 → 1.7.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- Y2IxZWQ2ODlhMWE0MTg5MGE5OWZiOGU2YWNjZjRhM2MxMThkMGFkZA==
4
+ YjhhNzM3MzA5MGZmZTdjMDg5MGI1YmVlMDY1ZGI2NWFmMTUyZGE5YQ==
5
5
  data.tar.gz: !binary |-
6
- ZGY4NWZkMzc0ZGI5MmQwODNiMmI1ZGNmY2Y0ZTNhOGFhNWY3YTA4YQ==
6
+ MTgxNDk2NTBkMWY0NzA2MDc0NGIwMjQzM2IxZjBlY2M0NGE3NWYxMA==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- OWZhY2Q3ZTExMzI1OTI5NmRjYzVhOGNiNWI5YzhhYjEyNzFlYjM4YTJhMmI5
10
- YTAzZWM2YWVkNDU1N2EwNjIyZGNjODk1NjZjODI5OTkwMzI3ZDExY2RkMTAy
11
- ZjU5NDA3NzA1YWZhN2Y2YTI2YjJiZThkMzNhODA2ZDcxYWVlYTg=
9
+ YWQ0ZGI3Yzk2NmQ5NDdlZDUzMmJkMzFiOGUyNjk0MzFkNmEwNjBlN2FhYTZj
10
+ N2I3NjM3Zjk1NDM5MjhjMWEwZWFjNTQxZWFjNTljMDllZjA3NjAzZmUyMzg4
11
+ ZThiMzBmM2U1ZjYxN2I0ZDUxYWIwNThhNzAxYTQxZjAyZWE0MGY=
12
12
  data.tar.gz: !binary |-
13
- ZWJiYzg2MGY5MWU1OTVmMzUxYTNkYzVkODJjNTBkOWYzMzgxMTkzMTFkODll
14
- YzY2ZDBmNjhlZTMzMWY3ZGFhYWU1ODQ4NWUwMGE2MzIzMWJlODg5OTBlODZj
15
- OTk3YzM1ZWZkMmRjNTg0NjMzMmExYjMwNzM1YTJmY2U1OTk2YjI=
13
+ ZWQwYmYxMGIxZjliYjA4NTNkZmZlNjI0MWEzNjcxNDI1ZGNlMDk0NDcyODg4
14
+ ZDI0MDdiMmZhNzE4NDY4ZGE3MDQwMTZlOTRjNjQ4M2ZiMmQzZmE4NDlhNTY0
15
+ ZWQzYTgyMThmYzNlYTkwZWYzNTliM2RmZjJlMzlmOGZkYTA3NDg=
data/.gitignore CHANGED
@@ -12,6 +12,13 @@ coverage
12
12
  .bundle
13
13
  .vendor
14
14
  _vendor
15
- !tmp/README
16
- tmp/*
15
+ tmp/
17
16
  doc
17
+ # JetBrains IDEA
18
+ *.iml
19
+ .idea/
20
+ # rbenv file
21
+ .ruby-version
22
+ # Vagrant folder
23
+ .vagrant/
24
+ .vagrant_files/
@@ -15,16 +15,23 @@ module Beaker
15
15
  @options = @options_parser.parse_args
16
16
  @logger = Beaker::Logger.new(@options)
17
17
  @options[:logger] = @logger
18
+ @execute = true
18
19
 
19
20
  if @options[:help]
20
21
  @logger.notify(@options_parser.usage)
21
- exit
22
+ @execute = false
23
+ return
22
24
  end
23
25
  if @options[:version]
24
26
  @logger.notify(VERSION_STRING % Beaker::Version::STRING)
25
- exit
27
+ @execute = false
28
+ return
26
29
  end
27
30
  @logger.info(@options.dump)
31
+ if @options[:parse_only]
32
+ @execute = false
33
+ return
34
+ end
28
35
 
29
36
  #add additional paths to the LOAD_PATH
30
37
  if not @options[:load_path].empty?
@@ -81,6 +88,9 @@ module Beaker
81
88
 
82
89
  def execute!
83
90
 
91
+ if !@execute
92
+ return
93
+ end
84
94
  begin
85
95
  trap(:INT) do
86
96
  @logger.warn "Interrupt received; exiting..."
@@ -675,14 +675,14 @@ module Beaker
675
675
  #
676
676
  def apply_manifest_on(host, manifest, opts = {}, &block)
677
677
  if host.is_a?(Array)
678
- host.each do |h|
678
+ return host.map do |h|
679
679
  apply_manifest_on(h, manifest, opts, &block)
680
680
  end
681
- return
682
681
  end
683
682
 
684
683
  on_options = {}
685
- on_options[:acceptable_exit_codes] = Array(opts.delete(:acceptable_exit_codes))
684
+ on_options[:acceptable_exit_codes] = Array(opts[:acceptable_exit_codes])
685
+
686
686
  args = ["--verbose"]
687
687
  args << "--parseonly" if opts[:parseonly]
688
688
  args << "--trace" if opts[:trace]
@@ -131,8 +131,8 @@ module Beaker
131
131
 
132
132
  #Create the PE install command string based upon the host and options settings
133
133
  # @param [Host] host The host that PE is to be installed on
134
+ # For UNIX machines using the full PE installer, the host object must have the 'pe_installer' field set correctly.
134
135
  # @param [Hash{Symbol=>String}] options The options
135
- # @option options [String] :installer The name of the installer to use for upgrading/installing
136
136
  # @option options [String] :pe_ver_win Default PE version to install or upgrade to on Windows hosts
137
137
  # (Othersie uses individual Windows hosts pe_ver)
138
138
  # @option options [String :pe_ver Default PE version to install or upgrade to
@@ -150,7 +150,7 @@ module Beaker
150
150
  elsif host['roles'].include? 'frictionless' and ! version_is_less(version, '3.2.0')
151
151
  "cd #{host['working_dir']} && curl -kO https://#{master}:8140/packages/#{version}/install.bash && bash install.bash"
152
152
  else
153
- "cd #{host['working_dir']}/#{host['dist']} && ./#{options[:installer]} -a #{host['working_dir']}/answers"
153
+ "cd #{host['working_dir']}/#{host['dist']} && ./#{host['pe_installer']} -a #{host['working_dir']}/answers"
154
154
  end
155
155
  end
156
156
 
@@ -258,7 +258,6 @@ module Beaker
258
258
  # (Otherwise uses individual hosts pe_ver)
259
259
  # @option options [String] :pe_ver_win Default PE version to install or upgrade to on Windows hosts
260
260
  # (Otherwise uses individual Windows hosts pe_ver)
261
- # @option options [String] :installer ('puppet-enterprise-installer') The name of the installer to use for upgrading/installing
262
261
  # @option options [Symbol] :type (:install) One of :upgrade or :install
263
262
  #
264
263
  #
@@ -268,7 +267,6 @@ module Beaker
268
267
  # @api private
269
268
  #
270
269
  def do_install hosts, options = {}
271
- options[:installer] = options[:installer] || 'puppet-enterprise-installer'
272
270
  options[:type] = options[:type] || :install
273
271
  hostcert='uname | grep -i sunos > /dev/null && hostname || hostname -s'
274
272
  master_certname = on(master, hostcert).stdout.strip
@@ -278,6 +276,7 @@ module Beaker
278
276
  # Set PE distribution for all the hosts, create working dir
279
277
  use_all_tar = ENV['PE_USE_ALL_TAR'] == 'true'
280
278
  hosts.each do |host|
279
+ host['pe_installer'] ||= 'puppet-enterprise-installer'
281
280
  if host['platform'] !~ /windows/
282
281
  platform = use_all_tar ? 'all' : host['platform']
283
282
  version = options[:pe_ver] || host['pe_ver']
@@ -452,12 +451,13 @@ module Beaker
452
451
  def install_pe
453
452
  #process the version files if necessary
454
453
  hosts.each do |host|
454
+ host['pe_dir'] ||= options[:pe_dir]
455
455
  if host['platform'] =~ /windows/
456
456
  host['pe_ver'] = host['pe_ver'] ||
457
- Beaker::Options::PEVersionScraper.load_pe_version(host[:pe_dir] || options[:pe_dir], options[:pe_version_file_win])
457
+ Beaker::Options::PEVersionScraper.load_pe_version(host[:pe_dir], options[:pe_version_file_win])
458
458
  else
459
459
  host['pe_ver'] = host['pe_ver'] ||
460
- Beaker::Options::PEVersionScraper.load_pe_version(host[:pe_dir] || options[:pe_dir], options[:pe_version_file])
460
+ Beaker::Options::PEVersionScraper.load_pe_version(host[:pe_dir], options[:pe_version_file])
461
461
  end
462
462
  end
463
463
  do_install sorted_hosts
@@ -466,31 +466,28 @@ module Beaker
466
466
  #Upgrade PE based upon host configuration and options
467
467
  # @param [String] path A path (either local directory or a URL to a listing of PE builds).
468
468
  # Will contain a LATEST file indicating the latest build to install.
469
+ # This is ignored if a pe_upgrade_ver and pe_upgrade_dir are specified
470
+ # in the host configuration file.
469
471
  # @example
470
472
  # upgrade_pe("http://neptune.puppetlabs.lan/3.0/ci-ready/")
471
473
  #
472
474
  # @note Install file names are assumed to be of the format puppet-enterprise-VERSION-PLATFORM.(tar)|(tar.gz)
473
475
  # for Unix like systems and puppet-enterprise-VERSION.msi for Windows systems.
474
476
  # @api dsl
475
- def upgrade_pe path
476
- version = Options::PEVersionScraper.load_pe_version(path, options[:pe_version_file])
477
- version_win = Options::PEVersionScraper.load_pe_version(path, options[:pe_version_file_win])
478
- pre_30 = version_is_less(version, '3.0')
479
- if pre_30
480
- do_install(sorted_hosts, {:type => :upgrade, :pe_dir => path, :pe_ver => version, :pe_ver_win => version_win, :installer => 'puppet-enterprise-upgrader'})
481
- else
482
- do_install(sorted_hosts, {:type => :upgrade, :pe_dir => path, :pe_ver => version, :pe_ver_win => version_win})
483
- end
484
- #at this point we've completed a successful upgrade, update the host pe_ver to reflect that
477
+ def upgrade_pe path=nil
485
478
  hosts.each do |host|
479
+ host['pe_dir'] = host['pe_upgrade_dir'] || path
486
480
  if host['platform'] =~ /windows/
487
- host['pe_ver'] = version_win
481
+ host['pe_ver'] = host['pe_upgrade_ver'] || Options::PEVersionScraper.load_pe_version(host['pe_dir'], options[:pe_version_file_win])
488
482
  else
489
- host['pe_ver'] = version
483
+ host['pe_ver'] = host['pe_upgrade_ver'] || Options::PEVersionScraper.load_pe_version(host['pe_dir'], options[:pe_version_file])
484
+ end
485
+ if version_is_less(host['pe_ver'], '3.0')
486
+ host['pe_installer'] ||= 'puppet-enterprise-upgrader'
490
487
  end
491
488
  end
489
+ do_install(sorted_hosts, {:type => :upgrade})
492
490
  end
493
-
494
491
  end
495
492
  end
496
493
  end
@@ -158,7 +158,7 @@ module Beaker
158
158
  if options[:silent]
159
159
  output_callback = nil
160
160
  else
161
- @logger.debug "\n#{log_prefix} $ #{cmdline}"
161
+ @logger.debug "\n#{log_prefix} #{Time.new.strftime('%H:%M:%S')}$ #{cmdline}"
162
162
  output_callback = logger.method(:host_output)
163
163
  end
164
164
 
@@ -18,7 +18,7 @@ module Beaker
18
18
  "10.255.#{rand_chunk}.#{rand_chunk}"
19
19
  end
20
20
 
21
- def make_vfile hosts
21
+ def make_vfile hosts, options = {}
22
22
  #HACK HACK HACK - add checks here to ensure that we have box + box_url
23
23
  #generate the VagrantFile
24
24
  v_file = "Vagrant.configure(\"2\") do |c|\n"
@@ -34,7 +34,7 @@ module Beaker
34
34
  @logger.debug "created Vagrantfile for VagrantHost #{host.name}"
35
35
  end
36
36
  v_file << " c.vm.provider :virtualbox do |vb|\n"
37
- v_file << " vb.customize [\"modifyvm\", :id, \"--memory\", \"1024\"]\n"
37
+ v_file << " vb.customize [\"modifyvm\", :id, \"--memory\", \"#{options['vagrant_memsize'] ||= '1024'}\"]\n"
38
38
  v_file << " end\n"
39
39
  v_file << "end\n"
40
40
  File.open(@vagrant_file, 'w') do |f|
@@ -65,11 +65,11 @@ module Beaker
65
65
  def set_ssh_config host, user
66
66
  f = Tempfile.new("#{host.name}")
67
67
  ssh_config = Dir.chdir(@vagrant_path) do
68
- stdin, stdout, stderr, wait_thr = Open3.popen3('vagrant', 'ssh-config', host.name)
69
- if not wait_thr.value.success?
70
- raise "Failed to 'vagrant ssh-config' for #{host.name}"
68
+ result = `vagrant ssh-config #{host.name}`
69
+ if $?.to_i != 0
70
+ raise "Failed to vagrant ssh-config for #{host.name}"
71
71
  end
72
- stdout.read
72
+ result
73
73
  end
74
74
  #replace hostname with ip
75
75
  ssh_config = ssh_config.gsub(/#{host.name}/, host['ip']) unless not host['ip']
@@ -117,7 +117,7 @@ module Beaker
117
117
  #make sure that any old boxes are dead dead dead
118
118
  vagrant_cmd("destroy --force") if File.file?(@vagrant_file)
119
119
 
120
- make_vfile @vagrant_hosts
120
+ make_vfile @vagrant_hosts, @options
121
121
 
122
122
  vagrant_cmd("up")
123
123
  else #set host ip of already up boxes
@@ -155,18 +155,12 @@ module Beaker
155
155
 
156
156
  def vagrant_cmd(args)
157
157
  Dir.chdir(@vagrant_path) do
158
- exit_status = 1
159
- Open3.popen3("vagrant #{args}") {|stdin, stdout, stderr, wait_thr|
160
- while line = stdout.gets
161
- @logger.debug(line)
162
- end
163
- if not wait_thr.value.success?
164
- raise "Failed to exec 'vagrant #{args}'"
165
- end
166
- exit_status = wait_thr.value
167
- }
168
- if exit_status != 0
169
- raise "Failed to execute vagrant_cmd ( #{args} )"
158
+ result = `vagrant #{args} 2>&1`
159
+ result.each_line do |line|
160
+ @logger.debug(line)
161
+ end
162
+ if $?.to_i != 0
163
+ raise "Failed to exec 'vagrant #{args}'"
170
164
  end
171
165
  end
172
166
  end
@@ -51,18 +51,18 @@ module Beaker
51
51
  options = args.last.is_a?(Hash) ? args.pop : {}
52
52
  @color = options[:color]
53
53
  case options[:log_level]
54
- when /debug/i
54
+ when /debug/i, :debug
55
55
  @log_level = :debug
56
- when /verbose/i
56
+ when /verbose/i, :verbose
57
57
  @log_level = :verbose
58
- when /info/i
58
+ when /info/i, :info
59
59
  @log_level = :info
60
- when /notify/i
60
+ when /notify/i, :notify
61
61
  @log_level = :notify
62
- when /warn/i
62
+ when /warn/i, :warn
63
63
  @log_level = :warn
64
64
  else
65
- @log_level = :info
65
+ @log_level = :verbose
66
66
  end
67
67
  @destinations = []
68
68
 
@@ -129,11 +129,11 @@ module Beaker
129
129
  end
130
130
 
131
131
  # Custom reporting for messages generated by host SUTs.
132
- # Will not print unless we are at {LOG_LEVELS} 'debug' or higher.
132
+ # Will not print unless we are at {LOG_LEVELS} 'verbose' or higher.
133
133
  # Strips any color codes already in the provided messages, then adds logger color codes before reporting
134
134
  # @param args[Array<String>] Strings to be reported
135
135
  def host_output *args
136
- return unless is_debug?
136
+ return unless is_verbose?
137
137
  strings = strip_colors_from args
138
138
  string = strings.join
139
139
  optionally_color GREY, string, false
@@ -135,11 +135,6 @@ module Beaker
135
135
  @cmd_options[:log_level] = val
136
136
  end
137
137
 
138
- opts.on '--[no-]debug',
139
- 'DEPRECATED, use --log-level' do |bool|
140
- @cmd_options[:log_level] = bool ? 'debug' : 'info'
141
- end
142
-
143
138
  opts.on '-d', '--[no-]dry-run',
144
139
  'Report what would happen on targets',
145
140
  '(default: false)' do |bool|
@@ -179,14 +174,24 @@ module Beaker
179
174
  @cmd_options[:version] = true
180
175
  end
181
176
 
182
- opts.on '-c', '--config FILE',
183
- 'DEPRECATED use --hosts' do |file|
184
- @cmd_options[:hosts_file] = file
177
+ opts.on('--parse-only', 'Display beaker parsed options and exit' ) do
178
+ @cmd_options[:parse_only] = true
185
179
  end
186
180
 
187
181
  opts.on('--help', 'Display this screen' ) do
188
182
  @cmd_options[:help] = true
189
183
  end
184
+
185
+ opts.on '-c', '--config FILE',
186
+ 'DEPRECATED, use --hosts' do |file|
187
+ @cmd_options[:hosts_file] = file
188
+ end
189
+
190
+ opts.on '--[no-]debug',
191
+ 'DEPRECATED, use --log-level' do |bool|
192
+ @cmd_options[:log_level] = bool ? 'debug' : 'info'
193
+ end
194
+
190
195
  end
191
196
 
192
197
  end
@@ -29,7 +29,7 @@ module Beaker
29
29
  def self.presets
30
30
  h = Beaker::Options::OptionsHash.new
31
31
  h.merge({
32
- :log_level => 'info',
32
+ :log_level => 'verbose',
33
33
  :hosts_file => 'sample.cfg',
34
34
  :options_file => nil,
35
35
  :type => 'pe',
@@ -22,7 +22,7 @@ module Beaker
22
22
  end
23
23
 
24
24
  def get_ip(host)
25
- host.exec(Command.new("ip a|awk '/g/{print$2}' | cut -d/ -f1 | head -1")).stdout.chomp
25
+ host.exec(Command.new("ip a|awk '/global/{print$2}' | cut -d/ -f1 | head -1")).stdout.chomp
26
26
  end
27
27
 
28
28
  def set_etc_hosts(host, etc_hosts)
@@ -247,7 +247,7 @@ module Beaker
247
247
  end
248
248
 
249
249
  def log_path(name)
250
- @@log_dir ||= File.join("log", @start_time.strftime("%F_%T"))
250
+ @@log_dir ||= File.join("log", @start_time.strftime("%F_%H_%M_%S"))
251
251
  unless File.directory?(@@log_dir) then
252
252
  FileUtils.mkdir_p(@@log_dir)
253
253
 
@@ -23,7 +23,7 @@ module Beaker
23
23
  if master['platform'].include? 'solaris'
24
24
  stdout = master.exec(Command.new("ifconfig -a inet| awk '/broadcast/ {print $2}' | cut -d/ -f1 | head -1")).stdout
25
25
  else
26
- stdout = master.exec(Command.new("ip a|awk '/g/{print$2}' | cut -d/ -f1 | head -1")).stdout
26
+ stdout = master.exec(Command.new("ip a|awk '/global/{print$2}' | cut -d/ -f1 | head -1")).stdout
27
27
  end
28
28
  ip=stdout.chomp
29
29
 
@@ -1,5 +1,5 @@
1
1
  module Beaker
2
2
  module Version
3
- STRING = '1.6.2'
3
+ STRING = '1.7.0'
4
4
  end
5
5
  end
@@ -310,7 +310,7 @@ describe ClassMixedWithDSLHelpers do
310
310
  subject.apply_manifest_on( agent, 'class { "boo": }')
311
311
  end
312
312
 
313
- it 'accepts an array of hosts' do
313
+ it 'operates on an array of hosts' do
314
314
  the_hosts = [master, agent]
315
315
 
316
316
  subject.should_receive( :create_remote_file ).twice.and_return( true )
@@ -321,10 +321,11 @@ describe ClassMixedWithDSLHelpers do
321
321
 
322
322
  subject.should_receive( :on ).
323
323
  with( host, 'puppet_command',
324
- :acceptable_exit_codes => [0] ).ordered
324
+ :acceptable_exit_codes => [0, 1] ).ordered
325
325
  end
326
326
 
327
- subject.apply_manifest_on( the_hosts, 'include foobar')
327
+ result = subject.apply_manifest_on( the_hosts, 'include foobar', :acceptable_exit_codes => [0,1] )
328
+ result.should(be_an(Array))
328
329
  end
329
330
 
330
331
  it 'adds acceptable exit codes with :catch_failures' do
@@ -130,7 +130,9 @@ describe ClassMixedWithDSLInstallUtils do
130
130
  end
131
131
 
132
132
  it 'generates a unix PE install command for a unix host' do
133
- expect( subject.installer_cmd( unixhost, { :installer => 'puppet-enterprise-installer' } ) ).to be === "cd /tmp/puppet-enterprise-3.1.0-rc0-230-g36c9e5c-debian-7-i386 && ./puppet-enterprise-installer -a /tmp/answers"
133
+ the_host = unixhost.dup
134
+ the_host['pe_installer'] = 'puppet-enterprise-installer'
135
+ expect( subject.installer_cmd( the_host, {} ) ).to be === "cd /tmp/puppet-enterprise-3.1.0-rc0-230-g36c9e5c-debian-7-i386 && ./puppet-enterprise-installer -a /tmp/answers"
134
136
  end
135
137
  end
136
138
 
@@ -350,35 +352,44 @@ describe ClassMixedWithDSLInstallUtils do
350
352
  it 'calls puppet-enterprise-upgrader for pre 3.0 upgrades' do
351
353
  Beaker::Options::PEVersionScraper.stub( :load_pe_version ).and_return( '2.8' )
352
354
  Beaker::Options::PEVersionScraper.stub( :load_pe_version_win ).and_return( '2.8' )
353
- subject.stub( :hosts ).and_return( [ hosts[1], hosts[0], hosts[2] ] )
355
+ the_hosts = [ hosts[0].dup, hosts[1].dup, hosts[2].dup ]
356
+ subject.stub( :hosts ).and_return( the_hosts )
354
357
  subject.stub( :options ).and_return( {} )
355
358
  version = version_win = '2.8'
356
359
  path = "/path/to/upgradepkg"
357
- subject.should_receive( :do_install ).with( hosts, { :type => :upgrade, :pe_dir => path, :pe_ver => version, :pe_ver_win => version_win, :installer => 'puppet-enterprise-upgrader' } )
360
+ subject.should_receive( :do_install ).with( the_hosts, { :type => :upgrade } )
358
361
  subject.upgrade_pe( path )
362
+ the_hosts.each do |h|
363
+ expect( h['pe_installer'] ).to be === 'puppet-enterprise-upgrader'
364
+ end
359
365
  end
360
366
 
361
367
  it 'uses standard upgrader for post 3.0 upgrades' do
362
368
  Beaker::Options::PEVersionScraper.stub( :load_pe_version ).and_return( '3.1' )
363
369
  Beaker::Options::PEVersionScraper.stub( :load_pe_version_win ).and_return( '3.1' )
364
- subject.stub( :hosts ).and_return( [ hosts[1], hosts[0], hosts[2] ] )
370
+ the_hosts = [ hosts[0].dup, hosts[1].dup, hosts[2].dup ]
371
+ subject.stub( :hosts ).and_return( the_hosts )
365
372
  subject.stub( :options ).and_return( {} )
366
373
  version = version_win = '3.1'
367
374
  path = "/path/to/upgradepkg"
368
- subject.should_receive( :do_install ).with( hosts, { :type => :upgrade, :pe_dir => path, :pe_ver => version, :pe_ver_win => version_win } )
375
+ subject.should_receive( :do_install ).with( the_hosts, { :type => :upgrade } )
369
376
  subject.upgrade_pe( path )
377
+ the_hosts.each do |h|
378
+ expect( h['pe_installer'] ).to be nil
379
+ end
370
380
  end
371
381
 
372
382
  it 'updates pe_ver post upgrade' do
373
383
  Beaker::Options::PEVersionScraper.stub( :load_pe_version ).and_return( '2.8' )
374
384
  Beaker::Options::PEVersionScraper.stub( :load_pe_version_win ).and_return( '2.8' )
375
- subject.stub( :hosts ).and_return( [ hosts[1], hosts[0], hosts[2] ] )
385
+ the_hosts = [ hosts[0].dup, hosts[1].dup, hosts[2].dup ]
386
+ subject.stub( :hosts ).and_return( the_hosts )
376
387
  subject.stub( :options ).and_return( {} )
377
388
  version = version_win = '2.8'
378
389
  path = "/path/to/upgradepkg"
379
- subject.should_receive( :do_install ).with( hosts, { :type => :upgrade, :pe_dir => path, :pe_ver => version, :pe_ver_win => version_win, :installer => 'puppet-enterprise-upgrader' } )
390
+ subject.should_receive( :do_install ).with( the_hosts, { :type => :upgrade } )
380
391
  subject.upgrade_pe( path )
381
- hosts.each do |h|
392
+ the_hosts.each do |h|
382
393
  expect( h['pe_ver'] ).to be === '2.8'
383
394
  end
384
395
  end
@@ -115,7 +115,7 @@ module Beaker
115
115
  it 'logs the amount of time spent executing the command' do
116
116
  result.exit_code = 0
117
117
 
118
- expect(host.logger).to receive(:debug).with(/host executed in \d\.\d{2} seconds/)
118
+ expect(host.logger).to receive(:debug).with(/executed in \d\.\d{2} seconds/)
119
119
 
120
120
  host.exec(command,{})
121
121
  end
@@ -28,6 +28,21 @@ module Beaker
28
28
  expect( File.read( File.expand_path( File.join( path, "Vagrantfile") ) ) ).to be === "Vagrant.configure(\"2\") do |c|\n c.vm.define 'vm1' do |v|\n v.vm.hostname = 'vm1'\n v.vm.box = 'vm1_of_my_box'\n v.vm.box_url = 'http://address.for.my.box.vm1'\n v.vm.base_mac = '0123456789'\n v.vm.network :private_network, ip: \"ip.address.for.vm1\", :netmask => \"255.255.0.0\"\n end\n c.vm.define 'vm2' do |v|\n v.vm.hostname = 'vm2'\n v.vm.box = 'vm2_of_my_box'\n v.vm.box_url = 'http://address.for.my.box.vm2'\n v.vm.base_mac = '0123456789'\n v.vm.network :private_network, ip: \"ip.address.for.vm2\", :netmask => \"255.255.0.0\"\n end\n c.vm.define 'vm3' do |v|\n v.vm.hostname = 'vm3'\n v.vm.box = 'vm3_of_my_box'\n v.vm.box_url = 'http://address.for.my.box.vm3'\n v.vm.base_mac = '0123456789'\n v.vm.network :private_network, ip: \"ip.address.for.vm3\", :netmask => \"255.255.0.0\"\n end\n c.vm.provider :virtualbox do |vb|\n vb.customize [\"modifyvm\", :id, \"--memory\", \"1024\"]\n end\nend\n"
29
29
  end
30
30
 
31
+ it "uses the memsize defined per vagrant host" do
32
+ FakeFS.activate!
33
+ path = vagrant.instance_variable_get( :@vagrant_path )
34
+ vagrant.stub( :randmac ).and_return( "0123456789" )
35
+
36
+ vagrant.make_vfile( @hosts, {'vagrant_memsize' => 'hello!'} )
37
+
38
+ generated_file = File.read( File.expand_path( File.join( path, "Vagrantfile") ) )
39
+
40
+ match = generated_file.match(/vb.customize \["modifyvm", :id, "--memory", "hello!"]/)
41
+
42
+ expect( match ).to_not be nil
43
+
44
+ end
45
+
31
46
  it "can generate a new /etc/hosts file referencing each host" do
32
47
 
33
48
  @hosts.each do |host|
@@ -66,8 +81,7 @@ module Beaker
66
81
  name = host.name
67
82
  Dir.stub( :chdir ).and_yield()
68
83
 
69
- out = double( 'stdout' )
70
- out.stub( :read ).and_return("Host #{host.name}
84
+ vagrant.should_receive(:`).and_return("Host #{host.name}
71
85
  HostName 127.0.0.1
72
86
  User vagrant
73
87
  Port 2222
@@ -76,12 +90,6 @@ module Beaker
76
90
  PasswordAuthentication no
77
91
  IdentityFile /home/root/.vagrant.d/insecure_private_key
78
92
  IdentitiesOnly yes")
79
- wait_thr = OpenStruct.new
80
- state = mock( 'state' )
81
- state.stub( :success? ).and_return( true )
82
- wait_thr.value = state
83
-
84
- Open3.stub( :popen3 ).with( 'vagrant', 'ssh-config', host.name ).and_return( [ "", out, "", wait_thr ])
85
93
 
86
94
  file = double( 'file' )
87
95
  file.stub( :path ).and_return( '/path/sshconfig' )
@@ -139,14 +147,15 @@ module Beaker
139
147
  end
140
148
 
141
149
  it "can provision a set of hosts" do
142
- vagrant.should_receive( :make_vfile ).with( @hosts ).once
150
+ options = vagrant.instance_variable_get( :@options )
151
+ vagrant.should_receive( :make_vfile ).with( @hosts, options ).once
143
152
  vagrant.should_receive( :vagrant_cmd ).with( "destroy --force" ).never
144
153
  vagrant.provision
145
154
  end
146
155
 
147
156
  it "destroys an existing set of hosts before provisioning" do
148
- vagrant.make_vfile(@hosts)
149
- vagrant.should_receive(:vagrant_cmd).with("destroy --force").once
157
+ vagrant.make_vfile( @hosts )
158
+ vagrant.should_receive( :vagrant_cmd ).with( "destroy --force" ).once
150
159
  vagrant.provision
151
160
  end
152
161
 
@@ -16,7 +16,7 @@ module Beaker
16
16
  context 'default for' do
17
17
  its(:destinations) { should include(STDOUT) }
18
18
  its(:color) { should be_nil }
19
- its(:log_level) { should be :info }
19
+ its(:log_level) { should be :verbose }
20
20
  end
21
21
  end
22
22
 
@@ -54,6 +54,30 @@ module Beaker
54
54
  colorized_logger.optionally_color "\e[00;30m", 'my string'
55
55
  end
56
56
 
57
+ context 'at verbose log_level' do
58
+ subject( :verbose_logger ) { Logger.new( my_io,
59
+ :log_level => 'verbose',
60
+ :quiet => true,
61
+ :color => true )
62
+ }
63
+
64
+ its( :is_debug? ) { should be_false }
65
+ its( :is_verbose? ) { should be_true }
66
+ its( :is_warn? ) { should be_true }
67
+
68
+ context 'but print' do
69
+ before do
70
+ my_io.stub :puts
71
+ my_io.should_receive( :print ).at_least :twice
72
+ end
73
+
74
+ it( 'warnings' ) { verbose_logger.warn 'IMA WARNING!' }
75
+ it( 'successes' ) { verbose_logger.success 'SUCCESS!' }
76
+ it( 'errors' ) { verbose_logger.error 'ERROR!' }
77
+ it( 'host_output' ) { verbose_logger.host_output 'ERROR!' }
78
+ it( 'debugs' ) { verbose_logger.debug 'NOT DEBUGGING!' }
79
+ end
80
+ end
57
81
 
58
82
  context 'at debug log_level' do
59
83
  subject( :debug_logger ) { Logger.new( my_io,
@@ -65,7 +89,6 @@ module Beaker
65
89
  its( :is_debug? ) { should be_true }
66
90
  its( :is_warn? ) { should be_true }
67
91
 
68
-
69
92
  context 'successfully print' do
70
93
  before do
71
94
  my_io.stub :puts
@@ -82,8 +105,9 @@ module Beaker
82
105
 
83
106
  context 'at info log_level' do
84
107
  subject( :info_logger ) { Logger.new( my_io,
85
- :quiet => true,
86
- :color => true )
108
+ :log_level => :info,
109
+ :quiet => true,
110
+ :color => true )
87
111
  }
88
112
 
89
113
  its( :is_debug? ) { should be_false }
@@ -36,7 +36,7 @@ module Beaker
36
36
  it "can exec the get_ip command" do
37
37
  host = make_host('name', { :stdout => "192.168.2.130\n" } )
38
38
 
39
- Command.should_receive( :new ).with( "ip a|awk '/g/{print$2}' | cut -d/ -f1 | head -1" ).once
39
+ Command.should_receive( :new ).with( "ip a|awk '/global/{print$2}' | cut -d/ -f1 | head -1" ).once
40
40
 
41
41
  expect( host_handler.get_ip( host ) ).to be === "192.168.2.130"
42
42
 
@@ -20,7 +20,7 @@ module Beaker
20
20
  path = Beaker::Utils::SetupHelper::ETC_HOSTS_PATH
21
21
  master = setup_helper.only_host_with_role(hosts, :master)
22
22
 
23
- Command.should_receive( :new ).with( "ip a|awk '/g/{print$2}' | cut -d/ -f1 | head -1" ).once
23
+ Command.should_receive( :new ).with( "ip a|awk '/global/{print$2}' | cut -d/ -f1 | head -1" ).once
24
24
  Command.should_receive( :new ).with( "cp %s %s.old" % [path, path] ).once
25
25
  Command.should_receive( :new ).with( "cp %s %s.new" % [path, path] ).once
26
26
  Command.should_receive( :new ).with( "grep -v '#{ip} #{master}' %s > %s.new" % [path, path] ).once
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: 1.6.2
4
+ version: 1.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Puppetlabs
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-01-31 00:00:00.000000000 Z
11
+ date: 2014-02-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec