1 AT_BANNER([reconnect library])
3 m4_define([__RECONNECT_CHECK],
5 AT_KEYWORDS([reconnect])
7 AT_CHECK([$3], [0], [$4])
10 m4_define([RECONNECT_CHECK],
14 [ovstest test-reconnect < input],
19 [$PYTHON3 $srcdir/test-reconnect.py < input],
22 ######################################################################
23 RECONNECT_CHECK([nothing happens if not enabled],
33 ######################################################################
34 RECONNECT_CHECK([quick connect, idle disconnect],
37 # Connection succeeds.
41 # Send inactivity probe.
45 # Idle timeout kills connection.
52 in BACKOFF for 0 ms (0 ms backoff)
54 # Connection succeeds.
58 in ACTIVE for 0 ms (0 ms backoff)
59 created 1000, last activity 1000, last connected 1000
60 1 successful connections out of 1 attempts, seqno 1
62 last connected 0 ms ago, connected 0 ms total
64 # Send inactivity probe.
69 in ACTIVE for 5000 ms (0 ms backoff)
72 in IDLE for 0 ms (0 ms backoff)
74 # Idle timeout kills connection.
79 in IDLE for 5000 ms (0 ms backoff)
83 in BACKOFF for 0 ms (1000 ms backoff)
84 1 successful connections out of 1 attempts, seqno 2
86 disconnected at 11000 ms (0 ms ago)
89 ######################################################################
90 RECONNECT_CHECK([slow connect, idle disconnect],
97 # Connect after 500 ms.
102 # Send inactivity probe.
106 # Idle timeout kills connection.
113 in BACKOFF for 0 ms (0 ms backoff)
119 in CONNECTING for 0 ms (0 ms backoff)
121 # Connect after 500 ms.
125 in CONNECTING for 500 ms (0 ms backoff)
128 in ACTIVE for 0 ms (0 ms backoff)
129 created 1000, last activity 1000, last connected 1500
130 1 successful connections out of 1 attempts, seqno 1
132 last connected 0 ms ago, connected 0 ms total
134 # Send inactivity probe.
139 in ACTIVE for 5000 ms (0 ms backoff)
142 in IDLE for 0 ms (0 ms backoff)
144 # Idle timeout kills connection.
149 in IDLE for 5000 ms (0 ms backoff)
153 in BACKOFF for 0 ms (1000 ms backoff)
154 1 successful connections out of 1 attempts, seqno 2
156 disconnected at 11500 ms (0 ms ago)
159 ######################################################################
160 RECONNECT_CHECK([connect backs off],
163 # First connection attempt fails after 1000 ms.
171 # Back off for 1000 ms.
175 # Second connection attempt fails after 1000 ms.
181 # Back off for 2000 ms.
185 # Third connection attempt fails after 2000 ms.
191 # Back off for 4000 ms.
195 # Third connection attempt fails after 4000 ms.
201 # Back off for 8000 ms.
205 # Third connection attempt fails after 8000 ms.
211 # Back off for 8000 ms.
215 # Fourth connection attempt fails after 8000 ms.
223 in BACKOFF for 0 ms (0 ms backoff)
225 # First connection attempt fails after 1000 ms.
229 in CONNECTING for 0 ms (0 ms backoff)
235 in CONNECTING for 1000 ms (0 ms backoff)
239 in BACKOFF for 0 ms (1000 ms backoff)
240 0 successful connections out of 1 attempts, seqno 0
242 # Back off for 1000 ms.
247 in BACKOFF for 1000 ms (1000 ms backoff)
251 # Second connection attempt fails after 1000 ms.
253 in CONNECTING for 0 ms (1000 ms backoff)
258 in CONNECTING for 1000 ms (1000 ms backoff)
262 in BACKOFF for 0 ms (2000 ms backoff)
263 0 successful connections out of 2 attempts, seqno 0
265 # Back off for 2000 ms.
270 in BACKOFF for 2000 ms (2000 ms backoff)
274 # Third connection attempt fails after 2000 ms.
276 in CONNECTING for 0 ms (2000 ms backoff)
281 in CONNECTING for 2000 ms (2000 ms backoff)
285 in BACKOFF for 0 ms (4000 ms backoff)
286 0 successful connections out of 3 attempts, seqno 0
288 # Back off for 4000 ms.
293 in BACKOFF for 4000 ms (4000 ms backoff)
297 # Third connection attempt fails after 4000 ms.
299 in CONNECTING for 0 ms (4000 ms backoff)
304 in CONNECTING for 4000 ms (4000 ms backoff)
308 in BACKOFF for 0 ms (8000 ms backoff)
309 0 successful connections out of 4 attempts, seqno 0
311 # Back off for 8000 ms.
316 in BACKOFF for 8000 ms (8000 ms backoff)
320 # Third connection attempt fails after 8000 ms.
322 in CONNECTING for 0 ms (8000 ms backoff)
327 in CONNECTING for 8000 ms (8000 ms backoff)
331 in BACKOFF for 0 ms (8000 ms backoff)
332 0 successful connections out of 5 attempts, seqno 0
334 # Back off for 8000 ms.
339 in BACKOFF for 8000 ms (8000 ms backoff)
343 # Fourth connection attempt fails after 8000 ms.
345 in CONNECTING for 0 ms (8000 ms backoff)
350 in CONNECTING for 8000 ms (8000 ms backoff)
354 in BACKOFF for 0 ms (8000 ms backoff)
355 0 successful connections out of 6 attempts, seqno 0
358 ######################################################################
359 RECONNECT_CHECK([connections with no data preserve backoff],
362 # First connect, then idle timeout kills connection.
371 # Back off for 1000 ms.
375 # Second connect, then idle timeout kills connection.
384 # Back off for 2000 ms.
388 # Third connect, then idle timeout kills connection.
397 # Back off for 4000 ms.
401 in BACKOFF for 0 ms (0 ms backoff)
403 # First connect, then idle timeout kills connection.
407 in ACTIVE for 0 ms (0 ms backoff)
408 created 1000, last activity 1000, last connected 1000
409 1 successful connections out of 1 attempts, seqno 1
411 last connected 0 ms ago, connected 0 ms total
416 in ACTIVE for 5000 ms (0 ms backoff)
419 in IDLE for 0 ms (0 ms backoff)
424 in IDLE for 5000 ms (0 ms backoff)
428 in BACKOFF for 0 ms (1000 ms backoff)
429 1 successful connections out of 1 attempts, seqno 2
431 disconnected at 11000 ms (0 ms ago)
433 # Back off for 1000 ms.
438 in BACKOFF for 1000 ms (1000 ms backoff)
439 last connected 11000 ms ago, connected 10000 ms total
443 # Second connect, then idle timeout kills connection.
447 in ACTIVE for 0 ms (1000 ms backoff)
448 created 1000, last activity 1000, last connected 12000
449 2 successful connections out of 2 attempts, seqno 3
451 last connected 0 ms ago, connected 10000 ms total
456 in ACTIVE for 5000 ms (1000 ms backoff)
459 in IDLE for 0 ms (1000 ms backoff)
464 in IDLE for 5000 ms (1000 ms backoff)
468 in BACKOFF for 0 ms (2000 ms backoff)
469 2 successful connections out of 2 attempts, seqno 4
471 disconnected at 22000 ms (0 ms ago)
473 # Back off for 2000 ms.
478 in BACKOFF for 2000 ms (2000 ms backoff)
479 last connected 12000 ms ago, connected 20000 ms total
483 # Third connect, then idle timeout kills connection.
487 in ACTIVE for 0 ms (2000 ms backoff)
488 created 1000, last activity 1000, last connected 24000
489 3 successful connections out of 3 attempts, seqno 5
491 last connected 0 ms ago, connected 20000 ms total
496 in ACTIVE for 5000 ms (2000 ms backoff)
499 in IDLE for 0 ms (2000 ms backoff)
504 in IDLE for 5000 ms (2000 ms backoff)
508 in BACKOFF for 0 ms (4000 ms backoff)
509 3 successful connections out of 3 attempts, seqno 6
511 disconnected at 34000 ms (0 ms ago)
513 # Back off for 4000 ms.
518 in BACKOFF for 4000 ms (4000 ms backoff)
519 last connected 14000 ms ago, connected 30000 ms total
522 ######################################################################
523 RECONNECT_CHECK([brief connection preserves backoff],
526 # First connection attempt fails after 1000 ms.
534 # Back off for 1000 ms.
538 # Second connection attempt fails after 1000 ms.
544 # Back off for 2000 ms.
548 # Third connection attempt succeeds after 500 ms.
554 # Connection drops after another 250 ms.
559 # Back off for 4000 ms.
564 in BACKOFF for 0 ms (0 ms backoff)
566 # First connection attempt fails after 1000 ms.
570 in CONNECTING for 0 ms (0 ms backoff)
576 in CONNECTING for 1000 ms (0 ms backoff)
580 in BACKOFF for 0 ms (1000 ms backoff)
581 0 successful connections out of 1 attempts, seqno 0
583 # Back off for 1000 ms.
588 in BACKOFF for 1000 ms (1000 ms backoff)
592 # Second connection attempt fails after 1000 ms.
594 in CONNECTING for 0 ms (1000 ms backoff)
599 in CONNECTING for 1000 ms (1000 ms backoff)
603 in BACKOFF for 0 ms (2000 ms backoff)
604 0 successful connections out of 2 attempts, seqno 0
606 # Back off for 2000 ms.
611 in BACKOFF for 2000 ms (2000 ms backoff)
615 # Third connection attempt succeeds after 500 ms.
617 in CONNECTING for 0 ms (2000 ms backoff)
621 in CONNECTING for 500 ms (2000 ms backoff)
624 in ACTIVE for 0 ms (2000 ms backoff)
625 created 1000, last activity 1000, last connected 6500
626 1 successful connections out of 3 attempts, seqno 1
628 last connected 0 ms ago, connected 0 ms total
630 # Connection drops after another 250 ms.
634 in ACTIVE for 250 ms (2000 ms backoff)
636 in BACKOFF for 0 ms (4000 ms backoff)
637 1 successful connections out of 3 attempts, seqno 2
639 disconnected at 6750 ms (0 ms ago)
642 # Back off for 4000 ms.
647 in BACKOFF for 4000 ms (4000 ms backoff)
648 last connected 4250 ms ago, connected 250 ms total
653 ######################################################################
654 RECONNECT_CHECK([brief connection with data preserves backoff],
657 # First connection attempt fails after 1000 ms.
665 # Back off for 1000 ms.
669 # Second connection attempt fails after 1000 ms.
675 # Back off for 2000 ms.
679 # Third connection attempt succeeds after 500 ms.
685 # Connection receives 3 chunks of data spaced 250 ms apart.
700 # Back off for 4000 ms.
706 in BACKOFF for 0 ms (0 ms backoff)
708 # First connection attempt fails after 1000 ms.
712 in CONNECTING for 0 ms (0 ms backoff)
718 in CONNECTING for 1000 ms (0 ms backoff)
722 in BACKOFF for 0 ms (1000 ms backoff)
723 0 successful connections out of 1 attempts, seqno 0
725 # Back off for 1000 ms.
730 in BACKOFF for 1000 ms (1000 ms backoff)
734 # Second connection attempt fails after 1000 ms.
736 in CONNECTING for 0 ms (1000 ms backoff)
741 in CONNECTING for 1000 ms (1000 ms backoff)
745 in BACKOFF for 0 ms (2000 ms backoff)
746 0 successful connections out of 2 attempts, seqno 0
748 # Back off for 2000 ms.
753 in BACKOFF for 2000 ms (2000 ms backoff)
757 # Third connection attempt succeeds after 500 ms.
759 in CONNECTING for 0 ms (2000 ms backoff)
763 in CONNECTING for 500 ms (2000 ms backoff)
766 in ACTIVE for 0 ms (2000 ms backoff)
767 created 1000, last activity 1000, last connected 6500
768 1 successful connections out of 3 attempts, seqno 1
770 last connected 0 ms ago, connected 0 ms total
772 # Connection receives 3 chunks of data spaced 250 ms apart.
776 in ACTIVE for 250 ms (2000 ms backoff)
779 created 1000, last activity 6750, last connected 6500
783 in ACTIVE for 500 ms (2000 ms backoff)
786 created 1000, last activity 7000, last connected 6500
790 in ACTIVE for 750 ms (2000 ms backoff)
793 created 1000, last activity 7250, last connected 6500
797 in BACKOFF for 0 ms (4000 ms backoff)
798 1 successful connections out of 3 attempts, seqno 2
800 disconnected at 7250 ms (0 ms ago)
803 # Back off for 4000 ms.
808 in BACKOFF for 4000 ms (4000 ms backoff)
809 last connected 4750 ms ago, connected 750 ms total
814 ######################################################################
815 RECONNECT_CHECK([long connection resets backoff],
818 # First connection attempt fails after 1000 ms.
826 # Back off for 1000 ms.
830 # Second connection attempt fails after 1000 ms.
836 # Back off for 2000 ms.
840 # Third connection attempt succeeds after 500 ms.
846 # Connection receives 3 chunks of data spaced 2000 ms apart.
861 # Back off for 1000 ms.
867 in BACKOFF for 0 ms (0 ms backoff)
869 # First connection attempt fails after 1000 ms.
873 in CONNECTING for 0 ms (0 ms backoff)
879 in CONNECTING for 1000 ms (0 ms backoff)
883 in BACKOFF for 0 ms (1000 ms backoff)
884 0 successful connections out of 1 attempts, seqno 0
886 # Back off for 1000 ms.
891 in BACKOFF for 1000 ms (1000 ms backoff)
895 # Second connection attempt fails after 1000 ms.
897 in CONNECTING for 0 ms (1000 ms backoff)
902 in CONNECTING for 1000 ms (1000 ms backoff)
906 in BACKOFF for 0 ms (2000 ms backoff)
907 0 successful connections out of 2 attempts, seqno 0
909 # Back off for 2000 ms.
914 in BACKOFF for 2000 ms (2000 ms backoff)
918 # Third connection attempt succeeds after 500 ms.
920 in CONNECTING for 0 ms (2000 ms backoff)
924 in CONNECTING for 500 ms (2000 ms backoff)
927 in ACTIVE for 0 ms (2000 ms backoff)
928 created 1000, last activity 1000, last connected 6500
929 1 successful connections out of 3 attempts, seqno 1
931 last connected 0 ms ago, connected 0 ms total
933 # Connection receives 3 chunks of data spaced 2000 ms apart.
937 in ACTIVE for 2000 ms (2000 ms backoff)
940 created 1000, last activity 8500, last connected 6500
944 in ACTIVE for 4000 ms (2000 ms backoff)
947 created 1000, last activity 10500, last connected 6500
951 in ACTIVE for 6000 ms (2000 ms backoff)
954 created 1000, last activity 12500, last connected 6500
958 in BACKOFF for 0 ms (1000 ms backoff)
959 1 successful connections out of 3 attempts, seqno 2
961 disconnected at 12500 ms (0 ms ago)
964 # Back off for 1000 ms.
969 in BACKOFF for 1000 ms (1000 ms backoff)
970 last connected 7000 ms ago, connected 6000 ms total
975 ######################################################################
976 RECONNECT_CHECK([connection attempt fails quickly],
979 # Connection fails quickly.
981 connect-failed ECONNREFUSED
983 # Back off for 1000 ms.
987 # Connection fails quickly again.
989 connect-failed ECONNREFUSED
991 # Back off for 2000 ms.
997 in BACKOFF for 0 ms (0 ms backoff)
999 # Connection fails quickly.
1002 connect-failed ECONNREFUSED
1003 in BACKOFF for 0 ms (1000 ms backoff)
1004 0 successful connections out of 1 attempts, seqno 0
1006 # Back off for 1000 ms.
1012 in BACKOFF for 1000 ms (1000 ms backoff)
1014 # Connection fails quickly again.
1017 connect-failed ECONNREFUSED
1018 in BACKOFF for 0 ms (2000 ms backoff)
1019 0 successful connections out of 2 attempts, seqno 0
1021 # Back off for 2000 ms.
1027 in BACKOFF for 2000 ms (2000 ms backoff)
1030 ######################################################################
1031 RECONNECT_CHECK([backoff-free tries work],
1032 [set-backoff-free-tries 2
1035 # Connection fails quickly.
1037 connect-failed ECONNREFUSED
1043 # Connection fails quickly again.
1045 connect-failed ECONNREFUSED
1047 # Back off for 1000 ms.
1052 set-backoff-free-tries 2
1054 in BACKOFF for 0 ms (0 ms backoff)
1056 # Connection fails quickly.
1059 connect-failed ECONNREFUSED
1060 0 successful connections out of 1 attempts, seqno 0
1068 # Connection fails quickly again.
1071 connect-failed ECONNREFUSED
1072 in BACKOFF for 0 ms (1000 ms backoff)
1073 0 successful connections out of 2 attempts, seqno 0
1075 # Back off for 1000 ms.
1081 in BACKOFF for 1000 ms (1000 ms backoff)
1084 ######################################################################
1085 RECONNECT_CHECK([max-tries of 1 honored],
1089 # Connection succeeds.
1093 # Send inactivity probe.
1097 # Idle timeout kills connection.
1106 in BACKOFF for 0 ms (0 ms backoff)
1109 # Connection succeeds.
1113 in ACTIVE for 0 ms (0 ms backoff)
1114 created 1000, last activity 1000, last connected 1000
1115 1 successful connections out of 1 attempts, seqno 1
1117 last connected 0 ms ago, connected 0 ms total
1119 # Send inactivity probe.
1124 in ACTIVE for 5000 ms (0 ms backoff)
1127 in IDLE for 0 ms (0 ms backoff)
1129 # Idle timeout kills connection.
1134 in IDLE for 5000 ms (0 ms backoff)
1138 in VOID for 0 ms (0 ms backoff)
1139 1 successful connections out of 1 attempts, seqno 2
1141 disconnected at 11000 ms (0 ms ago)
1144 ######################################################################
1145 RECONNECT_CHECK([max-tries of 0 honored],
1160 ######################################################################
1161 RECONNECT_CHECK([passive mode],
1170 # Listening never times out.
1174 # Listening failed (accept() returned funny error?). Back off and try again.
1180 # Connection accepted.
1186 # Connection times out.
1193 # Start listening again.
1201 in BACKOFF for 0 ms (0 ms backoff)
1209 in LISTENING for 0 ms (0 ms backoff)
1211 # Listening never times out.
1216 # Listening failed (accept() returned funny error?). Back off and try again.
1218 in BACKOFF for 0 ms (1000 ms backoff)
1223 in BACKOFF for 1000 ms (1000 ms backoff)
1227 in LISTENING for 0 ms (1000 ms backoff)
1229 # Connection accepted.
1231 in ACTIVE for 0 ms (1000 ms backoff)
1232 created 1000, last activity 1000, last connected 2000
1233 1 successful connections out of 1 attempts, seqno 1
1235 last connected 0 ms ago, connected 0 ms total
1237 created 1000, last activity 2000, last connected 2000
1241 in ACTIVE for 1000 ms (1000 ms backoff)
1243 created 1000, last activity 3000, last connected 2000
1245 # Connection times out.
1250 in ACTIVE for 6000 ms (1000 ms backoff)
1253 in IDLE for 0 ms (1000 ms backoff)
1258 in IDLE for 5000 ms (1000 ms backoff)
1262 in BACKOFF for 0 ms (0 ms backoff)
1263 1 successful connections out of 1 attempts, seqno 2
1265 disconnected at 13000 ms (0 ms ago)
1267 # Start listening again.
1273 in LISTENING for 0 ms (0 ms backoff)