Files
podman/test/system/195-run-namespaces.bats
Ed Santiago 33891e8e96 System tests: add test tags
BATS 1.8.0 introduces tags: metadata that can be applied to
a single test or one entire file, then used for filtering
in a test run.

Issue #19299 introduces the possibility of using OpenQA
for podman reverse dependency testing: continuous CI on
all packages that can affect podman, so we don't go two
months with no bodhi builds then get caught by surprise
when systemd or kernel or crun change in ways that break us.

This PR introduces one bats tag, "distro-integration".
The intention is for OpenQA (or other) tests to install
the podman-tests package and run:

    bats --filter-tags distro-integration /usr/share/podman/test/system

Goal is to keep the test list short and sweet: we do not
need to test command-line option parsing. We *DO* need to
test interactions with systemd, kernel, nethack, and other
critical components.

Signed-off-by: Ed Santiago <santiago@redhat.com>
2023-07-26 13:50:33 -06:00

54 lines
1.5 KiB
Bash

#!/usr/bin/env bats -*- bats -*-
#
# Tests for the namespace options
#
load helpers
# bats test_tags=distro-integration
@test "podman test all namespaces" {
# format is nsname | option name
tests="
cgroup | cgroupns
ipc | ipc
net | network
pid | pid
uts | uts
"
for nstype in private host; do
while read name option; do
local cname="c_${name}_$(random_string)"
# ipc is special, private does not allow joining from another container.
# Instead we must use "shareable".
local type=$nstype
if [ "$name" = "ipc" ] && [ "$type" = "private" ]; then
type="shareable"
fi
run_podman run --name $cname --$option $type -d $IMAGE sh -c \
"readlink /proc/self/ns/$name; sleep inf"
run_podman run --rm --$option container:$cname $IMAGE readlink /proc/self/ns/$name
con2_ns="$output"
run readlink /proc/self/ns/$name
host_ns="$output"
run_podman logs $cname
con1_ns="$output"
assert "$con1_ns" == "$con2_ns" "($name) namespace matches (type: $type)"
local matcher="=="
if [[ "$type" != "host" ]]; then
matcher="!="
fi
assert "$con1_ns" $matcher "$host_ns" "expected host namespace to ($matcher) (type: $type)"
run_podman rm -f -t0 $cname
done < <(parse_table "$tests")
done
}
# vim: filetype=sh