beaker 3.20.0 → 3.21.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 (55) hide show
  1. checksums.yaml +8 -8
  2. data/beaker.gemspec +4 -5
  3. data/docs/how_to/hypervisors/README.md +7 -3
  4. data/docs/tutorials/quick_start_rake_tasks.md +1 -1
  5. data/lib/beaker/command.rb +1 -1
  6. data/lib/beaker/host.rb +6 -4
  7. data/lib/beaker/host/windows/exec.rb +10 -0
  8. data/lib/beaker/host/windows/pkg.rb +1 -29
  9. data/lib/beaker/host_prebuilt_steps.rb +1 -0
  10. data/lib/beaker/hypervisor.rb +26 -37
  11. data/lib/beaker/ssh_connection.rb +8 -15
  12. data/lib/beaker/version.rb +1 -1
  13. data/spec/beaker/dsl/install_utils/windows_utils_spec.rb +1 -1
  14. data/spec/beaker/host/windows/exec_spec.rb +18 -0
  15. data/spec/beaker/host/windows/pkg_spec.rb +0 -7
  16. data/spec/beaker/host_prebuilt_steps_spec.rb +1 -0
  17. data/spec/beaker/host_spec.rb +31 -40
  18. data/spec/beaker/hypervisor/hypervisor_spec.rb +20 -34
  19. data/spec/beaker/ssh_connection_spec.rb +18 -19
  20. data/spec/spec_helper.rb +0 -1
  21. metadata +23 -57
  22. data/docs/how_to/hypervisors/aws.md +0 -149
  23. data/docs/how_to/hypervisors/ec2.md +0 -81
  24. data/docs/how_to/hypervisors/google_compute_engine.md +0 -41
  25. data/docs/how_to/hypervisors/vagrant.md +0 -165
  26. data/docs/how_to/hypervisors/vagrant_hosts_file_examples.md +0 -60
  27. data/docs/how_to/hypervisors/vagrant_libvirt.md +0 -58
  28. data/docs/how_to/hypervisors/vmware_fusion.md +0 -36
  29. data/docs/how_to/hypervisors/vsphere.md +0 -54
  30. data/lib/beaker/hypervisor/aws_sdk.rb +0 -989
  31. data/lib/beaker/hypervisor/ec2_helper.rb +0 -41
  32. data/lib/beaker/hypervisor/fusion.rb +0 -65
  33. data/lib/beaker/hypervisor/google_compute.rb +0 -164
  34. data/lib/beaker/hypervisor/google_compute_helper.rb +0 -577
  35. data/lib/beaker/hypervisor/vagrant.rb +0 -286
  36. data/lib/beaker/hypervisor/vagrant_custom.rb +0 -11
  37. data/lib/beaker/hypervisor/vagrant_fusion.rb +0 -17
  38. data/lib/beaker/hypervisor/vagrant_libvirt.rb +0 -41
  39. data/lib/beaker/hypervisor/vagrant_parallels.rb +0 -18
  40. data/lib/beaker/hypervisor/vagrant_virtualbox.rb +0 -76
  41. data/lib/beaker/hypervisor/vagrant_workstation.rb +0 -13
  42. data/lib/beaker/hypervisor/vsphere.rb +0 -85
  43. data/lib/beaker/hypervisor/vsphere_helper.rb +0 -204
  44. data/spec/beaker/hypervisor/aws_sdk_spec.rb +0 -980
  45. data/spec/beaker/hypervisor/ec2_helper_spec.rb +0 -44
  46. data/spec/beaker/hypervisor/fusion_spec.rb +0 -41
  47. data/spec/beaker/hypervisor/vagrant_custom_spec.rb +0 -46
  48. data/spec/beaker/hypervisor/vagrant_fusion_spec.rb +0 -32
  49. data/spec/beaker/hypervisor/vagrant_libvirt_spec.rb +0 -61
  50. data/spec/beaker/hypervisor/vagrant_parallels_spec.rb +0 -44
  51. data/spec/beaker/hypervisor/vagrant_spec.rb +0 -479
  52. data/spec/beaker/hypervisor/vagrant_virtualbox_spec.rb +0 -44
  53. data/spec/beaker/hypervisor/vagrant_workstation_spec.rb +0 -32
  54. data/spec/beaker/hypervisor/vsphere_helper_spec.rb +0 -163
  55. data/spec/beaker/hypervisor/vsphere_spec.rb +0 -90
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- NDQ3ZThiZTEzNTZkODA0ZTQ3YjI1NDA5MzkxZTAzMDE4NjljM2M1Zg==
4
+ MmE5NjhiZTUwNGM4MzE4Y2IxMjY3YjVlZWYwNzFlNTYwNDNlODUwMA==
5
5
  data.tar.gz: !binary |-
6
- NjVhMDY5ZDE5ZmI0ZTc0OWQ4MTIyZGM5YWM2YTVhNTc2YjUyMGYyMw==
6
+ MWViNWY1ZjJiNWVmYWU3N2QzMGMyZmQzZWQ0OGQ5YzVhYWQ5YjAzNQ==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- Y2Q1ZDBjOGVmMGJkNzA2MmVjMGFmOGUzNWRlMTEzZjVlNTkxZTA5ODkwNmU2
10
- ZjdjZTFiMTdmZjg5OTVlNDMwMmQ0NjI5MDhiYTRlNzg4ZTFhMjQ4NGExODJk
11
- OTgxN2RmMTkyM2Q0MmNmOTg5ZjMwNTBlZTRlZDI1MjFhNThlYjE=
9
+ NzFiZmUzY2ZkNDU1MTkyOGU5OGJmZDE0OGI1ZjYwZmIwMDgxMzgyYjE5ZDky
10
+ NzBhZWQ0ZTNlZTMwMDZjODgyY2FmYTJhMWJiMDMxNWNiMjAxMTQ4NWExOWM1
11
+ OGY2MDlhYmZmMTFlZTk5ZjQyYmVlOGRhYTE0ZjM1OGM5MDZiN2E=
12
12
  data.tar.gz: !binary |-
13
- ODJhZTkyNDgzMzA4Y2M2Y2FhNGJiOGI3YTI3NWQ5NjAzNzg5NTEyNTNmZjFj
14
- MzIyMjYyNDlmNjQ3ZDUwNTlmNGM2YWM2YjBiZWYwNzcyNjU3MjY2NmExZWQ5
15
- MTlmMjYxMTVkMDU0YzQ1ODllNDEzZjY1YzIzNzRlYWFjMGZiNjY=
13
+ ZGE5MGI0MWM5Y2U5MTYwMmQ2NGEzNmVkN2E3MTMzOGU0NDVjZGZkYTRlNWQ0
14
+ Y2FjMjMzY2I0OWQ5MmM5MjY3NGViZGIwNjg4ZTUyZDUzZDNmZDY1NzNkOTAz
15
+ NTJjNDRhMjVlOTU0YmNiYmEzYmI2MWEyZTI4ZmU1NmFiNWIyNmU=
@@ -51,13 +51,12 @@ Gem::Specification.new do |s|
51
51
  s.add_runtime_dependency 'beaker-puppet', '~> 0.0'
52
52
 
53
53
  # Optional provisioner specific support
54
- s.add_runtime_dependency 'fission', '~> 0.4'
55
- s.add_runtime_dependency 'google-api-client', '~> 0.9'
56
- s.add_runtime_dependency 'aws-sdk-v1', '~> 1.57'
57
54
  s.add_runtime_dependency 'docker-api'
58
55
  s.add_runtime_dependency 'fog', '~> 1.38'
56
+ s.add_runtime_dependency 'beaker-aws', '~> 0.1'
59
57
  s.add_runtime_dependency 'beaker-vmpooler', '~> 0.1'
58
+ s.add_runtime_dependency 'beaker-google', '~> 0.1'
59
+ s.add_runtime_dependency 'beaker-vagrant', '~> 0.1'
60
+ s.add_runtime_dependency 'beaker-vmware', '~> 0.1'
60
61
 
61
- # So fog doesn't always complain of unmet AWS dependencies
62
- s.add_runtime_dependency 'unf', '~> 0.1'
63
62
  end
@@ -41,9 +41,13 @@ In order to offset this, we've made a listing of gems and community-supported fo
41
41
 
42
42
  Hypervisor gems made by puppet (pre-included in beaker 3.x):
43
43
 
44
- | Hypervisor | Fork |
45
- |:----------------------:|:---------------------------------------------------------:|
46
- | Vmpooler | [beaker-vmpooler](https://github.com/puppetlabs/beaker-vmpooler) |
44
+ | Hypervisor | Fork |
45
+ | :----------------------: | :---------------------------------------------------------: |
46
+ | Vmpooler | [beaker-vmpooler](https://github.com/puppetlabs/beaker-vmpooler) |
47
+ | AWS | [beaker-aws](https://github.com/puppetlabs/beaker-aws) |
48
+ | Google Compute | [beaker-google](https://github.com/puppetlabs/beaker-google) |
49
+ | Vagrant | [beaker-vagrant](https://github.com/puppetlabs/beaker-vagrant) |
50
+ | VMware/Vsphere | [beaker-vmware](https://github.com/puppetlabs/beaker-vmware) |
47
51
 
48
52
  Hypervisor gems and beaker forks made by community:
49
53
 
@@ -8,7 +8,7 @@ We have developed some rake tasks to help new Beaker users get up and running qu
8
8
  * You will need to have already completed the Beaker installation tutorial - [Beaker Installation](installation.md)
9
9
 
10
10
  * Hypervisors are services that provision SUTs for Beaker. We have made two available in this quick start guide to allow you to get up
11
- and running. See the docs on how to setup [Vmpooler](../how_to/hypervisors/vsphere.md) and [Vagrant](../how_to/hypervisors/vagrant.md).
11
+ and running. See the docs on how to setup [Vmpooler](https://github.com/puppetlabs/beaker-vmpooler/blob/master/vmpooler.md) and [Vagrant](https://github.com/puppetlabs/beaker-vagrant/blob/master/docs/vagrant.md).
12
12
 
13
13
 
14
14
  ## How to use them
@@ -78,7 +78,7 @@ module Beaker
78
78
  end
79
79
 
80
80
  # This will cause things like `puppet -t -v agent` which is maybe bad.
81
- if host[:platform] =~ /cisco/
81
+ if host[:platform] =~ /cisco_ios_xr/
82
82
  cmd_line_array = [prepend_commands, env_string, cmd, options_string, args_string]
83
83
  else
84
84
  cmd_line_array = [env_string, prepend_commands, cmd, options_string, args_string]
@@ -242,9 +242,11 @@ module Beaker
242
242
  # Determine the ip address using logic specific to the hypervisor
243
243
  def get_public_ip
244
244
  case host_hash[:hypervisor]
245
- when 'ec2'
246
- if host_hash[:instance]
247
- host_hash[:instance].ip_address
245
+ when /^(ec2|openstack)$/
246
+ if self[:hypervisor] == 'ec2' && self[:instance]
247
+ return self[:instance].ip_address
248
+ elsif self[:hypervisor] == 'openstack' && self[:ip]
249
+ return self[:ip]
248
250
  else
249
251
  # In the case of using ec2 instances with the --no-provision flag, the ec2
250
252
  # instance object does not exist and we should just use the curl endpoint
@@ -274,7 +276,7 @@ module Beaker
274
276
  # create new connection object if necessary
275
277
  @connection ||= SshConnection.connect( { :ip => self['ip'], :vmhostname => self['vmhostname'], :hostname => @name },
276
278
  self['user'],
277
- self['ssh'], { :logger => @logger } )
279
+ self['ssh'], { :logger => @logger, :ssh_connection_preference => self[:ssh_connection_preference] } )
278
280
  # update connection information
279
281
  if self['ip'] && (@connection.ip != self['ip'])
280
282
  @connection.ip = self['ip']
@@ -108,4 +108,14 @@ module Windows::Exec
108
108
  false
109
109
  end
110
110
 
111
+ # Determine if cygwin is actually installed on the SUT. Differs from
112
+ # is_cygwin?, which is just a type check for a Windows::Host.
113
+ #
114
+ # @return [Boolean]
115
+ def cygwin_installed?
116
+ output = exec(Beaker::Command.new('cygcheck --check-setup cygwin'), :accept_all_exit_codes => true).stdout
117
+ return true if output.match(/cygwin/) && output.match(/OK/)
118
+ false
119
+ end
120
+
111
121
  end
@@ -12,9 +12,6 @@ module Windows::Pkg
12
12
  end
13
13
 
14
14
  def install_package(name, cmdline_args = '')
15
- cygwin = ""
16
- rootdir = ""
17
-
18
15
  arch = identify_windows_architecture
19
16
 
20
17
  if arch == '64'
@@ -25,15 +22,6 @@ module Windows::Pkg
25
22
  cygwin = "setup-x86.exe"
26
23
  end
27
24
 
28
- if not check_for_command(cygwin)
29
- command = "curl --retry 5 https://cygwin.com/#{cygwin} -o /cygdrive/c/Windows/System32/#{cygwin}"
30
- begin
31
- execute(command)
32
- rescue Beaker::Host::CommandFailure
33
- command.sub!('https', 'http')
34
- execute(command)
35
- end
36
- end
37
25
  execute("#{cygwin} -q -n -N -d -R #{rootdir} -s http://cygwin.osuosl.org -P #{name} #{cmdline_args}")
38
26
  end
39
27
 
@@ -101,23 +89,7 @@ module Windows::Pkg
101
89
 
102
90
  # @api private
103
91
  def identify_windows_architecture
104
- arch = nil
105
- execute("echo '' | wmic os get osarchitecture", :accept_all_exit_codes => true) do |result|
106
- arch = if result.exit_code == 0
107
- result.stdout =~ /64/ ? '64' : '32'
108
- else
109
- identify_windows_architecture_from_os_name_for_win2003
110
- end
111
- end
112
- arch
92
+ platform.arch =~ /64/ ? '64' : '32'
113
93
  end
114
94
 
115
- # @api private
116
- def identify_windows_architecture_from_os_name_for_win2003
117
- arch = nil
118
- execute("echo '' | wmic os get name | grep x64", :accept_all_exit_codes => true) do |result|
119
- arch = result.exit_code == 0 ? '64' : '32'
120
- end
121
- arch
122
- end
123
95
  end
@@ -107,6 +107,7 @@ module Beaker
107
107
  when host['platform'] =~ /cumulus/
108
108
  check_and_install_packages_if_needed(host, CUMULUS_PACKAGES)
109
109
  when (host['platform'] =~ /windows/ and host.is_cygwin?)
110
+ raise RuntimeError, "cygwin is not installed on #{host}" if !host.cygwin_installed?
110
111
  check_and_install_packages_if_needed(host, WINDOWS_PACKAGES)
111
112
  when (host['platform'] =~ /windows/ and not host.is_cygwin?)
112
113
  check_and_install_packages_if_needed(host, PSWINDOWS_PACKAGES)
@@ -26,28 +26,6 @@ module Beaker
26
26
  Beaker::Aixer
27
27
  when /^solaris$/
28
28
  Beaker::Solaris
29
- when /^vsphere$/
30
- Beaker::Vsphere
31
- when /^fusion$/
32
- Beaker::Fusion
33
- when /^ec2$/
34
- Beaker::AwsSdk
35
- when /^vagrant$/
36
- Beaker::Vagrant
37
- when /^vagrant_custom$/
38
- Beaker::VagrantCustom
39
- when /^vagrant_libvirt$/
40
- Beaker::VagrantLibvirt
41
- when /^vagrant_virtualbox$/
42
- Beaker::VagrantVirtualbox
43
- when /^vagrant_fusion$/
44
- Beaker::VagrantFusion
45
- when /^vagrant_workstation$/
46
- Beaker::VagrantWorkstation
47
- when /^vagrant_parallels$/
48
- Beaker::VagrantParallels
49
- when /^google$/
50
- Beaker::GoogleCompute
51
29
  when /^docker$/
52
30
  Beaker::Docker
53
31
  when /^openstack$/
@@ -63,12 +41,12 @@ module Beaker
63
41
  rescue LoadError
64
42
  raise "Invalid hypervisor: #{type}"
65
43
  end
66
- Beaker.const_get(type.capitalize)
44
+ Beaker.const_get(type.split('_').collect(&:capitalize).join)
67
45
  end
68
46
 
69
47
  hypervisor = hyper_class.new(hosts_to_provision, options)
48
+ self.set_ssh_connection_preference(hosts_to_provision, hypervisor)
70
49
  hypervisor.provision if options[:provision]
71
-
72
50
  hypervisor
73
51
  end
74
52
 
@@ -87,6 +65,29 @@ module Beaker
87
65
  nil
88
66
  end
89
67
 
68
+ DEFAULT_CONNECTION_PREFERENCE = ['ip', 'vmhostname', 'hostname']
69
+ #SSH connection method preference. Can be overwritten by hypervisor to change the order
70
+ def connection_preference
71
+ DEFAULT_CONNECTION_PREFERENCE
72
+ end
73
+
74
+ #Check if overriding method returns correct array with ip, vmhostname hostname as elements
75
+ def self.set_ssh_connection_preference(hosts_to_provision, hypervisor)
76
+ if hypervisor.connection_preference.sort == DEFAULT_CONNECTION_PREFERENCE.sort
77
+ hosts_to_provision.each{ |h| h[:ssh_connection_preference] = hypervisor.connection_preference}
78
+ else
79
+ raise ArgumentError, <<-HEREDOC
80
+ Hypervisor's overriding connection_pereference method is not matching the API.
81
+
82
+ Make sure your hypervisor's connection_preference returns an array
83
+ containing the following elements in any order you prefer:
84
+ "ip", "hostname", "vmhostname"
85
+
86
+ Please check hypervisor.rb file's "self.connection_preference" method for an example
87
+ HEREDOC
88
+ end
89
+ end
90
+
90
91
  #Proxy package managers on tests hosts created by this hypervisor, runs before validation and configuration.
91
92
  def proxy_package_manager
92
93
  if @options[:package_proxy]
@@ -143,21 +144,9 @@ module Beaker
143
144
  end
144
145
 
145
146
  [
146
- 'vsphere_helper',
147
- 'vagrant',
148
- 'vagrant_custom',
149
- 'vagrant_virtualbox',
150
- 'vagrant_parallels',
151
- 'vagrant_libvirt',
152
- 'vagrant_fusion',
153
- 'vagrant_workstation',
154
- 'fusion',
155
- 'aws_sdk',
156
- 'vsphere',
157
147
  'docker',
158
- 'google_compute',
159
148
  'openstack',
160
149
  'noop'
161
150
  ].each do |lib|
162
- require "beaker/hypervisor/#{lib}"
151
+ require "beaker/hypervisor/#{lib}"
163
152
  end
@@ -6,7 +6,7 @@ module Beaker
6
6
  class SshConnection
7
7
 
8
8
  attr_accessor :logger
9
- attr_accessor :ip, :vmhostname, :hostname
9
+ attr_accessor :ip, :vmhostname, :hostname, :ssh_connection_preference
10
10
 
11
11
  RETRYABLE_EXCEPTIONS = [
12
12
  SocketError,
@@ -33,6 +33,7 @@ module Beaker
33
33
  @ssh_opts = ssh_opts
34
34
  @logger = options[:logger]
35
35
  @options = options
36
+ @ssh_connection_preference = @options[:ssh_connection_preference]
36
37
  end
37
38
 
38
39
  def self.connect name_hash, user = 'root', ssh_opts = {}, options = {}
@@ -66,21 +67,13 @@ module Beaker
66
67
  # connect to the host
67
68
  def connect
68
69
  #try three ways to connect to host (vmhostname, ip, hostname)
69
- methods = []
70
- if @vmhostname
71
- @ssh ||= connect_block(@vmhostname, @user, @ssh_opts)
72
- methods << "vmhostname (#{@vmhostname})"
70
+ # Try each method in turn until we succeed
71
+ methods = @ssh_connection_preference.dup
72
+ while (not @ssh) && (not methods.empty?) do
73
+ @ssh = connect_block(instance_variable_get("@#{methods.shift}"), @user, @ssh_opts)
73
74
  end
74
- if @ip && !@ssh
75
- @ssh ||= connect_block(@ip, @user, @ssh_opts)
76
- methods << "ip (#{@ip})"
77
- end
78
- if @hostname && !@ssh
79
- @ssh ||= connect_block(@hostname, @user, @ssh_opts)
80
- methods << "hostname (#{@hostname})"
81
- end
82
- if not @ssh
83
- @logger.error "Failed to connect to #{@hostname}, attempted #{methods.join(', ')}"
75
+ unless @ssh
76
+ @logger.error "Failed to connect to #{@hostname}, attempted #{@ssh_connection_preference.join(', ')}"
84
77
  raise RuntimeError, "Cannot connect to #{@hostname}"
85
78
  end
86
79
  @ssh
@@ -1,5 +1,5 @@
1
1
  module Beaker
2
2
  module Version
3
- STRING = '3.20.0'
3
+ STRING = '3.21.0'
4
4
  end
5
5
  end
@@ -15,7 +15,7 @@ describe ClassMixedWithDSLInstallUtils do
15
15
  let( :batch_path ) { '/fake/batch/path' }
16
16
  let(:msi_path) { 'c:\\foo\\puppet.msi' }
17
17
  let(:winhost) { make_host( 'winhost',
18
- { :platform => 'windows',
18
+ { :platform => Beaker::Platform.new('windows-2008r2-64'),
19
19
  :pe_ver => '3.0',
20
20
  :working_dir => '/tmp',
21
21
  :is_cygwin => true} ) }
@@ -60,5 +60,23 @@ module Beaker
60
60
  instance.reboot
61
61
  end
62
62
  end
63
+
64
+ describe '#cygwin_installed?' do
65
+ let (:response) { double( 'response' ) }
66
+
67
+ it 'uses cygcheck to see if cygwin is installed' do
68
+ expect( Beaker::Command ).to receive(:new).with("cygcheck --check-setup cygwin").and_return(:foo)
69
+ expect( instance ).to receive( :exec ).with(:foo, :accept_all_exit_codes => true).and_return(response)
70
+ expect( response ).to receive(:stdout).and_return('cygwin OK')
71
+ expect(instance.cygwin_installed?).to eq(true)
72
+ end
73
+
74
+ it 'returns false when unable to find matching text' do
75
+ expect( Beaker::Command ).to receive(:new).with("cygcheck --check-setup cygwin").and_return(:foo)
76
+ expect( instance ).to receive( :exec ).with(:foo, :accept_all_exit_codes => true).and_return(response)
77
+ expect( response ).to receive(:stdout).and_return('No matching text')
78
+ expect(instance.cygwin_installed?).to eq(false)
79
+ end
80
+ end
63
81
  end
64
82
  end
@@ -39,17 +39,10 @@ module Beaker
39
39
  end
40
40
 
41
41
  it 'curls the SSL URL for cygwin\'s installer' do
42
- expect( instance ).to receive( :execute ).with( /^curl.*https\:/ ).ordered
43
42
  allow( instance ).to receive( :execute ).with( /^setup\-x86/ ).ordered
44
43
  instance.install_package( 'curl' )
45
44
  end
46
45
 
47
- it 'falls back to the non-SSL URL if that one fails' do
48
- allow( instance ).to receive( :execute ).with( /^curl.*https\:/ ).and_raise( Beaker::Host::CommandFailure ).ordered
49
- expect( instance ).to receive( :execute ).with( /^curl.*http\:/ ).ordered
50
- allow( instance ).to receive( :execute ).with( /^setup\-x86/ ).ordered
51
- instance.install_package( 'curl' )
52
- end
53
46
  end
54
47
  end
55
48
 
@@ -409,6 +409,7 @@ describe Beaker do
409
409
 
410
410
  hosts.each do |host|
411
411
  windows_pkgs.each do |pkg|
412
+ allow( host ).to receive( :cygwin_installed? ).and_return( true )
412
413
  allow( host ).to receive( :is_cygwin? ).and_return( true )
413
414
  expect( host ).to receive( :check_for_package ).with( pkg ).once.and_return( false )
414
415
  expect( host ).to receive( :install_package ).with( pkg ).once
@@ -122,62 +122,31 @@ module Beaker
122
122
  let(:cygwin64) { 'setup-x86_64.exe' }
123
123
  let(:package) { 'foo' }
124
124
 
125
- before(:each) do
126
- @platform = 'windows'
127
- allow( host ).to receive(:check_for_package).and_return(true)
128
- end
129
-
130
125
  context "testing osarchitecture" do
131
126
 
132
- before(:each) do
133
- expect( host ).to receive(:execute).with(/wmic os get osarchitecture/, anything).and_yield(success_osarch_check)
134
- end
135
-
136
- context "32 bit" do
137
- let(:success_osarch_check) { double(:success, :exit_code => 0, :stdout => '32-bit') }
138
-
139
- it "uses 32 bit cygwin" do
140
- expect( host ).to receive(:execute).with(/#{cygwin}.*#{package}/)
141
- host.install_package(package)
142
- end
143
- end
144
-
145
127
  context "64 bit" do
146
- let(:success_osarch_check) { double(:success, :exit_code => 0, :stdout => '64-bit') }
128
+ before do
129
+ @platform = Beaker::Platform.new('windows-2008r2-64')
130
+ end
147
131
 
148
132
  it "uses 64 bit cygwin" do
149
133
  expect( host ).to receive(:execute).with(/#{cygwin64}.*#{package}/)
150
134
  host.install_package(package)
151
135
  end
152
136
  end
153
- end
154
-
155
- context "testing os name" do
156
- let(:failed_osarch_check) { double(:failed, :exit_code => 1) }
157
-
158
- before(:each) do
159
- expect( host ).to receive(:execute).with(/wmic os get osarchitecture/, anything).and_yield(failed_osarch_check)
160
- expect( host ).to receive(:execute).with(/wmic os get name/, anything).and_yield(name_check)
161
- end
162
137
 
163
138
  context "32 bit" do
164
- let(:name_check) { double(:failure, :exit_code => 1) }
139
+ before do
140
+ @platform = Beaker::Platform.new('windows-10ent-32')
141
+ end
165
142
 
166
143
  it "uses 32 bit cygwin" do
167
144
  expect( host ).to receive(:execute).with(/#{cygwin}.*#{package}/)
168
145
  host.install_package(package)
169
146
  end
170
147
  end
171
-
172
- context "64 bit" do
173
- let(:name_check) { double(:success, :exit_code => 0) }
174
-
175
- it "uses 64 bit cygwin" do
176
- expect( host ).to receive(:execute).with(/#{cygwin64}.*#{package}/)
177
- host.install_package(package)
178
- end
179
- end
180
148
  end
149
+
181
150
  end
182
151
  end
183
152
 
@@ -710,12 +679,17 @@ module Beaker
710
679
  host.get_public_ip
711
680
  end
712
681
 
682
+ it 'call upon openstack host to get the ip address' do
683
+ host.host_hash[:hypervisor] = 'openstack'
684
+ expect(host.get_public_ip).to be(host.host_hash[:ip])
685
+ end
686
+
713
687
  it 'returns nil when no matching hypervisor is found' do
714
688
  host.host_hash[:hypervisor] = 'vmpooler'
715
689
  expect(host.get_public_ip).to be(nil)
716
690
  end
717
691
 
718
- it 'calls execute with curl if the host_hash[:instance] is not defined and the host is not an instance of Windows::Host' do
692
+ it 'calls execute with curl if the host_hash[:instance] is not defined for ec2 and the host is not an instance of Windows::Host' do
719
693
  host.host_hash[:hypervisor] = 'ec2'
720
694
  host.host_hash[:instance] = nil
721
695
  expect(host).to receive(:instance_of?).with(Windows::Host).and_return(false)
@@ -723,13 +697,30 @@ module Beaker
723
697
  host.get_public_ip
724
698
  end
725
699
 
726
- it 'calls execute with wget if the host_hash[:instance] is not defined and the host is an instance of Windows::Host' do
700
+ it 'calls execute with wget if the host_hash[:instance] is not defined for ec2 and the host is an instance of Windows::Host' do
727
701
  host.host_hash[:hypervisor] = 'ec2'
728
702
  host.host_hash[:instance] = nil
729
703
  expect(host).to receive(:instance_of?).with(Windows::Host).and_return(true)
730
704
  expect(host).to receive(:execute).with("wget http://169.254.169.254/latest/meta-data/public-ipv4").and_return('127.0.0.1')
731
705
  host.get_public_ip
732
706
  end
707
+
708
+ it 'calls execute with curl if the host_hash[:ip] is not defined for openstack and the host is not an instance of Windows::Host' do
709
+ host.host_hash[:hypervisor] = 'openstack'
710
+ host.host_hash[:ip] = nil
711
+ expect(host).to receive(:instance_of?).with(Windows::Host).and_return(false)
712
+ expect(host).to receive(:execute).with("curl http://169.254.169.254/latest/meta-data/public-ipv4").and_return('127.0.0.1')
713
+ host.get_public_ip
714
+ end
715
+
716
+ it 'calls execute with wget if the host_hash[:ip] is not defined for openstack and the host is an instance of Windows::Host' do
717
+ host.host_hash[:hypervisor] = 'openstack'
718
+ host.host_hash[:ip] = nil
719
+ expect(host).to receive(:instance_of?).with(Windows::Host).and_return(true)
720
+ expect(host).to receive(:execute).with("wget http://169.254.169.254/latest/meta-data/public-ipv4").and_return('127.0.0.1')
721
+ host.get_public_ip
722
+ end
723
+
733
724
  end
734
725
 
735
726
  describe '#ip' do