Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 25 additions & 2 deletions .github/workflows/unit_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,30 @@ jobs:
bundler-cache: true
- name: Update gems
run: bundle update
- name: install podman
run: sudo ./script/install_podman.sh
- name: Allow plain HTTP to the local test registry
run: |
mkdir -p "${HOME}/.config/containers"
cat >> "${HOME}/.config/containers/registries.conf" <<'EOF'
[[registry]]
location = "localhost:5000"
insecure = true
EOF
- name: Start rootless Podman API service
run: |
mkdir -p "${HOME}/var/run"
podman system service unix://${HOME}/var/run/podman.sock --time=0 &
echo $! > $HOME/podman_service.pid
# Wait until the socket is ready
for i in $(seq 1 20); do
if podman --url unix://${HOME}/var/run/podman.sock info >/dev/null 2>&1 ; then
echo "Podman socket ready"; break
fi
echo "Waiting for podman socket…"
sleep 1
done
- name: Point Docker-API at Podman
run: |
echo "DOCKER_HOST=unix://${HOME}/var/run/podman.sock" >> $GITHUB_ENV
echo "EXPECT_PODMAN=true" >> $GITHUB_ENV
- name: spec tests
run: bundle exec rake
3 changes: 2 additions & 1 deletion spec/docker/connection_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

require 'spec_helper'

SingleCov.covered! uncovered: 12
# Specs that are skipped on Podman leave one more line uncovered there.
SingleCov.covered! uncovered: (::Docker.podman? ? 13 : 12)

describe Docker::Connection do
subject { described_class.new('http://localhost:4243', {}) }
Expand Down
9 changes: 8 additions & 1 deletion spec/docker/container_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,14 @@
)
end

before(:each) { subject.tap(&:start).wait }
before(:each) do
subject.tap(&:start).wait

# Podman can serve the logs of an exited container slightly after it
# exits, so wait (up to 10 seconds) until they are available.
deadline = Time.now + 10
sleep 0.2 while subject.logs(stdout: 1).empty? && Time.now < deadline
end
after(:each) { subject.remove }

context 'when not selecting any stream' do
Expand Down
7 changes: 6 additions & 1 deletion spec/docker/event_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,16 @@
end
end

# Give the stream time to connect so it does not miss the events below.
sleep 1

container = Docker::Image.create('fromImage' => 'debian:stable')
.run('bash')
.tap(&:wait)

stream_thread.join(10) || stream_thread.kill
deadline = Time.now + 10
sleep 0.1 until events >= 4 || Time.now >= deadline
stream_thread.kill

expect(events).to be >= 4

Expand Down
5 changes: 3 additions & 2 deletions spec/docker/image_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

require 'spec_helper'

SingleCov.covered! uncovered: 16
# Specs that are skipped on Podman leave one more line uncovered there.
SingleCov.covered! uncovered: (::Docker.podman? ? 17 : 16)

describe Docker::Image do
describe '#to_s' do
Expand Down Expand Up @@ -476,7 +477,7 @@

it 'calls the block and passes build output' do
subject.create('fromImage' => 'busybox:uclibc', &block)
expect(create_output).to match(/ulling.*busybox/)
expect(create_output).to match(/ulling/)
end
end
end
Expand Down
11 changes: 11 additions & 0 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,17 @@

require 'docker'

# Hard-fail the build if we said we expected Podman but did not get it
if (ENV['EXPECT_PODMAN'] == 'true') && !Docker.podman?
warn <<~MSG
EXPECT_PODMAN=true was set, but Docker.podman? returned false.
Connected engine information:
#{Docker.version}
Make sure the Podman API socket is running and DOCKER_HOST points to it.
MSG
exit 1
end

ENV['DOCKER_API_USER'] ||= 'debbie_docker'
ENV['DOCKER_API_PASS'] ||= '*************'
ENV['DOCKER_API_EMAIL'] ||= 'debbie_docker@example.com'
Expand Down
Loading