beaker-docker 2.0.0 → 2.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/release.yml +2 -2
- data/.github/workflows/test.yml +6 -6
- data/.rubocop.yml +1 -1
- data/.rubocop_todo.yml +4 -9
- data/CHANGELOG.md +34 -1
- data/Gemfile +1 -0
- data/README.md +62 -0
- data/Rakefile +3 -10
- data/beaker-docker.gemspec +2 -5
- data/bin/beaker-docker +27 -1
- data/lib/beaker/hypervisor/docker.rb +4 -4
- data/lib/beaker-docker/version.rb +1 -1
- data/spec/beaker/hypervisor/docker_spec.rb +18 -33
- metadata +14 -50
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 841111065b59b77771dab0534b4f9e3f3963378c0a0daf27d86330ab0c733f7a
|
4
|
+
data.tar.gz: '025243139d8c52cad6a50cd5fa27e6cea07414cdb278aadb395072bd1897448d'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 98afc27265b51cd18868d25651e7003e50f9c26785af54ab277d0e9c673d256aad8a2f4b16905e096c1a2917766b247e44c11d75ae7a7f80e8bd6689174325b4
|
7
|
+
data.tar.gz: 3d84cef6317f571b79277c17cd3be523184a04fd81aa97bd7e4f3340417aabc19c2a07bbc339c13529e644efbf2b37f099ed1e41e6072d7f00b847e41b3fbb49
|
@@ -10,7 +10,7 @@ jobs:
|
|
10
10
|
runs-on: ubuntu-latest
|
11
11
|
if: github.repository_owner == 'voxpupuli'
|
12
12
|
steps:
|
13
|
-
- uses: actions/checkout@
|
13
|
+
- uses: actions/checkout@v4
|
14
14
|
- name: Install Ruby 3.0
|
15
15
|
uses: ruby/setup-ruby@v1
|
16
16
|
with:
|
@@ -18,7 +18,7 @@ jobs:
|
|
18
18
|
env:
|
19
19
|
BUNDLE_WITHOUT: release
|
20
20
|
- name: Build gem
|
21
|
-
run: gem build *.gemspec
|
21
|
+
run: gem build --strict --verbose *.gemspec
|
22
22
|
- name: Publish gem to rubygems.org
|
23
23
|
run: gem push *.gem
|
24
24
|
env:
|
data/.github/workflows/test.yml
CHANGED
@@ -13,7 +13,7 @@ jobs:
|
|
13
13
|
rubocop:
|
14
14
|
runs-on: ubuntu-latest
|
15
15
|
steps:
|
16
|
-
- uses: actions/checkout@
|
16
|
+
- uses: actions/checkout@v4
|
17
17
|
- name: Install Ruby 3.2
|
18
18
|
uses: ruby/setup-ruby@v1
|
19
19
|
with:
|
@@ -37,7 +37,7 @@ jobs:
|
|
37
37
|
COVERAGE: ${{ matrix.coverage }}
|
38
38
|
name: RSpec - Ruby ${{ matrix.ruby }}
|
39
39
|
steps:
|
40
|
-
- uses: actions/checkout@
|
40
|
+
- uses: actions/checkout@v4
|
41
41
|
- name: Install Ruby ${{ matrix.ruby }}
|
42
42
|
uses: ruby/setup-ruby@v1
|
43
43
|
with:
|
@@ -46,13 +46,13 @@ jobs:
|
|
46
46
|
- name: spec tests
|
47
47
|
run: bundle exec rake test:spec
|
48
48
|
- name: Build gem
|
49
|
-
run: gem build *.gemspec
|
49
|
+
run: gem build --strict --verbose *.gemspec
|
50
50
|
|
51
51
|
docker:
|
52
52
|
runs-on: ubuntu-latest
|
53
53
|
name: Docker
|
54
54
|
steps:
|
55
|
-
- uses: actions/checkout@
|
55
|
+
- uses: actions/checkout@v4
|
56
56
|
- name: Install Ruby 3.2
|
57
57
|
uses: ruby/setup-ruby@v1
|
58
58
|
with:
|
@@ -65,7 +65,7 @@ jobs:
|
|
65
65
|
runs-on: ubuntu-latest
|
66
66
|
name: Docker - Beaker in container connection test
|
67
67
|
steps:
|
68
|
-
- uses: actions/checkout@
|
68
|
+
- uses: actions/checkout@v4
|
69
69
|
# use this and not container key from gha to not have a docker network from github
|
70
70
|
- name: Run Beaker in docker container
|
71
71
|
uses: addnab/docker-run-action@v3
|
@@ -83,7 +83,7 @@ jobs:
|
|
83
83
|
runs-on: ubuntu-latest
|
84
84
|
name: Podman
|
85
85
|
steps:
|
86
|
-
- uses: actions/checkout@
|
86
|
+
- uses: actions/checkout@v4
|
87
87
|
- name: Install Ruby 3.2
|
88
88
|
uses: ruby/setup-ruby@v1
|
89
89
|
with:
|
data/.rubocop.yml
CHANGED
data/.rubocop_todo.yml
CHANGED
@@ -1,16 +1,11 @@
|
|
1
1
|
# This configuration was generated by
|
2
2
|
# `rubocop --auto-gen-config`
|
3
|
-
# on
|
3
|
+
# on 2024-03-17 17:48:41 UTC using RuboCop version 1.62.1.
|
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: 4
|
10
|
-
RSpec/AnyInstance:
|
11
|
-
Exclude:
|
12
|
-
- 'spec/beaker/hypervisor/docker_spec.rb'
|
13
|
-
|
14
9
|
# Offense count: 23
|
15
10
|
# Configuration parameters: CountAsOne.
|
16
11
|
RSpec/ExampleLength:
|
@@ -31,9 +26,9 @@ RSpec/MultipleExpectations:
|
|
31
26
|
RSpec/MultipleMemoizedHelpers:
|
32
27
|
Max: 12
|
33
28
|
|
34
|
-
# Offense count:
|
35
|
-
#
|
36
|
-
RSpec/
|
29
|
+
# Offense count: 7
|
30
|
+
# This cop supports unsafe autocorrection (--autocorrect-all).
|
31
|
+
RSpec/ReceiveMessages:
|
37
32
|
Exclude:
|
38
33
|
- 'spec/beaker/hypervisor/docker_spec.rb'
|
39
34
|
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,39 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## [2.2.0](https://github.com/voxpupuli/beaker-docker/tree/2.2.0) (2024-03-17)
|
4
|
+
|
5
|
+
[Full Changelog](https://github.com/voxpupuli/beaker-docker/compare/2.1.0...2.2.0)
|
6
|
+
|
7
|
+
**Implemented enhancements:**
|
8
|
+
|
9
|
+
- Implement writing out a containerfile for a host [\#125](https://github.com/voxpupuli/beaker-docker/pull/125) ([ekohl](https://github.com/ekohl))
|
10
|
+
- Support Amazon Linux 2023 [\#123](https://github.com/voxpupuli/beaker-docker/pull/123) ([treydock](https://github.com/treydock))
|
11
|
+
|
12
|
+
**Merged pull requests:**
|
13
|
+
|
14
|
+
- Rakefile: Use rubocop tasks from voxpupuli-rubocop [\#131](https://github.com/voxpupuli/beaker-docker/pull/131) ([bastelfreak](https://github.com/bastelfreak))
|
15
|
+
- voxpupuli-rubocop: Update 1.2-\>2.6 [\#129](https://github.com/voxpupuli/beaker-docker/pull/129) ([bastelfreak](https://github.com/bastelfreak))
|
16
|
+
- README.md: Document CLI; Add ToC [\#127](https://github.com/voxpupuli/beaker-docker/pull/127) ([bastelfreak](https://github.com/bastelfreak))
|
17
|
+
|
18
|
+
## [2.1.0](https://github.com/voxpupuli/beaker-docker/tree/2.1.0) (2023-05-05)
|
19
|
+
|
20
|
+
[Full Changelog](https://github.com/voxpupuli/beaker-docker/compare/2.0.0...2.1.0)
|
21
|
+
|
22
|
+
**Implemented enhancements:**
|
23
|
+
|
24
|
+
- switch to voxpupuli-rubocop & restore beaker 4 support [\#120](https://github.com/voxpupuli/beaker-docker/pull/120) ([bastelfreak](https://github.com/bastelfreak))
|
25
|
+
|
26
|
+
**Closed issues:**
|
27
|
+
|
28
|
+
- Enable SSH Agent forwarding on MacOS [\#117](https://github.com/voxpupuli/beaker-docker/issues/117)
|
29
|
+
|
30
|
+
**Merged pull requests:**
|
31
|
+
|
32
|
+
- GCG: Add faraday-retry dep [\#119](https://github.com/voxpupuli/beaker-docker/pull/119) ([bastelfreak](https://github.com/bastelfreak))
|
33
|
+
- CI: Build gems with strictness and verbosity [\#118](https://github.com/voxpupuli/beaker-docker/pull/118) ([bastelfreak](https://github.com/bastelfreak))
|
34
|
+
- rubocop: Fix RSpec/AnyInstance [\#116](https://github.com/voxpupuli/beaker-docker/pull/116) ([jay7x](https://github.com/jay7x))
|
35
|
+
- rubocop: Fix RSpec/VerifiedDoubles [\#115](https://github.com/voxpupuli/beaker-docker/pull/115) ([jay7x](https://github.com/jay7x))
|
36
|
+
|
3
37
|
## [2.0.0](https://github.com/voxpupuli/beaker-docker/tree/2.0.0) (2023-03-28)
|
4
38
|
|
5
39
|
[Full Changelog](https://github.com/voxpupuli/beaker-docker/compare/1.5.0...2.0.0)
|
@@ -65,7 +99,6 @@
|
|
65
99
|
|
66
100
|
**Merged pull requests:**
|
67
101
|
|
68
|
-
- Bump actions/checkout from 2 to 3 [\#90](https://github.com/voxpupuli/beaker-docker/pull/90) ([dependabot[bot]](https://github.com/apps/dependabot))
|
69
102
|
- dependabot: check for github actions as well [\#89](https://github.com/voxpupuli/beaker-docker/pull/89) ([bastelfreak](https://github.com/bastelfreak))
|
70
103
|
|
71
104
|
## [1.3.0](https://github.com/voxpupuli/beaker-docker/tree/1.3.0) (2022-12-18)
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -10,6 +10,18 @@
|
|
10
10
|
|
11
11
|
Beaker library to use docker hypervisor
|
12
12
|
|
13
|
+
* [How to use this wizardry](#how-to-use-this-wizardry)
|
14
|
+
* [Nodeset Options](#nodeset-options)
|
15
|
+
* [Privileged containers](#privileged-containers)
|
16
|
+
* [Cleaning up after tests](#cleaning-up-after-tests)
|
17
|
+
* [Working with `podman`](#working-with-podman)
|
18
|
+
* [Generating a Dockerfile](#generating-a-dockerfile)
|
19
|
+
* [Spec tests]()
|
20
|
+
* [Acceptance tests]()
|
21
|
+
* [Transfer Notice](#transfer-notice)
|
22
|
+
* [License](#license)
|
23
|
+
* [Release Information](#release-information)
|
24
|
+
|
13
25
|
## How to use this wizardry
|
14
26
|
|
15
27
|
This gem that allows you to use hosts with [docker](docker.md) hypervisor with [beaker](https://github.com/voxpupuli/beaker).
|
@@ -102,6 +114,56 @@ See the
|
|
102
114
|
[HostConfig](https://any-api.com/docker_com/engine/docs/Definitions/HostConfig)
|
103
115
|
portion of the docker API for more information.
|
104
116
|
|
117
|
+
## Generating a Dockerfile
|
118
|
+
|
119
|
+
Usually beaker-docker is used to provision docker instances with beaker. During
|
120
|
+
this step beaker-docker generates a Dockerfile and posts it to the docker daemon
|
121
|
+
API.
|
122
|
+
|
123
|
+
There's also a small CLI command to only generate the file:
|
124
|
+
|
125
|
+
```
|
126
|
+
bundle exec beaker-docker dockerfile archlinux-64
|
127
|
+
```
|
128
|
+
|
129
|
+
Will generate a local `Dockerfile`:
|
130
|
+
|
131
|
+
```dockerfile
|
132
|
+
FROM archlinux/archlinux
|
133
|
+
ENV container docker
|
134
|
+
RUN pacman --sync --refresh --noconfirm archlinux-keyring && pacman --sync --refresh --noconfirm --sysupgrade && pacman --sync --noconfirm curl ntp net-tools openssh && ssh-keygen -A && sed -ri 's/^#?UsePAM .*/UsePAM no/' /etc/ssh/sshd_config && systemctl enable sshd
|
135
|
+
RUN mkdir -p /var/run/sshd && echo root:root | chpasswd
|
136
|
+
RUN sed -ri -e 's/^#?PermitRootLogin .*/PermitRootLogin yes/' -e 's/^#?PasswordAuthentication .*/PasswordAuthentication yes/' -e 's/^#?UseDNS .*/UseDNS no/' -e 's/^#?MaxAuthTries.*/MaxAuthTries 1000/' /etc/ssh/sshd_config
|
137
|
+
EXPOSE 22
|
138
|
+
CMD ["/sbin/init"]
|
139
|
+
```
|
140
|
+
|
141
|
+
This works by calling
|
142
|
+
(beaker-hostgenerator](https://github.com/voxpupuli/beaker-hostgenerator?tab=readme-ov-file#beaker-host-generator).
|
143
|
+
So you can provide any host string that's supported by beaker-hostgenerator.
|
144
|
+
|
145
|
+
For non-rolling release distros this is usually `$os$majorversion-$architecture`
|
146
|
+
|
147
|
+
```
|
148
|
+
beaker-docker dockerfile centos9-64
|
149
|
+
```
|
150
|
+
|
151
|
+
```dockerfile
|
152
|
+
FROM quay.io/centos/centos:stream9
|
153
|
+
ENV container docker
|
154
|
+
RUN dnf clean all && dnf install -y sudo openssh-server openssh-clients chrony && ssh-keygen -A && sed 's@session *required *pam_loginuid.so@session optional pam_loginuid.so@g' -i /etc/pam.d/*
|
155
|
+
RUN mkdir -p /var/run/sshd && echo root:root | chpasswd
|
156
|
+
RUN sed -ri -e 's/^#?PermitRootLogin .*/PermitRootLogin yes/' -e 's/^#?PasswordAuthentication .*/PasswordAuthentication yes/' -e 's/^#?UseDNS .*/UseDNS no/' -e 's/^#?MaxAuthTries.*/MaxAuthTries 1000/' /etc/ssh/sshd_config
|
157
|
+
RUN cp /bin/true /sbin/agetty
|
158
|
+
RUN dnf install -y cronie crontabs initscripts iproute openssl wget which glibc-langpack-en hostname
|
159
|
+
EXPOSE 22
|
160
|
+
CMD ["/sbin/init"]
|
161
|
+
```
|
162
|
+
|
163
|
+
This requires a running docker daemon. You can also request a containerfile.
|
164
|
+
This will currently generate a `Containerfile` but with the same content (this
|
165
|
+
may change in the future, depending on the API spec).
|
166
|
+
|
105
167
|
## Spec tests
|
106
168
|
|
107
169
|
Spec test live under the `spec` folder. There are the default rake task and therefore can run with a simple command:
|
data/Rakefile
CHANGED
@@ -3,16 +3,9 @@
|
|
3
3
|
require 'rspec/core/rake_task'
|
4
4
|
|
5
5
|
begin
|
6
|
-
require 'rubocop/
|
6
|
+
require 'voxpupuli/rubocop/rake'
|
7
7
|
rescue LoadError
|
8
|
-
#
|
9
|
-
else
|
10
|
-
RuboCop::RakeTask.new(:rubocop) do |task|
|
11
|
-
# These make the rubocop experience maybe slightly less terrible
|
12
|
-
task.options = ['--display-cop-names', '--display-style-guide', '--extra-details']
|
13
|
-
# Use Rubocop's Github Actions formatter if possible
|
14
|
-
task.formatters << 'github' if ENV['GITHUB_ACTIONS'] == 'true'
|
15
|
-
end
|
8
|
+
# the voxpupuli-rubocop gem is optional
|
16
9
|
end
|
17
10
|
|
18
11
|
namespace :test do
|
@@ -73,7 +66,7 @@ rescue LoadError
|
|
73
66
|
# Do nothing if no required gem installed
|
74
67
|
else
|
75
68
|
GitHubChangelogGenerator::RakeTask.new :changelog do |config|
|
76
|
-
config.exclude_labels = %w[duplicate question invalid wontfix wont-fix skip-changelog]
|
69
|
+
config.exclude_labels = %w[duplicate question invalid wontfix wont-fix skip-changelog github_actions]
|
77
70
|
config.user = 'voxpupuli'
|
78
71
|
config.project = 'beaker-docker'
|
79
72
|
gem_version = Gem::Specification.load("#{config.project}.gemspec").version
|
data/beaker-docker.gemspec
CHANGED
@@ -28,13 +28,10 @@ Gem::Specification.new do |s|
|
|
28
28
|
s.add_development_dependency 'fakefs', '>= 1.3', '< 3.0'
|
29
29
|
s.add_development_dependency 'rake', '~> 13.0'
|
30
30
|
s.add_development_dependency 'rspec', '~> 3.0'
|
31
|
-
s.add_development_dependency 'rubocop', '~>
|
32
|
-
s.add_development_dependency 'rubocop-performance', '~> 1.10'
|
33
|
-
s.add_development_dependency 'rubocop-rake', '~> 0.2'
|
34
|
-
s.add_development_dependency 'rubocop-rspec', '>= 1.44'
|
31
|
+
s.add_development_dependency 'voxpupuli-rubocop', '~> 2.6.0'
|
35
32
|
|
36
33
|
# Run time dependencies
|
37
|
-
s.add_runtime_dependency 'beaker', '
|
34
|
+
s.add_runtime_dependency 'beaker', '>= 4', '< 6'
|
38
35
|
s.add_runtime_dependency 'docker-api', '~> 2.1'
|
39
36
|
s.add_runtime_dependency 'stringify-hash', '~> 0.0.0'
|
40
37
|
end
|
data/bin/beaker-docker
CHANGED
@@ -2,8 +2,27 @@
|
|
2
2
|
# frozen_string_literal: true
|
3
3
|
|
4
4
|
require 'rubygems' unless defined?(Gem)
|
5
|
+
require 'beaker'
|
5
6
|
require 'beaker-docker'
|
6
7
|
|
8
|
+
def dockerfile(hostspec, filename)
|
9
|
+
ENV['BEAKER_HYPERVISOR'] = 'docker'
|
10
|
+
options = Beaker::Options::Parser.new.parse_args(['--hosts', hostspec || '', '--no-provision'])
|
11
|
+
options[:logger] = Beaker::Logger.new(options)
|
12
|
+
network_manager = Beaker::NetworkManager.new(options, options[:logger])
|
13
|
+
network_manager.provision
|
14
|
+
hosts = network_manager.hosts
|
15
|
+
|
16
|
+
if hosts.size != 1
|
17
|
+
options[:logger].error "Found #{hosts.size} hosts, expected 1"
|
18
|
+
exit(1)
|
19
|
+
end
|
20
|
+
|
21
|
+
hypervisor = network_manager.hypervisors['docker']
|
22
|
+
# TODO: private method
|
23
|
+
File.write(filename, hypervisor.send(:dockerfile_for, hosts.first))
|
24
|
+
end
|
25
|
+
|
7
26
|
VERSION_STRING = <<'VER'
|
8
27
|
_ .--.
|
9
28
|
( ` )
|
@@ -25,6 +44,13 @@ VERSION_STRING = <<'VER'
|
|
25
44
|
'=='
|
26
45
|
VER
|
27
46
|
|
28
|
-
|
47
|
+
case ARGV[0]
|
48
|
+
when 'containerfile'
|
49
|
+
dockerfile(ARGV[1], ARGV[2] || 'Containerfile')
|
50
|
+
when 'dockerfile'
|
51
|
+
dockerfile(ARGV[1], ARGV[2] || 'Dockerfile')
|
52
|
+
else
|
53
|
+
puts VERSION_STRING % BeakerDocker::VERSION
|
54
|
+
end
|
29
55
|
|
30
56
|
exit 0
|
@@ -165,7 +165,7 @@ module Beaker
|
|
165
165
|
# Container to container
|
166
166
|
unless ip && port
|
167
167
|
ip = network_settings['IPAddress']
|
168
|
-
port = ip && !ip.empty? ? 22 : nil
|
168
|
+
port = (ip && !ip.empty?) ? 22 : nil
|
169
169
|
end
|
170
170
|
|
171
171
|
# Container through gateway
|
@@ -195,7 +195,7 @@ module Beaker
|
|
195
195
|
port = port22[0]['HostPort'] if port22
|
196
196
|
end
|
197
197
|
|
198
|
-
ssh_connection_info[:ip] = ip == '0.0.0.0' ? '127.0.0.1' : ip
|
198
|
+
ssh_connection_info[:ip] = (ip == '0.0.0.0') ? '127.0.0.1' : ip
|
199
199
|
ssh_connection_info[:port] = port || '22'
|
200
200
|
ssh_connection_info
|
201
201
|
end
|
@@ -375,7 +375,7 @@ module Beaker
|
|
375
375
|
container.exec(%w[apt-get update])
|
376
376
|
container.exec(%w[apt-get install -y openssh-server openssh-client])
|
377
377
|
container.exec(%w[sed 's@session\s*required\s*pam_loginuid.so@session optional pam_loginuid.so@g' -i /etc/pam.d/*])
|
378
|
-
when /el-[89]/, /fedora-(2[2-9]|3[0-9])/
|
378
|
+
when /el-[89]/, /fedora-(2[2-9]|3[0-9])/, /amazon-2023/
|
379
379
|
container.exec(%w[dnf clean all])
|
380
380
|
container.exec(%w[dnf install -y sudo openssh-server openssh-clients])
|
381
381
|
container.exec(%w[ssh-keygen -A])
|
@@ -509,7 +509,7 @@ module Beaker
|
|
509
509
|
RUN apt-get update \
|
510
510
|
&& apt-get install -y openssh-server openssh-client #{additional_packages.join(' ')}
|
511
511
|
DF
|
512
|
-
when /el-[89]/, /fedora-(2[2-9]|3)/
|
512
|
+
when /el-[89]/, /fedora-(2[2-9]|3)/, /amazon-2023/
|
513
513
|
dockerfile += <<~DF
|
514
514
|
RUN dnf clean all \
|
515
515
|
&& dnf install -y sudo openssh-server openssh-clients #{additional_packages.join(' ')} \
|
@@ -11,6 +11,7 @@ module Beaker
|
|
11
11
|
'centos-7-x86_64',
|
12
12
|
'sles-12-x86_64',
|
13
13
|
'archlinux-2017.12.27-x86_64',
|
14
|
+
'amazon-2023-x86_64',
|
14
15
|
]
|
15
16
|
|
16
17
|
describe Docker do
|
@@ -28,7 +29,7 @@ module Beaker
|
|
28
29
|
end
|
29
30
|
|
30
31
|
let(:logger) do
|
31
|
-
logger =
|
32
|
+
logger = instance_double(Logger)
|
32
33
|
allow(logger).to receive(:debug)
|
33
34
|
allow(logger).to receive(:info)
|
34
35
|
allow(logger).to receive(:warn)
|
@@ -52,7 +53,7 @@ module Beaker
|
|
52
53
|
end
|
53
54
|
|
54
55
|
let(:image) do
|
55
|
-
image =
|
56
|
+
image = instance_double(::Docker::Image)
|
56
57
|
allow(image).to receive(:id).and_return('zyxwvu')
|
57
58
|
allow(image).to receive(:tag)
|
58
59
|
image
|
@@ -87,7 +88,7 @@ module Beaker
|
|
87
88
|
end
|
88
89
|
|
89
90
|
let(:container) do
|
90
|
-
container =
|
91
|
+
container = instance_double(::Docker::Container)
|
91
92
|
allow(container).to receive(:id).and_return('abcdef')
|
92
93
|
allow(container).to receive(:start)
|
93
94
|
allow(container).to receive(:stats)
|
@@ -129,32 +130,16 @@ module Beaker
|
|
129
130
|
|
130
131
|
context 'with a working connection' do
|
131
132
|
before do
|
132
|
-
# Stub out all of the docker-api gem. we should never really call it
|
133
|
-
# from these tests
|
134
|
-
allow_any_instance_of(::Beaker::Docker).to receive(:require).with('docker')
|
133
|
+
# Stub out all of the docker-api gem. we should never really call it from these tests
|
135
134
|
allow(::Docker).to receive(:options).and_return(docker_options)
|
136
|
-
allow(::Docker).to receive(:options=)
|
137
|
-
allow(::Docker).to receive(:logger=)
|
138
135
|
allow(::Docker).to receive(:podman?).and_return(false)
|
139
136
|
allow(::Docker).to receive(:version).and_return(version)
|
140
137
|
allow(::Docker::Image).to receive(:build).and_return(image)
|
141
138
|
allow(::Docker::Image).to receive(:create).and_return(image)
|
142
139
|
allow(::Docker::Container).to receive(:create).and_return(container)
|
143
|
-
allow_any_instance_of(::Docker::Container).to receive(:start)
|
144
140
|
end
|
145
141
|
|
146
142
|
describe '#initialize' do
|
147
|
-
it 'requires the docker gem' do
|
148
|
-
expect_any_instance_of(::Beaker::Docker).to receive(:require).with('docker').once
|
149
|
-
|
150
|
-
docker
|
151
|
-
end
|
152
|
-
|
153
|
-
it 'fails when the gem is absent' do
|
154
|
-
allow_any_instance_of(::Beaker::Docker).to receive(:require).with('docker').and_raise(LoadError)
|
155
|
-
expect { docker }.to raise_error(LoadError)
|
156
|
-
end
|
157
|
-
|
158
143
|
it 'sets Docker options' do
|
159
144
|
expect(::Docker).to receive(:options=).with({ write_timeout: 300, read_timeout: 300 }).once
|
160
145
|
|
@@ -183,7 +168,7 @@ module Beaker
|
|
183
168
|
end
|
184
169
|
|
185
170
|
describe '#install_ssh_components' do
|
186
|
-
let(:test_container) {
|
171
|
+
let(:test_container) { object_double(container) }
|
187
172
|
let(:host) { hosts[0] }
|
188
173
|
|
189
174
|
before do
|
@@ -222,7 +207,7 @@ module Beaker
|
|
222
207
|
end
|
223
208
|
end
|
224
209
|
|
225
|
-
it '
|
210
|
+
it 'tags the image with the value of the tag' do
|
226
211
|
expect(image).to receive(:tag).with({ repo: 'my_tag' }).exactly(3).times
|
227
212
|
docker.provision
|
228
213
|
end
|
@@ -324,8 +309,8 @@ module Beaker
|
|
324
309
|
},
|
325
310
|
},
|
326
311
|
'Labels' => {
|
327
|
-
'one' => (index == 2 ? 3 : 1),
|
328
|
-
'two' => (index == 2 ? 4 : 2),
|
312
|
+
'one' => ((index == 2) ? 3 : 1),
|
313
|
+
'two' => ((index == 2) ? 4 : 2),
|
329
314
|
},
|
330
315
|
'name' => /\Abeaker-/,
|
331
316
|
})
|
@@ -355,8 +340,8 @@ module Beaker
|
|
355
340
|
},
|
356
341
|
},
|
357
342
|
'Labels' => {
|
358
|
-
'one' => (index == 2 ? 3 : 1),
|
359
|
-
'two' => (index == 2 ? 4 : 2),
|
343
|
+
'one' => ((index == 2) ? 3 : 1),
|
344
|
+
'two' => ((index == 2) ? 4 : 2),
|
360
345
|
},
|
361
346
|
})
|
362
347
|
end
|
@@ -412,8 +397,8 @@ module Beaker
|
|
412
397
|
},
|
413
398
|
},
|
414
399
|
'Labels' => {
|
415
|
-
'one' => (index == 2 ? 3 : 1),
|
416
|
-
'two' => (index == 2 ? 4 : 2),
|
400
|
+
'one' => ((index == 2) ? 3 : 1),
|
401
|
+
'two' => ((index == 2) ? 4 : 2),
|
417
402
|
},
|
418
403
|
'name' => /\Abeaker-/,
|
419
404
|
})
|
@@ -440,8 +425,8 @@ module Beaker
|
|
440
425
|
'CapAdd' => %w[NET_ADMIN SYS_ADMIN],
|
441
426
|
},
|
442
427
|
'Labels' => {
|
443
|
-
'one' => (index == 2 ? 3 : 1),
|
444
|
-
'two' => (index == 2 ? 4 : 2),
|
428
|
+
'one' => ((index == 2) ? 3 : 1),
|
429
|
+
'two' => ((index == 2) ? 4 : 2),
|
445
430
|
},
|
446
431
|
'name' => /\Abeaker-/,
|
447
432
|
})
|
@@ -474,8 +459,8 @@ module Beaker
|
|
474
459
|
},
|
475
460
|
},
|
476
461
|
'Labels' => {
|
477
|
-
'one' => (index == 2 ? 3 : 1),
|
478
|
-
'two' => (index == 2 ? 4 : 2),
|
462
|
+
'one' => ((index == 2) ? 3 : 1),
|
463
|
+
'two' => ((index == 2) ? 4 : 2),
|
479
464
|
},
|
480
465
|
'name' => /\Abeaker-/,
|
481
466
|
})
|
@@ -756,7 +741,7 @@ module Beaker
|
|
756
741
|
end
|
757
742
|
|
758
743
|
describe '#fix_ssh' do
|
759
|
-
let(:test_container) {
|
744
|
+
let(:test_container) { object_double(container) }
|
760
745
|
let(:host) { hosts[0] }
|
761
746
|
|
762
747
|
before do
|
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.
|
4
|
+
version: 2.2.0
|
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:
|
14
|
+
date: 2024-03-17 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: fakefs
|
@@ -62,75 +62,39 @@ dependencies:
|
|
62
62
|
- !ruby/object:Gem::Version
|
63
63
|
version: '3.0'
|
64
64
|
- !ruby/object:Gem::Dependency
|
65
|
-
name: rubocop
|
65
|
+
name: voxpupuli-rubocop
|
66
66
|
requirement: !ruby/object:Gem::Requirement
|
67
67
|
requirements:
|
68
68
|
- - "~>"
|
69
69
|
- !ruby/object:Gem::Version
|
70
|
-
version:
|
70
|
+
version: 2.6.0
|
71
71
|
type: :development
|
72
72
|
prerelease: false
|
73
73
|
version_requirements: !ruby/object:Gem::Requirement
|
74
74
|
requirements:
|
75
75
|
- - "~>"
|
76
76
|
- !ruby/object:Gem::Version
|
77
|
-
version:
|
77
|
+
version: 2.6.0
|
78
78
|
- !ruby/object:Gem::Dependency
|
79
|
-
name:
|
80
|
-
requirement: !ruby/object:Gem::Requirement
|
81
|
-
requirements:
|
82
|
-
- - "~>"
|
83
|
-
- !ruby/object:Gem::Version
|
84
|
-
version: '1.10'
|
85
|
-
type: :development
|
86
|
-
prerelease: false
|
87
|
-
version_requirements: !ruby/object:Gem::Requirement
|
88
|
-
requirements:
|
89
|
-
- - "~>"
|
90
|
-
- !ruby/object:Gem::Version
|
91
|
-
version: '1.10'
|
92
|
-
- !ruby/object:Gem::Dependency
|
93
|
-
name: rubocop-rake
|
94
|
-
requirement: !ruby/object:Gem::Requirement
|
95
|
-
requirements:
|
96
|
-
- - "~>"
|
97
|
-
- !ruby/object:Gem::Version
|
98
|
-
version: '0.2'
|
99
|
-
type: :development
|
100
|
-
prerelease: false
|
101
|
-
version_requirements: !ruby/object:Gem::Requirement
|
102
|
-
requirements:
|
103
|
-
- - "~>"
|
104
|
-
- !ruby/object:Gem::Version
|
105
|
-
version: '0.2'
|
106
|
-
- !ruby/object:Gem::Dependency
|
107
|
-
name: rubocop-rspec
|
79
|
+
name: beaker
|
108
80
|
requirement: !ruby/object:Gem::Requirement
|
109
81
|
requirements:
|
110
82
|
- - ">="
|
111
83
|
- !ruby/object:Gem::Version
|
112
|
-
version: '
|
113
|
-
|
114
|
-
prerelease: false
|
115
|
-
version_requirements: !ruby/object:Gem::Requirement
|
116
|
-
requirements:
|
117
|
-
- - ">="
|
118
|
-
- !ruby/object:Gem::Version
|
119
|
-
version: '1.44'
|
120
|
-
- !ruby/object:Gem::Dependency
|
121
|
-
name: beaker
|
122
|
-
requirement: !ruby/object:Gem::Requirement
|
123
|
-
requirements:
|
124
|
-
- - "~>"
|
84
|
+
version: '4'
|
85
|
+
- - "<"
|
125
86
|
- !ruby/object:Gem::Version
|
126
|
-
version: '
|
87
|
+
version: '6'
|
127
88
|
type: :runtime
|
128
89
|
prerelease: false
|
129
90
|
version_requirements: !ruby/object:Gem::Requirement
|
130
91
|
requirements:
|
131
|
-
- - "
|
92
|
+
- - ">="
|
93
|
+
- !ruby/object:Gem::Version
|
94
|
+
version: '4'
|
95
|
+
- - "<"
|
132
96
|
- !ruby/object:Gem::Version
|
133
|
-
version: '
|
97
|
+
version: '6'
|
134
98
|
- !ruby/object:Gem::Dependency
|
135
99
|
name: docker-api
|
136
100
|
requirement: !ruby/object:Gem::Requirement
|