teknoraver / rpms / systemd

Forked from rpms/systemd 3 months ago
Clone

Blame SOURCES/0190-test-show-and-check-almost-all-journal-entries-since.patch

ac3a84
From 3e7bcbb274618a0d3cea9027db4e6abb1207f27d Mon Sep 17 00:00:00 2001
ac3a84
From: Yu Watanabe <watanabe.yu+github@gmail.com>
ac3a84
Date: Fri, 16 Dec 2022 01:11:39 +0900
ac3a84
Subject: [PATCH] test: show and check almost all journal entries since the
ac3a84
 relevant command being invoked
ac3a84
MIME-Version: 1.0
ac3a84
Content-Type: text/plain; charset=UTF-8
ac3a84
Content-Transfer-Encoding: 8bit
ac3a84
ac3a84
For some reasons, journal timestamps from other sources sometimes
ac3a84
inconsistent. For example,
ac3a84
```
ac3a84
$ journalctl --file system.journal -o short-monotonic -u resmontest.service
ac3a84
[ 1112.168109] ns1.unsigned.test resolvectl[419]: → Q: ns1.unsigned.test IN AAAA
ac3a84
[ 1112.168109] ns1.unsigned.test resolvectl[419]: ← S: success
ac3a84
[ 1112.168109] ns1.unsigned.test resolvectl[419]: → Q: ns1.unsigned.test IN A
ac3a84
[ 1112.168109] ns1.unsigned.test resolvectl[419]: ← S: success
ac3a84
[ 1112.168109] ns1.unsigned.test resolvectl[419]: ← A: ns1.unsigned.test IN A 10.0.0.1
ac3a84
[ 1112.171961] ns1.unsigned.test systemd[1]: resmontest.service: Failed to load configuration: No such file or directory
ac3a84
[ 1112.172223] ns1.unsigned.test systemd[1]: resmontest.service: Trying to enqueue job resmontest.service/start/fail
ac3a84
[ 1112.179866] ns1.unsigned.test systemd[1]: resmontest.service: Installed new job resmontest.service/start as 312
ac3a84
[ 1112.179894] ns1.unsigned.test systemd[1]: resmontest.service: Enqueued job resmontest.service/start as 312
ac3a84
[ 1112.180389] ns1.unsigned.test systemd[1]: resmontest.service: Will spawn child (service_enter_start): /usr/bin/resolvectl
ac3a84
[ 1112.180418] ns1.unsigned.test systemd[1]: resmontest.service: Passing 0 fds to service
ac3a84
[ 1112.180447] ns1.unsigned.test systemd[1]: resmontest.service: About to execute /usr/bin/resolvectl monitor
ac3a84
[ 1112.180477] ns1.unsigned.test systemd[1]: resmontest.service: Forked /usr/bin/resolvectl as 419
ac3a84
[ 1112.180619] ns1.unsigned.test systemd[1]: resmontest.service: Changed dead -> start
ac3a84
[ 1112.180651] ns1.unsigned.test systemd[1]: Starting resmontest.service...
ac3a84
[ 1112.180799] ns1.unsigned.test systemd[419]: resmontest.service: Kernel keyring access prohibited, ignoring.
ac3a84
[ 1112.180895] ns1.unsigned.test systemd[419]: resmontest.service: Executing: /usr/bin/resolvectl monitor
ac3a84
[ 1112.181383] ns1.unsigned.test systemd[1]: resmontest.service: Got notification message from PID 419 (READY=1)
ac3a84
[ 1112.181413] ns1.unsigned.test systemd[1]: resmontest.service: Changed start -> running
ac3a84
[ 1112.181441] ns1.unsigned.test systemd[1]: resmontest.service: Job 312 resmontest.service/start finished, result=done
ac3a84
[ 1112.181469] ns1.unsigned.test systemd[1]: Started resmontest.service.
ac3a84
```
ac3a84
In such case, `journalctl -f` may not show the entries what we are interested in.
ac3a84
ac3a84
Fixes #25749. (At least, workarond for the issue.)
ac3a84
ac3a84
(cherry picked from commit ad48ff12bd0f7b19dc6bfa33c96221fd9c22e89c)
ac3a84
ac3a84
Related: #2138081
ac3a84
---
ac3a84
 test/units/testsuite-75.sh | 22 +++++++++++++---------
ac3a84
 1 file changed, 13 insertions(+), 9 deletions(-)
ac3a84
ac3a84
diff --git a/test/units/testsuite-75.sh b/test/units/testsuite-75.sh
ac3a84
index 844dbaebcc..852caac605 100755
ac3a84
--- a/test/units/testsuite-75.sh
ac3a84
+++ b/test/units/testsuite-75.sh
ac3a84
@@ -19,13 +19,14 @@ run() {
ac3a84
 monitor_check_rr() (
ac3a84
     set +x
ac3a84
     set +o pipefail
ac3a84
-    local match="${1:?}"
ac3a84
+    local since="${1:?}"
ac3a84
+    local match="${2:?}"
ac3a84
 
ac3a84
     # Wait until the first mention of the specified log message is
ac3a84
     # displayed. We turn off pipefail for this, since we don't care about the
ac3a84
     # lhs of this pipe expression, we only care about the rhs' result to be
ac3a84
     # clean
ac3a84
-    journalctl -u resmontest.service -f --full | grep -m1 "$match"
ac3a84
+    journalctl -u resmontest.service --since "$since" -f --full | grep -m1 "$match"
ac3a84
 )
ac3a84
 
ac3a84
 # Test for resolvectl, resolvconf
ac3a84
@@ -232,9 +233,10 @@ knotc reload
ac3a84
 
ac3a84
 : "--- nss-resolve/nss-myhostname tests"
ac3a84
 # Sanity check
ac3a84
+TIMESTAMP=$(date '+%F %T')
ac3a84
 run getent -s resolve hosts ns1.unsigned.test
ac3a84
 grep -qE "^10\.0\.0\.1\s+ns1\.unsigned\.test" "$RUN_OUT"
ac3a84
-monitor_check_rr "ns1.unsigned.test IN A 10.0.0.1"
ac3a84
+monitor_check_rr "$TIMESTAMP" "ns1.unsigned.test IN A 10.0.0.1"
ac3a84
 
ac3a84
 # Issue: https://github.com/systemd/systemd/issues/18812
ac3a84
 # PR: https://github.com/systemd/systemd/pull/18896
ac3a84
@@ -324,15 +326,16 @@ run delv dupe.signed.test
ac3a84
 grep -qF "; fully validated" "$RUN_OUT"
ac3a84
 
ac3a84
 # Test resolution of CNAME chains
ac3a84
+TIMESTAMP=$(date '+%F %T')
ac3a84
 run resolvectl query -t A cname-chain.signed.test
ac3a84
 grep -qF "follow14.final.signed.test IN A 10.0.0.14" "$RUN_OUT"
ac3a84
 grep -qF "authenticated: yes" "$RUN_OUT"
ac3a84
 
ac3a84
-monitor_check_rr "follow10.so.close.signed.test IN CNAME follow11.yet.so.far.signed.test"
ac3a84
-monitor_check_rr "follow11.yet.so.far.signed.test IN CNAME follow12.getting.hot.signed.test"
ac3a84
-monitor_check_rr "follow12.getting.hot.signed.test IN CNAME follow13.almost.final.signed.test"
ac3a84
-monitor_check_rr "follow13.almost.final.signed.test IN CNAME follow14.final.signed.test"
ac3a84
-monitor_check_rr "follow14.final.signed.test IN A 10.0.0.14"
ac3a84
+monitor_check_rr "$TIMESTAMP" "follow10.so.close.signed.test IN CNAME follow11.yet.so.far.signed.test"
ac3a84
+monitor_check_rr "$TIMESTAMP" "follow11.yet.so.far.signed.test IN CNAME follow12.getting.hot.signed.test"
ac3a84
+monitor_check_rr "$TIMESTAMP" "follow12.getting.hot.signed.test IN CNAME follow13.almost.final.signed.test"
ac3a84
+monitor_check_rr "$TIMESTAMP" "follow13.almost.final.signed.test IN CNAME follow14.final.signed.test"
ac3a84
+monitor_check_rr "$TIMESTAMP" "follow14.final.signed.test IN A 10.0.0.14"
ac3a84
 
ac3a84
 # Non-existing RR + CNAME chain
ac3a84
 run dig +dnssec AAAA cname-chain.signed.test
ac3a84
@@ -370,9 +373,10 @@ grep -qF 'this.should.be.authenticated.wild.onlinesign.test IN TXT "this is an o
ac3a84
 grep -qF "authenticated: yes" "$RUN_OUT"
ac3a84
 
ac3a84
 # Resolve via dbus method
ac3a84
+TIMESTAMP=$(date '+%F %T')
ac3a84
 run busctl call org.freedesktop.resolve1 /org/freedesktop/resolve1 org.freedesktop.resolve1.Manager ResolveHostname 'isit' 0 secondsub.onlinesign.test 0 0
ac3a84
 grep -qF '10 0 0 134 "secondsub.onlinesign.test"' "$RUN_OUT"
ac3a84
-monitor_check_rr "secondsub.onlinesign.test IN A 10.0.0.134"
ac3a84
+monitor_check_rr "$TIMESTAMP" "secondsub.onlinesign.test IN A 10.0.0.134"
ac3a84
 
ac3a84
 : "--- ZONE: untrusted.test (DNSSEC without propagated DS records) ---"
ac3a84
 run dig +short untrusted.test