buildah/tests/mount.bats

66 lines
2.1 KiB
Plaintext
Raw Permalink Normal View History

#!/usr/bin/env bats
load helpers
@test "mount-flags-order-verification" {
run_buildah 125 mount cnt1 --notruncate path1
check_options_flag_err "--notruncate"
run_buildah 125 mount cnt1 --notruncate
check_options_flag_err "--notruncate"
run_buildah 125 mount cnt1 path1 --notruncate
check_options_flag_err "--notruncate"
}
@test "mount one container" {
_prefetch alpine
run_buildah from --quiet --pull=false --signature-policy ${TESTSDIR}/policy.json alpine
cid=$output
run_buildah mount "$cid"
}
@test "mount bad container" {
run_buildah 125 mount badcontainer
}
@test "mount multi images" {
_prefetch alpine
run_buildah from --quiet --pull=false --signature-policy ${TESTSDIR}/policy.json alpine
cid1=$output
run_buildah from --quiet --pull-never --signature-policy ${TESTSDIR}/policy.json alpine
cid2=$output
run_buildah from --quiet --pull-never --signature-policy ${TESTSDIR}/policy.json alpine
cid3=$output
BATS tests - extensive but minor cleanup This started off as bug fixes necessary to get BATS tests actually working on RHEL8 (they weren't). It grew. I will defend my actions in the first comment post. Primary change: import some helpers from podman BATS tests, most importantly 'run_buildah' and 'is'. The vast majority of the changes you'll see here are of the form: - run buildah ... - [ $status = 0 ] - [ check $output ] + run_buildah ... ! automatically checks status + is "$output" "..." Also: chmod'ed some files -x. Necessary because rpmbuild tries to be oh-so-clever about requirements, and when it sees an executable file with a shebang line like '#!env bats' it helpfully adds 'Requires: /usr/bin/bats' to the rpm, which then fails to install because RHEL8 does not have bats. Also: refactored duplicate code in a few places, by writing and invoking module-specific helper functions. Also: changed a handful of 'buildah's to run_buildah, in order to get error checking and debug logging. Also: added descriptive reasons to many "skip"s. Also: selinux test: some tweakery to make it run on production system (context is different if /usr/bin/buildah is chcon'ed appropriately). I can't get this test to pass on Fedora from a build dir, and I'm actually not convinced that this test has ever passed, but let's see what CI shows. Also: selinux test: skip broken test (#1465). Also: version test: skip parts of it if running w/o sources. Tests are now passing as root on RHEL8; rootless has numerous failures which I don't believe are related to this PR. Signed-off-by: Ed Santiago <santiago@redhat.com> Closes: #1472 Approved by: TomSweeneyRedHat
2019-04-02 05:56:29 +08:00
run_buildah mount "$cid1" "$cid2" "$cid3"
}
@test "mount multi images one bad" {
_prefetch alpine
run_buildah from --quiet --pull=false --signature-policy ${TESTSDIR}/policy.json alpine
cid1=$output
run_buildah from --quiet --pull-never --signature-policy ${TESTSDIR}/policy.json alpine
cid2=$output
run_buildah from --quiet --pull-never --signature-policy ${TESTSDIR}/policy.json alpine
cid3=$output
run_buildah 125 mount "$cid1" badcontainer "$cid2" "$cid3"
}
@test "list currently mounted containers" {
_prefetch alpine
run_buildah from --quiet --pull=false --signature-policy ${TESTSDIR}/policy.json alpine
cid1=$output
run_buildah mount "$cid1"
run_buildah from --quiet --pull-never --signature-policy ${TESTSDIR}/policy.json alpine
cid2=$output
run_buildah mount "$cid2"
run_buildah from --quiet --pull-never --signature-policy ${TESTSDIR}/policy.json alpine
cid3=$output
run_buildah mount "$cid3"
run_buildah mount
expect_line_count 3
expect_output --from="${lines[0]}" --substring "/tmp" "mount line 1 of 3"
expect_output --from="${lines[1]}" --substring "/tmp" "mount line 2 of 3"
expect_output --from="${lines[2]}" --substring "/tmp" "mount line 3 of 3"
}