Skip to content

Commit

Permalink
Merge pull request #17603 from edsantiago/bats_cleanup
Browse files Browse the repository at this point in the history
Logs follow-until tests: loosen checks
  • Loading branch information
openshift-merge-robot authored Feb 22, 2023
2 parents d5a8248 + 12153da commit d71c341
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 15 deletions.
3 changes: 1 addition & 2 deletions test/system/010-images.bats
Original file line number Diff line number Diff line change
Expand Up @@ -272,8 +272,7 @@ Deleted: $pauseID" "infra images gets removed as well"
pname=$(random_string)
run_podman create --pod new:$pname $IMAGE

run_podman version --format "{{.Server.Version}}-{{.Server.Built}}"
pauseImage=localhost/podman-pause:$output
pauseImage=$(pause_image)
run_podman inspect --format '{{.ID}}' $pauseImage
pauseID=$output

Expand Down
10 changes: 6 additions & 4 deletions test/system/035-logs.bats
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ function _log_test_multi() {
doit c2 "sleep 1;echo b;sleep 2;echo c;sleep 3"

run_podman ${events_backend} logs -f c1 c2
is "$output" \
assert "$output" =~ \
"${cid[0]} a$etc
${cid[1]} b$etc
${cid[1]} c$etc
Expand Down Expand Up @@ -355,20 +355,22 @@ function _log_test_follow_until() {
fi

run_podman ${events_backend} run --log-driver=$driver --name $cname -d $IMAGE \
sh -c "while :; do echo $content && sleep 2; done"
sh -c "n=1;while :; do echo $content--\$n; n=\$((n+1));sleep 1; done"

t0=$SECONDS
# 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
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!"

assert "$output" == "$content
$content" "logs --until -f on running container works"
# Impossible to know how many lines we'll see, but require at least two
assert "$logs_seen" =~ "$content--1
$content--2.*" "logs --until -f on running container works"

run_podman ${events_backend} rm -t 0 -f $cname
}
Expand Down
4 changes: 2 additions & 2 deletions test/system/170-run-userns.bats
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,7 @@ function _require_crun() {

# Remove the pod and the pause image
run_podman pod rm $random_pod_name
run_podman version --format "{{.Server.Version}}-{{.Server.Built}}"
run_podman rmi -f localhost/podman-pause:$output
run_podman rmi -f $(pause_image)
}

@test "podman --remote --group-add keep-groups " {
Expand Down Expand Up @@ -142,4 +141,5 @@ EOF
pid=$output
run_podman run --rm --pod $pid $IMAGE id -u
is "${output}" "$user" "Container should run as the current user"
run_podman rmi -f $(pause_image)
}
17 changes: 12 additions & 5 deletions test/system/500-networking.bats
Original file line number Diff line number Diff line change
Expand Up @@ -665,21 +665,28 @@ EOF
if is_netavark; then
assert "$store" == "search example.com${nl}nameserver $subnet.1" "only integrated dns nameserver is set"
else
is "$store" ".*nameserver 1.1.1.1${nl}nameserver $searchIP${nl}nameserver 1.0.0.1${nl}nameserver 8.8.8.8" "nameserver order is correct"
assert "$store" == "search example.com
nameserver 1.1.1.1
nameserver $searchIP
nameserver 1.0.0.1
nameserver 8.8.8.8" "nameserver order is correct"
fi
# we should use the integrated dns server
run_podman run --network $netname --rm $IMAGE cat /etc/resolv.conf
is "$output" "search dns.podman.*" "correct search domain"
is "$output" ".*nameserver $subnet.1.*" "integrated dns nameserver is set"
assert "$output" =~ "search dns.podman.*" "correct search domain"
assert "$output" =~ ".*nameserver $subnet.1.*" \
"integrated dns nameserver is set"

# host network should keep localhost nameservers
if grep 127.0.0. /etc/resolv.conf >/dev/null; then
run_podman run --network host --rm $IMAGE cat /etc/resolv.conf
is "$output" ".*nameserver 127\.0\.0.*" "resolv.conf contains localhost nameserver"
assert "$output" =~ ".*nameserver 127\.0\.0.*" \
"resolv.conf contains localhost nameserver"
fi
# host net + dns still works
run_podman run --network host --dns 1.1.1.1 --rm $IMAGE cat /etc/resolv.conf
is "$output" ".*nameserver 1\.1\.1\.1.*" "resolv.conf contains 1.1.1.1 nameserver"
assert "$output" =~ ".*nameserver 1\.1\.1\.1.*" \
"resolv.conf contains 1.1.1.1 nameserver"
}

@test "podman run port forward range" {
Expand Down
3 changes: 1 addition & 2 deletions test/system/700-play.bats
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,7 @@ RELABEL="system_u:object_r:container_file_t:s0"
# Make sure that the K8s pause image isn't pulled but the local podman-pause is built.
run_podman images
run_podman 1 image exists k8s.gcr.io/pause
run_podman version --format "{{.Server.Version}}-{{.Server.Built}}"
run_podman image exists localhost/podman-pause:$output
run_podman image exists $(pause_image)

run_podman stop -a -t 0
run_podman pod rm -t 0 -f test_pod
Expand Down

0 comments on commit d71c341

Please sign in to comment.