Skip to content

Commit

Permalink
System tests: add test tags
Browse files Browse the repository at this point in the history
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, "openqa". The intention
is for OpenQA tests to install the podman-tests package
and run:

    bats --filter-tags openqa /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>
  • Loading branch information
edsantiago committed Jul 20, 2023
1 parent 6156923 commit 91c265b
Show file tree
Hide file tree
Showing 10 changed files with 26 additions and 0 deletions.
1 change: 1 addition & 0 deletions hack/bats
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ for i;do
--rootless) TEST_ROOT= ;;
--remote) REMOTE=remote ;;
--ts|-T) bats_opts+=("-T") ;;
--tag=*) bats_filter=("--filter-tags" "$value") ;;
*/*.bats) TESTS=$i ;;
*)
if [[ $i =~ : ]]; then
Expand Down
2 changes: 2 additions & 0 deletions test/system/075-exec.bats
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

load helpers

# bats test_tags=openqa
@test "podman exec - basic test" {
rand_filename=$(random_string 20)
rand_content=$(random_string 50)
Expand Down Expand Up @@ -43,6 +44,7 @@ load helpers
run_podman rm $cid
}

# bats test_tags=openqa
@test "podman exec - leak check" {
skip_if_remote "test is meaningless over remote"

Expand Down
2 changes: 2 additions & 0 deletions test/system/080-pause.bats
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

load helpers

# bats test_tags=openqa
@test "podman pause/unpause" {
if is_rootless && ! is_cgroupsv2; then
skip "'podman pause' (rootless) only works with cgroups v2"
Expand Down Expand Up @@ -58,6 +59,7 @@ load helpers
run_podman 125 unpause $cname
}

# bats test_tags=openqa
@test "podman unpause --all" {
if is_rootless && ! is_cgroupsv2; then
skip "'podman pause' (rootless) only works with cgroups v2"
Expand Down
3 changes: 3 additions & 0 deletions test/system/090-events.bats
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

load helpers

# bats test_tags=openqa
@test "events with a filter by label" {
cname=test-$(random_string 30 | tr A-Z a-z)
labelname=$(random_string 10)
Expand Down Expand Up @@ -141,6 +142,7 @@ function _events_disjunctive_filters() {
_events_disjunctive_filters ""
}

# bats test_tags=openqa
@test "events with events_logfile_path in containers.conf" {
skip_if_remote "remote does not support --events-backend"
events_file=$PODMAN_TMPDIR/events.log
Expand All @@ -162,6 +164,7 @@ function _populate_events_file() {
done
}

# bats test_tags=openqa
@test "events log-file rotation" {
skip_if_remote "setting CONTAINERS_CONF_OVERRIDE logger options does not affect remote client"

Expand Down
1 change: 1 addition & 0 deletions test/system/130-kill.bats
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

load helpers

# bats test_tags=openqa
@test "podman kill - test signal handling in containers" {

# Prepare for 'logs -f'
Expand Down
2 changes: 2 additions & 0 deletions test/system/170-run-userns.bats
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
#
# Tests for podman build
#
# bats file_tags=openqa
#

load helpers

Expand Down
2 changes: 2 additions & 0 deletions test/system/190-run-ipcns.bats
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
#
# Tests for podman build
#
# bats file_tags=openqa
#

load helpers

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

load helpers

# bats test_tags=openqa
@test "podman test all namespaces" {
# format is nsname | option name
tests="
Expand Down
3 changes: 3 additions & 0 deletions test/system/260-sdnotify.bats
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ function _assert_mainpid_is_conmon() {
_stop_socat
}

# bats test_tags=openqa
@test "sdnotify : conmon" {
export NOTIFY_SOCKET=$PODMAN_TMPDIR/conmon.sock
_start_socat
Expand Down Expand Up @@ -141,6 +142,7 @@ READY=1" "sdnotify sent MAINPID and READY"

# These tests can fail in dev. environment because of SELinux.
# quick fix: chcon -t container_runtime_exec_t ./bin/podman
# bats test_tags=openqa
@test "sdnotify : container" {
_prefetch $SYSTEMD_IMAGE

Expand Down Expand Up @@ -393,6 +395,7 @@ spec:
" > $fname
}

# bats test_tags=openqa
@test "podman kube play - exit-code propagation" {
fname=$PODMAN_TMPDIR/$(random_string).yaml

Expand Down
9 changes: 9 additions & 0 deletions test/system/410-selinux.bats
Original file line number Diff line number Diff line change
Expand Up @@ -34,26 +34,32 @@ function check_label() {
}


# bats test_tags=openqa
@test "podman selinux: confined container" {
check_label "" "container_t"
}

# bats test_tags=openqa
@test "podman selinux: container with label=disable" {
check_label "--security-opt label=disable" "spc_t"
}

# bats test_tags=openqa
@test "podman selinux: privileged container" {
check_label "--privileged --userns=host" "spc_t"
}

# bats test_tags=openqa
@test "podman selinux: init container" {
check_label "--systemd=always" "container_init_t"
}

# bats test_tags=openqa
@test "podman selinux: init container with --security-opt type" {
check_label "--systemd=always --security-opt=label=type:spc_t" "spc_t"
}

# bats test_tags=openqa
@test "podman selinux: init container with --security-opt level&type" {
check_label "--systemd=always --security-opt=label=level:s0:c1,c2 --security-opt=label=type:spc_t" "spc_t" "s0:c1,c2"
}
Expand All @@ -62,6 +68,7 @@ function check_label() {
check_label "--systemd=always --security-opt=label=level:s0:c1,c2" "container_init_t" "s0:c1,c2"
}

# bats test_tags=openqa
@test "podman selinux: pid=host" {
# FIXME this test fails when run rootless with runc:
# Error: container_linux.go:367: starting container process caused: process_linux.go:495: container init caused: readonly path /proc/asound: operation not permitted: OCI permission denied
Expand Down Expand Up @@ -153,6 +160,7 @@ function check_label() {
}

# pr #7902 - containers in pods should all run under same context
# bats test_tags=openqa
@test "podman selinux: containers in pods share full context" {
skip_if_no_selinux

Expand Down Expand Up @@ -226,6 +234,7 @@ function check_label() {
is "$output" "Error.*: $expect" "podman emits useful diagnostic on failure"
}

# bats test_tags=openqa
@test "podman selinux: check relabel" {
skip_if_no_selinux

Expand Down

0 comments on commit 91c265b

Please sign in to comment.