beaker-docker 2.1.0 → 2.2.1
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 +1 -1
- data/.github/workflows/test.yml +5 -5
- data/.rubocop_todo.yml +7 -1
- data/CHANGELOG.md +23 -1
- data/README.md +62 -0
- data/Rakefile +3 -10
- data/beaker-docker.gemspec +1 -1
- data/bin/beaker-docker +27 -1
- data/lib/beaker/hypervisor/docker.rb +7 -7
- data/lib/beaker-docker/version.rb +1 -1
- data/spec/beaker/hypervisor/docker_spec.rb +47 -58
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6264189ab77d7c85932a5e565c593365f07450b25d38796e1349c5304754b7cc
|
4
|
+
data.tar.gz: fa7f1dcde6a3b11121972a67a91c2c365db17f0ea2e22e36777cef1b07cb88c9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ff0d8b74a89100b457d1beed90cf9f53e33c93ca891b8c377ee795a06fc261154ee5fd9c88eddc5c68b6517d4129961109e874eac2925ca56907962cd26ad2d6
|
7
|
+
data.tar.gz: 4af9b0bd85a33e02c078f743fd9eeeacaed4862e8dfc3f4497713a0dbd630658fb68100a8fdad8d0e7022dfa998f34a57f55c727b0e1b2264fcdb7337ad23109
|
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:
|
@@ -52,7 +52,7 @@ jobs:
|
|
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_todo.yml
CHANGED
@@ -1,6 +1,6 @@
|
|
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
|
@@ -26,6 +26,12 @@ RSpec/MultipleExpectations:
|
|
26
26
|
RSpec/MultipleMemoizedHelpers:
|
27
27
|
Max: 12
|
28
28
|
|
29
|
+
# Offense count: 7
|
30
|
+
# This cop supports unsafe autocorrection (--autocorrect-all).
|
31
|
+
RSpec/ReceiveMessages:
|
32
|
+
Exclude:
|
33
|
+
- 'spec/beaker/hypervisor/docker_spec.rb'
|
34
|
+
|
29
35
|
# Offense count: 26
|
30
36
|
# This cop supports safe autocorrection (--autocorrect).
|
31
37
|
# Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, AllowedPatterns.
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,28 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## [2.2.1](https://github.com/voxpupuli/beaker-docker/tree/2.2.1) (2024-03-27)
|
4
|
+
|
5
|
+
[Full Changelog](https://github.com/voxpupuli/beaker-docker/compare/2.2.0...2.2.1)
|
6
|
+
|
7
|
+
**Fixed bugs:**
|
8
|
+
|
9
|
+
- Fix privileged remote docker port forward resolution [\#126](https://github.com/voxpupuli/beaker-docker/pull/126) ([h0tw1r3](https://github.com/h0tw1r3))
|
10
|
+
|
11
|
+
## [2.2.0](https://github.com/voxpupuli/beaker-docker/tree/2.2.0) (2024-03-17)
|
12
|
+
|
13
|
+
[Full Changelog](https://github.com/voxpupuli/beaker-docker/compare/2.1.0...2.2.0)
|
14
|
+
|
15
|
+
**Implemented enhancements:**
|
16
|
+
|
17
|
+
- Implement writing out a containerfile for a host [\#125](https://github.com/voxpupuli/beaker-docker/pull/125) ([ekohl](https://github.com/ekohl))
|
18
|
+
- Support Amazon Linux 2023 [\#123](https://github.com/voxpupuli/beaker-docker/pull/123) ([treydock](https://github.com/treydock))
|
19
|
+
|
20
|
+
**Merged pull requests:**
|
21
|
+
|
22
|
+
- Rakefile: Use rubocop tasks from voxpupuli-rubocop [\#131](https://github.com/voxpupuli/beaker-docker/pull/131) ([bastelfreak](https://github.com/bastelfreak))
|
23
|
+
- voxpupuli-rubocop: Update 1.2-\>2.6 [\#129](https://github.com/voxpupuli/beaker-docker/pull/129) ([bastelfreak](https://github.com/bastelfreak))
|
24
|
+
- README.md: Document CLI; Add ToC [\#127](https://github.com/voxpupuli/beaker-docker/pull/127) ([bastelfreak](https://github.com/bastelfreak))
|
25
|
+
|
3
26
|
## [2.1.0](https://github.com/voxpupuli/beaker-docker/tree/2.1.0) (2023-05-05)
|
4
27
|
|
5
28
|
[Full Changelog](https://github.com/voxpupuli/beaker-docker/compare/2.0.0...2.1.0)
|
@@ -84,7 +107,6 @@
|
|
84
107
|
|
85
108
|
**Merged pull requests:**
|
86
109
|
|
87
|
-
- Bump actions/checkout from 2 to 3 [\#90](https://github.com/voxpupuli/beaker-docker/pull/90) ([dependabot[bot]](https://github.com/apps/dependabot))
|
88
110
|
- dependabot: check for github actions as well [\#89](https://github.com/voxpupuli/beaker-docker/pull/89) ([bastelfreak](https://github.com/bastelfreak))
|
89
111
|
|
90
112
|
## [1.3.0](https://github.com/voxpupuli/beaker-docker/tree/1.3.0) (2022-12-18)
|
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,7 +28,7 @@ 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 'voxpupuli-rubocop', '~>
|
31
|
+
s.add_development_dependency 'voxpupuli-rubocop', '~> 2.6.0'
|
32
32
|
|
33
33
|
# Run time dependencies
|
34
34
|
s.add_runtime_dependency 'beaker', '>= 4', '< 6'
|
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
|
@@ -188,14 +188,14 @@ module Beaker
|
|
188
188
|
end
|
189
189
|
end
|
190
190
|
|
191
|
-
if host_config['NetworkMode'] != 'slirp4netns' && network_settings['IPAddress'] && !network_settings['IPAddress'].empty?
|
192
|
-
|
193
|
-
|
191
|
+
ip = network_settings['IPAddress'] if ip.nil? && host_config['NetworkMode'] != 'slirp4netns' && network_settings['IPAddress'] && !network_settings['IPAddress'].empty?
|
192
|
+
|
193
|
+
if port.nil?
|
194
194
|
port22 = network_settings.dig('Ports', '22/tcp')
|
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
|
@@ -109,6 +110,12 @@ module Beaker
|
|
109
110
|
|
110
111
|
before do
|
111
112
|
allow(::Docker).to receive(:rootless?).and_return(true)
|
113
|
+
@docker_host = ENV.fetch('DOCKER_HOST', nil)
|
114
|
+
ENV.delete('DOCKER_HOST') if @docker_host
|
115
|
+
end
|
116
|
+
|
117
|
+
after do
|
118
|
+
ENV['DOCKER_HOST'] = @docker_host if @docker_host
|
112
119
|
end
|
113
120
|
|
114
121
|
context 'with connection failure' do
|
@@ -206,7 +213,7 @@ module Beaker
|
|
206
213
|
end
|
207
214
|
end
|
208
215
|
|
209
|
-
it '
|
216
|
+
it 'tags the image with the value of the tag' do
|
210
217
|
expect(image).to receive(:tag).with({ repo: 'my_tag' }).exactly(3).times
|
211
218
|
docker.provision
|
212
219
|
end
|
@@ -308,8 +315,8 @@ module Beaker
|
|
308
315
|
},
|
309
316
|
},
|
310
317
|
'Labels' => {
|
311
|
-
'one' => (index == 2 ? 3 : 1),
|
312
|
-
'two' => (index == 2 ? 4 : 2),
|
318
|
+
'one' => ((index == 2) ? 3 : 1),
|
319
|
+
'two' => ((index == 2) ? 4 : 2),
|
313
320
|
},
|
314
321
|
'name' => /\Abeaker-/,
|
315
322
|
})
|
@@ -339,8 +346,8 @@ module Beaker
|
|
339
346
|
},
|
340
347
|
},
|
341
348
|
'Labels' => {
|
342
|
-
'one' => (index == 2 ? 3 : 1),
|
343
|
-
'two' => (index == 2 ? 4 : 2),
|
349
|
+
'one' => ((index == 2) ? 3 : 1),
|
350
|
+
'two' => ((index == 2) ? 4 : 2),
|
344
351
|
},
|
345
352
|
})
|
346
353
|
end
|
@@ -396,8 +403,8 @@ module Beaker
|
|
396
403
|
},
|
397
404
|
},
|
398
405
|
'Labels' => {
|
399
|
-
'one' => (index == 2 ? 3 : 1),
|
400
|
-
'two' => (index == 2 ? 4 : 2),
|
406
|
+
'one' => ((index == 2) ? 3 : 1),
|
407
|
+
'two' => ((index == 2) ? 4 : 2),
|
401
408
|
},
|
402
409
|
'name' => /\Abeaker-/,
|
403
410
|
})
|
@@ -424,8 +431,8 @@ module Beaker
|
|
424
431
|
'CapAdd' => %w[NET_ADMIN SYS_ADMIN],
|
425
432
|
},
|
426
433
|
'Labels' => {
|
427
|
-
'one' => (index == 2 ? 3 : 1),
|
428
|
-
'two' => (index == 2 ? 4 : 2),
|
434
|
+
'one' => ((index == 2) ? 3 : 1),
|
435
|
+
'two' => ((index == 2) ? 4 : 2),
|
429
436
|
},
|
430
437
|
'name' => /\Abeaker-/,
|
431
438
|
})
|
@@ -458,8 +465,8 @@ module Beaker
|
|
458
465
|
},
|
459
466
|
},
|
460
467
|
'Labels' => {
|
461
|
-
'one' => (index == 2 ? 3 : 1),
|
462
|
-
'two' => (index == 2 ? 4 : 2),
|
468
|
+
'one' => ((index == 2) ? 3 : 1),
|
469
|
+
'two' => ((index == 2) ? 4 : 2),
|
463
470
|
},
|
464
471
|
'name' => /\Abeaker-/,
|
465
472
|
})
|
@@ -475,64 +482,46 @@ module Beaker
|
|
475
482
|
end
|
476
483
|
|
477
484
|
context 'when connecting to ssh' do
|
478
|
-
|
479
|
-
|
480
|
-
|
481
|
-
|
482
|
-
|
483
|
-
it 'exposes port 22 to beaker' do
|
484
|
-
ENV['DOCKER_HOST'] = nil
|
485
|
-
docker.provision
|
486
|
-
|
487
|
-
expect(hosts[0]['ip']).to eq '127.0.0.1'
|
488
|
-
expect(hosts[0]['port']).to eq 8022
|
489
|
-
end
|
490
|
-
|
491
|
-
it 'exposes port 22 to beaker when using DOCKER_HOST' do
|
492
|
-
ENV['DOCKER_HOST'] = 'tcp://192.0.2.2:2375'
|
493
|
-
docker.provision
|
494
|
-
|
495
|
-
expect(hosts[0]['ip']).to eq '192.0.2.2'
|
496
|
-
expect(hosts[0]['port']).to eq 8022
|
497
|
-
end
|
485
|
+
%w[rootless privileged].each do |mode|
|
486
|
+
context "when #{mode}" do
|
487
|
+
let(:container_mode) do
|
488
|
+
mode
|
489
|
+
end
|
498
490
|
|
499
|
-
|
500
|
-
|
501
|
-
docker.provision
|
491
|
+
it 'exposes port 22 to beaker' do
|
492
|
+
docker.provision
|
502
493
|
|
503
|
-
|
504
|
-
|
505
|
-
|
506
|
-
expect(hosts[0]['ssh'][:port]).to eq 8022
|
507
|
-
expect(hosts[0]['ssh'][:forward_agent]).to be true
|
508
|
-
end
|
494
|
+
expect(hosts[0]['ip']).to eq '127.0.0.1'
|
495
|
+
expect(hosts[0]['port']).to eq 8022
|
496
|
+
end
|
509
497
|
|
510
|
-
|
511
|
-
|
512
|
-
FileUtils.touch('/.dockerenv')
|
498
|
+
it 'exposes port 22 to beaker when using DOCKER_HOST' do
|
499
|
+
ENV['DOCKER_HOST'] = 'tcp://192.0.2.2:2375'
|
513
500
|
docker.provision
|
514
501
|
|
515
|
-
expect(hosts[0]['ip']).to eq '192.0.2.
|
502
|
+
expect(hosts[0]['ip']).to eq '192.0.2.2'
|
516
503
|
expect(hosts[0]['port']).to eq 8022
|
517
504
|
end
|
518
|
-
end
|
519
|
-
end
|
520
|
-
|
521
|
-
context 'when rootful' do
|
522
|
-
before { @docker_host = ENV.fetch('DOCKER_HOST', nil) }
|
523
505
|
|
524
|
-
|
506
|
+
it 'has ssh agent forwarding enabled' do
|
507
|
+
docker.provision
|
525
508
|
|
526
|
-
|
527
|
-
|
528
|
-
|
509
|
+
expect(hosts[0]['ip']).to eq '127.0.0.1'
|
510
|
+
expect(hosts[0]['port']).to eq 8022
|
511
|
+
expect(hosts[0]['ssh'][:password]).to eq 'root'
|
512
|
+
expect(hosts[0]['ssh'][:port]).to eq 8022
|
513
|
+
expect(hosts[0]['ssh'][:forward_agent]).to be true
|
514
|
+
end
|
529
515
|
|
530
|
-
|
531
|
-
|
532
|
-
|
516
|
+
it 'connects to gateway ip' do
|
517
|
+
FakeFS do
|
518
|
+
FileUtils.touch('/.dockerenv')
|
519
|
+
docker.provision
|
533
520
|
|
534
|
-
|
535
|
-
|
521
|
+
expect(hosts[0]['ip']).to eq '192.0.2.254'
|
522
|
+
expect(hosts[0]['port']).to eq 8022
|
523
|
+
end
|
524
|
+
end
|
536
525
|
end
|
537
526
|
end
|
538
527
|
end
|
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.1
|
4
|
+
version: 2.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Vox Pupuli
|
@@ -11,7 +11,7 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date:
|
14
|
+
date: 2024-03-27 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: fakefs
|
@@ -67,14 +67,14 @@ dependencies:
|
|
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
79
|
name: beaker
|
80
80
|
requirement: !ruby/object:Gem::Requirement
|