Skip to content

Commit

Permalink
Misc minor test fixes
Browse files Browse the repository at this point in the history
...for dealing with flakes in parallel mode

Signed-off-by: Ed Santiago <[email protected]>
  • Loading branch information
edsantiago committed Sep 17, 2024
1 parent 7fcf94d commit 8402b65
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 11 deletions.
4 changes: 2 additions & 2 deletions test/system/055-rm.bats
Original file line number Diff line number Diff line change
Expand Up @@ -127,10 +127,10 @@ function __run_healthcheck_container() {
run_podman run -d --name $1 \
--health-cmd /bin/false \
--health-interval 1s \
--health-retries 1 \
--health-retries 2 \
--health-timeout 1s \
--health-on-failure=stop \
--stop-timeout=1 \
--stop-timeout=2 \
--health-start-period 0 \
--stop-signal SIGTERM \
$IMAGE sleep infinity
Expand Down
7 changes: 6 additions & 1 deletion test/system/220-healthcheck.bats
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,12 @@ function _check_health {
local hc_status="$5"

# Loop-wait (up to a few seconds) for healthcheck event (#20342)
# Allow a margin when running parallel, because of system load
local timeout=5
if [[ -n "$PARALLEL_JOBSLOT" ]]; then
timeout=$((timeout + 3))
fi

while :; do
run_podman events --filter container=$ctrname --filter event=health_status \
--since "$since" --stream=false --format "{{.HealthStatus}}"
Expand Down Expand Up @@ -157,7 +162,7 @@ Log[-1].Output | \"Uh-oh on stdout!\\\nUh-oh on stderr!\\\n\"

# Wait for the container in the background and create the $wait_file to
# signal the specified wait condition was met.
(timeout --foreground -v --kill=5 5 $PODMAN wait --condition=$condition $ctr && touch $wait_file) &
(timeout --foreground -v --kill=5 10 $PODMAN wait --condition=$condition $ctr && touch $wait_file) &

# Sleep 1 second to make sure above commands are running
sleep 1
Expand Down
6 changes: 4 additions & 2 deletions test/system/252-quadlet.bats
Original file line number Diff line number Diff line change
Expand Up @@ -428,12 +428,14 @@ EOF

# A quadlet container depends on a named quadlet volume
@test "quadlet - named volume dependency" {
local volume_name="v-$(safename)"

# Save the unit name to use as the volume for the container
local quadlet_vol_unit=dep_$(safename).volume
local quadlet_vol_file=$PODMAN_TMPDIR/${quadlet_vol_unit}
cat > $quadlet_vol_file <<EOF
[Volume]
VolumeName=foo
VolumeName=$volume_name
EOF

# Have quadlet create the systemd unit file for the volume unit
Expand All @@ -442,7 +444,6 @@ EOF

# Save the volume service name since the variable will be overwritten
local vol_service=$QUADLET_SERVICE_NAME
local volume_name="foo"

local quadlet_file=$PODMAN_TMPDIR/user_$(safename).container
cat > $quadlet_file <<EOF
Expand Down Expand Up @@ -975,6 +976,7 @@ EOF

service_setup $QUADLET_SERVICE_NAME

# FIXME: log.91: Starting, not Started
# Ensure we have output. Output is synced via sd-notify (socat in Exec)
run journalctl "--since=$STARTED_TIME" --unit="$QUADLET_SERVICE_NAME"
is "$output" '.*Started.*\.service.*'
Expand Down
19 changes: 13 additions & 6 deletions test/system/500-networking.bats
Original file line number Diff line number Diff line change
Expand Up @@ -169,18 +169,25 @@ load helpers.network
local con2_name=con2-$(safename)
run_podman pod create --name $pod_name --infra-name $infra_name
pid="$output"
run_podman run --pod $pod_name --name $con1_name $IMAGE cat /etc/hosts
is "$output" ".*\s$pod_name $infra_name.*" "Pod hostname in /etc/hosts"
is "$output" ".*127.0.0.1\s$con1_name.*" "Container1 name in /etc/hosts"
run_podman run --rm --pod $pod_name --name $con1_name $IMAGE cat /etc/hosts
assert "$output" =~ ".*\s$pod_name $infra_name.*" \
"Pod hostname in /etc/hosts"
assert "$output" =~ ".*127.0.0.1\s$con1_name.*" \
"Container1 name in /etc/hosts"
# get the length of the hosts file
old_lines=${#lines[@]}

# since the first container should be cleaned up now we should only see the
# new host entry and the old one should be removed (lines check)
run_podman run --pod $pod_name --name $con2_name $IMAGE cat /etc/hosts
is "$output" ".*\s$pod_name $infra_name.*" "Pod hostname in /etc/hosts"
is "$output" ".*127.0.0.1\s$con2_name.*" "Container2 name in /etc/hosts"
is "${#lines[@]}" "$old_lines" "Number of hosts lines is equal"
assert "$output" =~ ".*\s$pod_name $infra_name.*" \
"Pod hostname in /etc/hosts"
assert "$output" =~ ".*127.0.0.1\s$con2_name.*" \
"Container2 name in /etc/hosts"
assert "$output" !~ "$con1_name" \
"Container1 name should not be in /etc/hosts"
is "${#lines[@]}" "$old_lines" \
"Number of hosts lines is equal"

run_podman run --pod $pod_name $IMAGE sh -c "hostname && cat /etc/hostname"
is "${lines[0]}" "$pod_name" "hostname is the pod hostname"
Expand Down

0 comments on commit 8402b65

Please sign in to comment.