beaker-docker 3.0.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: 17c2d4bee3cddacd85d34a58f05cfe7bacd408798b33fda5ad2dae86f6dfd54b
4
- data.tar.gz: 7cace9fa1d40da17c5688d7c1e65e14ddbc4e6258af775443ce119eeccf06e80
3
+ metadata.gz: 9671831d726e2c11bc67a47389a773e4d790228efc42ea0c701ecf63c98c5f1c
4
+ data.tar.gz: cfe816617cf164e57f54de609361d807a24ffea356e80bd6cdea34fff84a5f6b
5
5
  SHA512:
6
- metadata.gz: 153752e625e0b4326187f090d232ec7463ef433d464049817d701d153d861673dda80f90a6005bf07937fc0487e80b1fd18c252cc30a59386f82e40c0d43ae70
7
- data.tar.gz: 6f027a769a4001fb1c1ec408e3931a3638765d47821077b8673844ceaeb0f4c96191174964be663e7494a431e3d69928b30a7debf1ccf106a78d32173140fa7a
6
+ metadata.gz: 1b5f040eaacb8872a172c507c79a3ecaa8d5fdc7ad9e179e9f3939fc3959e03e147e9d4515a9afa58a105be268a2db2c038c4711fc466208c99d1a7268145ddc
7
+ data.tar.gz: 7da95bd35c838a090de937e02cb04601e4dadb8f7523d2791cc1207651fa306bcc4234f08cacb941da51d89becf7a46816c7d8f72e1454ccc2a3d399e33873ad
@@ -15,7 +15,7 @@ jobs:
15
15
  name: Build the gem
16
16
  runs-on: ubuntu-24.04
17
17
  steps:
18
- - uses: actions/checkout@v4
18
+ - uses: actions/checkout@v5
19
19
  - name: Install Ruby
20
20
  uses: ruby/setup-ruby@v1
21
21
  with:
@@ -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:
@@ -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@v4
74
+ # - uses: actions/checkout@v5
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,7 +99,7 @@ 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@v4
102
+ - uses: actions/checkout@v5
103
103
  - name: Install Ruby ${{ matrix.ruby }}
104
104
  uses: ruby/setup-ruby@v1
105
105
  with:
data/.rubocop_todo.yml CHANGED
@@ -1,26 +1,22 @@
1
1
  # This configuration was generated by
2
2
  # `rubocop --auto-gen-config --no-auto-gen-timestamp`
3
- # using RuboCop version 1.75.8.
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,13 @@
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
+
3
11
  ## [3.0.0](https://github.com/voxpupuli/beaker-docker/tree/3.0.0) (2025-08-11)
4
12
 
5
13
  [Full Changelog](https://github.com/voxpupuli/beaker-docker/compare/2.6.0...3.0.0)
@@ -28,7 +28,7 @@ Gem::Specification.new do |s|
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', '~> 4.1.0'
31
+ s.add_development_dependency 'voxpupuli-rubocop', '~> 4.2.0'
32
32
 
33
33
  # Run time dependencies
34
34
  s.add_dependency 'beaker', '>= 4', '< 8'
@@ -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 = '3.0.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
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.0.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: 4.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: 4.1.0
76
+ version: 4.2.0
77
77
  - !ruby/object:Gem::Dependency
78
78
  name: beaker
79
79
  requirement: !ruby/object:Gem::Requirement