test: make system tests more reliable

This commit is contained in:
Miroslav Lichvar 2021-04-15 11:26:29 +02:00
parent 862aa285a2
commit a9f0c681cb
4 changed files with 24 additions and 10 deletions

View file

@ -28,9 +28,9 @@ for command in \
"maxdelay $server 1e-1" \ "maxdelay $server 1e-1" \
"maxdelaydevratio $server 5.0" \ "maxdelaydevratio $server 5.0" \
"maxdelayratio $server 3.0" \ "maxdelayratio $server 3.0" \
"maxpoll $server 5" \ "maxpoll $server 12" \
"maxupdateskew $server 10.0" \ "maxupdateskew $server 10.0" \
"minpoll $server 3" \ "minpoll $server 10" \
"minstratum $server 1" \ "minstratum $server 1" \
"offline" \ "offline" \
"online" \ "online" \
@ -66,7 +66,7 @@ check_chronyc_output "^Name/IP address Mode KeyID Type KLen Last Atm
run_chronyc "clients" || test_fail run_chronyc "clients" || test_fail
check_chronyc_output "^Hostname NTP Drop Int IntL Last Cmd Drop Int Last 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 || test_fail
run_chronyc "ntpdata $server" || test_fail run_chronyc "ntpdata $server" || test_fail
@ -77,7 +77,7 @@ Leap status : Normal
Version : 4 Version : 4
Mode : Server Mode : Server
Stratum : 10 Stratum : 10
Poll interval : (-6|[0345]) \([0-9]+ seconds\) Poll interval : (-6|[0-9]+) \([0-9]+ seconds\)
Precision : [0-9 +-]+ \(0\.[0-9]+ seconds\) Precision : [0-9 +-]+ \(0\.[0-9]+ seconds\)
Root delay : 0\.000000 seconds Root delay : 0\.000000 seconds
Root dispersion : 0\.000000 seconds Root dispersion : 0\.000000 seconds

View file

@ -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 echo "server 127.123.5.3" > $TEST_DIR/conf5.d/3.sources
start_chronyd || test_fail start_chronyd || test_fail
wait_for_sync || test_fail
run_chronyc "sources" || test_fail run_chronyc "sources" || test_fail
check_chronyc_output "^[^=]* check_chronyc_output "^[^=]*
@ -66,8 +65,8 @@ check_chronyc_output "^[^=]*
.. 127\.123\.2\.2 [^^]* .. 127\.123\.2\.2 [^^]*
.. 127\.123\.2\.3 [^^]* .. 127\.123\.2\.3 [^^]*
.. 127\.123\.4\.4 [^^]* .. 127\.123\.4\.4 [^^]*
.. 127\.123\.1\.2 *0 6 [^^]* .. 127\.123\.1\.2 *[05] 6 [^^]*
.. 127\.123\.5\.2 *0 7 [^^]* .. 127\.123\.5\.2 *[05] 7 [^^]*
.. 127\.123\.5\.4 [^^]*$" || test_fail .. 127\.123\.5\.4 [^^]*$" || test_fail
stop_chronyd || test_fail stop_chronyd || test_fail

View file

@ -40,7 +40,7 @@ ntsdumpdir $TEST_LIBDIR
ntsprocesses 3" ntsprocesses 3"
start_chronyd || test_fail start_chronyd || test_fail
sleep 3 wait_for_sync || test_fail
run_chronyc "authdata" || test_fail run_chronyc "authdata" || test_fail
check_chronyc_output "^Name/IP address Mode KeyID Type KLen Last Atmp NAK Cook CLen 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))" server_options="port $ntpport nts ntsport $((ntsport + 1))"
start_chronyd || test_fail start_chronyd || test_fail
sleep 2 wait_for_sync || test_fail
run_chronyc "authdata" || test_fail run_chronyc "authdata" || test_fail
check_chronyc_output "^Name/IP address Mode KeyID Type KLen Last Atmp NAK Cook CLen check_chronyc_output "^Name/IP address Mode KeyID Type KLen Last Atmp NAK Cook CLen

View file

@ -262,8 +262,23 @@ start_chronyd() {
} }
wait_for_sync() { wait_for_sync() {
local prev_length
test_message 1 0 "waiting for synchronization" 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 # Stop the chronyd instance