From 202cab612467166b1cb7951ae98a8f7d8a746626 Mon Sep 17 00:00:00 2001 From: Urvashi Mohnani Date: Thu, 25 Jan 2024 13:37:21 -0500 Subject: [PATCH] Fix inspect test that rely on digest Given that we can have multiple image digests, fix the inspect test to check whether the digest given matches one of the digests of the image. Signed-off-by: Urvashi Mohnani --- test/system/030-run.bats | 8 ++++++-- test/system/120-load.bats | 8 ++++---- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/test/system/030-run.bats b/test/system/030-run.bats index 7b302cb918..2148d3f17f 100644 --- a/test/system/030-run.bats +++ b/test/system/030-run.bats @@ -629,12 +629,16 @@ json-file | f @test "podman inspect includes image data" { randomname=$(random_string 30) - run_podman inspect $IMAGE --format "{{.ID}} {{.Digest}}" + run_podman inspect $IMAGE --format "{{.ID}}" expected="$IMAGE $output" + run_podman inspect $IMAGE --format "{{.RepoDigests}}" + expectedDigests="$output" run_podman run --name $randomname $IMAGE true - run_podman container inspect $randomname --format "{{.ImageName}} {{.Image}} {{.ImageDigest}}" + run_podman container inspect $randomname --format "{{.ImageName}} {{.Image}}" is "$output" "$expected" + run_podman container inspect $randomname --format "{{.ImageDigest}}" + assert "$output" =~ "$expectedDigests" run_podman rm -f -t0 $randomname } diff --git a/test/system/120-load.bats b/test/system/120-load.bats index e05f5196e2..df4df99ba5 100644 --- a/test/system/120-load.bats +++ b/test/system/120-load.bats @@ -109,8 +109,8 @@ verify_iid_and_name() { _sudo true || skip "cannot sudo to $notme" # Preserve digest of original image; we will compare against it later - run_podman image inspect --format '{{.Digest}}' $IMAGE - src_digest=$output + run_podman image inspect --format '{{.RepoDigests}}' $IMAGE + src_digests=$output # image name that is not likely to exist in the destination newname=foo.bar/nonesuch/c_$(random_string 10 | tr A-Z a-z):mytag @@ -132,14 +132,14 @@ verify_iid_and_name() { # Confirm that we have it, and that its digest matches our original run_podman image inspect --format '{{.Digest}}' $newname - is "$output" "$src_digest" "Digest of re-fetched image matches original" + assert "$output" =~ "$src_digests" "Digest of re-fetched image is in list of original image digests" # test tagging capability run_podman untag $IMAGE $newname run_podman image scp ${notme}@localhost::$newname foobar:123 run_podman image inspect --format '{{.Digest}}' foobar:123 - is "$output" "$src_digest" "Digest of re-fetched image matches original" + assert "$output" =~ "$src_digest" "Digest of re-fetched image is in list of original image digests" # remove root img for transfer back with another name _sudo $PODMAN image rm $newname