beaker-docker 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/lib/beaker-docker/version.rb +1 -1
- data/lib/beaker/hypervisor/docker.rb +22 -2
- data/spec/beaker/hypervisor/docker_spec.rb +54 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
MjdhOGRmZjc5ODBhODgyMzY1ZTcwZDY5ZmU1ZGVhZjkxMDVmNTE2NQ==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
MGNhYTQzMmMyODMyNGJjNzNiOTdhMzhmZmMyNGQyMjE3MGM0ZjdiMA==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
YzkzNWJiZmVkYjBjMWI3MjVmMGVmYmJjMDU1ZWZmNDA0NzNkY2EwMGMyOTk4
|
10
|
+
ZDE4YmJkYmE2NDZkOGFlMDY3OTEwZjJiMTQxY2EzYmFmMjMxNWU0ZjZhMzIz
|
11
|
+
ZTIzNzhiYzgwOGE5YmVhYTZjY2VlNGZhNjZkYzNmMDk2ODQ0Y2Y=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
NGI0YWViODYwYWRmN2I3ZmUzYTU4MDE2NWJjODc1YTJhZTYxMjMwODNkODA2
|
14
|
+
NWViYzUyMThlOTdjMDJjMDkxODVhYmM5NjVhMWY4MGQwYzU5ZjE0N2ZlYTA5
|
15
|
+
YWY2NGMwNDIyNDhjZDIxOWI4ZDk3ZWZlNmY3NjNiZDUwYWQ2YjQ=
|
@@ -70,6 +70,17 @@ module Beaker
|
|
70
70
|
container_opts = {
|
71
71
|
'Image' => image_name,
|
72
72
|
'Hostname' => host.name,
|
73
|
+
'name' => host.name,
|
74
|
+
'HostConfig' => {
|
75
|
+
'PortBindings' => {
|
76
|
+
'22/tcp' => [{ 'HostPort' => rand.to_s[2..5], 'HostIp' => '0.0.0.0'}]
|
77
|
+
},
|
78
|
+
'PublishAllPorts' => true,
|
79
|
+
'Privileged' => true,
|
80
|
+
'RestartPolicy' => {
|
81
|
+
'Name' => 'always'
|
82
|
+
}
|
83
|
+
}
|
73
84
|
}
|
74
85
|
container = find_container(host)
|
75
86
|
|
@@ -102,7 +113,7 @@ module Beaker
|
|
102
113
|
fix_ssh(container) if @options[:provision] == false
|
103
114
|
|
104
115
|
@logger.debug("Starting container #{container.id}")
|
105
|
-
container.start
|
116
|
+
container.start
|
106
117
|
|
107
118
|
# Find out where the ssh port is from the container
|
108
119
|
# When running on swarm DOCKER_HOST points to the swarm manager so we have to get the
|
@@ -114,7 +125,11 @@ module Beaker
|
|
114
125
|
ip = URI.parse(ENV['DOCKER_HOST']).host
|
115
126
|
else
|
116
127
|
# Swarm or local docker host
|
117
|
-
|
128
|
+
if in_container?
|
129
|
+
ip = container.json["NetworkSettings"]["Gateway"]
|
130
|
+
else
|
131
|
+
ip = container.json["NetworkSettings"]["Ports"]["22/tcp"][0]["HostIp"]
|
132
|
+
end
|
118
133
|
end
|
119
134
|
|
120
135
|
@logger.info("Using docker server at #{ip}")
|
@@ -332,5 +347,10 @@ module Beaker
|
|
332
347
|
end.first
|
333
348
|
end
|
334
349
|
|
350
|
+
# return true if we are inside a docker container
|
351
|
+
def in_container?
|
352
|
+
return File.file?('/.dockerenv')
|
353
|
+
end
|
354
|
+
|
335
355
|
end
|
336
356
|
end
|
@@ -63,6 +63,7 @@ module Beaker
|
|
63
63
|
},
|
64
64
|
],
|
65
65
|
},
|
66
|
+
'Gateway' => '192.0.2.254'
|
66
67
|
},
|
67
68
|
})
|
68
69
|
allow( container ).to receive(:kill)
|
@@ -180,6 +181,17 @@ module Beaker
|
|
180
181
|
expect( ::Docker::Container ).to receive(:create).with({
|
181
182
|
'Image' => image.id,
|
182
183
|
'Hostname' => host.name,
|
184
|
+
'name' => host.name,
|
185
|
+
'HostConfig' => {
|
186
|
+
'PortBindings' => {
|
187
|
+
'22/tcp' => [{ 'HostPort' => /\b\d{4}\b/, 'HostIp' => '0.0.0.0'}]
|
188
|
+
},
|
189
|
+
'PublishAllPorts' => true,
|
190
|
+
'Privileged' => true,
|
191
|
+
'RestartPolicy' => {
|
192
|
+
'Name' => 'always'
|
193
|
+
}
|
194
|
+
}
|
183
195
|
})
|
184
196
|
end
|
185
197
|
|
@@ -199,6 +211,17 @@ module Beaker
|
|
199
211
|
expect( ::Docker::Container ).to receive(:create).with({
|
200
212
|
'Image' => image.id,
|
201
213
|
'Hostname' => host.name,
|
214
|
+
'name' => host.name,
|
215
|
+
'HostConfig' => {
|
216
|
+
'PortBindings' => {
|
217
|
+
'22/tcp' => [{ 'HostPort' => /\b\d{4}\b/, 'HostIp' => '0.0.0.0'}]
|
218
|
+
},
|
219
|
+
'PublishAllPorts' => true,
|
220
|
+
'Privileged' => true,
|
221
|
+
'RestartPolicy' => {
|
222
|
+
'Name' => 'always'
|
223
|
+
}
|
224
|
+
}
|
202
225
|
})
|
203
226
|
end
|
204
227
|
|
@@ -214,6 +237,16 @@ module Beaker
|
|
214
237
|
'Image' => image.id,
|
215
238
|
'Hostname' => host.name,
|
216
239
|
'name' => container_name,
|
240
|
+
'HostConfig' => {
|
241
|
+
'PortBindings' => {
|
242
|
+
'22/tcp' => [{ 'HostPort' => /\b\d{4}\b/, 'HostIp' => '0.0.0.0'}]
|
243
|
+
},
|
244
|
+
'PublishAllPorts' => true,
|
245
|
+
'Privileged' => true,
|
246
|
+
'RestartPolicy' => {
|
247
|
+
'Name' => 'always'
|
248
|
+
}
|
249
|
+
}
|
217
250
|
})
|
218
251
|
end
|
219
252
|
|
@@ -251,6 +284,7 @@ module Beaker
|
|
251
284
|
expect( ::Docker::Container ).to receive(:create).with({
|
252
285
|
'Image' => image.id,
|
253
286
|
'Hostname' => host.name,
|
287
|
+
'name' => host.name,
|
254
288
|
'HostConfig' => {
|
255
289
|
'Binds' => [
|
256
290
|
'/source_folder:/mount_point',
|
@@ -258,7 +292,15 @@ module Beaker
|
|
258
292
|
'/different_folder:/different_mount:rw',
|
259
293
|
"#{File.expand_path('./')}:/relative_mount",
|
260
294
|
"#{File.expand_path('local_folder')}:/another_relative_mount",
|
261
|
-
]
|
295
|
+
],
|
296
|
+
'PortBindings' => {
|
297
|
+
'22/tcp' => [{ 'HostPort' => /\b\d{4}\b/, 'HostIp' => '0.0.0.0'}]
|
298
|
+
},
|
299
|
+
'PublishAllPorts' => true,
|
300
|
+
'Privileged' => true,
|
301
|
+
'RestartPolicy' => {
|
302
|
+
'Name' => 'always'
|
303
|
+
}
|
262
304
|
}
|
263
305
|
})
|
264
306
|
end
|
@@ -267,7 +309,7 @@ module Beaker
|
|
267
309
|
end
|
268
310
|
|
269
311
|
it 'should start the container' do
|
270
|
-
expect( container ).to receive(:start)
|
312
|
+
expect( container ).to receive(:start)
|
271
313
|
|
272
314
|
docker.provision
|
273
315
|
end
|
@@ -303,6 +345,16 @@ module Beaker
|
|
303
345
|
expect( hosts[0]['ssh'][:forward_agent] ).to be === true
|
304
346
|
end
|
305
347
|
|
348
|
+
it 'should connect to gateway ip' do
|
349
|
+
FakeFS do
|
350
|
+
File.open('/.dockerenv', 'w') { }
|
351
|
+
docker.provision
|
352
|
+
|
353
|
+
expect( hosts[0]['ip'] ).to be === '192.0.2.254'
|
354
|
+
expect( hosts[0]['port'] ).to be === 8022
|
355
|
+
end
|
356
|
+
end
|
357
|
+
|
306
358
|
end
|
307
359
|
|
308
360
|
it "should generate a new /etc/hosts file referencing each host" do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: beaker-docker
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Rishi Javia, Kevin Imber, Tony Vu
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-08-
|
11
|
+
date: 2017-08-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|