beaker-docker 2.6.0 → 3.0.1

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: 9461ac90b3758ec88518396e0de669dab94f8e208565e8bd0489037aeb17bd96
4
- data.tar.gz: a14e3cdbed23ffa9e9b189ec3338572c6f8ea16ce63f8e1e513d94638b337ba7
3
+ metadata.gz: 9671831d726e2c11bc67a47389a773e4d790228efc42ea0c701ecf63c98c5f1c
4
+ data.tar.gz: cfe816617cf164e57f54de609361d807a24ffea356e80bd6cdea34fff84a5f6b
5
5
  SHA512:
6
- metadata.gz: 107f131290bdf17ba2a768315a93bc7ba76bfa548a493ca557136c79ab3ea8fc35ef8071b24da72540b54d2c2e5cfcc7418a019f0e6f9aa94435ce79b2c4aafa
7
- data.tar.gz: 6aad94b620154a24ad669b49af1df9ecce4e22a0e833d6aa35e21d15c953eaa16dd5b807815bd8d1c054a4b758cfb04108226ca3505f2ae6a5df4234def243cf
6
+ metadata.gz: 1b5f040eaacb8872a172c507c79a3ecaa8d5fdc7ad9e179e9f3939fc3959e03e147e9d4515a9afa58a105be268a2db2c038c4711fc466208c99d1a7268145ddc
7
+ data.tar.gz: 7da95bd35c838a090de937e02cb04601e4dadb8f7523d2791cc1207651fa306bcc4234f08cacb941da51d89becf7a46816c7d8f72e1454ccc2a3d399e33873ad
@@ -0,0 +1,41 @@
1
+ ---
2
+ # https://docs.github.com/en/repositories/releasing-projects-on-github/automatically-generated-release-notes
3
+
4
+ changelog:
5
+ exclude:
6
+ labels:
7
+ - duplicate
8
+ - invalid
9
+ - modulesync
10
+ - question
11
+ - skip-changelog
12
+ - wont-fix
13
+ - wontfix
14
+ - github_actions
15
+
16
+ categories:
17
+ - title: Breaking Changes 🛠
18
+ labels:
19
+ - backwards-incompatible
20
+
21
+ - title: New Features 🎉
22
+ labels:
23
+ - enhancement
24
+
25
+ - title: Bug Fixes 🐛
26
+ labels:
27
+ - bug
28
+ - bugfix
29
+
30
+ - title: Documentation Updates 📚
31
+ labels:
32
+ - documentation
33
+ - docs
34
+
35
+ - title: Dependency Updates ⬆️
36
+ labels:
37
+ - dependencies
38
+
39
+ - title: Other Changes
40
+ labels:
41
+ - "*"
@@ -1,33 +1,106 @@
1
1
  ---
2
- name: Release
2
+ name: Gem Release
3
3
 
4
4
  on:
5
5
  push:
6
6
  tags:
7
7
  - '*'
8
8
 
9
+ permissions: {}
10
+
9
11
  jobs:
10
- release:
11
- runs-on: ubuntu-24.04
12
+ build-release:
13
+ # Prevent releases from forked repositories
12
14
  if: github.repository_owner == 'voxpupuli'
15
+ name: Build the gem
16
+ runs-on: ubuntu-24.04
13
17
  steps:
14
- - uses: actions/checkout@v4
15
- - name: Install Ruby 3.4
18
+ - uses: actions/checkout@v5
19
+ - name: Install Ruby
16
20
  uses: ruby/setup-ruby@v1
17
21
  with:
18
- ruby-version: '3.4'
19
- env:
20
- BUNDLE_WITHOUT: release
22
+ ruby-version: 'ruby'
21
23
  - name: Build gem
22
- run: gem build --strict --verbose *.gemspec
24
+ shell: bash
25
+ run: gem build --verbose *.gemspec
26
+ - name: Upload gem to GitHub cache
27
+ uses: actions/upload-artifact@v4
28
+ with:
29
+ name: gem-artifact
30
+ path: '*.gem'
31
+ retention-days: 1
32
+ compression-level: 0
33
+
34
+ create-github-release:
35
+ needs: build-release
36
+ name: Create GitHub release
37
+ runs-on: ubuntu-24.04
38
+ permissions:
39
+ contents: write # clone repo and create release
40
+ steps:
41
+ - name: Download gem from GitHub cache
42
+ uses: actions/download-artifact@v5
43
+ with:
44
+ name: gem-artifact
45
+ - name: Create Release
46
+ shell: bash
47
+ env:
48
+ GH_TOKEN: ${{ github.token }}
49
+ run: gh release create --repo ${{ github.repository }} ${{ github.ref_name }} --generate-notes *.gem
50
+
51
+ release-to-github:
52
+ needs: build-release
53
+ name: Release to GitHub
54
+ runs-on: ubuntu-24.04
55
+ permissions:
56
+ packages: write # publish to rubygems.pkg.github.com
57
+ steps:
58
+ - name: Download gem from GitHub cache
59
+ uses: actions/download-artifact@v5
60
+ with:
61
+ name: gem-artifact
62
+ - name: Publish gem to GitHub packages
63
+ run: gem push --host https://rubygems.pkg.github.com/${{ github.repository_owner }} *.gem
64
+ env:
65
+ GEM_HOST_API_KEY: ${{ secrets.GITHUB_TOKEN }}
66
+
67
+ release-to-rubygems:
68
+ needs: build-release
69
+ name: Release gem to rubygems.org
70
+ runs-on: ubuntu-24.04
71
+ environment: release # recommended by rubygems.org
72
+ permissions:
73
+ id-token: write # rubygems.org authentication
74
+ steps:
75
+ - name: Download gem from GitHub cache
76
+ uses: actions/download-artifact@v5
77
+ with:
78
+ name: gem-artifact
79
+ - uses: rubygems/configure-rubygems-credentials@v1.0.0
23
80
  - name: Publish gem to rubygems.org
81
+ shell: bash
24
82
  run: gem push *.gem
25
- env:
26
- GEM_HOST_API_KEY: '${{ secrets.RUBYGEMS_AUTH_TOKEN }}'
27
- - name: Setup GitHub packages access
83
+
84
+ release-verification:
85
+ name: Check that all releases are done
86
+ runs-on: ubuntu-24.04
87
+ permissions:
88
+ contents: read # minimal permissions that we have to grant
89
+ needs:
90
+ - create-github-release
91
+ - release-to-github
92
+ - release-to-rubygems
93
+ steps:
94
+ - name: Download gem from GitHub cache
95
+ uses: actions/download-artifact@v5
96
+ with:
97
+ name: gem-artifact
98
+ - name: Install Ruby
99
+ uses: ruby/setup-ruby@v1
100
+ with:
101
+ ruby-version: 'ruby'
102
+ - name: Wait for release to propagate
103
+ shell: bash
28
104
  run: |
29
- mkdir -p ~/.gem
30
- echo ":github: Bearer ${{ secrets.GITHUB_TOKEN }}" >> ~/.gem/credentials
31
- chmod 0600 ~/.gem/credentials
32
- - name: Publish gem to GitHub packages
33
- run: gem push --key github --host https://rubygems.pkg.github.com/voxpupuli *.gem
105
+ gem install rubygems-await
106
+ gem await *.gem
@@ -7,8 +7,8 @@ on:
7
7
  branches:
8
8
  - master
9
9
 
10
- env:
11
- BUNDLE_WITHOUT: release
10
+ permissions:
11
+ contents: read
12
12
 
13
13
  jobs:
14
14
  rubocop_and_matrix:
@@ -16,7 +16,7 @@ jobs:
16
16
  outputs:
17
17
  ruby: ${{ steps.ruby.outputs.versions }}
18
18
  steps:
19
- - uses: actions/checkout@v4
19
+ - uses: actions/checkout@v5
20
20
  - name: Install Ruby 3.4
21
21
  uses: ruby/setup-ruby@v1
22
22
  with:
@@ -36,7 +36,7 @@ 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@v4
39
+ - uses: actions/checkout@v5
40
40
  - name: Install Ruby ${{ matrix.ruby }}
41
41
  uses: ruby/setup-ruby@v1
42
42
  with:
@@ -56,7 +56,7 @@ 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@v4
59
+ - uses: actions/checkout@v5
60
60
  - name: Install Ruby ${{ matrix.ruby }}
61
61
  uses: ruby/setup-ruby@v1
62
62
  with:
@@ -65,24 +65,25 @@ jobs:
65
65
  - name: Run acceptance tests
66
66
  run: bundle exec rake test:acceptance
67
67
 
68
- beaker_in_container:
69
- runs-on: ubuntu-24.04
70
- needs: rubocop_and_matrix
71
- name: Docker - Beaker in container connection test
72
- steps:
73
- - uses: actions/checkout@v4
74
- # use this and not container key from gha to not have a docker network from github
75
- - name: Run Beaker in docker container
76
- uses: addnab/docker-run-action@v3
77
- with:
78
- image: puppet/puppet-dev-tools:2023-02-24-1bca42e
79
- options: -v ${{ github.workspace }}:/work
80
- run: |
81
- cd /work
82
- ls -la
83
- bundle install
84
- export DOCKER_IN_DOCKER=true
85
- bundle exec rake test:acceptance
68
+ # this job is currently broken because puppet/puppet-dev-tools:2023-02-24-1bca42e is too old
69
+ #beaker_in_container:
70
+ # runs-on: ubuntu-24.04
71
+ # needs: rubocop_and_matrix
72
+ # name: Docker - Beaker in container connection test
73
+ # steps:
74
+ # - uses: actions/checkout@v5
75
+ # # use this and not container key from gha to not have a docker network from github
76
+ # - name: Run Beaker in docker container
77
+ # uses: addnab/docker-run-action@v3
78
+ # with:
79
+ # image: puppet/puppet-dev-tools:2023-02-24-1bca42e
80
+ # options: -v ${{ github.workspace }}:/work
81
+ # run: |
82
+ # cd /work
83
+ # ls -la
84
+ # bundle install
85
+ # export DOCKER_IN_DOCKER=true
86
+ # bundle exec rake test:acceptance
86
87
 
87
88
  # verifies that podman service is a dropin replacement for docker
88
89
  podman:
@@ -98,7 +99,7 @@ jobs:
98
99
  run: |
99
100
  sudo systemctl stop docker.service docker.socket && systemctl start --user podman.socket
100
101
  echo "DOCKER_HOST=unix:///run/user/$(id -u)/podman/podman.sock" >> "$GITHUB_ENV"
101
- - uses: actions/checkout@v4
102
+ - uses: actions/checkout@v5
102
103
  - name: Install Ruby ${{ matrix.ruby }}
103
104
  uses: ruby/setup-ruby@v1
104
105
  with:
@@ -111,7 +112,7 @@ jobs:
111
112
  needs:
112
113
  - rubocop_and_matrix
113
114
  - docker
114
- - beaker_in_container
115
+ # - beaker_in_container
115
116
  - podman
116
117
  - rspec
117
118
  runs-on: ubuntu-24.04
data/.rubocop.yml CHANGED
@@ -8,3 +8,6 @@ Naming/FileName:
8
8
  Description: Some files violates the snake_case convention
9
9
  Exclude:
10
10
  - 'lib/beaker-docker.rb'
11
+
12
+ AllCops:
13
+ TargetRubyVersion: 3.2
data/.rubocop_todo.yml CHANGED
@@ -1,26 +1,22 @@
1
1
  # This configuration was generated by
2
- # `rubocop --auto-gen-config`
3
- # on 2025-05-27 19:37:43 UTC using RuboCop version 1.75.7.
2
+ # `rubocop --auto-gen-config --no-auto-gen-timestamp`
3
+ # using RuboCop version 1.79.2.
4
4
  # The point is for the user to remove these configuration records
5
5
  # one by one as the offenses are removed from the code base.
6
6
  # Note that changes in the inspected code, or installation of new
7
7
  # versions of RuboCop, may require this file to be generated again.
8
8
 
9
- # Offense count: 23
9
+ # Offense count: 39
10
10
  # Configuration parameters: CountAsOne.
11
11
  RSpec/ExampleLength:
12
- Max: 53
12
+ Max: 36
13
13
 
14
- # Offense count: 44
14
+ # Offense count: 60
15
15
  # Configuration parameters: .
16
16
  # SupportedStyles: have_received, receive
17
17
  RSpec/MessageSpies:
18
18
  EnforcedStyle: receive
19
19
 
20
- # Offense count: 14
21
- RSpec/MultipleExpectations:
22
- Max: 5
23
-
24
20
  # Offense count: 17
25
21
  # Configuration parameters: AllowSubject.
26
22
  RSpec/MultipleMemoizedHelpers:
@@ -32,9 +28,9 @@ RSpec/ReceiveMessages:
32
28
  Exclude:
33
29
  - 'spec/beaker/hypervisor/docker_spec.rb'
34
30
 
35
- # Offense count: 28
31
+ # Offense count: 19
36
32
  # This cop supports safe autocorrection (--autocorrect).
37
- # Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, AllowedPatterns, SplitStrings.
33
+ # Configuration parameters: AllowHeredoc, AllowURI, AllowQualifiedName, URISchemes, IgnoreCopDirectives, AllowedPatterns, SplitStrings.
38
34
  # URISchemes: http, https
39
35
  Layout/LineLength:
40
36
  Max: 198
data/CHANGELOG.md CHANGED
@@ -1,5 +1,25 @@
1
1
  # Changelog
2
2
 
3
+ ## [3.0.1](https://github.com/voxpupuli/beaker-docker/tree/3.0.1) (2025-09-30)
4
+
5
+ [Full Changelog](https://github.com/voxpupuli/beaker-docker/compare/3.0.0...3.0.1)
6
+
7
+ **Fixed bugs:**
8
+
9
+ - fix: deep merge dockeropts [\#167](https://github.com/voxpupuli/beaker-docker/pull/167) ([mpldr](https://github.com/mpldr))
10
+
11
+ ## [3.0.0](https://github.com/voxpupuli/beaker-docker/tree/3.0.0) (2025-08-11)
12
+
13
+ [Full Changelog](https://github.com/voxpupuli/beaker-docker/compare/2.6.0...3.0.0)
14
+
15
+ **Breaking changes:**
16
+
17
+ - Require Ruby 3.2 or newer [\#163](https://github.com/voxpupuli/beaker-docker/pull/163) ([bastelfreak](https://github.com/bastelfreak))
18
+
19
+ **Implemented enhancements:**
20
+
21
+ - beaker: Allow 7.x [\#162](https://github.com/voxpupuli/beaker-docker/pull/162) ([bastelfreak](https://github.com/bastelfreak))
22
+
3
23
  ## [2.6.0](https://github.com/voxpupuli/beaker-docker/tree/2.6.0) (2025-05-28)
4
24
 
5
25
  [Full Changelog](https://github.com/voxpupuli/beaker-docker/compare/2.5.2...2.6.0)
data/Gemfile CHANGED
@@ -4,7 +4,7 @@ source ENV['GEM_SOURCE'] || 'https://rubygems.org'
4
4
 
5
5
  gemspec
6
6
 
7
- group :release do
8
- gem 'faraday-retry', require: false
9
- gem 'github_changelog_generator', require: false
7
+ group :release, optional: true do
8
+ gem 'faraday-retry', '~> 2.1', require: false
9
+ gem 'github_changelog_generator', '~> 1.16.4', require: false
10
10
  end
@@ -22,16 +22,16 @@ Gem::Specification.new do |s|
22
22
  s.executables = `git ls-files -- bin/*`.split("\n").map { |f| File.basename(f) }
23
23
  s.require_paths = ['lib']
24
24
 
25
- s.required_ruby_version = '>= 2.7', '< 4'
25
+ s.required_ruby_version = '>= 3.2', '< 4'
26
26
 
27
27
  # Testing dependencies
28
28
  s.add_development_dependency 'fakefs', '>= 1.3', '< 4'
29
29
  s.add_development_dependency 'rake', '~> 13.0'
30
30
  s.add_development_dependency 'rspec', '~> 3.0'
31
- s.add_development_dependency 'voxpupuli-rubocop', '~> 3.1.0'
31
+ s.add_development_dependency 'voxpupuli-rubocop', '~> 4.2.0'
32
32
 
33
33
  # Run time dependencies
34
- s.add_dependency 'beaker', '>= 4', '< 7'
34
+ s.add_dependency 'beaker', '>= 4', '< 8'
35
35
  s.add_dependency 'docker-api', '~> 2.3'
36
36
  # excon is a docker-api dependency, 1.2.6 is broken
37
37
  # https://github.com/excon/excon/issues/884
@@ -70,7 +70,7 @@ module Beaker
70
70
  end
71
71
 
72
72
  def get_container_opts(host, image_name)
73
- container_opts = {}
73
+ container_opts = StringifyHash.new
74
74
  container_opts['ExposedPorts'] = { '22/tcp' => {} } if host['dockerfile']
75
75
 
76
76
  container_opts.merge!({
@@ -225,12 +225,8 @@ module Beaker
225
225
  ### BEGIN CONTAINER OPTIONS MANGLING ###
226
226
 
227
227
  container_opts = get_container_opts(host, image_name)
228
- if host['dockeropts'] || @options[:dockeropts]
229
- dockeropts = host['dockeropts'] || @options[:dockeropts]
230
- dockeropts.each do |k, v|
231
- container_opts[k] = v
232
- end
233
- end
228
+ container_opts.merge!(@options[:dockeropts]) if @options[:dockeropts]
229
+ container_opts.merge!(host['dockeropts']) if host['dockeropts']
234
230
 
235
231
  container = find_container(host)
236
232
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module BeakerDocker
4
- VERSION = '2.6.0'
4
+ VERSION = '3.0.1'
5
5
  end
@@ -19,7 +19,7 @@ module Beaker
19
19
  let(:hosts) do
20
20
  the_hosts = make_hosts
21
21
  the_hosts[2]['dockeropts'] = {
22
- 'Labels' => {
22
+ Labels: {
23
23
  'one' => 3,
24
24
  'two' => 4,
25
25
  },
@@ -43,7 +43,7 @@ module Beaker
43
43
  forward_ssh_agent: true,
44
44
  provision: true,
45
45
  dockeropts: {
46
- 'Labels' => {
46
+ Labels: {
47
47
  'one' => 1,
48
48
  'two' => 2,
49
49
  },
@@ -298,64 +298,103 @@ module Beaker
298
298
  docker.provision
299
299
  end
300
300
 
301
- it 'creates a container based on the Image (identified by image.id)' do
301
+ it 'creates a container with correct image and hostname' do
302
+ hosts.each_with_index do |host, _index|
303
+ expect(::Docker::Container).to receive(:create) do |args|
304
+ expect(args[:Image]).to eq(image.id)
305
+ expect(args[:Hostname]).to eq(host.name)
306
+ end.and_return(container)
307
+ end
308
+
309
+ docker.provision
310
+ end
311
+
312
+ it 'creates a container with correct host config settings' do
313
+ hosts.each_with_index do |_host, _index|
314
+ expect(::Docker::Container).to receive(:create) do |args|
315
+ expect(args[:HostConfig][:PublishAllPorts]).to be true
316
+ expect(args[:HostConfig][:Privileged]).to be true
317
+ expect(args[:HostConfig][:RestartPolicy][:Name]).to eq('always')
318
+ end.and_return(container)
319
+ end
320
+
321
+ docker.provision
322
+ end
323
+
324
+ it 'creates a container with correct port bindings' do
325
+ hosts.each_with_index do |_host, _index|
326
+ expect(::Docker::Container).to receive(:create) do |args|
327
+ expect(args[:HostConfig][:PortBindings]['22/tcp'][0]['HostPort']).to be_a(String)
328
+ expect(args[:HostConfig][:PortBindings]['22/tcp'][0]['HostIp']).to eq('0.0.0.0')
329
+ end.and_return(container)
330
+ end
331
+
332
+ docker.provision
333
+ end
334
+
335
+ it 'creates a container with correct labels and name' do
336
+ hosts.each_with_index do |_host, index|
337
+ expect(::Docker::Container).to receive(:create) do |args|
338
+ expect(args[:Labels][:one]).to eq(((index == 2) ? 3 : 1))
339
+ expect(args[:Labels][:two]).to eq(((index == 2) ? 4 : 2))
340
+ expect(args[:name]).to match(/\Abeaker-/)
341
+ end.and_return(container)
342
+ end
343
+
344
+ docker.provision
345
+ end
346
+
347
+ it 'creates a named container with correct basic properties' do
302
348
  hosts.each_with_index do |host, index|
303
- expect(::Docker::Container).to receive(:create).with({
304
- 'Image' => image.id,
305
- 'Hostname' => host.name,
306
- 'HostConfig' => {
307
- 'PortBindings' => {
308
- '22/tcp' => [{ 'HostPort' => /\b\d{4}\b/, 'HostIp' => '0.0.0.0' }],
309
- },
310
- 'PublishAllPorts' => true,
311
- 'Privileged' => true,
312
- 'RestartPolicy' => {
313
- 'Name' => 'always',
314
- },
315
- },
316
- 'Labels' => {
317
- 'one' => ((index == 2) ? 3 : 1),
318
- 'two' => ((index == 2) ? 4 : 2),
319
- },
320
- 'name' => /\Abeaker-/,
321
- })
349
+ container_name = "spec-container-#{index}"
350
+ host['docker_container_name'] = container_name
351
+
352
+ allow(::Docker::Container).to receive(:all).and_return([])
353
+ expect(::Docker::Container).to receive(:create) do |args|
354
+ expect(args[:Image]).to eq(image.id)
355
+ expect(args[:Hostname]).to eq(host.name)
356
+ expect(args[:name]).to eq(container_name)
357
+ end.and_return(container)
322
358
  end
323
359
 
324
360
  docker.provision
325
361
  end
326
362
 
327
- it 'creates a named container based on the Image (identified by image.id)' do
363
+ it 'creates a named container with correct host config' do
328
364
  hosts.each_with_index do |host, index|
329
365
  container_name = "spec-container-#{index}"
330
366
  host['docker_container_name'] = container_name
331
367
 
332
368
  allow(::Docker::Container).to receive(:all).and_return([])
333
- expect(::Docker::Container).to receive(:create).with({
334
- 'Image' => image.id,
335
- 'Hostname' => host.name,
336
- 'name' => container_name,
337
- 'HostConfig' => {
338
- 'PortBindings' => {
339
- '22/tcp' => [{ 'HostPort' => /\b\d{4}\b/, 'HostIp' => '0.0.0.0' }],
340
- },
341
- 'PublishAllPorts' => true,
342
- 'Privileged' => true,
343
- 'RestartPolicy' => {
344
- 'Name' => 'always',
345
- },
346
- },
347
- 'Labels' => {
348
- 'one' => ((index == 2) ? 3 : 1),
349
- 'two' => ((index == 2) ? 4 : 2),
350
- },
351
- })
369
+ expect(::Docker::Container).to receive(:create) do |args|
370
+ expect(args[:HostConfig][:PublishAllPorts]).to be true
371
+ expect(args[:HostConfig][:Privileged]).to be true
372
+ expect(args[:HostConfig][:RestartPolicy][:Name]).to eq('always')
373
+ end.and_return(container)
352
374
  end
353
375
 
354
376
  docker.provision
355
377
  end
356
378
 
357
- it 'creates a container with volumes bound' do
379
+ it 'creates a named container with correct port bindings and labels' do
358
380
  hosts.each_with_index do |host, index|
381
+ container_name = "spec-container-#{index}"
382
+ host['docker_container_name'] = container_name
383
+
384
+ allow(::Docker::Container).to receive(:all).and_return([])
385
+ expect(::Docker::Container).to receive(:create) do |args|
386
+ expect(args[:HostConfig][:PortBindings]['22/tcp'][0]['HostPort']).to be_a(String)
387
+ expect(args[:HostConfig][:PortBindings]['22/tcp'][0]['HostIp']).to eq('0.0.0.0')
388
+ expect(args[:Labels][:one]).to eq(((index == 2) ? 3 : 1))
389
+ expect(args[:Labels][:two]).to eq(((index == 2) ? 4 : 2))
390
+ end.and_return(container)
391
+ end
392
+
393
+ docker.provision
394
+ end
395
+
396
+ it 'creates a container with volumes bound' do
397
+ hosts.each_with_index do |host, _index|
359
398
  host['mount_folders'] = {
360
399
  'mount1' => {
361
400
  'host_path' => '/source_folder',
@@ -381,94 +420,220 @@ module Beaker
381
420
  },
382
421
  }
383
422
 
384
- expect(::Docker::Container).to receive(:create).with({
385
- 'Image' => image.id,
386
- 'Hostname' => host.name,
387
- 'HostConfig' => {
388
- 'Binds' => [
389
- '/source_folder:/mount_point:z',
390
- '/another_folder:/another_mount:ro',
391
- '/different_folder:/different_mount:rw',
392
- "#{File.expand_path('./')}:/relative_mount:z",
393
- "#{File.expand_path('local_folder')}:/another_relative_mount:z",
394
- ],
395
- 'PortBindings' => {
396
- '22/tcp' => [{ 'HostPort' => /\b\d{4}\b/, 'HostIp' => '0.0.0.0' }],
397
- },
398
- 'PublishAllPorts' => true,
399
- 'Privileged' => true,
400
- 'RestartPolicy' => {
401
- 'Name' => 'always',
402
- },
403
- },
404
- 'Labels' => {
405
- 'one' => ((index == 2) ? 3 : 1),
406
- 'two' => ((index == 2) ? 4 : 2),
407
- },
408
- 'name' => /\Abeaker-/,
409
- })
423
+ expect(::Docker::Container).to receive(:create) do |args|
424
+ expect(args[:HostConfig][:Binds]).to eq([
425
+ '/source_folder:/mount_point:z',
426
+ '/another_folder:/another_mount:ro',
427
+ '/different_folder:/different_mount:rw',
428
+ "#{File.expand_path('./')}:/relative_mount:z",
429
+ "#{File.expand_path('local_folder')}:/another_relative_mount:z",
430
+ ])
431
+ end.and_return(container)
432
+ end
433
+
434
+ docker.provision
435
+ end
436
+
437
+ it 'creates a volume container with correct image and hostname' do
438
+ hosts.each_with_index do |host, _index|
439
+ host['mount_folders'] = {
440
+ 'mount1' => {
441
+ 'host_path' => '/source_folder',
442
+ 'container_path' => '/mount_point',
443
+ },
444
+ }
445
+
446
+ expect(::Docker::Container).to receive(:create) do |args|
447
+ expect(args[:Image]).to eq(image.id)
448
+ expect(args[:Hostname]).to eq(host.name)
449
+ end.and_return(container)
450
+ end
451
+
452
+ docker.provision
453
+ end
454
+
455
+ it 'creates a volume container with correct labels and name' do
456
+ hosts.each_with_index do |host, index|
457
+ host['mount_folders'] = {
458
+ 'mount1' => {
459
+ 'host_path' => '/source_folder',
460
+ 'container_path' => '/mount_point',
461
+ },
462
+ }
463
+
464
+ expect(::Docker::Container).to receive(:create) do |args|
465
+ expect(args[:Labels][:one]).to eq(((index == 2) ? 3 : 1))
466
+ expect(args[:Labels][:two]).to eq(((index == 2) ? 4 : 2))
467
+ expect(args[:name]).to match(/\Abeaker-/)
468
+ end.and_return(container)
469
+ end
470
+
471
+ docker.provision
472
+ end
473
+
474
+ it 'creates a volume container with correct port bindings' do
475
+ hosts.each_with_index do |host, _index|
476
+ host['mount_folders'] = {
477
+ 'mount1' => {
478
+ 'host_path' => '/source_folder',
479
+ 'container_path' => '/mount_point',
480
+ },
481
+ }
482
+
483
+ expect(::Docker::Container).to receive(:create) do |args|
484
+ expect(args[:HostConfig][:PortBindings]['22/tcp'][0]['HostPort']).to be_a(String)
485
+ expect(args[:HostConfig][:PortBindings]['22/tcp'][0]['HostIp']).to eq('0.0.0.0')
486
+ end.and_return(container)
487
+ end
488
+
489
+ docker.provision
490
+ end
491
+
492
+ it 'creates a volume container with correct container settings' do
493
+ hosts.each_with_index do |host, _index|
494
+ host['mount_folders'] = {
495
+ 'mount1' => {
496
+ 'host_path' => '/source_folder',
497
+ 'container_path' => '/mount_point',
498
+ },
499
+ }
500
+
501
+ expect(::Docker::Container).to receive(:create) do |args|
502
+ expect(args[:HostConfig][:PublishAllPorts]).to be true
503
+ expect(args[:HostConfig][:Privileged]).to be true
504
+ expect(args[:HostConfig][:RestartPolicy][:Name]).to eq('always')
505
+ end.and_return(container)
410
506
  end
411
507
 
412
508
  docker.provision
413
509
  end
414
510
 
415
511
  it 'creates a container with capabilities added' do
512
+ hosts.each_with_index do |host, _index|
513
+ host['docker_cap_add'] = %w[NET_ADMIN SYS_ADMIN]
514
+
515
+ expect(::Docker::Container).to receive(:create) do |args|
516
+ expect(args[:HostConfig][:CapAdd]).to eq(%w[NET_ADMIN SYS_ADMIN])
517
+ end.and_return(container)
518
+ end
519
+
520
+ docker.provision
521
+ end
522
+
523
+ it 'creates a cap container with correct image and hostname' do
524
+ hosts.each_with_index do |host, _index|
525
+ host['docker_cap_add'] = %w[NET_ADMIN SYS_ADMIN]
526
+
527
+ expect(::Docker::Container).to receive(:create) do |args|
528
+ expect(args[:Image]).to eq(image.id)
529
+ expect(args[:Hostname]).to eq(host.name)
530
+ end.and_return(container)
531
+ end
532
+
533
+ docker.provision
534
+ end
535
+
536
+ it 'creates a cap container with correct labels and name' do
416
537
  hosts.each_with_index do |host, index|
417
538
  host['docker_cap_add'] = %w[NET_ADMIN SYS_ADMIN]
418
539
 
419
- expect(::Docker::Container).to receive(:create).with({
420
- 'Image' => image.id,
421
- 'Hostname' => host.name,
422
- 'HostConfig' => {
423
- 'PortBindings' => {
424
- '22/tcp' => [{ 'HostPort' => /\b\d{4}\b/, 'HostIp' => '0.0.0.0' }],
425
- },
426
- 'PublishAllPorts' => true,
427
- 'RestartPolicy' => {
428
- 'Name' => 'always',
429
- },
430
- 'CapAdd' => %w[NET_ADMIN SYS_ADMIN],
431
- },
432
- 'Labels' => {
433
- 'one' => ((index == 2) ? 3 : 1),
434
- 'two' => ((index == 2) ? 4 : 2),
435
- },
436
- 'name' => /\Abeaker-/,
437
- })
540
+ expect(::Docker::Container).to receive(:create) do |args|
541
+ expect(args[:Labels][:one]).to eq(((index == 2) ? 3 : 1))
542
+ expect(args[:Labels][:two]).to eq(((index == 2) ? 4 : 2))
543
+ expect(args[:name]).to match(/\Abeaker-/)
544
+ end.and_return(container)
545
+ end
546
+
547
+ docker.provision
548
+ end
549
+
550
+ it 'creates a cap container with correct host config' do
551
+ hosts.each_with_index do |host, _index|
552
+ host['docker_cap_add'] = %w[NET_ADMIN SYS_ADMIN]
553
+
554
+ expect(::Docker::Container).to receive(:create) do |args|
555
+ expect(args[:HostConfig][:PortBindings]['22/tcp'][0]['HostPort']).to be_a(String)
556
+ expect(args[:HostConfig][:PortBindings]['22/tcp'][0]['HostIp']).to eq('0.0.0.0')
557
+ expect(args[:HostConfig][:PublishAllPorts]).to be true
558
+ expect(args[:HostConfig][:RestartPolicy][:Name]).to eq('always')
559
+ end.and_return(container)
438
560
  end
439
561
 
440
562
  docker.provision
441
563
  end
442
564
 
443
565
  it 'creates a container with port bindings' do
566
+ hosts.each_with_index do |host, _index|
567
+ host['docker_port_bindings'] = {
568
+ '8080/tcp' => [{ 'HostPort' => '8080', 'HostIp' => '0.0.0.0' }],
569
+ }
570
+
571
+ expect(::Docker::Container).to receive(:create) do |args|
572
+ expect(args[:ExposedPorts]).to eq({ '8080/tcp' => {} })
573
+ expect(args[:HostConfig][:PortBindings]['8080/tcp']).to eq([{ 'HostPort' => '8080', 'HostIp' => '0.0.0.0' }])
574
+ end.and_return(container)
575
+ end
576
+
577
+ docker.provision
578
+ end
579
+
580
+ it 'creates a port binding container with correct image and hostname' do
581
+ hosts.each_with_index do |host, _index|
582
+ host['docker_port_bindings'] = {
583
+ '8080/tcp' => [{ 'HostPort' => '8080', 'HostIp' => '0.0.0.0' }],
584
+ }
585
+
586
+ expect(::Docker::Container).to receive(:create) do |args|
587
+ expect(args[:Image]).to eq(image.id)
588
+ expect(args[:Hostname]).to eq(host.name)
589
+ end.and_return(container)
590
+ end
591
+
592
+ docker.provision
593
+ end
594
+
595
+ it 'creates a port binding container with correct labels and name' do
444
596
  hosts.each_with_index do |host, index|
445
597
  host['docker_port_bindings'] = {
446
598
  '8080/tcp' => [{ 'HostPort' => '8080', 'HostIp' => '0.0.0.0' }],
447
599
  }
448
600
 
449
- expect(::Docker::Container).to receive(:create).with({
450
- 'ExposedPorts' => {
451
- '8080/tcp' => {},
452
- },
453
- 'Image' => image.id,
454
- 'Hostname' => host.name,
455
- 'HostConfig' => {
456
- 'PortBindings' => {
457
- '22/tcp' => [{ 'HostPort' => /\b\d{4}\b/, 'HostIp' => '0.0.0.0' }],
458
- '8080/tcp' => [{ 'HostPort' => '8080', 'HostIp' => '0.0.0.0' }],
459
- },
460
- 'PublishAllPorts' => true,
461
- 'Privileged' => true,
462
- 'RestartPolicy' => {
463
- 'Name' => 'always',
464
- },
465
- },
466
- 'Labels' => {
467
- 'one' => ((index == 2) ? 3 : 1),
468
- 'two' => ((index == 2) ? 4 : 2),
469
- },
470
- 'name' => /\Abeaker-/,
471
- })
601
+ expect(::Docker::Container).to receive(:create) do |args|
602
+ expect(args[:Labels][:one]).to eq(((index == 2) ? 3 : 1))
603
+ expect(args[:Labels][:two]).to eq(((index == 2) ? 4 : 2))
604
+ expect(args[:name]).to match(/\Abeaker-/)
605
+ end.and_return(container)
606
+ end
607
+
608
+ docker.provision
609
+ end
610
+
611
+ it 'creates a port binding container with correct port bindings' do
612
+ hosts.each_with_index do |host, _index|
613
+ host['docker_port_bindings'] = {
614
+ '8080/tcp' => [{ 'HostPort' => '8080', 'HostIp' => '0.0.0.0' }],
615
+ }
616
+
617
+ expect(::Docker::Container).to receive(:create) do |args|
618
+ expect(args[:HostConfig][:PortBindings]['22/tcp'][0]['HostPort']).to be_a(String)
619
+ expect(args[:HostConfig][:PortBindings]['22/tcp'][0]['HostIp']).to eq('0.0.0.0')
620
+ end.and_return(container)
621
+ end
622
+
623
+ docker.provision
624
+ end
625
+
626
+ it 'creates a port binding container with correct container settings' do
627
+ hosts.each_with_index do |host, _index|
628
+ host['docker_port_bindings'] = {
629
+ '8080/tcp' => [{ 'HostPort' => '8080', 'HostIp' => '0.0.0.0' }],
630
+ }
631
+
632
+ expect(::Docker::Container).to receive(:create) do |args|
633
+ expect(args[:HostConfig][:PublishAllPorts]).to be true
634
+ expect(args[:HostConfig][:Privileged]).to be true
635
+ expect(args[:HostConfig][:RestartPolicy][:Name]).to eq('always')
636
+ end.and_return(container)
472
637
  end
473
638
 
474
639
  docker.provision
data/spec/spec_helper.rb CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  require 'beaker'
4
4
 
5
- Dir['./lib/beaker/hypervisor/*.rb'].sort.each { |file| require file }
5
+ Dir['./lib/beaker/hypervisor/*.rb'].each { |file| require file }
6
6
 
7
7
  # setup & require beaker's spec_helper.rb
8
8
  beaker_gem_spec = Gem::Specification.find_by_name('beaker')
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: 2.6.0
4
+ version: 3.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Vox Pupuli
@@ -66,14 +66,14 @@ dependencies:
66
66
  requirements:
67
67
  - - "~>"
68
68
  - !ruby/object:Gem::Version
69
- version: 3.1.0
69
+ version: 4.2.0
70
70
  type: :development
71
71
  prerelease: false
72
72
  version_requirements: !ruby/object:Gem::Requirement
73
73
  requirements:
74
74
  - - "~>"
75
75
  - !ruby/object:Gem::Version
76
- version: 3.1.0
76
+ version: 4.2.0
77
77
  - !ruby/object:Gem::Dependency
78
78
  name: beaker
79
79
  requirement: !ruby/object:Gem::Requirement
@@ -83,7 +83,7 @@ dependencies:
83
83
  version: '4'
84
84
  - - "<"
85
85
  - !ruby/object:Gem::Version
86
- version: '7'
86
+ version: '8'
87
87
  type: :runtime
88
88
  prerelease: false
89
89
  version_requirements: !ruby/object:Gem::Requirement
@@ -93,7 +93,7 @@ dependencies:
93
93
  version: '4'
94
94
  - - "<"
95
95
  - !ruby/object:Gem::Version
96
- version: '7'
96
+ version: '8'
97
97
  - !ruby/object:Gem::Dependency
98
98
  name: docker-api
99
99
  requirement: !ruby/object:Gem::Requirement
@@ -158,6 +158,7 @@ extra_rdoc_files: []
158
158
  files:
159
159
  - ".editorconfig"
160
160
  - ".github/dependabot.yml"
161
+ - ".github/release.yml"
161
162
  - ".github/workflows/release.yml"
162
163
  - ".github/workflows/test.yml"
163
164
  - ".gitignore"
@@ -193,7 +194,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
193
194
  requirements:
194
195
  - - ">="
195
196
  - !ruby/object:Gem::Version
196
- version: '2.7'
197
+ version: '3.2'
197
198
  - - "<"
198
199
  - !ruby/object:Gem::Version
199
200
  version: '4'
@@ -203,7 +204,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
203
204
  - !ruby/object:Gem::Version
204
205
  version: '0'
205
206
  requirements: []
206
- rubygems_version: 3.6.7
207
+ rubygems_version: 3.6.9
207
208
  specification_version: 4
208
209
  summary: Docker hypervisor for Beaker acceptance testing framework
209
210
  test_files: []