Files
podman/test/system/195-run-namespaces.bats
Ed Santiago 5831bd68bf System tests: add test tags
[
  Clean cherry-pick of #19302. This is a low-risk change
  with potentially very high ROI: the opportunity to catch
  interaction problems with updates in other system components.
]

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-08-01 10:56:17 -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