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 Test Quadlet - Volume dependency test did not test the dependency #16970

Merged
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
30 changes: 20 additions & 10 deletions test/system/252-quadlet.bats
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ function service_cleanup() {
if [[ -n "$expected_state" ]]; then
run systemctl show --property=ActiveState "$service"
assert "$output" = "ActiveState=$expected_state" \
"state of service after systemctl stop"
"state of service $service after systemctl stop"
fi

rm -f "$UNIT_DIR/$service"
Expand Down Expand Up @@ -246,13 +246,17 @@ EOF

# A quadlet container depends on a quadlet volume
@test "quadlet - volume dependency" {
local quadlet_vol_file=$PODMAN_TMPDIR/dep_$(random_string).volume
# Save the unit name to use as the volume for the container
local quadlet_vol_unit=dep_$(random_string).volume
local quadlet_vol_file=$PODMAN_TMPDIR/${quadlet_vol_unit}
cat > $quadlet_vol_file <<EOF
[Volume]
EOF

# Have quadlet create the systemd unit file for the volume unit
run_quadlet "$quadlet_vol_file"

# Save the volume service name since the variable will be overwritten
local vol_service=$QUADLET_SERVICE_NAME
local volume_name=systemd-$(basename $quadlet_vol_file .volume)

Expand All @@ -261,26 +265,32 @@ EOF
[Container]
Image=$IMAGE
Exec=top
Volume=$vol_service:/tmp
Volume=$quadlet_vol_unit:/tmp
EOF

# Have quadlet create the systemd unit file for the container unit
run_quadlet "$quadlet_file"

# Save the container service name for readability
local container_service=$QUADLET_SERVICE_NAME

# Volume should not exist
run_podman volume ls
assert "$output" !~ ".*${volume_name}.*"
run_podman 1 volume exists ${volume_name}

service_setup $QUADLET_SERVICE_NAME
# Start the container service which should also trigger the start of the volume service
service_setup $container_service

# Volume system unit should be active
run systemctl show --property=ActiveState "$vol_service"
assert "$output" = "ActiveState=active" \
"volume should be active via dependency"

# Volume should exist
volume_name=systemd-$(basename $quadlet_vol_file .volume)
run_podman volume ls
is "$output" ".*local.*${volume_name}.*"
run_podman volume exists ${volume_name}

service_cleanup $QUADLET_SERVICE_NAME inactive
# Shutdown the service and remove the volume
service_cleanup $container_service failed
run_podman volume rm $volume_name
}

@test "quadlet kube - basic" {
Expand Down