Skip to content

Commit 20fb712

Browse files
committed
test/system: do not connect to github server
This is an unnecessary network connection that flakes from time to time. Spawn our own local server instead and use that. That also allows to check that the actual file content has been copied. Signed-off-by: Paul Holzinger <[email protected]>
1 parent 706f72b commit 20fb712

File tree

1 file changed

+24
-2
lines changed

1 file changed

+24
-2
lines changed

test/system/070-build.bats

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
#
66

77
load helpers
8+
load helpers.network
89

910
# bats test_tags=distro-integration
1011
@test "podman build - basic test" {
@@ -279,20 +280,41 @@ EOF
279280
tmpdir=$PODMAN_TMPDIR/build-test
280281
mkdir -p $tmpdir
281282

283+
# Create a test file with random content
284+
INDEX=$PODMAN_TMPDIR/index.txt
285+
local content="test-$(random_string)"
286+
echo "$content" > $INDEX
287+
echo READY > $PODMAN_TMPDIR/ready
288+
289+
# Setup local webserver
290+
local host_port=$(random_free_port)
291+
local server=http://127.0.0.1:$host_port
292+
serverctr="c1-$(safename)"
293+
run_podman run -d --name $serverctr -p "$host_port:80" \
294+
-v $INDEX:/var/www/index.txt:Z \
295+
-v $PODMAN_TMPDIR/ready:/var/www/ready:Z \
296+
-w /var/www \
297+
$IMAGE /bin/busybox-extras httpd -f -p 80
298+
299+
wait_for_command_output "curl -s -S $server/ready" "READY"
300+
282301
cat >$tmpdir/Dockerfile <<EOF
283302
FROM $IMAGE
284-
ADD https://github.com/containers/podman/blob/main/README.md /tmp/
303+
ADD $server/index.txt /tmp/
285304
EOF
286305

287306
imgname="b-$(safename)"
288307
run_podman build -t $imgname $tmpdir
289-
run_podman run --rm $imgname stat /tmp/README.md
308+
run_podman run --rm $imgname cat /tmp/index.txt
309+
assert "$output" == "$content" "file has right content"
290310
run_podman rmi -f $imgname
291311

292312
# Now test COPY. That should fail.
293313
sed -i -e 's/ADD/COPY/' $tmpdir/Dockerfile
294314
run_podman 125 build -t $imgname $tmpdir
295315
is "$output" ".* building at STEP .*: source can't be a URL for COPY"
316+
317+
run_podman rm -f -t0 $serverctr
296318
}
297319

298320

0 commit comments

Comments
 (0)