|
6 | 6 |
|
7 | 7 | load helpers |
8 | 8 | load helpers.network |
| 9 | +load helpers.registry |
9 | 10 |
|
10 | 11 | @test "podman build - basic test" { |
11 | 12 | rand_filename=$(random_string 20) |
|
951 | 952 | "--pull-never fails with expected error message" |
952 | 953 | } |
953 | 954 |
|
| 955 | +@test "podman build --pull=newer" { |
| 956 | + skip_if_remote "tests depend on start_registry which does not work with podman-remote" |
| 957 | + start_registry |
| 958 | + |
| 959 | + local registry=localhost:${PODMAN_LOGIN_REGISTRY_PORT} |
| 960 | + local image_for_test=$registry/i-$(safename):$(random_string) |
| 961 | + local authfile=$PODMAN_TMPDIR/authfile.json |
| 962 | + local tmpdir=$PODMAN_TMPDIR/build-test |
| 963 | + |
| 964 | + run_podman login --authfile=$authfile \ |
| 965 | + --tls-verify=false \ |
| 966 | + --username ${PODMAN_LOGIN_USER} \ |
| 967 | + --password ${PODMAN_LOGIN_PASS} \ |
| 968 | + $registry |
| 969 | + |
| 970 | + # Generate a test image and push it to the registry. |
| 971 | + # For safety in parallel runs, test image must be isolated |
| 972 | + # from $IMAGE. A simple add-tag will not work. (#23756) |
| 973 | + run_podman create -q $IMAGE true |
| 974 | + local tmpcid=$output |
| 975 | + run_podman commit -q $tmpcid $image_for_test |
| 976 | + run_podman rm $tmpcid |
| 977 | + run_podman image push --tls-verify=false --authfile=$authfile $image_for_test |
| 978 | + |
| 979 | + local tmpdir=$PODMAN_TMPDIR/build-test |
| 980 | + mkdir -p $tmpdir |
| 981 | + |
| 982 | + # Now build using $image_for_test |
| 983 | + cat >$tmpdir/Containerfile <<EOF |
| 984 | +FROM $image_for_test |
| 985 | +EOF |
| 986 | + |
| 987 | + # Build the image |
| 988 | + run_podman build $tmpdir --pull=newer --tls-verify=false --authfile=$authfile |
| 989 | + is "$output" ".*pull" "pull seen in log" |
| 990 | + is "$output" ".*COMMIT" "COMMIT seen in log" |
| 991 | + |
| 992 | + # Build again |
| 993 | + run_podman build $tmpdir --pull=newer --tls-verify=false --authfile=$authfile |
| 994 | + assert "$output" !~ "pull" "should not pull the image again" |
| 995 | + |
| 996 | + # Now refresh the remote image |
| 997 | + run_podman create -q $IMAGE true |
| 998 | + local tmpcid=$output |
| 999 | + run_podman commit -q $tmpcid $image_for_test |
| 1000 | + run_podman rm $tmpcid |
| 1001 | + run_podman image push --tls-verify=false --authfile=$authfile $image_for_test |
| 1002 | + |
| 1003 | + # Build one more time |
| 1004 | + run_podman build $tmpdir --pull=newer --tls-verify=false --authfile=$authfile |
| 1005 | + is "$output" ".*pull" "pull seen in log" |
| 1006 | + |
| 1007 | + run_podman image rm --ignore $image_for_test |
| 1008 | +} |
| 1009 | + |
954 | 1010 | @test "podman build --logfile test" { |
955 | 1011 | tmpdir=$PODMAN_TMPDIR/build-test |
956 | 1012 | mkdir -p $tmpdir |
|
0 commit comments