beaker-docker 0.8.0 → 0.8.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 +4 -4
- data/.github/workflows/release.yml +24 -0
- data/.github/workflows/test.yml +82 -9
- data/Gemfile.local +5 -0
- data/Rakefile +6 -2
- data/acceptance/config/nodes/hosts.yaml +14 -9
- data/acceptance/tests/00_default_spec.rb +10 -0
- data/lib/beaker-docker/version.rb +1 -1
- data/lib/beaker/hypervisor/docker.rb +33 -22
- data/spec/beaker/hypervisor/docker_spec.rb +1 -0
- metadata +6 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d1f70940dc7c4b43db06838e143fc4e4a498247be0ed67ae0926ae84527f5786
|
4
|
+
data.tar.gz: b12830fb23b10ccf1718be061c3e6ffe3e81c0b47b3aff58e3882e2e0a843c7d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d182e05ba8dea02f896571bb5cf100f3a313349e1178f3eb9daf5e62f7ec93572114e4e1cf6e10a34aa18e8280d7be0ff7ed8a1482984cbd07ae3a530a7a0be9
|
7
|
+
data.tar.gz: 478ac68e7088d66a8f5a4732f59a1337b355293b5a5f8d38551e5d54b81e6e7634528139b4c5717462b3d0b4a8558de05afc83b2f2c51705f0e8d16b7fb885a8
|
@@ -0,0 +1,24 @@
|
|
1
|
+
name: Release
|
2
|
+
|
3
|
+
on:
|
4
|
+
create:
|
5
|
+
ref_type: tag
|
6
|
+
|
7
|
+
jobs:
|
8
|
+
release:
|
9
|
+
runs-on: ubuntu-latest
|
10
|
+
if: github.repository == 'voxpupuli/beaker-docker'
|
11
|
+
env:
|
12
|
+
BUNDLE_WITHOUT: release
|
13
|
+
steps:
|
14
|
+
- uses: actions/checkout@v2
|
15
|
+
- name: Install Ruby 2.7
|
16
|
+
uses: ruby/setup-ruby@v1
|
17
|
+
with:
|
18
|
+
ruby-version: '2.7'
|
19
|
+
- name: Build gem
|
20
|
+
run: gem build *.gemspec
|
21
|
+
- name: Publish gem
|
22
|
+
run: gem push *.gem
|
23
|
+
env:
|
24
|
+
GEM_HOST_API_KEY: '${{ secrets.RUBYGEMS_AUTH_TOKEN }}'
|
data/.github/workflows/test.yml
CHANGED
@@ -1,13 +1,19 @@
|
|
1
1
|
name: Test
|
2
2
|
|
3
3
|
on:
|
4
|
-
|
4
|
+
push:
|
5
|
+
branches:
|
6
|
+
- test_me_github
|
7
|
+
pull_request:
|
8
|
+
branches:
|
9
|
+
- main
|
10
|
+
- master
|
5
11
|
|
6
12
|
jobs:
|
7
|
-
|
13
|
+
rspec:
|
8
14
|
runs-on: ubuntu-latest
|
9
15
|
strategy:
|
10
|
-
fail-fast:
|
16
|
+
fail-fast: true
|
11
17
|
matrix:
|
12
18
|
ruby:
|
13
19
|
- "2.4"
|
@@ -16,7 +22,7 @@ jobs:
|
|
16
22
|
- "2.7"
|
17
23
|
env:
|
18
24
|
BUNDLE_WITHOUT: release
|
19
|
-
name: Ruby ${{ matrix.ruby }}
|
25
|
+
name: RSpec - Ruby ${{ matrix.ruby }}
|
20
26
|
steps:
|
21
27
|
- uses: actions/checkout@v2
|
22
28
|
- name: Install Ruby ${{ matrix.ruby }}
|
@@ -24,9 +30,76 @@ jobs:
|
|
24
30
|
with:
|
25
31
|
ruby-version: ${{ matrix.ruby }}
|
26
32
|
bundler-cache: true
|
27
|
-
- name:
|
33
|
+
- name: install bundler
|
34
|
+
run: |
|
35
|
+
gem install bundler -v '~> 1.17.3'
|
36
|
+
bundle update
|
37
|
+
- name: spec tests
|
28
38
|
run: bundle exec rake test:spec
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
39
|
+
|
40
|
+
docker:
|
41
|
+
runs-on: ubuntu-latest
|
42
|
+
strategy:
|
43
|
+
fail-fast: true
|
44
|
+
matrix:
|
45
|
+
ruby:
|
46
|
+
- "2.6"
|
47
|
+
env:
|
48
|
+
BUNDLE_WITHOUT: release
|
49
|
+
name: Docker - Ruby ${{ matrix.ruby }}
|
50
|
+
steps:
|
51
|
+
- uses: actions/checkout@v2
|
52
|
+
- name: Install Ruby ${{ matrix.ruby }}
|
53
|
+
uses: ruby/setup-ruby@v1
|
54
|
+
with:
|
55
|
+
ruby-version: ${{ matrix.ruby }}
|
56
|
+
bundler-cache: true
|
57
|
+
- name: install bundler
|
58
|
+
run: |
|
59
|
+
gem install bundler -v '~> 1.17.3'
|
60
|
+
bundle update
|
61
|
+
- name: install container runtime
|
62
|
+
run: |
|
63
|
+
sudo apt-get remove -y docker docker-engine docker.io containerd runc ||:
|
64
|
+
sudo apt-get update -y
|
65
|
+
sudo apt-get install -y apt-transport-https ca-certificates curl gnupg-agent software-properties-common
|
66
|
+
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
|
67
|
+
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
|
68
|
+
sudo apt-get update -y
|
69
|
+
sudo apt-get install -y docker-ce docker-ce-cli containerd.io
|
70
|
+
sudo systemctl start docker
|
71
|
+
- name: Run acceptance tests
|
72
|
+
run: bundle exec rake test:acceptance
|
73
|
+
|
74
|
+
podman:
|
75
|
+
runs-on: ubuntu-latest
|
76
|
+
strategy:
|
77
|
+
fail-fast: true
|
78
|
+
matrix:
|
79
|
+
ruby:
|
80
|
+
- "2.6"
|
81
|
+
env:
|
82
|
+
BUNDLE_WITHOUT: release
|
83
|
+
name: Podman - Ruby ${{ matrix.ruby }}
|
84
|
+
steps:
|
85
|
+
- uses: actions/checkout@v2
|
86
|
+
- name: Install Ruby ${{ matrix.ruby }}
|
87
|
+
uses: ruby/setup-ruby@v1
|
88
|
+
with:
|
89
|
+
ruby-version: ${{ matrix.ruby }}
|
90
|
+
bundler-cache: true
|
91
|
+
- name: install bundler
|
92
|
+
run: |
|
93
|
+
gem install bundler -v '~> 1.17.3'
|
94
|
+
bundle update
|
95
|
+
# We need the latest version of podman for this to work
|
96
|
+
- name: install container runtime
|
97
|
+
run: |
|
98
|
+
. /etc/os-release
|
99
|
+
curl -L https://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/stable/xUbuntu_${VERSION_ID}/Release.key | sudo apt-key add -
|
100
|
+
echo "deb https://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/stable/xUbuntu_${VERSION_ID}/ /" | sudo tee /etc/apt/sources.list.d/podman.list > /dev/null
|
101
|
+
sudo apt-get update
|
102
|
+
sudo apt-get -y install podman
|
103
|
+
sudo systemctl start podman
|
104
|
+
- name: Run acceptance tests
|
105
|
+
run: bundle exec rake test:acceptance
|
data/Gemfile.local
ADDED
data/Rakefile
CHANGED
@@ -32,11 +32,15 @@ A quick acceptance test, named because it has no pre-suites to run
|
|
32
32
|
beaker_test_base_dir = File.join(beaker_gem_dir, 'acceptance/tests/base')
|
33
33
|
load_path_option = File.join(beaker_gem_dir, 'acceptance/lib')
|
34
34
|
|
35
|
+
ENV['BEAKER_setfile'] = 'acceptance/config/nodes/hosts.yaml'
|
35
36
|
sh("beaker",
|
36
37
|
"--hosts", "acceptance/config/nodes/hosts.yaml",
|
37
|
-
|
38
|
+
# We can't run these tests until the rsync support in the main
|
39
|
+
# beaker/host.rb is updated to work with passwords.
|
40
|
+
# "--tests", beaker_test_base_dir,
|
41
|
+
# "--load-path", load_path_option,
|
42
|
+
"--tests", 'acceptance/tests/',
|
38
43
|
"--log-level", "debug",
|
39
|
-
"--load-path", load_path_option,
|
40
44
|
"--debug")
|
41
45
|
end
|
42
46
|
|
@@ -12,12 +12,6 @@ HOSTS:
|
|
12
12
|
- classifier
|
13
13
|
- default
|
14
14
|
docker_cmd: '["/sbin/init"]'
|
15
|
-
docker_cap_add:
|
16
|
-
- AUDIT_WRITE
|
17
|
-
dockeropts:
|
18
|
-
Labels:
|
19
|
-
one: '1'
|
20
|
-
two: '2'
|
21
15
|
centos7:
|
22
16
|
platform: el-7-x86_64
|
23
17
|
hypervisor: docker
|
@@ -26,10 +20,21 @@ HOSTS:
|
|
26
20
|
- agent
|
27
21
|
docker_cmd: '/usr/sbin/sshd -D -E /var/log/sshd.log'
|
28
22
|
use_image_entrypoint: true
|
29
|
-
dockeropts:
|
30
|
-
HostConfig:
|
31
|
-
Privileged: true
|
32
23
|
CONFIG:
|
33
24
|
nfs_server: none
|
34
25
|
consoleport: 443
|
35
26
|
log_level: verbose
|
27
|
+
# Ubuntu runners need to run with full privileges
|
28
|
+
# RHEL derivitives just need the docker cap AUDIT_WRITE
|
29
|
+
dockeropts:
|
30
|
+
HostConfig:
|
31
|
+
Privileged: true
|
32
|
+
# docker_cap_add:
|
33
|
+
# - AUDIT_WRITE
|
34
|
+
type: aio
|
35
|
+
ssh:
|
36
|
+
verify_host_key: false
|
37
|
+
user_known_hosts_file: '/dev/null'
|
38
|
+
password: root
|
39
|
+
auth_methods:
|
40
|
+
- password
|
@@ -135,32 +135,35 @@ module Beaker
|
|
135
135
|
port: nil
|
136
136
|
}
|
137
137
|
|
138
|
+
container_json = container.json
|
139
|
+
network_settings = container_json['NetworkSettings']
|
140
|
+
host_config = container_json['HostConfig']
|
141
|
+
|
142
|
+
ip = nil
|
143
|
+
port = nil
|
138
144
|
# Talking against a remote docker host which is a normal docker host
|
139
145
|
if @docker_type == 'docker' && ENV['DOCKER_HOST'] && !ENV.fetch('DOCKER_HOST','').include?(':///')
|
140
146
|
ip = URI.parse(ENV['DOCKER_HOST']).host
|
141
147
|
else
|
142
148
|
# Swarm or local docker host
|
143
149
|
if in_container?
|
144
|
-
|
150
|
+
gw = network_settings['Gateway']
|
151
|
+
ip = gw unless (gw.nil? || gw.empty?)
|
145
152
|
else
|
146
|
-
|
153
|
+
port22 = network_settings.dig('Ports','22/tcp')
|
154
|
+
ip = port22[0]["HostIp"] if port22
|
147
155
|
end
|
148
156
|
end
|
149
157
|
|
150
|
-
network_settings
|
151
|
-
|
152
|
-
|
153
|
-
port = '22'
|
154
|
-
if host_config['NetworkMode'] == 'bridge' && network_settings['IPAddress'] && !network_settings['IPAddress'].empty?
|
155
|
-
ssh_connection_info[:ip] = network_settings['IPAddress']
|
158
|
+
if host_config['NetworkMode'] != 'slirp4netns' && network_settings['IPAddress'] && !network_settings['IPAddress'].empty?
|
159
|
+
ip = network_settings['IPAddress']
|
156
160
|
else
|
157
|
-
|
158
|
-
|
159
|
-
# Update host metadata
|
160
|
-
ssh_connection_info[:ip] = (ip == '0.0.0.0') ? '127.0.0.1' : ip
|
161
|
+
port22 = network_settings.dig('Ports','22/tcp')
|
162
|
+
port = port22[0]['HostPort'] if port22
|
161
163
|
end
|
162
164
|
|
163
|
-
ssh_connection_info[:
|
165
|
+
ssh_connection_info[:ip] = (ip == '0.0.0.0') ? '127.0.0.1' : ip
|
166
|
+
ssh_connection_info[:port] = port || '22'
|
164
167
|
ssh_connection_info
|
165
168
|
end
|
166
169
|
|
@@ -242,7 +245,8 @@ module Beaker
|
|
242
245
|
while(!ok && (retries < 5))
|
243
246
|
container = ::Docker::Container.create(container_opts)
|
244
247
|
|
245
|
-
|
248
|
+
ssh_info = get_ssh_connection_info(container)
|
249
|
+
if ssh_info[:ip] == '127.0.0.1' && (ssh_info[:port].to_i < 1024) && (Process.uid != 0)
|
246
250
|
@logger.debug("#{host} was given a port less than 1024 but you are not running as root, retrying")
|
247
251
|
|
248
252
|
container.delete
|
@@ -267,19 +271,19 @@ module Beaker
|
|
267
271
|
@logger.debug("Starting container #{container.id}")
|
268
272
|
container.start
|
269
273
|
|
274
|
+
begin
|
275
|
+
container.stats
|
276
|
+
rescue StandardError => e
|
277
|
+
container.delete
|
278
|
+
raise "Container '#{container.id}' in a bad state: #{e}"
|
279
|
+
end
|
280
|
+
|
270
281
|
# Preserve the ability to talk directly to the underlying API
|
271
282
|
#
|
272
283
|
# You can use any method defined by the docker-api gem on this object
|
273
284
|
# https://github.com/swipely/docker-api
|
274
285
|
host[:docker_container] = container
|
275
286
|
|
276
|
-
ssh_connection_info = get_ssh_connection_info(container)
|
277
|
-
|
278
|
-
ip = ssh_connection_info[:ip]
|
279
|
-
port = ssh_connection_info[:port]
|
280
|
-
|
281
|
-
@logger.info("Using container connection at #{ip}:#{port}")
|
282
|
-
|
283
287
|
if install_and_run_ssh(host)
|
284
288
|
@logger.notify("Installing ssh components and starting ssh daemon in #{host} container")
|
285
289
|
install_ssh_components(container, host)
|
@@ -287,6 +291,13 @@ module Beaker
|
|
287
291
|
fix_ssh(container, host)
|
288
292
|
end
|
289
293
|
|
294
|
+
ssh_connection_info = get_ssh_connection_info(container)
|
295
|
+
|
296
|
+
ip = ssh_connection_info[:ip]
|
297
|
+
port = ssh_connection_info[:port]
|
298
|
+
|
299
|
+
@logger.info("Using container connection at #{ip}:#{port}")
|
300
|
+
|
290
301
|
forward_ssh_agent = @options[:forward_ssh_agent] || false
|
291
302
|
|
292
303
|
host['ip'] = ip
|
@@ -298,7 +309,7 @@ module Beaker
|
|
298
309
|
:auth_methods => ['password', 'publickey', 'hostbased', 'keyboard-interactive']
|
299
310
|
}
|
300
311
|
|
301
|
-
@logger.debug("node available as
|
312
|
+
@logger.debug("node available as ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no root@#{ip} -p #{port}")
|
302
313
|
host['docker_container_id'] = container.id
|
303
314
|
host['docker_image_id'] = image.id
|
304
315
|
host['vm_ip'] = container.json["NetworkSettings"]["IPAddress"].to_s
|
@@ -88,6 +88,7 @@ module Beaker
|
|
88
88
|
container = double('Docker::Container')
|
89
89
|
allow( container ).to receive(:id).and_return('abcdef')
|
90
90
|
allow( container ).to receive(:start)
|
91
|
+
allow( container ).to receive(:stats)
|
91
92
|
allow( container ).to receive(:info).and_return(
|
92
93
|
*(0..2).map { |index| { 'Names' => ["/spec-container-#{index}"] } }
|
93
94
|
)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: beaker-docker
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.8.
|
4
|
+
version: 0.8.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Rishi Javia, Kevin Imber, Tony Vu
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-02-
|
11
|
+
date: 2021-02-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|
@@ -131,14 +131,17 @@ extensions: []
|
|
131
131
|
extra_rdoc_files: []
|
132
132
|
files:
|
133
133
|
- ".github/dependabot.yml"
|
134
|
+
- ".github/workflows/release.yml"
|
134
135
|
- ".github/workflows/test.yml"
|
135
136
|
- ".gitignore"
|
136
137
|
- ".simplecov"
|
137
138
|
- Gemfile
|
139
|
+
- Gemfile.local
|
138
140
|
- LICENSE
|
139
141
|
- README.md
|
140
142
|
- Rakefile
|
141
143
|
- acceptance/config/nodes/hosts.yaml
|
144
|
+
- acceptance/tests/00_default_spec.rb
|
142
145
|
- beaker-docker.gemspec
|
143
146
|
- bin/beaker-docker
|
144
147
|
- docker.md
|
@@ -165,7 +168,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
165
168
|
- !ruby/object:Gem::Version
|
166
169
|
version: '0'
|
167
170
|
requirements: []
|
168
|
-
rubygems_version: 3.
|
171
|
+
rubygems_version: 3.1.4
|
169
172
|
signing_key:
|
170
173
|
specification_version: 4
|
171
174
|
summary: Beaker DSL Extension Helpers!
|