mirror of
https://github.com/containers/podman
synced 2024-10-21 01:34:37 +00:00
bd0582dd34
Various small fixes to get BATS tests working again.
Split from #2947 because that one keeps getting stalled,
and I'm hoping these separate changes get approved.
I consider these changes urgent because RHEL8 gating
tests are failing, and will fail even more if/when #2272
gets picked up and packaged for RHEL8, and I consider
it important to have clean passing tests for RHEL8.
* info test: 'insecure registries' is gone. A recent
commit (d1a7378aa
) changed the format of 'podman info',
removing the 'insecure registries' key. Deal with it.
* info test: remove check for .host.{Conmon,OCIRuntime}.package;
the value on f28 and f29 is 'Unknown' (instead of an NVR).
We can live without this check.
* 'load' test: skip when running in CI, because stdin
is not a tty.
* container restore: fix arg processing. #2272 broke argument
processing: 'podman container restore', with no args, should
exit with 'argument required' error. Root cause is that the
new --import option takes the place of an argument, so the
checkAllAndLatest() call had to be changed to not exit on error.
Workaround is (sigh) to copy/paste the skipped checkAllAndLatest()
code, with minor tweaks to accommodate --import.
Signed-off-by: Ed Santiago <santiago@redhat.com>
101 lines
2.8 KiB
Bash
101 lines
2.8 KiB
Bash
#!/usr/bin/env bats -*- bats -*-
|
|
#
|
|
# tests for podman load
|
|
#
|
|
|
|
load helpers
|
|
|
|
# Custom helpers for this test only. These just save us having to duplicate
|
|
# the same thing four times (two tests, each with -i and stdin).
|
|
#
|
|
# initialize, read image ID and name
|
|
get_iid_and_name() {
|
|
run_podman images --format '{{.ID}} {{.Repository}}:{{.Tag}}'
|
|
read iid img_name < <(echo "$output")
|
|
|
|
archive=$PODMAN_TMPDIR/myimage-$(random_string 8).tar
|
|
}
|
|
|
|
# Simple verification of image ID and name
|
|
verify_iid_and_name() {
|
|
run_podman images --format '{{.ID}} {{.Repository}}:{{.Tag}}'
|
|
read new_iid new_img_name < <(echo "$output")
|
|
|
|
# Verify
|
|
is "$new_iid" "$iid" "Image ID of loaded image == original"
|
|
is "$new_img_name" "$1" "Name & tag of restored image"
|
|
}
|
|
|
|
|
|
@test "podman load - by image ID" {
|
|
# FIXME: how to build a simple archive instead?
|
|
get_iid_and_name
|
|
|
|
# Save image by ID, and remove it.
|
|
run_podman save $iid -o $archive
|
|
run_podman rmi $iid
|
|
|
|
# Load using -i; IID should be preserved, but name is not.
|
|
run_podman load -i $archive
|
|
verify_iid_and_name "<none>:<none>"
|
|
|
|
# Same as above, using stdin
|
|
run_podman rmi $iid
|
|
run_podman load < $archive
|
|
verify_iid_and_name "<none>:<none>"
|
|
|
|
# Cleanup: since load-by-iid doesn't preserve name, re-tag it;
|
|
# otherwise our global teardown will rmi and re-pull our standard image.
|
|
run_podman tag $iid $img_name
|
|
}
|
|
|
|
@test "podman load - by image name" {
|
|
get_iid_and_name
|
|
run_podman save $img_name -o $archive
|
|
run_podman rmi $iid
|
|
|
|
# Load using -i; this time the image should be tagged.
|
|
run_podman load -i $archive
|
|
verify_iid_and_name $img_name
|
|
|
|
# Same as above, using stdin
|
|
run_podman rmi $iid
|
|
run_podman load < $archive
|
|
verify_iid_and_name $img_name
|
|
}
|
|
|
|
@test "podman load - NAME and NAME:TAG arguments work (requires: #2674)" {
|
|
get_iid_and_name
|
|
run_podman save $iid -o $archive
|
|
run_podman rmi $iid
|
|
|
|
# Load with just a name (note: names must be lower-case)
|
|
random_name=$(random_string 20 | tr A-Z a-z)
|
|
run_podman load -i $archive $random_name
|
|
verify_iid_and_name "localhost/$random_name:latest"
|
|
|
|
# Load with NAME:TAG arg
|
|
run_podman rmi $iid
|
|
random_tag=$(random_string 10 | tr A-Z a-z)
|
|
run_podman load -i $archive $random_name:$random_tag
|
|
verify_iid_and_name "localhost/$random_name:$random_tag"
|
|
|
|
# Cleanup: restore desired image name
|
|
run_podman tag $iid $img_name
|
|
run_podman rmi "$random_name:$random_tag"
|
|
}
|
|
|
|
|
|
@test "podman load - will not read from tty" {
|
|
if [ ! -t 0 ]; then
|
|
skip "STDIN is not a tty"
|
|
fi
|
|
|
|
run_podman 125 load
|
|
is "$output" \
|
|
"Error: cannot read from terminal. Use command-line redirection" \
|
|
"Diagnostic from 'podman load' without redirection or -i"
|
|
}
|
|
|
|
# vim: filetype=sh
|