beaker 1.21.0 → 2.0.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 (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
@@ -1,108 +0,0 @@
1
- require 'blimpy'
2
- require 'yaml' unless defined?(YAML)
3
- require 'beaker/hypervisor/ec2_helper'
4
-
5
- module Beaker
6
- class Blimper < Beaker::Hypervisor
7
-
8
- def initialize(blimpy_hosts, options)
9
- @options = options
10
- @logger = options[:logger]
11
- @hosts = blimpy_hosts
12
- @blimpy = Blimpy
13
- end
14
-
15
- def provision
16
- ami_spec= YAML.load_file(@options[:ec2_yaml])["AMI"]
17
-
18
- fleet = @blimpy.fleet do |fleet|
19
- @hosts.each do |host|
20
- amitype = host['vmname'] || host['platform']
21
- amisize = host['amisize'] || 'm1.small'
22
- #use snapshot provided for this host
23
- image_type = host['snapshot']
24
- if not image_type
25
- raise "No snapshot/image_type provided for blimpy provisioning"
26
- end
27
- ami = ami_spec[amitype]
28
- fleet.add(:aws) do |ship|
29
- ship.name = host.name
30
- ship.ports = Beaker::EC2Helper.amiports(host['roles'])
31
- ship.image_id = ami[:image][image_type.to_sym]
32
- if not ship.image_id
33
- raise "No image_id found for host #{ship.name} (#{amitype}:#{amisize}) using snapshot/image_type #{image_type}"
34
- end
35
- ship.flavor = amisize
36
- ship.region = ami[:region]
37
- ship.username = 'root'
38
- ship.tags = {
39
- :department => @options[:department],
40
- :project => @options[:project],
41
- :jenkins_build_url => @options[:jenkins_build_url],
42
- }
43
- end
44
- @logger.debug "Added #{host.name} (#{amitype}:#{amisize}) using snapshot/image_type #{image_type} to blimpy fleet"
45
- end
46
- end
47
-
48
- # Attempt to start the fleet, we wrap it with some error handling that
49
- # deals with generic Fog errors and retrying in case these errors are
50
- # transient.
51
- fleet_retries = 0
52
- begin
53
- fleet.start
54
- rescue Fog::Errors::Error, SystemCallError => ex
55
- fleet_retries += 1
56
- if fleet_retries <= 3
57
- sleep_time = rand(10) + 10
58
- @logger.notify("Calling fleet.destroy, sleeping #{sleep_time} seconds and retrying fleet.start due to exception #{ex.class.to_s} (#{ex.message}), retry attempt #{fleet_retries}.")
59
- begin
60
- timeout(30) do
61
- fleet.destroy
62
- end
63
- rescue
64
- end
65
- sleep sleep_time
66
- retry
67
- else
68
- @logger.error("Retried Fog #{fleet_retries} times, giving up and throwing the exception")
69
- raise ex
70
- end
71
- end
72
-
73
- # Configure our nodes to match the blimp fleet
74
- # Also generate hosts entries for the fleet, since we're iterating
75
- etc_hosts = "127.0.0.1\tlocalhost localhost.localdomain\n"
76
- fleet.ships.each do |ship|
77
- ship.wait_for_sshd
78
- name = ship.name
79
- host = @hosts.select { |host| host.name == name }[0]
80
- host['ip'] = ship.dns
81
- host.exec(Command.new("hostname #{name}"))
82
- ip = get_ip(host)
83
- domain = get_domain_name(host)
84
- etc_hosts += "#{ip}\t#{name}\t#{name}.#{domain}\n"
85
- end
86
-
87
- # Send our hosts information to the nodes
88
- @hosts.each do |host|
89
- set_etc_hosts(host, etc_hosts)
90
- end
91
-
92
- end #revert_blimpy
93
-
94
- def cleanup
95
- fleet = @blimpy.fleet do |fleet|
96
- @hosts.each do |host|
97
- fleet.add(:aws) do |ship|
98
- ship.name = host.name
99
- end
100
- end
101
- end
102
-
103
- @logger.notify "Destroying Blimpy boxes"
104
- fleet.destroy
105
- end
106
-
107
- end
108
- end
@@ -1,42 +0,0 @@
1
- require 'spec_helper'
2
- require 'blimpy'
3
-
4
- module Beaker
5
- describe Blimper do
6
- let( :blimper ) { Beaker::Blimper.new( @hosts, make_opts ) }
7
- let( :amispec ) { { "centos-5-x86-64-west" => { :image => { :pe => "ami-sekrit1" }, :region => "us-west-2" },
8
- "centos-6-x86-64-west" => { :image => { :pe => "ami-sekrit2" }, :region => "us-west-2" },
9
- "centos-7-x86-64-west" => { :image => { :pe => "ami-sekrit3" }, :region => "us-west-2" } }}
10
-
11
- before :each do
12
- @hosts = make_hosts( { :snapshot => :pe })
13
- @hosts[0][:platform] = "centos-5-x86-64-west"
14
- @hosts[1][:platform] = "centos-6-x86-64-west"
15
- @hosts[2][:platform] = "centos-7-x86-64-west"
16
- blimper.instance_variable_set( :@blimpy, MockBlimpy )
17
- end
18
-
19
- it "can provision a set of hosts" do
20
- YAML.stub( :load_file ).and_return( {"AMI" => amispec} )
21
- blimper.stub( :get_ip ) do |host|
22
- host['ip']
23
- end
24
- blimper.stub( :get_domain_name ).and_return( 'domain' )
25
- blimper.stub( :sleep ).and_return( true )
26
-
27
- @hosts.each do |host|
28
- blimper.should_receive( :set_etc_hosts ).with( host, "127.0.0.1\tlocalhost localhost.localdomain\nvm1.my.ip\tvm1\tvm1.domain\nvm2.my.ip\tvm2\tvm2.domain\nvm3.my.ip\tvm3\tvm3.domain\n" )
29
- end
30
-
31
- blimper.provision
32
- end
33
-
34
- it "calls fleet.destroy on cleanup" do
35
- MockFleet.any_instance.should_receive( :add ).with( :aws ).exactly( @hosts.length ).times
36
- MockFleet.any_instance.should_receive( :destroy ).once
37
-
38
- blimper.cleanup
39
- end
40
-
41
- end
42
- end
@@ -1 +0,0 @@
1
- 3.0.0
@@ -1,161 +0,0 @@
1
- require 'spec_helper'
2
-
3
- module Beaker
4
- #most testing already covered in Command, just need to cover env variable handling
5
- describe PuppetCommand do
6
- let(:command) { @command || '/bin/ls' }
7
- let(:args) { @args || Array.new }
8
- let(:options) { @options || {} }
9
- subject(:cmd) { PuppetCommand.new( command, args, options ) }
10
- let(:host) { make_host( 'name', { :platform => @platform } ) }
11
-
12
- let( :nix_path ) { %q[PATH="/usr/bin:/opt/puppet-git-repos/hiera/bin:${PATH}"] }
13
- let( :nix_lib ) { %q[RUBYLIB="/opt/puppet-git-repos/hiera/lib:/opt/puppet-git-repos/hiera-puppet/lib:${RUBYLIB}"] }
14
-
15
- it 'creates a Windows env for a Windows host' do
16
- @platform = 'windows'
17
- @command = 'agent'
18
- @args = [ 'to', 'the', 'baz' ]
19
- @options = { :foo => 'bar' }
20
-
21
- expect( host ).to be_a_kind_of Windows::Host
22
- expect( cmd.options ).to be == options
23
- expect( cmd.args ).to be == [@args]
24
- expect( cmd.command ).to be == "puppet " + @command
25
-
26
- expect( cmd.args_string ).to be == 'to the baz'
27
- expect( cmd.options_string ).to be == '--foo=bar'
28
-
29
- win_path = %q[/opt/puppet-git-repos/hiera/bin:${PATH}]
30
- win_lib = %q[`cygpath -w /opt/puppet-git-repos/hiera/lib`;`cygpath -w /opt/puppet-git-repos/hiera-puppet/lib`;${RUBYLIB}]
31
- cmd_exe = %q[cmd.exe /c]
32
-
33
- command_line = cmd.environment_string_for( host, cmd.environment )
34
- expect( command_line ).to include( win_path )
35
- expect( command_line ).to include( win_lib )
36
- expect( command_line ).to include( cmd_exe )
37
- end
38
-
39
- it 'creates a Unix env for a Unix host' do
40
- @platform = 'unix'
41
- @command = 'agent'
42
- @args = [ 'to', 'the', 'baz' ]
43
- @options = { :foo => 'bar' }
44
-
45
- expect( host ).to be_a_kind_of Unix::Host
46
- expect( cmd.options ).to be == @options
47
- expect( cmd.args ).to be == [@args]
48
- expect( cmd.command ).to be == "puppet " + @command
49
-
50
- expect( cmd.args_string ).to be == 'to the baz'
51
- expect( cmd.options_string ).to be == '--foo=bar'
52
-
53
- command_line = cmd.environment_string_for( host, cmd.environment )
54
- expect( command_line ).to include( nix_path )
55
- expect( command_line ).to include( nix_lib )
56
- end
57
-
58
- it 'creates an AIX env for an AIX host' do
59
- @platform = 'aix'
60
- @command = 'agent'
61
- @args = [ 'to', 'the', 'baz' ]
62
- @options = { :foo => 'bar' }
63
-
64
- expect( host ).to be_a_kind_of Aix::Host
65
- expect( cmd.options ).to be == @options
66
- expect( cmd.args ).to be == [@args]
67
- expect( cmd.command ).to be == "puppet " + @command
68
-
69
- expect( cmd.args_string ).to be == 'to the baz'
70
- expect( cmd.options_string ).to be == '--foo=bar'
71
-
72
- command_line = cmd.environment_string_for( host, cmd.environment )
73
- expect( command_line ).to include( nix_path )
74
- expect( command_line ).to include( nix_lib )
75
- end
76
-
77
- it 'correctly adds additional ENV to default ENV' do
78
- @platform = 'unix'
79
- @command = 'agent'
80
- @args = [ 'to', 'the', 'baz' ]
81
- @options = { :foo => 'bar', 'ENV' => {'PATH' => '/STRING_ENV/bin'} }
82
-
83
- expect( host ).to be_a_kind_of Unix::Host
84
- expect( cmd.options ).to be == @options
85
- expect( cmd.args ).to be == [@args]
86
- expect( cmd.command ).to be == "puppet " + @command
87
-
88
- expect( cmd.args_string ).to be == 'to the baz'
89
- expect( cmd.options_string ).to be == '--foo=bar'
90
- custom = %q[PATH="/STRING_ENV/bin"]
91
-
92
- command_line = cmd.environment_string_for( host, cmd.environment )
93
- expect( command_line ).to include( nix_path )
94
- expect( command_line ).to include( nix_lib )
95
- expect( command_line ).to include( custom )
96
- end
97
-
98
- it 'correctly adds additional :ENV to default ENV' do
99
- @platform = 'unix'
100
- @command = 'agent'
101
- @args = [ 'to', 'the', 'baz' ]
102
- @options = { :foo => 'bar', :ENV => {'PATH' => '/SYMBOL_ENV/bin'} }
103
-
104
- expect( host ).to be_a_kind_of Unix::Host
105
- expect( cmd.options ).to be == @options
106
- expect( cmd.args ).to be == [@args]
107
- expect( cmd.command ).to be == "puppet " + @command
108
-
109
- expect( cmd.args_string ).to be == 'to the baz'
110
- expect( cmd.options_string ).to be == '--foo=bar'
111
-
112
- custom = %q[PATH="/SYMBOL_ENV/bin"]
113
- command_line = cmd.environment_string_for( host, cmd.environment )
114
- expect( command_line ).to include( nix_path )
115
- expect( command_line ).to include( nix_lib )
116
- expect( command_line ).to include( custom )
117
- end
118
-
119
- it 'correctly adds additional :environment to default ENV' do
120
- @platform = 'unix'
121
- @command = 'agent'
122
- @args = [ 'to', 'the', 'baz' ]
123
- @options = { :foo => 'bar', :environment => {'PATH' => '/SYMBOL_ENVIRONMENT/bin'} }
124
-
125
- expect( host ).to be_a_kind_of Unix::Host
126
- expect( cmd.options ).to be == @options
127
- expect( cmd.args ).to be == [@args]
128
- expect( cmd.command ).to be == "puppet " + @command
129
-
130
- expect( cmd.args_string ).to be == 'to the baz'
131
- expect( cmd.options_string ).to be == '--foo=bar'
132
-
133
- custom = %q[PATH="/SYMBOL_ENVIRONMENT/bin"]
134
- command_line = cmd.environment_string_for( host, cmd.environment )
135
- expect( command_line ).to include( nix_path )
136
- expect( command_line ).to include( nix_lib )
137
- expect( command_line ).to include( custom )
138
- end
139
-
140
- it 'correctly adds additional environment to default ENV' do
141
- @platform = 'unix'
142
- @command = 'agent'
143
- @args = [ 'to', 'the', 'baz' ]
144
- @options = { :foo => 'bar', 'environment' => {'PATH' => '/STRING_ENVIRONMENT/bin'} }
145
-
146
- expect( host ).to be_a_kind_of Unix::Host
147
- expect( cmd.options ).to be == @options
148
- expect( cmd.args ).to be == [@args]
149
- expect( cmd.command ).to be == "puppet " + @command
150
-
151
- expect( cmd.args_string ).to be == 'to the baz'
152
- expect( cmd.options_string ).to be == '--foo=bar'
153
-
154
- custom = %q[PATH="/STRING_ENVIRONMENT/bin"]
155
- command_line = cmd.environment_string_for( host, cmd.environment )
156
- expect( command_line ).to include( nix_path )
157
- expect( command_line ).to include( nix_lib )
158
- expect( command_line ).to include( custom )
159
- end
160
- end
161
- end
@@ -1,48 +0,0 @@
1
- class MockShip
2
- attr_accessor :name, :ports, :image_id, :flavor, :region, :username, :dns, :tags
3
-
4
- def initialize
5
- @dns = "my.ip.address"
6
- end
7
-
8
- def wait_for_sshd
9
- @dns = "#{@name}.my.ip"
10
- return true
11
- end
12
-
13
- end
14
-
15
- class MockFleet
16
- attr_accessor :ships
17
- @@attempts = 0
18
-
19
- def initialize
20
- @ships = []
21
- end
22
-
23
- def add type
24
- @ships << MockShip.new
25
- yield(@ships[-1])
26
- @ships[-1]
27
- end
28
-
29
- def start
30
- if @@attempts < 1
31
- @@attempts += 1
32
- raise Fog::Errors::Error
33
- end
34
- end
35
-
36
- def destroy
37
- end
38
-
39
- end
40
-
41
- class MockBlimpy
42
- @@fleet = nil
43
- def self.fleet
44
- yield(@@fleet = MockFleet.new)
45
- @@fleet
46
- end
47
-
48
- end