beaker-docker 1.0.0 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2de8c341eaa907ce915686f4af31417659a391ace3e844cd10de5b6b3a6f963a
4
- data.tar.gz: 533955311e2c5a195bbc884a15dd71ae0a54603097baaf0afc41ca7226fef083
3
+ metadata.gz: 3f4f7b1cd703a47b1d9e0ef3ee4674fefca4859b051f1a9d3d90cd84e9d00314
4
+ data.tar.gz: c7a93b50fd1d1c17bf54d58082131e29e6e20837a46ec65e12e013fa1fdb3aca
5
5
  SHA512:
6
- metadata.gz: a0ae7bb38381077821e427d7f46ff135649ef686b381c4438a6dd046ffec455f32169226f5e7799a52bd7360cca8fd118e06c3db507b55776647a6273736b5c7
7
- data.tar.gz: 8250ec4f91378d821e0bbf3cf92a5038971df55f224ac03142148fe2dd8ee8137c6e86f11c94c597d1555e163c664b299076807cf6026eb1b2d6c0beaaadd08c
6
+ metadata.gz: ffc27af960c9686c3371d52e124a759456d57c64172443c061b573a4ffbb5756529c5ac686e379e707dc0480e495c7b64111745ba5930e3094803a07ed3534b4
7
+ data.tar.gz: 8633cd8a006ed012159784c42934818162d33a1d5d9062d520ed1152e001773aa1de5701ce3e71de263d25fa5b38d3948b61e12936b26c7a1440c64933e4c315
data/CHANGELOG.md CHANGED
@@ -1,5 +1,24 @@
1
1
  # Changelog
2
2
 
3
+ ## [1.0.1](https://github.com/voxpupuli/beaker-docker/tree/1.0.1) (2021-09-13)
4
+
5
+ [Full Changelog](https://github.com/voxpupuli/beaker-docker/compare/1.0.0...1.0.1)
6
+
7
+ **Implemented enhancements:**
8
+
9
+ - Initial EL9 support [\#55](https://github.com/voxpupuli/beaker-docker/pull/55) ([ekohl](https://github.com/ekohl))
10
+ - Add support for additional Docker port bindings [\#54](https://github.com/voxpupuli/beaker-docker/pull/54) ([treydock](https://github.com/treydock))
11
+
12
+ **Fixed bugs:**
13
+
14
+ - Fix IP detection in WSL2 environments [\#56](https://github.com/voxpupuli/beaker-docker/pull/56) ([trevor-vaughan](https://github.com/trevor-vaughan))
15
+ - Fix SSH port binding [\#53](https://github.com/voxpupuli/beaker-docker/pull/53) ([treydock](https://github.com/treydock))
16
+ - Added ENV DOCKER\_IN\_DOCKER to fix SSH conn info [\#51](https://github.com/voxpupuli/beaker-docker/pull/51) ([QueerCodingGirl](https://github.com/QueerCodingGirl))
17
+
18
+ **Closed issues:**
19
+
20
+ - Regression with 1.0.0 WRT SSH port usage [\#52](https://github.com/voxpupuli/beaker-docker/issues/52)
21
+
3
22
  ## [1.0.0](https://github.com/voxpupuli/beaker-docker/tree/1.0.0) (2021-08-06)
4
23
 
5
24
  [Full Changelog](https://github.com/voxpupuli/beaker-docker/compare/0.8.4...1.0.0)
data/docker.md CHANGED
@@ -188,3 +188,7 @@ node available as ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=
188
188
  ```
189
189
 
190
190
  The tests should then run as normal from there.
191
+
192
+
193
+ ### Docker-in-Docker (dind) ###
194
+ If you are using docker in docker, set the environment variable DOCKER_IN_DOCKER=true. Beaker-docker will then not try to use the DOCKER_HOST address for the ssh connection to the containers.
@@ -127,6 +127,11 @@ module Beaker
127
127
  { rm: true, buildargs: buildargs_for(host) })
128
128
  end
129
129
 
130
+ # Nested Docker scenarios
131
+ def nested_docker?
132
+ ENV['DOCKER_IN_DOCKER'] || ENV['WSLENV']
133
+ end
134
+
130
135
  # Find out where the ssh port is from the container
131
136
  # When running on swarm DOCKER_HOST points to the swarm manager so we have to get the
132
137
  # IP of the swarm slave via the container data
@@ -144,11 +149,11 @@ module Beaker
144
149
  ip = nil
145
150
  port = nil
146
151
  # Talking against a remote docker host which is a normal docker host
147
- if @docker_type == 'docker' && ENV['DOCKER_HOST'] && !ENV.fetch('DOCKER_HOST','').include?(':///')
152
+ if @docker_type == 'docker' && ENV['DOCKER_HOST'] && !ENV.fetch('DOCKER_HOST','').include?(':///') && !nested_docker?
148
153
  ip = URI.parse(ENV['DOCKER_HOST']).host
149
154
  else
150
155
  # Swarm or local docker host
151
- if in_container?
156
+ if in_container? && !nested_docker?
152
157
  gw = network_settings['Gateway']
153
158
  ip = gw unless (gw.nil? || gw.empty?)
154
159
  else
@@ -156,6 +161,9 @@ module Beaker
156
161
 
157
162
  # Host to Container
158
163
  port22 = network_settings.dig('PortBindings','22/tcp')
164
+ if port22.nil? && network_settings.key?('Ports')
165
+ port22 = network_settings.dig('Ports','22/tcp')
166
+ end
159
167
  ip = port22[0]['HostIp'] if port22
160
168
  port = port22[0]['HostPort'] if port22
161
169
 
@@ -284,6 +292,14 @@ module Beaker
284
292
  container_opts['name'] = ['beaker', host.name, SecureRandom.uuid.split('-').last].join('-')
285
293
  end
286
294
 
295
+ if host['docker_port_bindings']
296
+ container_opts['ExposedPorts'] = {} if container_opts['ExposedPorts'].nil?
297
+ host['docker_port_bindings'].each_pair do |port, bind|
298
+ container_opts['ExposedPorts'][port.to_s] = {}
299
+ container_opts['HostConfig']['PortBindings'][port.to_s] = bind
300
+ end
301
+ end
302
+
287
303
  ### END CONTAINER OPTIONS MANGLING ###
288
304
 
289
305
  @logger.debug("Creating container from image #{image_name}")
@@ -382,7 +398,7 @@ module Beaker
382
398
  container.exec(%w(apt-get update))
383
399
  container.exec(%w(apt-get install -y openssh-server openssh-client))
384
400
  container.exec(%w(sed 's@session\s*required\s*pam_loginuid.so@session optional pam_loginuid.so@g' -i /etc/pam.d/*))
385
- when /el-8/, /fedora-(2[2-9]|3[0-9])/
401
+ when /el-[89]/, /fedora-(2[2-9]|3[0-9])/
386
402
  container.exec(%w(dnf clean all))
387
403
  container.exec(%w(dnf install -y sudo openssh-server openssh-clients))
388
404
  container.exec(%w(ssh-keygen -t rsa -f /etc/ssh/ssh_host_rsa_key))
@@ -519,7 +535,7 @@ module Beaker
519
535
  RUN apt-get update
520
536
  RUN apt-get install -y openssh-server openssh-client #{Beaker::HostPrebuiltSteps::CUMULUS_PACKAGES.join(' ')}
521
537
  EOF
522
- when /el-8/, /fedora-(2[2-9]|3)/
538
+ when /el-[89]/, /fedora-(2[2-9]|3)/
523
539
  dockerfile += <<~EOF
524
540
  RUN dnf clean all
525
541
  RUN dnf install -y sudo openssh-server openssh-clients #{Beaker::HostPrebuiltSteps::RHEL8_PACKAGES.join(' ')}
@@ -1,3 +1,3 @@
1
1
  module BeakerDocker
2
- VERSION = '1.0.0'
2
+ VERSION = '1.0.1'
3
3
  end
@@ -68,7 +68,7 @@ module Beaker
68
68
  'Ports' => {
69
69
  '22/tcp' => [
70
70
  {
71
- 'HostIp' => '127.0.1.1',
71
+ 'HostIp' => '0.0.0.0',
72
72
  'HostPort' => 8022,
73
73
  },
74
74
  ],
@@ -476,6 +476,40 @@ module Beaker
476
476
  docker.provision
477
477
  end
478
478
 
479
+ it 'should create a container with port bindings' do
480
+ hosts.each_with_index do |host, index|
481
+ host['docker_port_bindings'] = {
482
+ '8080/tcp' => [{ 'HostPort' => '8080', 'HostIp' => '0.0.0.0'}]
483
+ }
484
+
485
+ expect( ::Docker::Container ).to receive(:create).with({
486
+ 'ExposedPorts' => {
487
+ '8080/tcp' => {},
488
+ },
489
+ 'Image' => image.id,
490
+ 'Hostname' => host.name,
491
+ 'HostConfig' => {
492
+ 'PortBindings' => {
493
+ '22/tcp' => [{ 'HostPort' => /\b\d{4}\b/, 'HostIp' => '0.0.0.0'}],
494
+ '8080/tcp' => [{ 'HostPort' => '8080', 'HostIp' => '0.0.0.0'}]
495
+ },
496
+ 'PublishAllPorts' => true,
497
+ 'Privileged' => true,
498
+ 'RestartPolicy' => {
499
+ 'Name' => 'always'
500
+ },
501
+ },
502
+ 'Labels' => {
503
+ 'one' => (index == 2 ? 3 : 1),
504
+ 'two' => (index == 2 ? 4 : 2),
505
+ },
506
+ 'name' => /\Abeaker-/
507
+ })
508
+ end
509
+
510
+ docker.provision
511
+ end
512
+
479
513
  it 'should start the container' do
480
514
  expect( container ).to receive(:start)
481
515
 
@@ -491,7 +525,7 @@ module Beaker
491
525
  ENV['DOCKER_HOST'] = nil
492
526
  docker.provision
493
527
 
494
- expect( hosts[0]['ip'] ).to be === '192.0.2.1'
528
+ expect( hosts[0]['ip'] ).to be === '127.0.0.1'
495
529
  expect( hosts[0]['port'] ).to be === 8022
496
530
  end
497
531
 
@@ -507,7 +541,7 @@ module Beaker
507
541
  ENV['DOCKER_HOST'] = nil
508
542
  docker.provision
509
543
 
510
- expect( hosts[0]['ip'] ).to be === '192.0.2.1'
544
+ expect( hosts[0]['ip'] ).to be === '127.0.0.1'
511
545
  expect( hosts[0]['port'] ).to be === 8022
512
546
  expect( hosts[0]['ssh'][:password] ).to be === 'root'
513
547
  expect( hosts[0]['ssh'][:port] ).to be === 8022
@@ -537,8 +571,8 @@ module Beaker
537
571
  ENV['DOCKER_HOST'] = nil
538
572
  docker.provision
539
573
 
540
- expect( hosts[0]['ip'] ).to be === '192.0.2.1'
541
- expect( hosts[0]['port'] ).to be === 22
574
+ expect( hosts[0]['ip'] ).to be === '127.0.0.1'
575
+ expect( hosts[0]['port'] ).to be === 8022
542
576
  end
543
577
  end
544
578
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: beaker-docker
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Vox Pupuli
@@ -11,7 +11,7 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2021-08-06 00:00:00.000000000 Z
14
+ date: 2021-09-13 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: rspec