Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

System tests: add test tags #19302

Merged
merged 1 commit into from
Jul 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions hack/bats
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ $0 is a wrapper for invoking podman system tests.
runs only subtests within FILENAME-PATTERH whose names
match that string.

--tag=TAG Passed on to bats as '--filter-tags TAG'
As of 2023-07-26 the only tag used is 'distro-integration'

-T Passed on to bats, which will then show timing data

--help display usage message
Expand Down Expand Up @@ -83,6 +86,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
3 changes: 3 additions & 0 deletions test/system/001-basic.bats
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ function setup() {

#### DO NOT ADD ANY TESTS HERE! ADD NEW TESTS AT BOTTOM!

# bats test_tags=distro-integration
@test "podman version emits reasonable output" {
run_podman version

Expand All @@ -38,6 +39,7 @@ function setup() {
is "$output" ".*The --config flag is ignored by Podman. Exists for Docker compatibility\+" "verify warning for --config option"
}

# bats test_tags=distro-integration
@test "podman info" {
# These will be displayed on the test output stream, offering an
# at-a-glance overview of important system configuration details
Expand Down Expand Up @@ -71,6 +73,7 @@ function setup() {
"--context=swarm should fail"
}

# bats test_tags=distro-integration
@test "podman can pull an image" {
run_podman rmi -a -f

Expand Down
3 changes: 3 additions & 0 deletions test/system/030-run.bats
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
load helpers
load helpers.network

# bats test_tags=distro-integration
@test "podman run - basic tests" {
rand=$(random_string 30)

Expand Down Expand Up @@ -296,6 +297,7 @@ echo $rand | 0 | $rand
}

# #6829 : add username to /etc/passwd inside container if --userns=keep-id
# bats test_tags=distro-integration
@test "podman run : add username to /etc/passwd if --userns=keep-id" {
skip_if_not_rootless "--userns=keep-id only works in rootless mode"
# Default: always run as root
Expand Down Expand Up @@ -695,6 +697,7 @@ json-file | f
# https://github.com/containers/podman/issues/9096
# podman exec may truncate stdout/stderr; actually a bug in conmon:
# https://github.com/containers/conmon/issues/236
# bats test_tags=distro-integration
@test "podman run - does not truncate or hang with big output" {
# Size, in bytes, to dd and to expect in return
char_count=700000
Expand Down
1 change: 1 addition & 0 deletions test/system/032-sig-proxy.bats
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ load helpers.sig-proxy

# Each of the tests below does some setup, then invokes the helper from helpers.sig-proxy.bash.

# bats test_tags=distro-integration
@test "podman sigproxy test: run" {
# We're forced to use $PODMAN because run_podman cannot be backgrounded
$PODMAN run -i --name c_run $IMAGE sh -c "$SLEEPLOOP" &
Expand Down
2 changes: 2 additions & 0 deletions test/system/035-logs.bats
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,7 @@ timeout: sending signal TERM to command.*" "logs --since -f on running container
_log_test_follow_since k8s-file
}

# bats test_tags=distro-integration
@test "podman logs - --since --follow journald" {
# We can't use journald on RHEL as rootless: rhbz#1895105
skip_if_journald_unavailable
Expand Down Expand Up @@ -379,6 +380,7 @@ $content--2.*" "logs --until -f on running container works"
_log_test_follow_until k8s-file
}

# bats test_tags=distro-integration
@test "podman logs - --until --follow journald" {
# We can't use journald on RHEL as rootless: rhbz#1895105
skip_if_journald_unavailable
Expand Down
2 changes: 2 additions & 0 deletions test/system/070-build.bats
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

load helpers

# bats test_tags=distro-integration
@test "podman build - basic test" {
rand_filename=$(random_string 20)
rand_content=$(random_string 50)
Expand Down Expand Up @@ -267,6 +268,7 @@ EOF
}


# bats test_tags=distro-integration
@test "podman build - workdir, cmd, env, label" {
tmpdir=$PODMAN_TMPDIR/build-test
mkdir -p $tmpdir
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=distro-integration
@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=distro-integration
@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=distro-integration
@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=distro-integration
@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=distro-integration
@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=distro-integration
@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=distro-integration
@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=distro-integration
@test "podman kill - test signal handling in containers" {

# Prepare for 'logs -f'
Expand Down
1 change: 1 addition & 0 deletions test/system/160-volumes.bats
Original file line number Diff line number Diff line change
Expand Up @@ -395,6 +395,7 @@ EOF
is "$output" "" "no more volumes to prune"
}

# bats test_tags=distro-integration
@test "podman volume type=bind" {
myvoldir=${PODMAN_TMPDIR}/volume_$(random_string)
mkdir $myvoldir
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=distro-integration
#

load helpers

Expand Down
2 changes: 2 additions & 0 deletions test/system/180-blkio.bats
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
#
# podman blkio-related tests
#
# bats file_tags=distro-integration
#

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=distro-integration
#

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=distro-integration
@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=distro-integration
@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=distro-integration
@test "sdnotify : container" {
_prefetch $SYSTEMD_IMAGE

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

# bats test_tags=distro-integration
@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=distro-integration
@test "podman selinux: confined container" {
check_label "" "container_t"
}

# FIXME #19376 - container-selinux broken -- bats test_tags=distro-integration
@test "podman selinux: container with label=disable" {
check_label "--security-opt label=disable" "spc_t"
}

# FIXME #19376 - container-selinux broken -- bats test_tags=distro-integration
@test "podman selinux: privileged container" {
check_label "--privileged --userns=host" "spc_t"
}

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

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

# bats test_tags=distro-integration
@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"
}

# FIXME #19376 - container-selinux broken -- bats test_tags=distro-integration
@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=distro-integration
@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=distro-integration
@test "podman selinux: check relabel" {
skip_if_no_selinux

Expand Down
1 change: 1 addition & 0 deletions test/system/500-networking.bats
Original file line number Diff line number Diff line change
Expand Up @@ -449,6 +449,7 @@ load helpers.network
}

# Test for https://github.com/containers/podman/issues/10052
# bats test_tags=distro-integration
@test "podman network connect/disconnect with port forwarding" {
random_1=$(random_string 30)
HOST_PORT=$(random_free_port)
Expand Down