Skip to content

Commit

Permalink
CI: parallelize logs test as much as possible
Browse files Browse the repository at this point in the history
Any test that uses --events-backend=file cannot be run in parallel
due to containers#23750. This seems to be a hard block, unfixable.

All other tests, enable ci:parallel.

And, bring in timing fixes containers#23600. Thanks, @Honny1!

Signed-off-by: Ed Santiago <santiago@redhat.com>
  • Loading branch information
edsantiago committed Sep 23, 2024
1 parent edcee32 commit 4be6bf2
Showing 1 changed file with 27 additions and 10 deletions.
37 changes: 27 additions & 10 deletions test/system/035-logs.bats
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

load helpers

# bats test_tags=ci:parallel
@test "podman logs - basic test" {
rand_string=$(random_string 40)

Expand Down Expand Up @@ -62,10 +63,12 @@ function _log_test_tail() {
run_podman rm $cid
}

# CANNOT BE PARALLELIZED - #23750, events-backend=file cannot coexist with journal
@test "podman logs - tail test, k8s-file" {
_log_test_tail k8s-file
}

# bats test_tags=ci:parallel
@test "podman logs - tail test, journald" {
# We can't use journald on RHEL as rootless: rhbz#1895105
skip_if_journald_unavailable
Expand Down Expand Up @@ -117,10 +120,12 @@ ${cid[1]} b2" "Sequential output from c2"
run_podman rm -f -t0 ${cid[0]} ${cid[1]}
}

# CANNOT BE PARALLELIZED - #23750, events-backend=file cannot coexist with journal
@test "podman logs - multi k8s-file" {
_log_test_multi k8s-file
}

# bats test_tags=ci:parallel
@test "podman logs - multi journald" {
# We can't use journald on RHEL as rootless: rhbz#1895105
skip_if_journald_unavailable
Expand All @@ -146,17 +151,20 @@ function _log_test_restarted() {
run_podman rm -f -t0 $cname
}

# CANNOT BE PARALLELIZED - #23750, events-backend=file cannot coexist with journal
@test "podman logs restarted - k8s-file" {
_log_test_restarted k8s-file
}

# bats test_tags=ci:parallel
@test "podman logs restarted journald" {
# We can't use journald on RHEL as rootless: rhbz#1895105
skip_if_journald_unavailable

_log_test_restarted journald
}

# CANNOT BE PARALLELIZED - #23750, events-backend=file cannot coexist with journal
@test "podman logs - journald log driver requires journald events backend" {
skip_if_remote "remote does not support --events-backend"
# We can't use journald on RHEL as rootless: rhbz#1895105
Expand Down Expand Up @@ -203,10 +211,12 @@ $s_after"
run_podman rm -t 1 -f $cname
}

# CANNOT BE PARALLELIZED - #23750, events-backend=file cannot coexist with journal
@test "podman logs - since k8s-file" {
_log_test_since k8s-file
}

# bats test_tags=ci:parallel
@test "podman logs - since journald" {
# We can't use journald on RHEL as rootless: rhbz#1895105
skip_if_journald_unavailable
Expand Down Expand Up @@ -256,10 +266,12 @@ $s_after"
run_podman rm -t 0 -f $cname
}

# CANNOT BE PARALLELIZED - #23750, events-backend=file cannot coexist with journal
@test "podman logs - until k8s-file" {
_log_test_until k8s-file
}

# bats test_tags=ci:parallel
@test "podman logs - until journald" {
# We can't use journald on RHEL as rootless: rhbz#1895105
skip_if_journald_unavailable
Expand Down Expand Up @@ -289,10 +301,12 @@ $contentC" "logs -f on exited container works"
run_podman ${events_backend} rm -t 0 -f $cname
}

# CANNOT BE PARALLELIZED - #23750, events-backend=file cannot coexist with journal
@test "podman logs - --follow k8s-file" {
_log_test_follow k8s-file
}

# bats test_tags=ci:parallel
@test "podman logs - --follow journald" {
# We can't use journald on RHEL as rootless: rhbz#1895105
skip_if_journald_unavailable
Expand Down Expand Up @@ -320,25 +334,26 @@ function _log_test_follow_since() {

# Now do the same with a running container to check #16950.
run_podman ${events_backend} run --log-driver=$driver --name $cname -d $IMAGE \
sh -c "sleep 1; while :; do echo $content && sleep 5; done"
sh -c "sleep 1; while :; do echo $content && sleep 1; done"

# sleep is required to make sure the podman event backend no longer sees the start event in the log
# This value must be greater or equal than the value given in --since below
sleep 0.2

# Make sure podman logs actually follows by giving a low timeout and check that the command times out
PODMAN_TIMEOUT=3 run_podman 124 ${events_backend} logs --since 0.1s -f $cname
assert "$output" =~ "^$content
assert "$output" =~ "$content
timeout: sending signal TERM to command.*" "logs --since -f on running container works"

run_podman ${events_backend} rm -t 0 -f $cname
}

# CANNOT BE PARALLELIZED - #23750, events-backend=file cannot coexist with journal
@test "podman logs - --since --follow k8s-file" {
_log_test_follow_since k8s-file
}

# bats test_tags=distro-integration
# bats test_tags=distro-integration, ci:parallel
@test "podman logs - --since --follow journald" {
# We can't use journald on RHEL as rootless: rhbz#1895105
skip_if_journald_unavailable
Expand All @@ -359,16 +374,16 @@ function _log_test_follow_until() {
run_podman ${events_backend} run --log-driver=$driver --name $cname -d $IMAGE \
sh -c "n=1;while :; do echo $content--\$n; n=\$((n+1));sleep 0.1; done"

t0=$SECONDS
t0=$(date +%s%3N)
# The logs command should exit after the until time even when follow is set
PODMAN_TIMEOUT=10 run_podman ${events_backend} logs --until 3s -f $cname
t1=$SECONDS
t1=$(date +%s%3N)
logs_seen="$output"

# The delta should be 3 but because it could be a bit longer on a slow system such as CI we also accept 4.
delta_t=$(( $t1 - $t0 ))
assert $delta_t -gt 2 "podman logs --until: exited too early!"
assert $delta_t -lt 5 "podman logs --until: exited too late!"
# The delta should be 3 but could be longer on a slow CI system
delta_t_ms=$(( $t1 - $t0 ))
assert $delta_t_ms -gt 2000 "podman logs --until: exited too early!"
assert $delta_t_ms -lt 5000 "podman logs --until: exited too late!"

# Impossible to know how many lines we'll see, but require at least two
assert "$logs_seen" =~ "$content--1
Expand All @@ -377,11 +392,12 @@ $content--2.*" "logs --until -f on running container works"
run_podman ${events_backend} rm -t 0 -f $cname
}

# CANNOT BE PARALLELIZED - #23750, events-backend=file cannot coexist with journal
@test "podman logs - --until --follow k8s-file" {
_log_test_follow_until k8s-file
}

# bats test_tags=distro-integration
# bats test_tags=distro-integration, ci:parallel
@test "podman logs - --until --follow journald" {
# We can't use journald on RHEL as rootless: rhbz#1895105
skip_if_journald_unavailable
Expand All @@ -390,6 +406,7 @@ $content--2.*" "logs --until -f on running container works"
}

# https://github.com/containers/podman/issues/19545
# CANNOT BE PARALLELIZED - #23750, events-backend=file cannot coexist with journal
@test "podman logs --tail, k8s-file with partial lines" {
cname="c-$(safename)"

Expand Down

0 comments on commit 4be6bf2

Please sign in to comment.