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