]> git.ipfire.org Git - thirdparty/chrony.git/commitdiff
test: make system tests more reliable
authorMiroslav Lichvar <mlichvar@redhat.com>
Thu, 15 Apr 2021 09:26:29 +0000 (11:26 +0200)
committerMiroslav Lichvar <mlichvar@redhat.com>
Thu, 15 Apr 2021 13:17:13 +0000 (15:17 +0200)
test/system/007-cmdmon
test/system/008-confload
test/system/010-nts
test/system/test.common

index 870c551acd55cf97c66ea67cb468bfce990e2274..abacb7a5cf2c22b33f4e10a2711e4f2e82541520 100755 (executable)
@@ -28,9 +28,9 @@ for command in \
        "maxdelay $server 1e-1" \
        "maxdelaydevratio $server 5.0" \
        "maxdelayratio $server 3.0" \
-       "maxpoll $server 5" \
+       "maxpoll $server 12" \
        "maxupdateskew $server 10.0" \
-       "minpoll $server 3" \
+       "minpoll $server 10" \
        "minstratum $server 1" \
        "offline" \
        "online" \
@@ -66,7 +66,7 @@ check_chronyc_output "^Name/IP address             Mode KeyID Type KLen Last Atm
 run_chronyc "clients" || test_fail
 check_chronyc_output "^Hostname                      NTP   Drop Int IntL Last     Cmd   Drop Int  Last
 ===============================================================================
-127\.0\.0\.1                       [0-9 ]+    0 [-0-9 ]+   -     [0-9]       0      0   -     -$" \
+127\.0\.0\.1               [0-9 ]+    0 [-0-9 ]+   -  [ 0-9]+       0      0   -     -$" \
        || test_fail
 
 run_chronyc "ntpdata $server" || test_fail
@@ -77,7 +77,7 @@ Leap status     : Normal
 Version         : 4
 Mode            : Server
 Stratum         : 10
-Poll interval   : (-6|[0345]) \([0-9]+ seconds\)
+Poll interval   : (-6|[0-9]+) \([0-9]+ seconds\)
 Precision       : [0-9 +-]+ \(0\.[0-9]+ seconds\)
 Root delay      : 0\.000000 seconds
 Root dispersion : 0\.000000 seconds
index 689e38b7e8a0dd023be1dd32234e386f98a483c7..a7fc1d52ace99bce4896330767569f7883ba47f2 100755 (executable)
@@ -32,7 +32,6 @@ echo "server 127.123.5.2" > $TEST_DIR/conf5.d/2.sources
 echo "server 127.123.5.3" > $TEST_DIR/conf5.d/3.sources
 
 start_chronyd || test_fail
-wait_for_sync || test_fail
 
 run_chronyc "sources" || test_fail
 check_chronyc_output "^[^=]*
@@ -66,8 +65,8 @@ check_chronyc_output "^[^=]*
 .. 127\.123\.2\.2 [^^]*
 .. 127\.123\.2\.3 [^^]*
 .. 127\.123\.4\.4 [^^]*
-.. 127\.123\.1\.2 *0   6 [^^]*
-.. 127\.123\.5\.2 *0   7 [^^]*
+.. 127\.123\.1\.2 *[05]   6 [^^]*
+.. 127\.123\.5\.2 *[05]   7 [^^]*
 .. 127\.123\.5\.4 [^^]*$" || test_fail
 
 stop_chronyd || test_fail
index ff8a5c5b34825d5179db9068560c0a387e44bd25..7897ceb05ea2bbe6aaa7f92e48fd8946f7896294 100755 (executable)
@@ -40,7 +40,7 @@ ntsdumpdir $TEST_LIBDIR
 ntsprocesses 3"
 
 start_chronyd || test_fail
-sleep 3
+wait_for_sync || test_fail
 
 run_chronyc "authdata" || test_fail
 check_chronyc_output "^Name/IP address             Mode KeyID Type KLen Last Atmp  NAK Cook CLen
@@ -56,7 +56,7 @@ rm -f $TEST_LOGDIR/measurements.log
 server_options="port $ntpport nts ntsport $((ntsport + 1))"
 
 start_chronyd || test_fail
-sleep 2
+wait_for_sync || test_fail
 
 run_chronyc "authdata" || test_fail
 check_chronyc_output "^Name/IP address             Mode KeyID Type KLen Last Atmp  NAK Cook CLen
index 8671649e598158e58437e5adff152d306ec5edd4..2c5b2597e069f6b71c6fb9f9b2edc8836ccfbff8 100644 (file)
@@ -262,8 +262,23 @@ start_chronyd() {
 }
 
 wait_for_sync() {
+       local prev_length
+
        test_message 1 0 "waiting for synchronization"
-       sleep 1 && test_ok || test_error
+       prev_length=$msg_length
+
+       for i in $(seq 1 10); do
+               run_chronyc "ntpdata $server" > /dev/null 2>&1 || break
+               if check_chronyc_output "Total RX +: [1-9]" > /dev/null 2>&1; then
+                       msg_length=$prev_length
+                       test_ok
+                       return
+               fi
+               sleep 1
+       done
+
+       msg_length=$prev_length
+       test_error
 }
 
 # Stop the chronyd instance