[chrony-dev] [RFC PATCH 8/9] test: add 153-dualtransport test

[ Thread Index | Date Index | More chrony.tuxfamily.org/chrony-dev Archives ]


No simulation test covers multiple sources with the same address and
different ports.

Add a test with a client using a server with NTP and NTP over PTP at the
same time, falling back to NTP while NTP-over-PTP packets are dropped,
and two peers using both with each other. Check addresses of the sources
in logs, chronyc commands and output with IPv4 and IPv6 addresses,
names, and CSV, and separate dump files.
---
 test/simulation/153-dualtransport | 265 ++++++++++++++++++++++++++++++
 1 file changed, 265 insertions(+)
 create mode 100755 test/simulation/153-dualtransport

diff --git a/test/simulation/153-dualtransport b/test/simulation/153-dualtransport
new file mode 100755
index 0000000..bf7e78d
--- /dev/null
+++ b/test/simulation/153-dualtransport
@@ -0,0 +1,265 @@
+#!/usr/bin/env bash
+
+. ./test.common
+
+test_start "NTP and NTP-over-PTP with same address"
+
+check_config_h 'FEAT_CMDMON 1' || test_skip
+
+# One server providing both NTP and NTP over PTP, and a client using it
+# as two sources at the same time
+server_conf="ptpport 319"
+client_server_conf="
+server 192.168.123.1 minpoll 6 maxpoll 6
+server 192.168.123.1 minpoll 6 maxpoll 6 port 319 prefer maxunreach 4"
+client_conf="ptpport 319
+logdir tmp
+log measurements statistics tracking"
+
+run_test || test_fail
+check_chronyd_exit || test_fail
+check_source_selection || test_fail
+check_sync || test_fail
+
+check_file_messages "	2	1	[^	]*	[0-9]*	123	1	" 150 160 log.packets || test_fail
+check_file_messages "	1	2	[^	]*	123	[0-9]*	1	" 150 160 log.packets || test_fail
+check_file_messages "	2	1	.*	319	319	1	" 150 160 log.packets || test_fail
+check_file_messages "	1	2	.*	319	319	1	" 150 160 log.packets || test_fail
+check_file_messages "^[0-9-]* [0-9:]* 192\.168\.123\.1 " 140 160 measurements.log || test_fail
+check_file_messages "^[0-9-]* [0-9:]* 192\.168\.123\.1:319 " 140 160 measurements.log || test_fail
+check_file_messages "^[0-9-]* [0-9:]* 192\.168\.123\.1 " 140 160 statistics.log || test_fail
+check_file_messages "^[0-9-]* [0-9:]* 192\.168\.123\.1:319 " 140 160 statistics.log || test_fail
+check_file_messages "^[0-9-]* [0-9:]* 192\.168\.123\.1:319 " 140 160 tracking.log || test_fail
+check_log_messages "Selected source 192\.168\.123\.1:319" 1 1 || test_fail
+
+# Drop NTP-over-PTP packets for 2000 seconds, the client is expected to
+# switch to the NTP source and back
+base_delay="(+ 1e-4 (* -1 (equal 0.1 port 319) (equal 1000 time 5000)))"
+
+run_test || test_fail
+check_chronyd_exit || test_fail
+check_source_selection || test_fail
+check_sync || test_fail
+
+check_file_messages "	2	1	[^	]*	[0-9]*	123	1	" 150 160 log.packets || test_fail
+check_file_messages "	1	2	[^	]*	123	[0-9]*	1	" 150 160 log.packets || test_fail
+check_file_messages "	2	1	.*	319	319	1	" 150 160 log.packets || test_fail
+check_file_messages "	1	2	.*	319	319	1	" 115 135 log.packets || test_fail
+check_log_messages "Selected source 192\.168\.123\.1:319" 2 3 || test_fail
+check_log_messages "Selected source 192\.168\.123\.1$" 1 2 || test_fail
+
+base_delay=$default_base_delay
+
+# The client can address the two sources separately with chronyc
+chronyc_conf="sources
+sourcestats
+ntpdata 192.168.123.1:319
+tracking
+minpoll 192.168.123.1:319 5
+delete 192.168.123.1:319
+sources
+ntpdata 192.168.123.1
+ntpdata 192.168.123.1:319"
+
+run_test || test_fail
+check_chronyd_exit || test_fail
+
+check_chronyc_output "^MS Name/IP address .*
+=*
+\^[-+] 192\.168\.123\.1 +1   6   377 [^
+]*
+\^\* 192\.168\.123\.1:319 +1   6   377 [^
+]*
+Name/IP Address .*
+=*
+192\.168\.123\.1 +[0-9]+ [^
+]*
+192\.168\.123\.1:319 +[0-9]+ [^
+]*
+Remote address  : 192\.168\.123\.1 \(C0A87B01\)
+Remote port     : 319
+.*
+Reference ID    : C0A87B01 \(192\.168\.123\.1:319\)
+.*
+200 OK
+200 OK
+MS Name/IP address .*
+=*
+\^. 192\.168\.123\.1 +1   6   377 [^
+]*
+Remote address  : 192\.168\.123\.1 \(C0A87B01\)
+Remote port     : 123
+.*
+503 No such source$" || test_fail
+
+check_log_messages "Source 192\.168\.123\.1:319 new minpoll 5" 1 1 || test_fail
+check_log_messages "Removed source 192\.168\.123\.1:319" 1 1 || test_fail
+
+if check_config_h 'FEAT_IPV6 1'; then
+	ip_family=6
+	client_server_conf="
+	server fc00::123:1 minpoll 6 maxpoll 6
+	server fc00::123:1 minpoll 6 maxpoll 6 port 319 prefer maxunreach 4"
+	chronyc_conf="sources
+	ntpdata [fc00::123:1]:319
+	delete [fc00::123:1]:319
+	sources"
+
+	run_test || test_fail
+	check_chronyd_exit || test_fail
+
+	check_chronyc_output "^MS Name/IP address .*
+=*
+\^[-+] fc00::123:1 +1   6   377 [^
+]*
+\^\* \[fc00::123:1\]:319 +1   6   377 [^
+]*
+Remote address  : fc00::123:1 \([0-9A-F]{8}\)
+Remote port     : 319
+.*
+200 OK
+MS Name/IP address .*
+=*
+\^. fc00::123:1 +1   6   377 [^
+]*$" || test_fail
+fi
+
+ip_family=$default_ip_family
+client_server_conf="
+server 192.168.123.1 minpoll 6 maxpoll 6
+server 192.168.123.1 minpoll 6 maxpoll 6 port 319 prefer maxunreach 4"
+chronyc_options="-c"
+chronyc_conf="sources"
+
+run_test || test_fail
+check_chronyd_exit || test_fail
+
+check_chronyc_output "^\^,.,192\.168\.123\.1,1,6,377,[^
+]*
+\^,\*,192\.168\.123\.1:319,1,6,377,[^
+]*$" || test_fail
+
+# Sources specified by name are printed with the port and the name with port
+# can be used in commands.  Without the port, the commands select the source
+# using the NTP port.
+dns=1
+client_server_conf="
+server node1.net1.clk minpoll 6 maxpoll 6
+server node1.net1.clk minpoll 6 maxpoll 6 port 319 prefer maxunreach 4"
+chronyc_options=""
+chronyc_conf="sources
+authdata
+sourcename node1.net1.clk:319
+ntpdata node1.net1.clk:319
+selectopts 192.168.123.1:319 +trust
+selectdata
+offset 192.168.123.1:319 0.0001
+ntpdata 192.168.123.1
+delete node1.net1.clk
+sources"
+
+run_test || test_fail
+check_chronyd_exit || test_fail
+
+check_chronyc_output "^MS Name/IP address .*
+=*
+\^[-+] node1\.net1\.clk +1   6   377 [^
+]*
+\^\* node1\.net1\.clk:319 +1   6   377 [^
+]*
+Name/IP address .*
+=*
+node1\.net1\.clk +- [^
+]*
+node1\.net1\.clk:319 +- [^
+]*
+node1\.net1\.clk
+Remote address  : 192\.168\.123\.1 \(C0A87B01\)
+Remote port     : 319
+.*
+200 OK
+S Name/IP Address .*
+=*
+. node1\.net1\.clk +N ----- ----- [^
+]*
+\* node1\.net1\.clk:319 +N -PT-- -PT-- [^
+]*
+200 OK
+Remote address  : 192\.168\.123\.1 \(C0A87B01\)
+Remote port     : 123
+.*
+200 OK
+MS Name/IP address .*
+=*
+\^. node1\.net1\.clk:319 +1   6   377 [^
+]*$" || test_fail
+
+check_log_messages "Selected source 192\.168\.123\.1:319 (node1\.net1\.clk)" 1 1 || test_fail
+check_log_messages "Source 192\.168\.123\.1:319 new offset" 1 1 || test_fail
+check_log_messages "Removed source 192\.168\.123\.1 (node1\.net1\.clk)" 1 1 || test_fail
+check_log_messages "Removed source 192\.168\.123\.1:319" 0 0 || test_fail
+
+dns=0
+client_server_conf="
+server 192.168.123.1 minpoll 6 maxpoll 6
+server 192.168.123.1 minpoll 6 maxpoll 6 port 319 prefer maxunreach 4"
+chronyc_conf=""
+
+# Dump files are saved and loaded separately for the two sources
+limit=1000
+client_conf="ptpport 319
+dumpdir tmp"
+client_chronyd_options="-r"
+
+run_test || test_fail
+check_chronyd_exit || test_fail
+
+check_log_messages "Loaded dump file" 0 0 || test_fail
+check_file_messages "." 10 30 192.168.123.1.dat || test_fail
+check_file_messages "." 10 30 192.168.123.1:319.dat || test_fail
+
+client_start=$limit
+limit=2000
+
+run_test || test_fail
+check_chronyd_exit || test_fail
+
+check_log_messages "Loaded dump file for 192\.168\.123\.1$" 1 1 || test_fail
+check_log_messages "Loaded dump file for 192\.168\.123\.1:319" 1 1 || test_fail
+
+client_start=$default_client_start
+client_chronyd_options=$default_client_chronyd_options
+limit=$default_limit
+
+# Two peers using both NTP and NTP over PTP with each other.  Block
+# communication between 3 and 1 to make 3 depend on its peer.
+cat > tmp/peer.keys <<-EOF
+1 MD5 1234567890
+EOF
+
+base_delay="(+ 1e-4 (* -1 (equal 0.1 from 3) (equal 0.1 to 1)))"
+clients=2
+peers=2
+max_sync_time=420
+client_server_conf=""
+client_server_options="minpoll 6 maxpoll 6"
+client_peer_options="minpoll 6 maxpoll 6 port 319 key 1"
+client_lpeer_options="
+peer 192.168.123.2 minpoll 6 maxpoll 6 key 1"
+client_rpeer_options="
+peer 192.168.123.3 minpoll 6 maxpoll 6 key 1"
+client_conf="ptpport 319
+authselectmode ignore
+keyfile tmp/peer.keys"
+
+run_test || test_fail
+check_chronyd_exit || test_fail
+check_source_selection || test_fail
+check_sync || test_fail
+
+check_file_messages "	2	3	.*	319	319	1	" 150 160 log.packets || test_fail
+check_file_messages "	3	2	.*	319	319	1	" 150 160 log.packets || test_fail
+check_file_messages "	2	3	.*	123	123	1	" 150 160 log.packets || test_fail
+check_file_messages "	3	2	.*	123	123	1	" 150 160 log.packets || test_fail
+
+test_pass
-- 
2.43.0


-- 
To unsubscribe email chrony-dev-request@xxxxxxxxxxxxxxxxxxxx with "unsubscribe" in the subject.
For help email chrony-dev-request@xxxxxxxxxxxxxxxxxxxx with "help" in the subject.
Trouble?  Email listmaster@xxxxxxxxxxxxxxxxxxxx.


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/