-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
test/system: Add test for journald log check in quadlet #22736
Conversation
Ephemeral COPR build failed. @containers/packit-build please check. |
/release-note-none |
test/system/252-quadlet.bats
Outdated
cat > $quadlet_file <<EOF | ||
[Container] | ||
Image=$IMAGE | ||
Exec=sh -c "echo I AM AN OUTPUT; echo I AM AN ERROR 1>&2; sleep inf" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This test takes over 10s because sleep does not react to SIGTERM. please use a different command or set StopTimeout=0 in the quadlet file
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Got it. Will update the command.
test/system/252-quadlet.bats
Outdated
@@ -1542,4 +1542,27 @@ EOF | |||
service_cleanup $QUADLET_SERVICE_NAME inactive | |||
run_podman rmi $untagged_image:latest $built_image $(pause_image) | |||
} | |||
|
|||
@test "quadlet - output and error message" { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We already check the journal in quadlet - oneshot
, I suggest you add you stdout/err check in this test for timing reasons
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @Luap99 Thanks a lot for your advice. But in the oneshot case the point it write the logs to journald is a little different. In oneshot case the log is checked after the process is finished. But in this case want to check if we can get the logs during the process is still running just like a normal services. So I'd like to keep it a separated one.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for your PR. Can you clarify what the purpose of that testing would be? Is there some reason to believe that podman could possibly buffer journal output until a process terminates? There is buffering / time delay going on, but it is not podman's fault. And as @Luap99 mentioned, your test will flake due to this race condition.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This case want to check the services that started by the service file generated from quadlet can send stdout/stderr/syslog to the journal. Normally the services will keep running so from the user view there maybe have a slight different with the test case with oneshot. I am not saying there is problem exist in the podman write logs to journal during the process is running, but that is something that my test scenario want to covered and checked.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is fine to cover that but I think it still makes more sense to just extend an existing test for that.
The quadlet tests are not exactly fast as they need to generate/daemon-reload/start unit every time so I think it would help if you just add the print to an existing unit
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I still prefer this being added to an existing test, i.e. "quadlet - ContainerName
.
quadlet tests are slow (around 2.5s), it does not sounds like much but in the sum this adds up quickly.
As person doing a lot of work to speed system test up (#22826, #22821) we really need to be more careful when adding new tests.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just checked the “quadlet - ContainerName” I think it is OK to combine them to one test. Will update the steps to it.
test/system/252-quadlet.bats
Outdated
run journalctl "--since=$STARTED_TIME" --unit="$QUADLET_SERVICE_NAME" | ||
assert "$output" =~ 'I AM AN OUTPUT' "Output can be found with journalctl" | ||
assert "$output" =~ 'I AM AN ERROR' "Error can be found with journalctl" | ||
assert "$output" =~ "Starting $QUADLET_SERVICE_NAME" "Status information can be found with journalctl" | ||
|
||
run journalctl "--since=$STARTED_TIME" -p 3 --unit="$QUADLET_SERVICE_NAME" | ||
assert "$output" =~ 'I AM AN ERROR' "Error can be found with journalctl -p 3" | ||
assert "$output" != .*"I AM AN OUTPUT".* "Output can not be found with journalctl -p 3" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is racy you first have to wait for the output to be logged but I really suggest to add it to the other test instead where it already works without flakes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Understand it. Will add a wait for here to ignore that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks again for your PR. Please do clarify the perceived problem that this test addresses. A few comments inline should you wish to continue with this approach.
test/system/252-quadlet.bats
Outdated
run_quadlet "$quadlet_file" | ||
service_setup $QUADLET_SERVICE_NAME | ||
|
||
run journalctl "--since=$STARTED_TIME" --unit="$QUADLET_SERVICE_NAME" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Due to the systemd race condition, this will have to be done in a while/timeout loop. (If you choose to continue with this testing approach).
test/system/252-quadlet.bats
Outdated
assert "$output" =~ 'I AM AN ERROR' "Error can be found with journalctl" | ||
assert "$output" =~ "Starting $QUADLET_SERVICE_NAME" "Status information can be found with journalctl" | ||
|
||
run journalctl "--since=$STARTED_TIME" -p 3 --unit="$QUADLET_SERVICE_NAME" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No undocumented magic constants, please, those make it very hard for future maintainers. This might be better:
# log priority 3 == err
run journalctl ... --priority 3 ...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Got it. Will update it. Thanks a lot for the advice.
Hi @edsantiago and @Luap99 Updated the tests based on your advices. Can you help to review it again? Thanks a lot! |
Hi @Luap99 commit updated to add steps to “quadlet - ContainerName” case. Please help to review it. Thanks a lot! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for adding to the existing test. A few suggestions inline, and one blocker.
test/system/252-quadlet.bats
Outdated
sleep "$step" | ||
count=$(( count - 1 )) | ||
done | ||
die "Wait for $expect_str shows up in journalctl output timeout" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggestion: "Timed out waiting for '$expect_str' in journal"
Hi @edsantiago Thanks a lot for your comments. Update the pullreq again. Can you help to review it? Thanks a lot! |
Hi @ypu, I think we're stuck waiting for each other. Are you waiting for my review? I cannot review until CI passes, and CI is not passing. So I am waiting for you to fix that. I believe the current problem has been fixed in main, so it should be very easy to fix by simply rebasing. At your convenience, please rebase and repush. Once CI passes, please feel free to ping me again. |
Add some test steps into quadlet - ContainerName. These steps are used to ensure the default configuration for quadlets generated service files is sending stdout/stderr/syslog to the journald. Signed-off-by: Yiqiao Pu <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thank you!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/lgtm
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: edsantiago, Luap99, ypu The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
This test is used to ensure the default configuration for quadlets generated service files is sending stdout/stderr/syslog to the journald.
Does this PR introduce a user-facing change?