mirror of
https://gitlab.com/chrony/chrony.git
synced 2025-12-03 17:45:07 -05:00
test: add 149-sourcedir test
This commit is contained in:
189
test/simulation/149-sourcedir
Executable file
189
test/simulation/149-sourcedir
Executable file
@@ -0,0 +1,189 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
. ./test.common
|
||||
|
||||
test_start "sourcedir directive"
|
||||
|
||||
check_config_h 'FEAT_CMDMON 1' || test_skip
|
||||
|
||||
servers=4
|
||||
limit=191
|
||||
update_executable="tmp/update-sourcedir"
|
||||
client_server_conf="sourcedir tmp"
|
||||
base_delay="(+ 1e-4 (* 5 (equal 0.1 from $[servers + 2])))"
|
||||
chronyc_start=1
|
||||
chronyc_conf="timeout 6000
|
||||
activity
|
||||
$(for i in $(seq 1 18); do echo "reload sources"; echo activity; done)"
|
||||
|
||||
cat > tmp/sources.sources <<EOF
|
||||
pool nodes-1-2-3-4.net1.clk iburst
|
||||
EOF
|
||||
|
||||
cat > tmp/update-sourcedir <<EOF
|
||||
#!/usr/bin/env bash
|
||||
case "\$1" in
|
||||
19) s="pool nodes-1-2-3-4.net1.clk";;
|
||||
39) s="pool nodes-1-2-3-4.net1.clk maxsources 3";;
|
||||
59) s="pool nodes-1-2-3.net1.clk";;
|
||||
79) s="pool nodes-1-2-3.net1.clk
|
||||
server nodes-3-4.net1.clk";;
|
||||
99) s="server nodes-3-4.net1.clk";;
|
||||
119) s="server nodes-1-2-3.net1.clk";;
|
||||
139) s="server 192.168.123.2";;
|
||||
159) s="server 192.168.123.2 maxdelay 0.1";;
|
||||
179) s="";;
|
||||
*) exit 0;;
|
||||
esac
|
||||
echo "\$s" > tmp/sources.sources
|
||||
EOF
|
||||
chmod 755 tmp/update-sourcedir
|
||||
|
||||
run_test || test_fail
|
||||
check_chronyd_exit || test_fail
|
||||
|
||||
check_log_messages "T00:0.:[135].Z \(Added\|Removed\)" 0 0 || test_fail
|
||||
check_log_messages "T00:0.:..Z Added pool nodes-1-2-3-4\." 3 3 || test_fail
|
||||
check_log_messages "T00:0.:..Z Removed pool nodes-1-2-3-4\." 3 3 || test_fail
|
||||
check_log_messages "T00:0.:..Z Added pool nodes-1-2-3\." 1 1 || test_fail
|
||||
check_log_messages "T00:0.:..Z Removed pool nodes-1-2-3\." 1 1 || test_fail
|
||||
check_log_messages "T00:0.:..Z Added source ID#" 2 2 || test_fail
|
||||
check_log_messages "T00:0.:..Z Added source 192.168.123.[1234]" 2 2 || test_fail
|
||||
check_log_messages "T00:0.:..Z Removed source 192.168.123.[1234]" 4 4 || test_fail
|
||||
|
||||
check_chronyc_output "^200 OK
|
||||
0 sources online
|
||||
0 sources offline
|
||||
4 sources doing burst \(return to online\)
|
||||
0 sources doing burst \(return to offline\)
|
||||
0 sources with unknown address
|
||||
200 OK
|
||||
200 OK
|
||||
4 sources online
|
||||
0 sources offline
|
||||
0 sources doing burst \(return to online\)
|
||||
0 sources doing burst \(return to offline\)
|
||||
0 sources with unknown address
|
||||
200 OK
|
||||
200 OK
|
||||
4 sources online
|
||||
0 sources offline
|
||||
0 sources doing burst \(return to online\)
|
||||
0 sources doing burst \(return to offline\)
|
||||
0 sources with unknown address
|
||||
200 OK
|
||||
200 OK
|
||||
4 sources online
|
||||
0 sources offline
|
||||
0 sources doing burst \(return to online\)
|
||||
0 sources doing burst \(return to offline\)
|
||||
0 sources with unknown address
|
||||
200 OK
|
||||
200 OK
|
||||
3 sources online
|
||||
0 sources offline
|
||||
0 sources doing burst \(return to online\)
|
||||
0 sources doing burst \(return to offline\)
|
||||
0 sources with unknown address
|
||||
200 OK
|
||||
200 OK
|
||||
3 sources online
|
||||
0 sources offline
|
||||
0 sources doing burst \(return to online\)
|
||||
0 sources doing burst \(return to offline\)
|
||||
0 sources with unknown address
|
||||
200 OK
|
||||
200 OK
|
||||
3 sources online
|
||||
0 sources offline
|
||||
0 sources doing burst \(return to online\)
|
||||
0 sources doing burst \(return to offline\)
|
||||
5 sources with unknown address
|
||||
200 OK
|
||||
200 OK
|
||||
3 sources online
|
||||
0 sources offline
|
||||
0 sources doing burst \(return to online\)
|
||||
0 sources doing burst \(return to offline\)
|
||||
5 sources with unknown address
|
||||
200 OK
|
||||
200 OK
|
||||
4 sources online
|
||||
0 sources offline
|
||||
0 sources doing burst \(return to online\)
|
||||
0 sources doing burst \(return to offline\)
|
||||
5 sources with unknown address
|
||||
200 OK
|
||||
200 OK
|
||||
4 sources online
|
||||
0 sources offline
|
||||
0 sources doing burst \(return to online\)
|
||||
0 sources doing burst \(return to offline\)
|
||||
5 sources with unknown address
|
||||
200 OK
|
||||
200 OK
|
||||
1 sources online
|
||||
0 sources offline
|
||||
0 sources doing burst \(return to online\)
|
||||
0 sources doing burst \(return to offline\)
|
||||
0 sources with unknown address
|
||||
200 OK
|
||||
200 OK
|
||||
1 sources online
|
||||
0 sources offline
|
||||
0 sources doing burst \(return to online\)
|
||||
0 sources doing burst \(return to offline\)
|
||||
0 sources with unknown address
|
||||
200 OK
|
||||
200 OK
|
||||
1 sources online
|
||||
0 sources offline
|
||||
0 sources doing burst \(return to online\)
|
||||
0 sources doing burst \(return to offline\)
|
||||
0 sources with unknown address
|
||||
200 OK
|
||||
200 OK
|
||||
1 sources online
|
||||
0 sources offline
|
||||
0 sources doing burst \(return to online\)
|
||||
0 sources doing burst \(return to offline\)
|
||||
0 sources with unknown address
|
||||
200 OK
|
||||
200 OK
|
||||
1 sources online
|
||||
0 sources offline
|
||||
0 sources doing burst \(return to online\)
|
||||
0 sources doing burst \(return to offline\)
|
||||
0 sources with unknown address
|
||||
200 OK
|
||||
200 OK
|
||||
1 sources online
|
||||
0 sources offline
|
||||
0 sources doing burst \(return to online\)
|
||||
0 sources doing burst \(return to offline\)
|
||||
0 sources with unknown address
|
||||
200 OK
|
||||
200 OK
|
||||
1 sources online
|
||||
0 sources offline
|
||||
0 sources doing burst \(return to online\)
|
||||
0 sources doing burst \(return to offline\)
|
||||
0 sources with unknown address
|
||||
200 OK
|
||||
200 OK
|
||||
1 sources online
|
||||
0 sources offline
|
||||
0 sources doing burst \(return to online\)
|
||||
0 sources doing burst \(return to offline\)
|
||||
0 sources with unknown address
|
||||
200 OK
|
||||
200 OK
|
||||
0 sources online
|
||||
0 sources offline
|
||||
0 sources doing burst \(return to online\)
|
||||
0 sources doing burst \(return to offline\)
|
||||
0 sources with unknown address$" || test_fail
|
||||
|
||||
check_packet_interval || test_fail
|
||||
|
||||
test_pass
|
||||
@@ -39,6 +39,7 @@ default_refclock_jitter=""
|
||||
default_refclock_offset=0.0
|
||||
|
||||
default_update_interval=0
|
||||
default_update_executable=""
|
||||
default_shift_pll=2
|
||||
|
||||
default_server_strata=1
|
||||
@@ -463,7 +464,9 @@ run_simulation() {
|
||||
-o tmp/log.offset -f tmp/log.freq -p tmp/log.packets \
|
||||
-R $(awk "BEGIN {print $update_interval < 0 ? 2^-($update_interval) : 1}") \
|
||||
-r $(awk "BEGIN {print $max_sync_time * 2^$update_interval}") \
|
||||
-l $(awk "BEGIN {print $limit * 2^$update_interval}") && test_ok || test_error
|
||||
-l $(awk "BEGIN {print $limit * 2^$update_interval}") \
|
||||
$([ "$update_executable" != "" ] && printf "%s" "-e $update_executable") && \
|
||||
test_ok || test_error
|
||||
}
|
||||
|
||||
run_test() {
|
||||
|
||||
Reference in New Issue
Block a user