Skip to content

Commit

Permalink
[WIP] tests: Sanity checks for container image
Browse files Browse the repository at this point in the history
Draft; Haven't tested this yet due to the skopeo issue.
  • Loading branch information
kelvinfan001 committed Jul 13, 2021
1 parent af69ca7 commit 3f53747
Showing 1 changed file with 35 additions and 1 deletion.
36 changes: 35 additions & 1 deletion tests/kolainst/destructive/container-image
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,49 @@ set -euo pipefail
. ${KOLA_EXT_DATA}/libtest.sh

set -x
cd $(mktemp -d)

case "${AUTOPKGTEST_REBOOT_MARK:-}" in
"")

# Test rebase
checksum=$(rpm-ostree status --json | jq -r '.deployments[0].checksum')
rpm-ostree ex-container export --repo=/ostree/repo ${checksum} containers-storage:localhost/fcos
rpm-ostree rebase containers-storage:localhost/fcos:latest
rpm-ostree rebase containers-storage:localhost/fcos:latest --experimental
rpmostree_assert_status ".deployments[0][\"container-image-reference\"] == ${checksum}"
echo "ok rebase to container image reference"

/tmp/autopkgtest-reboot "1"
;;
"1")
if rpm-ostree deploy 42 2>err.txt; then
fatal "unexpectedly deployed version from container image reference"
fi
assert_file_has_content err.txt 'Cannot look up version/checksum while tracking a container image reference'
echo "ok cannot deploy when tracking container image"

# Test layering
if rpm -q foo 2>/dev/null; then
fatal "found foo"
fi
rpm-ostree install ${KOLA_EXT_DATA}/rpm-repos/0/packages/x86_64/foo-1.2-3.x86_64.rpm
echo "ok install foo locally"
/tmp/autopkgtest-reboot "2"
;;
"2")
assert_streq $(rpm -q foo) foo-1.2-3.x86_64
echo "ok pkg foo added locally"

# Test upgrade
rpm-ostree upgrade > out.txt;
assert_file_has_content out.txt "No upgrade available."
echo "ok no upgrade available"

new_commit=$(ostree commit -b vmcheck --tree=ref=vmcheck_tmp/with_foo)
rpm-ostree ex-container export --repo=/ostree/repo ${new_commit} containers-storage:localhost/fcos
rpm-ostree upgrade
/tmp/autopkgtest-reboot "3"
;;
"3")
rpmostree_assert_status ".deployments[0][\"container-image-reference\"] == ${new_commit}"
echo "ok upgrade"

0 comments on commit 3f53747

Please sign in to comment.