beaker 1.10.0 → 1.11.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/.travis.yml +2 -2
- data/Rakefile +14 -1
- data/beaker.gemspec +2 -1
- data/lib/beaker/answers/version20.rb +7 -7
- data/lib/beaker/answers/version28.rb +7 -7
- data/lib/beaker/answers/version30.rb +10 -9
- data/lib/beaker/dsl/helpers.rb +137 -6
- data/lib/beaker/dsl/install_utils.rb +60 -45
- data/lib/beaker/host/unix/pkg.rb +7 -7
- data/lib/beaker/host/windows.rb +4 -0
- data/lib/beaker/host_prebuilt_steps.rb +9 -2
- data/lib/beaker/hypervisor.rb +3 -1
- data/lib/beaker/hypervisor/docker.rb +154 -0
- data/lib/beaker/hypervisor/ec2_helper.rb +1 -1
- data/lib/beaker/hypervisor/google_compute_helper.rb +1 -1
- data/lib/beaker/options/parser.rb +7 -0
- data/lib/beaker/options/presets.rb +72 -52
- data/lib/beaker/test_case.rb +1 -14
- data/lib/beaker/version.rb +1 -1
- data/spec/beaker/answers_spec.rb +40 -27
- data/spec/beaker/dsl/helpers_spec.rb +114 -7
- data/spec/beaker/dsl/install_utils_spec.rb +17 -15
- data/spec/beaker/hypervisor/docker_spec.rb +212 -0
- data/spec/beaker/hypervisor/vagrant_spec.rb +2 -1
- data/spec/beaker/options/parser_spec.rb +2 -3
- data/spec/helpers.rb +1 -1
- metadata +21 -4
@@ -0,0 +1,212 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
# fake the docker-api
|
4
|
+
module Docker
|
5
|
+
class Image
|
6
|
+
end
|
7
|
+
class Container
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
module Beaker
|
12
|
+
describe Docker do
|
13
|
+
let(:hosts) { make_hosts }
|
14
|
+
|
15
|
+
let(:logger) do
|
16
|
+
logger = double('logger')
|
17
|
+
logger.stub(:debug)
|
18
|
+
logger.stub(:info)
|
19
|
+
logger.stub(:warn)
|
20
|
+
logger.stub(:error)
|
21
|
+
logger.stub(:notify)
|
22
|
+
logger
|
23
|
+
end
|
24
|
+
|
25
|
+
let(:image) do
|
26
|
+
image = double('Docker::Image')
|
27
|
+
image.stub(:id)
|
28
|
+
image.stub(:tag)
|
29
|
+
image.stub(:delete)
|
30
|
+
image
|
31
|
+
end
|
32
|
+
|
33
|
+
let(:container) do
|
34
|
+
container = double('Docker::Container')
|
35
|
+
container.stub(:id)
|
36
|
+
container.stub(:start)
|
37
|
+
container.stub(:json).and_return({
|
38
|
+
'NetworkSettings' => {
|
39
|
+
'Ports' => {
|
40
|
+
'22/tcp' => [
|
41
|
+
{
|
42
|
+
'HostIp' => '127.0.1.1',
|
43
|
+
'HostPort' => 8022,
|
44
|
+
},
|
45
|
+
],
|
46
|
+
},
|
47
|
+
},
|
48
|
+
})
|
49
|
+
container.stub(:stop)
|
50
|
+
container.stub(:delete)
|
51
|
+
container
|
52
|
+
end
|
53
|
+
|
54
|
+
let (:docker) { ::Beaker::Docker.new( hosts, { :logger => logger }) }
|
55
|
+
|
56
|
+
before :each do
|
57
|
+
# Stub out all of the docker-api gem. we should never really call it
|
58
|
+
# from these tests
|
59
|
+
::Beaker::Docker.any_instance.stub(:require).with('docker')
|
60
|
+
::Docker.stub(:options=)
|
61
|
+
::Docker.stub(:logger=)
|
62
|
+
::Docker.stub(:validate_version!)
|
63
|
+
::Docker::Image.stub(:build).and_return(image)
|
64
|
+
::Docker::Container.stub(:create).and_return(container)
|
65
|
+
::Docker::Container.any_instance.stub(:start)
|
66
|
+
end
|
67
|
+
|
68
|
+
describe '#initialize' do
|
69
|
+
it 'should require the docker gem' do
|
70
|
+
::Beaker::Docker.any_instance.should_receive(:require).with('docker').once
|
71
|
+
|
72
|
+
docker
|
73
|
+
end
|
74
|
+
|
75
|
+
it 'should fail when the gem is absent' do
|
76
|
+
::Beaker::Docker.any_instance.stub(:require).with('docker').and_raise(LoadError)
|
77
|
+
expect { docker }.to raise_error(LoadError)
|
78
|
+
end
|
79
|
+
|
80
|
+
it 'should set Docker options' do
|
81
|
+
::Docker.should_receive(:options=).once
|
82
|
+
|
83
|
+
docker
|
84
|
+
end
|
85
|
+
|
86
|
+
it 'should check the Docker gem can work with the api' do
|
87
|
+
::Docker.should_receive(:validate_version!).once
|
88
|
+
|
89
|
+
docker
|
90
|
+
end
|
91
|
+
|
92
|
+
it 'should hook the Beaker logger into the Docker one' do
|
93
|
+
::Docker.should_receive(:logger=).with(logger)
|
94
|
+
|
95
|
+
docker
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
99
|
+
describe '#provision' do
|
100
|
+
before :each do
|
101
|
+
docker.stub(:dockerfile_for)
|
102
|
+
end
|
103
|
+
|
104
|
+
it 'should call dockerfile_for with all the hosts' do
|
105
|
+
hosts.each do |host|
|
106
|
+
docker.should_receive(:dockerfile_for).with(host).and_return('')
|
107
|
+
end
|
108
|
+
|
109
|
+
docker.provision
|
110
|
+
end
|
111
|
+
|
112
|
+
it 'should pass the Dockerfile on to Docker::Image.create' do
|
113
|
+
docker.stub(:dockerfile_for).and_return('special testing value')
|
114
|
+
::Docker::Image.should_receive(:build).with('special testing value', { :rm => true })
|
115
|
+
|
116
|
+
docker.provision
|
117
|
+
end
|
118
|
+
|
119
|
+
it 'should tag the Image with the host.name' do
|
120
|
+
hosts.each do |host|
|
121
|
+
image.should_receive(:tag).with({
|
122
|
+
:repo => host.name,
|
123
|
+
:force => true,
|
124
|
+
})
|
125
|
+
end
|
126
|
+
|
127
|
+
docker.provision
|
128
|
+
end
|
129
|
+
|
130
|
+
it 'should create a container based on the Image (identified by host.name)' do
|
131
|
+
hosts.each do |host|
|
132
|
+
::Docker::Container.should_receive(:create).with({
|
133
|
+
'Image' => host.name,
|
134
|
+
'Hostname' => host.name,
|
135
|
+
})
|
136
|
+
end
|
137
|
+
|
138
|
+
docker.provision
|
139
|
+
end
|
140
|
+
|
141
|
+
it 'should start the container' do
|
142
|
+
container.should_receive(:start).with({'PublishAllPorts' => true})
|
143
|
+
|
144
|
+
docker.provision
|
145
|
+
end
|
146
|
+
|
147
|
+
it 'should expose port 22 to beaker' do
|
148
|
+
docker.provision
|
149
|
+
|
150
|
+
hosts[0]['ip'].should == '127.0.1.1'
|
151
|
+
hosts[0]['port'].should == 8022
|
152
|
+
end
|
153
|
+
|
154
|
+
it 'should record the image and container for later' do
|
155
|
+
docker.provision
|
156
|
+
|
157
|
+
hosts[0]['docker_image'].should == image
|
158
|
+
hosts[0]['docker_container'].should == container
|
159
|
+
end
|
160
|
+
end
|
161
|
+
|
162
|
+
describe '#cleanup' do
|
163
|
+
before :each do
|
164
|
+
# get into a state where there's something to clean
|
165
|
+
docker.stub(:dockerfile_for)
|
166
|
+
docker.provision
|
167
|
+
end
|
168
|
+
|
169
|
+
it 'should stop the containers' do
|
170
|
+
container.should_receive(:stop)
|
171
|
+
docker.cleanup
|
172
|
+
end
|
173
|
+
|
174
|
+
it 'should delete the containers' do
|
175
|
+
container.should_receive(:delete)
|
176
|
+
docker.cleanup
|
177
|
+
end
|
178
|
+
|
179
|
+
it 'should delete the images' do
|
180
|
+
image.should_receive(:delete)
|
181
|
+
docker.cleanup
|
182
|
+
end
|
183
|
+
end
|
184
|
+
|
185
|
+
describe '#dockerfile_for' do
|
186
|
+
it 'should raise on an unsupported platform' do
|
187
|
+
expect { docker.send(:dockerfile_for, {'platform' => 'a_sidewalk' }) }.to raise_error(/platform a_sidewalk not yet supported on docker/)
|
188
|
+
end
|
189
|
+
|
190
|
+
it 'should add docker_image_commands as RUN statements' do
|
191
|
+
dockerfile = docker.send(:dockerfile_for, {
|
192
|
+
'platform' => 'el-',
|
193
|
+
'docker_image_commands' => [
|
194
|
+
'special one',
|
195
|
+
'special two',
|
196
|
+
'special three',
|
197
|
+
]
|
198
|
+
})
|
199
|
+
|
200
|
+
dockerfile.should =~ /RUN special one\nRUN special two\nRUN special three/
|
201
|
+
end
|
202
|
+
|
203
|
+
it 'should use zypper on sles' do
|
204
|
+
dockerfile = docker.send(:dockerfile_for, {
|
205
|
+
'platform' => 'sles',
|
206
|
+
})
|
207
|
+
|
208
|
+
dockerfile.should =~ /RUN zypper -n in openssh/
|
209
|
+
end
|
210
|
+
end
|
211
|
+
end
|
212
|
+
end
|
@@ -91,7 +91,8 @@ module Beaker
|
|
91
91
|
host = @hosts[0]
|
92
92
|
host[:platform] = 'windows'
|
93
93
|
|
94
|
-
Command.should_receive( :new ).with("
|
94
|
+
Command.should_receive( :new ).with("cp -r .ssh /cygdrive/c/Users/Administrator/.").once
|
95
|
+
Command.should_receive( :new ).with("chown -R Administrator /cygdrive/c/Users/Administrator/.ssh").once
|
95
96
|
|
96
97
|
vagrant.copy_ssh_to_root( host, options )
|
97
98
|
|
@@ -132,11 +132,10 @@ module Beaker
|
|
132
132
|
|
133
133
|
it "can correctly combine arguments from different sources" do
|
134
134
|
FakeFS.deactivate!
|
135
|
-
build_url = ENV["BUILD_URL"]
|
136
135
|
ENV["BUILD_URL"] = "http://my.build.url/"
|
136
|
+
build_url = ENV["BUILD_URL"]
|
137
137
|
args = ["-h", hosts_path, "--log-level", "debug", "--type", "git", "--install", "PUPPET/1.0,HIERA/hello"]
|
138
|
-
expect(parser.parse_args(args)).to be === {:project=>"Beaker", :department=>"#{ENV['USER']}", :validate=>true, :jenkins_build_url=> "http://my.build.url/", :log_level=>"debug", :trace_limit=>10, :hosts_file=>hosts_path, :options_file=>nil, :type=>"git", :provision=>true, :preserve_hosts=>'never', :root_keys=>false, :quiet=>false, :xml=>false, :color=>true, :dry_run=>false, :timeout=>300, :fail_mode=>'slow', :timesync=>false, :repo_proxy=>false, :add_el_extras=>false, :add_master_entry=>false, :consoleport=>443, :pe_dir=>"/opt/enterprise/dists", :pe_version_file=>"LATEST", :pe_version_file_win=>"LATEST-win", :dot_fog=>"#{home}/.fog", :help=>false, :ec2_yaml=>"config/image_templates/ec2.yaml", :ssh=>{:config=>false, :paranoid=>false, :timeout=>300, :auth_methods=>["publickey"], :port=>22, :forward_agent=>true, :keys=>["#{home}/.ssh/id_rsa"], :user_known_hosts_file=>"#{home}/.ssh/known_hosts"}, :install=>["git://github.com/puppetlabs/puppet.git#1.0", "git://github.com/puppetlabs/hiera.git#hello"], :HOSTS=>{:"pe-ubuntu-lucid"=>{:roles=>["agent", "dashboard", "database", "master"], :vmname=>"pe-ubuntu-lucid", :platform=>"ubuntu-10.04-i386", :snapshot=>"clean-w-keys", :hypervisor=>"fusion"}, :"pe-centos6"=>{:roles=>["agent"], :vmname=>"pe-centos6", :platform=>"el-6-i386", :hypervisor=>"fusion", :snapshot=>"clean-w-keys"}}, :nfs_server=>"none", :helper=>[], :load_path=>[], :tests=>[], :pre_suite=>[], :post_suite=>[], :modules=>[]}
|
139
|
-
ENV["BUILD_URL"] = build_url
|
138
|
+
expect(parser.parse_args(args)).to be === {:project=>"Beaker", :department=>"#{ENV['USER']}", :validate=>true, :jenkins_build_url=> "http://my.build.url/", :forge_host=>"vulcan-acceptance.delivery.puppetlabs.net", :log_level=>"debug", :trace_limit=>10, :hosts_file=>hosts_path, :options_file=>nil, :type=>"git", :provision=>true, :preserve_hosts=>'never', :root_keys=>false, :quiet=>false, :xml=>false, :color=>true, :dry_run=>false, :timeout=>300, :fail_mode=>'slow', :timesync=>false, :repo_proxy=>false, :add_el_extras=>false, :add_master_entry=>false, :consoleport=>443, :pe_dir=>"/opt/enterprise/dists", :pe_version_file=>"LATEST", :pe_version_file_win=>"LATEST-win", :dot_fog=>"#{home}/.fog", :help=>false, :ec2_yaml=>"config/image_templates/ec2.yaml", :ssh=>{:config=>false, :paranoid=>false, :timeout=>300, :auth_methods=>["publickey"], :port=>22, :forward_agent=>true, :keys=>["#{home}/.ssh/id_rsa"], :user_known_hosts_file=>"#{home}/.ssh/known_hosts"}, :install=>["git://github.com/puppetlabs/puppet.git#1.0", "git://github.com/puppetlabs/hiera.git#hello"], :HOSTS=>{:"pe-ubuntu-lucid"=>{:roles=>["agent", "dashboard", "database", "master"], :vmname=>"pe-ubuntu-lucid", :platform=>"ubuntu-10.04-i386", :snapshot=>"clean-w-keys", :hypervisor=>"fusion"}, :"pe-centos6"=>{:roles=>["agent"], :vmname=>"pe-centos6", :platform=>"el-6-i386", :hypervisor=>"fusion", :snapshot=>"clean-w-keys"}}, :nfs_server=>"none", :home=>"#{home}", :answers=>{:q_puppet_enterpriseconsole_auth_user_email=>"admin@example.com", :q_puppet_enterpriseconsole_auth_password=>"~!@\#$%^*-/ aZ", :q_puppet_enterpriseconsole_smtp_host=>nil, :q_puppet_enterpriseconsole_smtp_port=>25, :q_puppet_enterpriseconsole_smtp_username=>nil, :q_puppet_enterpriseconsole_smtp_password=>nil, :q_puppet_enterpriseconsole_smtp_use_tls=>"n", :q_verify_packages=>"y", :q_puppetdb_password=>"~!@\#$%^*-/ aZ"}, :helper=>[], :load_path=>[], :tests=>[], :pre_suite=>[], :post_suite=>[], :modules=>[]}
|
140
139
|
end
|
141
140
|
|
142
141
|
it "ensures that fail-mode is one of fast/slow" do
|
data/spec/helpers.rb
CHANGED
@@ -47,7 +47,7 @@ module HostHelpers
|
|
47
47
|
end
|
48
48
|
|
49
49
|
def make_opts
|
50
|
-
Beaker::Options::Presets.presets.merge( { :logger => logger,
|
50
|
+
Beaker::Options::Presets.presets.merge( Beaker::Options::Presets.env_vars ).merge( { :logger => logger,
|
51
51
|
:host_config => 'sample.config',
|
52
52
|
:type => :foss,
|
53
53
|
:pooling_api => 'http://vcloud.delivery.puppetlabs.net/',
|
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.
|
4
|
+
version: 1.11.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-
|
11
|
+
date: 2014-05-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: minitest
|
@@ -226,14 +226,14 @@ dependencies:
|
|
226
226
|
requirements:
|
227
227
|
- - ~>
|
228
228
|
- !ruby/object:Gem::Version
|
229
|
-
version: 0.
|
229
|
+
version: 0.7.1
|
230
230
|
type: :runtime
|
231
231
|
prerelease: false
|
232
232
|
version_requirements: !ruby/object:Gem::Requirement
|
233
233
|
requirements:
|
234
234
|
- - ~>
|
235
235
|
- !ruby/object:Gem::Version
|
236
|
-
version: 0.
|
236
|
+
version: 0.7.1
|
237
237
|
- !ruby/object:Gem::Dependency
|
238
238
|
name: aws-sdk
|
239
239
|
requirement: !ruby/object:Gem::Requirement
|
@@ -248,6 +248,20 @@ dependencies:
|
|
248
248
|
- - ~>
|
249
249
|
- !ruby/object:Gem::Version
|
250
250
|
version: '1.38'
|
251
|
+
- !ruby/object:Gem::Dependency
|
252
|
+
name: docker-api
|
253
|
+
requirement: !ruby/object:Gem::Requirement
|
254
|
+
requirements:
|
255
|
+
- - ! '>='
|
256
|
+
- !ruby/object:Gem::Version
|
257
|
+
version: '0'
|
258
|
+
type: :runtime
|
259
|
+
prerelease: false
|
260
|
+
version_requirements: !ruby/object:Gem::Requirement
|
261
|
+
requirements:
|
262
|
+
- - ! '>='
|
263
|
+
- !ruby/object:Gem::Version
|
264
|
+
version: '0'
|
251
265
|
- !ruby/object:Gem::Dependency
|
252
266
|
name: nokogiri
|
253
267
|
requirement: !ruby/object:Gem::Requirement
|
@@ -349,6 +363,7 @@ files:
|
|
349
363
|
- lib/beaker/hypervisor/aixer.rb
|
350
364
|
- lib/beaker/hypervisor/aws_sdk.rb
|
351
365
|
- lib/beaker/hypervisor/blimper.rb
|
366
|
+
- lib/beaker/hypervisor/docker.rb
|
352
367
|
- lib/beaker/hypervisor/ec2_helper.rb
|
353
368
|
- lib/beaker/hypervisor/fusion.rb
|
354
369
|
- lib/beaker/hypervisor/google_compute.rb
|
@@ -396,6 +411,7 @@ files:
|
|
396
411
|
- spec/beaker/hypervisor/aixer_spec.rb
|
397
412
|
- spec/beaker/hypervisor/aws_sdk_spec.rb
|
398
413
|
- spec/beaker/hypervisor/blimper_spec.rb
|
414
|
+
- spec/beaker/hypervisor/docker_spec.rb
|
399
415
|
- spec/beaker/hypervisor/ec2_helper_spec.rb
|
400
416
|
- spec/beaker/hypervisor/fusion_spec.rb
|
401
417
|
- spec/beaker/hypervisor/google_compute.rb
|
@@ -475,6 +491,7 @@ test_files:
|
|
475
491
|
- spec/beaker/hypervisor/aixer_spec.rb
|
476
492
|
- spec/beaker/hypervisor/aws_sdk_spec.rb
|
477
493
|
- spec/beaker/hypervisor/blimper_spec.rb
|
494
|
+
- spec/beaker/hypervisor/docker_spec.rb
|
478
495
|
- spec/beaker/hypervisor/ec2_helper_spec.rb
|
479
496
|
- spec/beaker/hypervisor/fusion_spec.rb
|
480
497
|
- spec/beaker/hypervisor/google_compute.rb
|