beaker-docker 3.1.1 → 3.1.3

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 20458b7863defa8965bb32ebf8509c39cb8879b6a3d77c738fe76c55ad80b7b0
4
- data.tar.gz: de353c5f2b2a75edefed8e4926eeb07792717173db68cfa3081fa5e747920a17
3
+ metadata.gz: 9f1ee5ab53b86ffda7555b85471e7427d811d910ae943fdc60618dc71247780d
4
+ data.tar.gz: b88d72d90e95dbe4a986cf9444fedd2eca6eeee3c59efea73ad1e044afe72da0
5
5
  SHA512:
6
- metadata.gz: b17e5c8962e810565652fd962a7240c2d328e3ac08793da48416040fa7b4351863b85d0e0043518c57e1b31db7cd5c433103e394bc262504fae6f7d42485c4f2
7
- data.tar.gz: 38928914ecb2b8b5bbfc9fff9dacfce07a852d0c937e22b5ebea97dcccba77a7442ca0c9c61ad23bd0b224a6c26037cf2f9b08e34a984c39fe0aa3207b5e4e30
6
+ metadata.gz: 404f1d4b7d9c644583a76d4e4be545c613126d80be170b464a69a64d54abaec614697b728ffb52685d0c29bdca0970f2df3d9cfb6711ac3071d7433e3be196fa
7
+ data.tar.gz: c0634e2844595b1e691042ad3f65041fffa9a218e47c47214ddb9eff0de1d1ba4569a692a2c27d74cd09927be3a609e1648f825caf34e06b68ce68cdc8f7b7fc
@@ -15,16 +15,16 @@ jobs:
15
15
  name: Build the gem
16
16
  runs-on: ubuntu-24.04
17
17
  steps:
18
- - uses: actions/checkout@v6
18
+ - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
19
19
  - name: Install Ruby
20
- uses: ruby/setup-ruby@v1
20
+ uses: ruby/setup-ruby@95ef2b042f9d7a56d8268cba8559e2842e2ad01b # v1.321.0
21
21
  with:
22
22
  ruby-version: 'ruby'
23
23
  - name: Build gem
24
24
  shell: bash
25
25
  run: gem build --verbose *.gemspec
26
26
  - name: Upload gem to GitHub cache
27
- uses: actions/upload-artifact@v6
27
+ uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
28
28
  with:
29
29
  name: gem-artifact
30
30
  path: '*.gem'
@@ -39,7 +39,7 @@ jobs:
39
39
  contents: write # clone repo and create release
40
40
  steps:
41
41
  - name: Download gem from GitHub cache
42
- uses: actions/download-artifact@v7
42
+ uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
43
43
  with:
44
44
  name: gem-artifact
45
45
  - name: Create Release
@@ -56,7 +56,7 @@ jobs:
56
56
  packages: write # publish to rubygems.pkg.github.com
57
57
  steps:
58
58
  - name: Download gem from GitHub cache
59
- uses: actions/download-artifact@v7
59
+ uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
60
60
  with:
61
61
  name: gem-artifact
62
62
  - name: Publish gem to GitHub packages
@@ -73,10 +73,10 @@ jobs:
73
73
  id-token: write # rubygems.org authentication
74
74
  steps:
75
75
  - name: Download gem from GitHub cache
76
- uses: actions/download-artifact@v7
76
+ uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
77
77
  with:
78
78
  name: gem-artifact
79
- - uses: rubygems/configure-rubygems-credentials@v1.0.0
79
+ - uses: rubygems/configure-rubygems-credentials@dc5a8d8553e6ee01fc26761a49e99e733d17954a # v2.1.0
80
80
  - name: Publish gem to rubygems.org
81
81
  shell: bash
82
82
  run: gem push *.gem
@@ -92,11 +92,11 @@ jobs:
92
92
  - release-to-rubygems
93
93
  steps:
94
94
  - name: Download gem from GitHub cache
95
- uses: actions/download-artifact@v7
95
+ uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
96
96
  with:
97
97
  name: gem-artifact
98
98
  - name: Install Ruby
99
- uses: ruby/setup-ruby@v1
99
+ uses: ruby/setup-ruby@95ef2b042f9d7a56d8268cba8559e2842e2ad01b # v1.321.0
100
100
  with:
101
101
  ruby-version: 'ruby'
102
102
  - name: Wait for release to propagate
@@ -16,16 +16,16 @@ jobs:
16
16
  outputs:
17
17
  ruby: ${{ steps.ruby.outputs.versions }}
18
18
  steps:
19
- - uses: actions/checkout@v6
19
+ - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
20
20
  - name: Install Ruby 4.0
21
- uses: ruby/setup-ruby@v1
21
+ uses: ruby/setup-ruby@95ef2b042f9d7a56d8268cba8559e2842e2ad01b # v1.321.0
22
22
  with:
23
23
  ruby-version: '4.0'
24
24
  bundler-cache: true
25
25
  - name: Run Rubocop
26
26
  run: bundle exec rake rubocop
27
27
  - id: ruby
28
- uses: voxpupuli/ruby-version@v2
28
+ uses: voxpupuli/ruby-version@be0467ce7366d206b2e87f5b7a032a030120b7cb # 2.0.0
29
29
 
30
30
  rspec:
31
31
  runs-on: ubuntu-24.04
@@ -36,9 +36,9 @@ jobs:
36
36
  ruby: ${{ fromJSON(needs.rubocop_and_matrix.outputs.ruby) }}
37
37
  name: RSpec - Ruby ${{ matrix.ruby }}
38
38
  steps:
39
- - uses: actions/checkout@v6
39
+ - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
40
40
  - name: Install Ruby ${{ matrix.ruby }}
41
- uses: ruby/setup-ruby@v1
41
+ uses: ruby/setup-ruby@95ef2b042f9d7a56d8268cba8559e2842e2ad01b # v1.321.0
42
42
  with:
43
43
  ruby-version: ${{ matrix.ruby }}
44
44
  bundler-cache: true
@@ -56,9 +56,9 @@ jobs:
56
56
  ruby: ${{ fromJSON(needs.rubocop_and_matrix.outputs.ruby) }}
57
57
  name: Docker on Ruby ${{ matrix.ruby }}
58
58
  steps:
59
- - uses: actions/checkout@v6
59
+ - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
60
60
  - name: Install Ruby ${{ matrix.ruby }}
61
- uses: ruby/setup-ruby@v1
61
+ uses: ruby/setup-ruby@95ef2b042f9d7a56d8268cba8559e2842e2ad01b # v1.321.0
62
62
  with:
63
63
  ruby-version: ${{ matrix.ruby }}
64
64
  bundler-cache: true
@@ -71,7 +71,7 @@ jobs:
71
71
  # needs: rubocop_and_matrix
72
72
  # name: Docker - Beaker in container connection test
73
73
  # steps:
74
- # - uses: actions/checkout@v6
74
+ # - uses: actions/checkout@v7
75
75
  # # use this and not container key from gha to not have a docker network from github
76
76
  # - name: Run Beaker in docker container
77
77
  # uses: addnab/docker-run-action@v3
@@ -99,9 +99,9 @@ jobs:
99
99
  run: |
100
100
  sudo systemctl stop docker.service docker.socket && systemctl start --user podman.socket
101
101
  echo "DOCKER_HOST=unix:///run/user/$(id -u)/podman/podman.sock" >> "$GITHUB_ENV"
102
- - uses: actions/checkout@v6
102
+ - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
103
103
  - name: Install Ruby ${{ matrix.ruby }}
104
- uses: ruby/setup-ruby@v1
104
+ uses: ruby/setup-ruby@95ef2b042f9d7a56d8268cba8559e2842e2ad01b # v1.321.0
105
105
  with:
106
106
  ruby-version: ${{ matrix.ruby }}
107
107
  bundler-cache: true
@@ -109,6 +109,7 @@ jobs:
109
109
  run: bundle exec rake test:acceptance
110
110
 
111
111
  tests:
112
+ if: always()
112
113
  needs:
113
114
  - rubocop_and_matrix
114
115
  - docker
@@ -118,4 +119,7 @@ jobs:
118
119
  runs-on: ubuntu-24.04
119
120
  name: Test suite
120
121
  steps:
121
- - run: echo Test suite completed
122
+ - name: Decide whether the needed jobs succeeded or failed
123
+ uses: re-actors/alls-green@release/v1
124
+ with:
125
+ jobs: ${{ toJSON(needs) }}
data/CHANGELOG.md CHANGED
@@ -1,5 +1,27 @@
1
1
  # Changelog
2
2
 
3
+ ## [3.1.3](https://github.com/voxpupuli/beaker-docker/tree/3.1.3) (2026-08-21)
4
+
5
+ [Full Changelog](https://github.com/voxpupuli/beaker-docker/compare/3.1.2...3.1.3)
6
+
7
+ **Fixed bugs:**
8
+
9
+ - Fix ssh connection routing under Podman: network naming and container detection [\#194](https://github.com/voxpupuli/beaker-docker/pull/194) ([miharp](https://github.com/miharp))
10
+
11
+ **Closed issues:**
12
+
13
+ - `in_container?` only checks `/.dockerenv`, so the gateway connection path never triggers under Podman [\#193](https://github.com/voxpupuli/beaker-docker/issues/193)
14
+ - `DOCKER_IN_DOCKER=true` crashes with NoMethodError on Podman 5: `Networks[NetworkMode]` lookup assumes Docker's network naming [\#192](https://github.com/voxpupuli/beaker-docker/issues/192)
15
+
16
+ ## [3.1.2](https://github.com/voxpupuli/beaker-docker/tree/3.1.2) (2026-02-27)
17
+
18
+ [Full Changelog](https://github.com/voxpupuli/beaker-docker/compare/3.1.1...3.1.2)
19
+
20
+ **Fixed bugs:**
21
+
22
+ - fix: complete the support for docker-ce \>= v29 network configuration [\#183](https://github.com/voxpupuli/beaker-docker/pull/183) ([mxey](https://github.com/mxey))
23
+ - Handle empty IPAddress when setting host vm\_ip [\#182](https://github.com/voxpupuli/beaker-docker/pull/182) ([uvNikita](https://github.com/uvNikita))
24
+
3
25
  ## [3.1.1](https://github.com/voxpupuli/beaker-docker/tree/3.1.1) (2026-01-31)
4
26
 
5
27
  [Full Changelog](https://github.com/voxpupuli/beaker-docker/compare/3.1.0...3.1.1)
data/docker.md CHANGED
@@ -200,4 +200,17 @@ The tests should then run as normal from there.
200
200
 
201
201
 
202
202
  ### Docker-in-Docker (dind) ###
203
- 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.
203
+ If beaker itself runs inside a container (for example in a CI job) and the test
204
+ containers are created as siblings on the same host, beaker-docker detects
205
+ this automatically (via `/.dockerenv` on docker or `/run/.containerenv` on
206
+ podman) and connects through the bridge gateway and each test container's
207
+ published ssh port. No configuration is needed as long as the published port
208
+ is reachable via the gateway address.
209
+
210
+ If gateway routing does not work in your environment (ssh port not published
211
+ to the host, or a firewall blocking traffic to the gateway), set the
212
+ environment variable DOCKER_IN_DOCKER=true. Beaker-docker then ignores the
213
+ DOCKER_HOST address and published ports, and connects to each test
214
+ container's network IP directly; make sure the beaker container is attached
215
+ to the same network as the test containers. This works with podman as well
216
+ as docker, and is also enabled automatically under WSL.
@@ -151,6 +151,10 @@ module Beaker
151
151
  elsif in_container? && !nested_docker?
152
152
  # Swarm or local docker host
153
153
  gw = network_settings['Gateway']
154
+
155
+ # also handle scenarios where network_settings['Gateway'] is not set (e.g. docker-ce >= v29)
156
+ gw = container_network(network_settings, host_config)['Gateway'] if gw.nil? || gw.empty?
157
+
154
158
  ip = gw unless gw.nil? || gw.empty?
155
159
  else
156
160
  # The many faces of container networking
@@ -166,7 +170,7 @@ module Beaker
166
170
  unless ip && port
167
171
  ip = network_settings['IPAddress'] # podman
168
172
  # also handle scenarios where network_settings['IPAddress'] is not set (e.g. docker-ce >= v29)
169
- ip = network_settings['Networks'][host_config['NetworkMode']]['IPAddress'] if ip.nil? || ip.empty?
173
+ ip = container_network(network_settings, host_config)['IPAddress'] if ip.nil? || ip.empty?
170
174
  port = (ip && !ip.empty?) ? 22 : nil
171
175
  end
172
176
 
@@ -356,7 +360,11 @@ module Beaker
356
360
  @logger.debug("node available as ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no root@#{ip} -p #{port}")
357
361
  host['docker_container_id'] = container.id
358
362
  host['docker_image_id'] = image.id
359
- host['vm_ip'] = container.json['NetworkSettings']['IPAddress'].to_s
363
+ host_config = container.json['HostConfig']
364
+ vm_ip = container.json['NetworkSettings']['IPAddress']
365
+ # handle scenarios where network_settings['IPAddress'] is not set (e.g. docker-ce >= v29)
366
+ vm_ip = container_network(container.json['NetworkSettings'], host_config)['IPAddress'] if vm_ip.nil? || vm_ip.empty?
367
+ host['vm_ip'] = vm_ip.to_s
360
368
 
361
369
  def host.reboot
362
370
  @logger.warn('Rebooting containers is ineffective...ignoring')
@@ -455,6 +463,15 @@ module Beaker
455
463
 
456
464
  private
457
465
 
466
+ # Look up the network a container is attached to. Podman's Docker-compatible
467
+ # API reports HostConfig.NetworkMode as 'bridge' but keys
468
+ # NetworkSettings.Networks by the actual network name, so fall back to the
469
+ # first attached network when the NetworkMode key is missing.
470
+ def container_network(network_settings, host_config)
471
+ networks = network_settings['Networks'] || {}
472
+ networks[host_config['NetworkMode']] || networks.values.first || {}
473
+ end
474
+
458
475
  def root_password
459
476
  'root'
460
477
  end
@@ -631,9 +648,9 @@ module Beaker
631
648
  nil
632
649
  end
633
650
 
634
- # return true if we are inside a docker container
651
+ # return true if we are inside a docker or podman container
635
652
  def in_container?
636
- File.file?('/.dockerenv')
653
+ File.file?('/.dockerenv') || File.file?('/run/.containerenv')
637
654
  end
638
655
  end
639
656
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module BeakerDocker
4
- VERSION = '3.1.1'
4
+ VERSION = '3.1.3'
5
5
  end
@@ -686,17 +686,27 @@ module Beaker
686
686
  expect(hosts[0]['port']).to eq 8022
687
687
  end
688
688
  end
689
+
690
+ it 'connects to gateway ip inside a podman container' do
691
+ FakeFS do
692
+ FileUtils.mkdir_p('/run')
693
+ FileUtils.touch('/run/.containerenv')
694
+ docker.provision
695
+
696
+ expect(hosts[0]['ip']).to eq '192.0.2.254'
697
+ expect(hosts[0]['port']).to eq 8022
698
+ end
699
+ end
689
700
  end
690
701
  end
691
702
 
692
- context 'when IPAddress is empty but available in Networks' do
703
+ context 'when using newer docker-ce where IPs are only in Networks' do
693
704
  let(:container_config) do
694
705
  {
695
706
  'HostConfig' => {
696
707
  'NetworkMode' => 'bridge',
697
708
  },
698
709
  'NetworkSettings' => {
699
- 'IPAddress' => '',
700
710
  'Ports' => {
701
711
  '22/tcp' => [
702
712
  {
@@ -705,9 +715,9 @@ module Beaker
705
715
  },
706
716
  ],
707
717
  },
708
- 'Gateway' => '192.0.2.254',
709
718
  'Networks' => {
710
719
  'bridge' => {
720
+ 'Gateway' => '192.0.2.254',
711
721
  'IPAddress' => '192.0.2.10',
712
722
  },
713
723
  },
@@ -723,8 +733,67 @@ module Beaker
723
733
 
724
734
  expect(hosts[0]['ip']).to eq '192.0.2.10'
725
735
  expect(hosts[0]['port']).to eq 22
736
+ expect(hosts[0]['vm_ip']).to eq '192.0.2.10'
726
737
  end
727
738
  end
739
+
740
+ it 'stills finds gateway' do
741
+ ENV['DOCKER_IN_DOCKER'] = nil
742
+ ENV['DOCKER_HOST'] = nil
743
+ FakeFS do
744
+ FileUtils.touch('/.dockerenv')
745
+ docker.provision
746
+
747
+ expect(hosts[0]['ip']).to eq '192.0.2.254'
748
+ expect(hosts[0]['port']).to eq 8022
749
+ expect(hosts[0]['vm_ip']).to eq '192.0.2.10'
750
+ end
751
+ end
752
+ end
753
+
754
+ context 'when using podman where Networks is keyed by network name instead of NetworkMode' do
755
+ let(:container_config) do
756
+ {
757
+ 'HostConfig' => {
758
+ 'NetworkMode' => 'bridge',
759
+ },
760
+ 'NetworkSettings' => {
761
+ 'Ports' => {
762
+ '22/tcp' => [
763
+ {
764
+ 'HostIp' => '0.0.0.0',
765
+ 'HostPort' => 8022,
766
+ },
767
+ ],
768
+ },
769
+ 'Networks' => {
770
+ 'podman' => {
771
+ 'Gateway' => '192.0.2.254',
772
+ 'IPAddress' => '192.0.2.10',
773
+ },
774
+ },
775
+ },
776
+ }
777
+ end
778
+
779
+ it 'falls back to the first network for the container IP' do
780
+ ENV['DOCKER_IN_DOCKER'] = 'true'
781
+ docker.provision
782
+
783
+ expect(hosts[0]['ip']).to eq '192.0.2.10'
784
+ expect(hosts[0]['port']).to eq 22
785
+ expect(hosts[0]['vm_ip']).to eq '192.0.2.10'
786
+ end
787
+
788
+ it 'still connects via the published port from the host' do
789
+ ENV['DOCKER_IN_DOCKER'] = nil
790
+ ENV['DOCKER_HOST'] = nil
791
+ docker.provision
792
+
793
+ expect(hosts[0]['ip']).to eq '127.0.0.1'
794
+ expect(hosts[0]['port']).to eq 8022
795
+ expect(hosts[0]['vm_ip']).to eq '192.0.2.10'
796
+ end
728
797
  end
729
798
  end
730
799
 
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: 3.1.1
4
+ version: 3.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Vox Pupuli
@@ -218,7 +218,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
218
218
  - !ruby/object:Gem::Version
219
219
  version: '0'
220
220
  requirements: []
221
- rubygems_version: 4.0.3
221
+ rubygems_version: 4.0.16
222
222
  specification_version: 4
223
223
  summary: Docker hypervisor for Beaker acceptance testing framework
224
224
  test_files: []