From a9f0c681cb427ade46ee53b57ff08be6e5fbd98d Mon Sep 17 00:00:00 2001 From: Miroslav Lichvar Date: Thu, 15 Apr 2021 11:26:29 +0200 Subject: [PATCH] test: make system tests more reliable --- test/system/007-cmdmon | 8 ++++---- test/system/008-confload | 5 ++--- test/system/010-nts | 4 ++-- test/system/test.common | 17 ++++++++++++++++- 4 files changed, 24 insertions(+), 10 deletions(-) diff --git a/test/system/007-cmdmon b/test/system/007-cmdmon index 870c551..abacb7a 100755 --- a/test/system/007-cmdmon +++ b/test/system/007-cmdmon @@ -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 diff --git a/test/system/008-confload b/test/system/008-confload index 689e38b..a7fc1d5 100755 --- a/test/system/008-confload +++ b/test/system/008-confload @@ -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 diff --git a/test/system/010-nts b/test/system/010-nts index ff8a5c5..7897ceb 100755 --- a/test/system/010-nts +++ b/test/system/010-nts @@ -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 diff --git a/test/system/test.common b/test/system/test.common index 8671649..2c5b259 100644 --- a/test/system/test.common +++ b/test/system/test.common @@ -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