1 AT_BANNER([reconnect library])
3 m4_define([__RECONNECT_CHECK],
6 AT_KEYWORDS([reconnect])
8 AT_CHECK([$4], [0], [$5])
11 m4_define([RECONNECT_CHECK],
16 [test-reconnect < input],
20 [AT_SKIP_IF([test $HAVE_PYTHON = no])],
22 [$PYTHON $srcdir/test-reconnect.py < input],
25 ######################################################################
26 RECONNECT_CHECK([nothing happens if not enabled],
36 ######################################################################
37 RECONNECT_CHECK([quick connect, idle disconnect],
40 # Connection succeeds.
44 # Send inactivity probe.
48 # Idle timeout kills connection.
55 in BACKOFF for 0 ms (0 ms backoff)
57 # Connection succeeds.
61 in ACTIVE for 0 ms (0 ms backoff)
62 1 successful connections out of 1 attempts, seqno 1
63 connected (0 ms), total 0 ms connected
65 # Send inactivity probe.
70 in ACTIVE for 5000 ms (0 ms backoff)
71 connected (5000 ms), total 5000 ms connected
74 in IDLE for 0 ms (0 ms backoff)
76 # Idle timeout kills connection.
81 in IDLE for 5000 ms (0 ms backoff)
82 connected (10000 ms), total 10000 ms connected
86 in BACKOFF for 0 ms (1000 ms backoff)
87 1 successful connections out of 1 attempts, seqno 2
88 not connected (0 ms), total 10000 ms connected
91 ######################################################################
92 RECONNECT_CHECK([slow connect, idle disconnect],
99 # Connect after 500 ms.
104 # Send inactivity probe.
108 # Idle timeout kills connection.
115 in BACKOFF for 0 ms (0 ms backoff)
121 in CONNECT_IN_PROGRESS for 0 ms (0 ms backoff)
123 # Connect after 500 ms.
127 in CONNECT_IN_PROGRESS for 500 ms (0 ms backoff)
130 in ACTIVE for 0 ms (0 ms backoff)
131 created 1000, last received 1000, last connected 1500
132 1 successful connections out of 1 attempts, seqno 1
133 connected (0 ms), total 0 ms connected
135 # Send inactivity probe.
140 in ACTIVE for 5000 ms (0 ms backoff)
141 connected (5000 ms), total 5000 ms connected
144 in IDLE for 0 ms (0 ms backoff)
146 # Idle timeout kills connection.
151 in IDLE for 5000 ms (0 ms backoff)
152 connected (10000 ms), total 10000 ms connected
156 in BACKOFF for 0 ms (1000 ms backoff)
157 1 successful connections out of 1 attempts, seqno 2
158 not connected (0 ms), total 10000 ms connected
161 ######################################################################
162 RECONNECT_CHECK([connect backs off],
165 # First connection attempt fails after 1000 ms.
173 # Back off for 1000 ms.
177 # Second connection attempt fails after 1000 ms.
183 # Back off for 2000 ms.
187 # Third connection attempt fails after 2000 ms.
193 # Back off for 4000 ms.
197 # Third connection attempt fails after 4000 ms.
203 # Back off for 8000 ms.
207 # Third connection attempt fails after 8000 ms.
213 # Back off for 8000 ms.
217 # Fourth connection attempt fails after 8000 ms.
225 in BACKOFF for 0 ms (0 ms backoff)
227 # First connection attempt fails after 1000 ms.
231 in CONNECT_IN_PROGRESS for 0 ms (0 ms backoff)
237 in CONNECT_IN_PROGRESS for 1000 ms (0 ms backoff)
241 in BACKOFF for 0 ms (1000 ms backoff)
242 0 successful connections out of 1 attempts, seqno 0
244 # Back off for 1000 ms.
249 in BACKOFF for 1000 ms (1000 ms backoff)
253 # Second connection attempt fails after 1000 ms.
255 in CONNECT_IN_PROGRESS for 0 ms (1000 ms backoff)
260 in CONNECT_IN_PROGRESS for 1000 ms (1000 ms backoff)
264 in BACKOFF for 0 ms (2000 ms backoff)
265 0 successful connections out of 2 attempts, seqno 0
267 # Back off for 2000 ms.
272 in BACKOFF for 2000 ms (2000 ms backoff)
276 # Third connection attempt fails after 2000 ms.
278 in CONNECT_IN_PROGRESS for 0 ms (2000 ms backoff)
283 in CONNECT_IN_PROGRESS for 2000 ms (2000 ms backoff)
287 in BACKOFF for 0 ms (4000 ms backoff)
288 0 successful connections out of 3 attempts, seqno 0
290 # Back off for 4000 ms.
295 in BACKOFF for 4000 ms (4000 ms backoff)
299 # Third connection attempt fails after 4000 ms.
301 in CONNECT_IN_PROGRESS for 0 ms (4000 ms backoff)
306 in CONNECT_IN_PROGRESS for 4000 ms (4000 ms backoff)
310 in BACKOFF for 0 ms (8000 ms backoff)
311 0 successful connections out of 4 attempts, seqno 0
313 # Back off for 8000 ms.
318 in BACKOFF for 8000 ms (8000 ms backoff)
322 # Third connection attempt fails after 8000 ms.
324 in CONNECT_IN_PROGRESS for 0 ms (8000 ms backoff)
329 in CONNECT_IN_PROGRESS for 8000 ms (8000 ms backoff)
333 in BACKOFF for 0 ms (8000 ms backoff)
334 0 successful connections out of 5 attempts, seqno 0
336 # Back off for 8000 ms.
341 in BACKOFF for 8000 ms (8000 ms backoff)
345 # Fourth connection attempt fails after 8000 ms.
347 in CONNECT_IN_PROGRESS for 0 ms (8000 ms backoff)
352 in CONNECT_IN_PROGRESS for 8000 ms (8000 ms backoff)
356 in BACKOFF for 0 ms (8000 ms backoff)
357 0 successful connections out of 6 attempts, seqno 0
360 ######################################################################
361 RECONNECT_CHECK([connections with no data preserve backoff],
364 # First connect, then idle timeout kills connection.
373 # Back off for 1000 ms.
377 # Second connect, then idle timeout kills connection.
386 # Back off for 2000 ms.
390 # Third connect, then idle timeout kills connection.
399 # Back off for 4000 ms.
403 in BACKOFF for 0 ms (0 ms backoff)
405 # First connect, then idle timeout kills connection.
409 in ACTIVE for 0 ms (0 ms backoff)
410 1 successful connections out of 1 attempts, seqno 1
411 connected (0 ms), total 0 ms connected
416 in ACTIVE for 5000 ms (0 ms backoff)
417 connected (5000 ms), total 5000 ms connected
420 in IDLE for 0 ms (0 ms backoff)
425 in IDLE for 5000 ms (0 ms backoff)
426 connected (10000 ms), total 10000 ms connected
430 in BACKOFF for 0 ms (1000 ms backoff)
431 1 successful connections out of 1 attempts, seqno 2
432 not connected (0 ms), total 10000 ms connected
434 # Back off for 1000 ms.
439 in BACKOFF for 1000 ms (1000 ms backoff)
443 # Second connect, then idle timeout kills connection.
447 in ACTIVE for 0 ms (1000 ms backoff)
448 created 1000, last received 1000, last connected 12000
449 2 successful connections out of 2 attempts, seqno 3
450 connected (0 ms), total 10000 ms connected
455 in ACTIVE for 5000 ms (1000 ms backoff)
456 connected (5000 ms), total 15000 ms connected
459 in IDLE for 0 ms (1000 ms backoff)
464 in IDLE for 5000 ms (1000 ms backoff)
465 connected (10000 ms), total 20000 ms connected
469 in BACKOFF for 0 ms (2000 ms backoff)
470 2 successful connections out of 2 attempts, seqno 4
471 not connected (0 ms), total 20000 ms connected
473 # Back off for 2000 ms.
478 in BACKOFF for 2000 ms (2000 ms backoff)
482 # Third connect, then idle timeout kills connection.
486 in ACTIVE for 0 ms (2000 ms backoff)
487 created 1000, last received 1000, last connected 24000
488 3 successful connections out of 3 attempts, seqno 5
489 connected (0 ms), total 20000 ms connected
494 in ACTIVE for 5000 ms (2000 ms backoff)
495 connected (5000 ms), total 25000 ms connected
498 in IDLE for 0 ms (2000 ms backoff)
503 in IDLE for 5000 ms (2000 ms backoff)
504 connected (10000 ms), total 30000 ms connected
508 in BACKOFF for 0 ms (4000 ms backoff)
509 3 successful connections out of 3 attempts, seqno 6
510 not connected (0 ms), total 30000 ms connected
512 # Back off for 4000 ms.
517 in BACKOFF for 4000 ms (4000 ms backoff)
520 ######################################################################
521 RECONNECT_CHECK([brief connection preserves backoff],
524 # First connection attempt fails after 1000 ms.
532 # Back off for 1000 ms.
536 # Second connection attempt fails after 1000 ms.
542 # Back off for 2000 ms.
546 # Third connection attempt succeeds after 500 ms.
552 # Connection drops after another 250 ms.
557 # Back off for 4000 ms.
562 in BACKOFF for 0 ms (0 ms backoff)
564 # First connection attempt fails after 1000 ms.
568 in CONNECT_IN_PROGRESS for 0 ms (0 ms backoff)
574 in CONNECT_IN_PROGRESS for 1000 ms (0 ms backoff)
578 in BACKOFF for 0 ms (1000 ms backoff)
579 0 successful connections out of 1 attempts, seqno 0
581 # Back off for 1000 ms.
586 in BACKOFF for 1000 ms (1000 ms backoff)
590 # Second connection attempt fails after 1000 ms.
592 in CONNECT_IN_PROGRESS for 0 ms (1000 ms backoff)
597 in CONNECT_IN_PROGRESS for 1000 ms (1000 ms backoff)
601 in BACKOFF for 0 ms (2000 ms backoff)
602 0 successful connections out of 2 attempts, seqno 0
604 # Back off for 2000 ms.
609 in BACKOFF for 2000 ms (2000 ms backoff)
613 # Third connection attempt succeeds after 500 ms.
615 in CONNECT_IN_PROGRESS for 0 ms (2000 ms backoff)
619 in CONNECT_IN_PROGRESS for 500 ms (2000 ms backoff)
622 in ACTIVE for 0 ms (2000 ms backoff)
623 created 1000, last received 1000, last connected 6500
624 1 successful connections out of 3 attempts, seqno 1
625 connected (0 ms), total 0 ms connected
627 # Connection drops after another 250 ms.
631 in ACTIVE for 250 ms (2000 ms backoff)
632 connected (250 ms), total 250 ms connected
634 in BACKOFF for 0 ms (4000 ms backoff)
635 1 successful connections out of 3 attempts, seqno 2
636 not connected (0 ms), total 250 ms connected
639 # Back off for 4000 ms.
644 in BACKOFF for 4000 ms (4000 ms backoff)
649 ######################################################################
650 RECONNECT_CHECK([brief connection with data preserves backoff],
653 # First connection attempt fails after 1000 ms.
661 # Back off for 1000 ms.
665 # Second connection attempt fails after 1000 ms.
671 # Back off for 2000 ms.
675 # Third connection attempt succeeds after 500 ms.
681 # Connection receives 3 chunks of data spaced 250 ms apart.
696 # Back off for 4000 ms.
702 in BACKOFF for 0 ms (0 ms backoff)
704 # First connection attempt fails after 1000 ms.
708 in CONNECT_IN_PROGRESS for 0 ms (0 ms backoff)
714 in CONNECT_IN_PROGRESS for 1000 ms (0 ms backoff)
718 in BACKOFF for 0 ms (1000 ms backoff)
719 0 successful connections out of 1 attempts, seqno 0
721 # Back off for 1000 ms.
726 in BACKOFF for 1000 ms (1000 ms backoff)
730 # Second connection attempt fails after 1000 ms.
732 in CONNECT_IN_PROGRESS for 0 ms (1000 ms backoff)
737 in CONNECT_IN_PROGRESS for 1000 ms (1000 ms backoff)
741 in BACKOFF for 0 ms (2000 ms backoff)
742 0 successful connections out of 2 attempts, seqno 0
744 # Back off for 2000 ms.
749 in BACKOFF for 2000 ms (2000 ms backoff)
753 # Third connection attempt succeeds after 500 ms.
755 in CONNECT_IN_PROGRESS for 0 ms (2000 ms backoff)
759 in CONNECT_IN_PROGRESS for 500 ms (2000 ms backoff)
762 in ACTIVE for 0 ms (2000 ms backoff)
763 created 1000, last received 1000, last connected 6500
764 1 successful connections out of 3 attempts, seqno 1
765 connected (0 ms), total 0 ms connected
767 # Connection receives 3 chunks of data spaced 250 ms apart.
771 in ACTIVE for 250 ms (2000 ms backoff)
772 connected (250 ms), total 250 ms connected
775 created 1000, last received 6750, last connected 6500
779 in ACTIVE for 500 ms (2000 ms backoff)
780 connected (500 ms), total 500 ms connected
783 created 1000, last received 7000, last connected 6500
787 in ACTIVE for 750 ms (2000 ms backoff)
788 connected (750 ms), total 750 ms connected
791 created 1000, last received 7250, last connected 6500
795 in BACKOFF for 0 ms (4000 ms backoff)
796 1 successful connections out of 3 attempts, seqno 2
797 not connected (0 ms), total 750 ms connected
800 # Back off for 4000 ms.
805 in BACKOFF for 4000 ms (4000 ms backoff)
810 ######################################################################
811 RECONNECT_CHECK([long connection resets backoff],
814 # First connection attempt fails after 1000 ms.
822 # Back off for 1000 ms.
826 # Second connection attempt fails after 1000 ms.
832 # Back off for 2000 ms.
836 # Third connection attempt succeeds after 500 ms.
842 # Connection receives 3 chunks of data spaced 2000 ms apart.
857 # Back off for 1000 ms.
863 in BACKOFF for 0 ms (0 ms backoff)
865 # First connection attempt fails after 1000 ms.
869 in CONNECT_IN_PROGRESS for 0 ms (0 ms backoff)
875 in CONNECT_IN_PROGRESS for 1000 ms (0 ms backoff)
879 in BACKOFF for 0 ms (1000 ms backoff)
880 0 successful connections out of 1 attempts, seqno 0
882 # Back off for 1000 ms.
887 in BACKOFF for 1000 ms (1000 ms backoff)
891 # Second connection attempt fails after 1000 ms.
893 in CONNECT_IN_PROGRESS for 0 ms (1000 ms backoff)
898 in CONNECT_IN_PROGRESS for 1000 ms (1000 ms backoff)
902 in BACKOFF for 0 ms (2000 ms backoff)
903 0 successful connections out of 2 attempts, seqno 0
905 # Back off for 2000 ms.
910 in BACKOFF for 2000 ms (2000 ms backoff)
914 # Third connection attempt succeeds after 500 ms.
916 in CONNECT_IN_PROGRESS for 0 ms (2000 ms backoff)
920 in CONNECT_IN_PROGRESS for 500 ms (2000 ms backoff)
923 in ACTIVE for 0 ms (2000 ms backoff)
924 created 1000, last received 1000, last connected 6500
925 1 successful connections out of 3 attempts, seqno 1
926 connected (0 ms), total 0 ms connected
928 # Connection receives 3 chunks of data spaced 2000 ms apart.
932 in ACTIVE for 2000 ms (2000 ms backoff)
933 connected (2000 ms), total 2000 ms connected
936 created 1000, last received 8500, last connected 6500
940 in ACTIVE for 4000 ms (2000 ms backoff)
941 connected (4000 ms), total 4000 ms connected
944 created 1000, last received 10500, last connected 6500
948 in ACTIVE for 6000 ms (2000 ms backoff)
949 connected (6000 ms), total 6000 ms connected
952 created 1000, last received 12500, last connected 6500
956 in BACKOFF for 0 ms (1000 ms backoff)
957 1 successful connections out of 3 attempts, seqno 2
958 not connected (0 ms), total 6000 ms connected
961 # Back off for 1000 ms.
966 in BACKOFF for 1000 ms (1000 ms backoff)
971 ######################################################################
972 RECONNECT_CHECK([connection attempt fails quickly],
975 # Connection fails quickly.
977 connect-failed ECONNREFUSED
979 # Back off for 1000 ms.
983 # Connection fails quickly again.
985 connect-failed ECONNREFUSED
987 # Back off for 2000 ms.
993 in BACKOFF for 0 ms (0 ms backoff)
995 # Connection fails quickly.
998 connect-failed ECONNREFUSED
999 in BACKOFF for 0 ms (1000 ms backoff)
1000 0 successful connections out of 1 attempts, seqno 0
1002 # Back off for 1000 ms.
1008 in BACKOFF for 1000 ms (1000 ms backoff)
1010 # Connection fails quickly again.
1013 connect-failed ECONNREFUSED
1014 in BACKOFF for 0 ms (2000 ms backoff)
1015 0 successful connections out of 2 attempts, seqno 0
1017 # Back off for 2000 ms.
1023 in BACKOFF for 2000 ms (2000 ms backoff)
1026 ######################################################################
1027 RECONNECT_CHECK([max-tries of 1 honored],
1031 # Connection succeeds.
1035 # Send inactivity probe.
1039 # Idle timeout kills connection.
1048 in BACKOFF for 0 ms (0 ms backoff)
1051 # Connection succeeds.
1055 in ACTIVE for 0 ms (0 ms backoff)
1056 1 successful connections out of 1 attempts, seqno 1
1057 connected (0 ms), total 0 ms connected
1059 # Send inactivity probe.
1064 in ACTIVE for 5000 ms (0 ms backoff)
1065 connected (5000 ms), total 5000 ms connected
1068 in IDLE for 0 ms (0 ms backoff)
1070 # Idle timeout kills connection.
1075 in IDLE for 5000 ms (0 ms backoff)
1076 connected (10000 ms), total 10000 ms connected
1080 in VOID for 0 ms (1000 ms backoff)
1081 1 successful connections out of 1 attempts, seqno 2
1082 not connected (0 ms), total 10000 ms connected
1085 ######################################################################
1086 RECONNECT_CHECK([max-tries of 0 honored],
1101 ######################################################################
1102 RECONNECT_CHECK([passive mode],
1111 # Listening never times out.
1115 # Listening failed (accept() returned funny error?). Back off and try again.
1121 # Connection accepted.
1127 # Connection times out.
1134 # Start listening again.
1142 in BACKOFF for 0 ms (0 ms backoff)
1150 in LISTENING for 0 ms (0 ms backoff)
1152 # Listening never times out.
1157 # Listening failed (accept() returned funny error?). Back off and try again.
1159 in BACKOFF for 0 ms (1000 ms backoff)
1164 in BACKOFF for 1000 ms (1000 ms backoff)
1168 in LISTENING for 0 ms (1000 ms backoff)
1170 # Connection accepted.
1172 in ACTIVE for 0 ms (1000 ms backoff)
1173 created 1000, last received 1000, last connected 2000
1174 1 successful connections out of 1 attempts, seqno 1
1175 connected (0 ms), total 0 ms connected
1177 created 1000, last received 2000, last connected 2000
1181 in ACTIVE for 1000 ms (1000 ms backoff)
1182 connected (1000 ms), total 1000 ms connected
1184 created 1000, last received 3000, last connected 2000
1186 # Connection times out.
1191 in ACTIVE for 6000 ms (1000 ms backoff)
1192 connected (6000 ms), total 6000 ms connected
1195 in IDLE for 0 ms (1000 ms backoff)
1200 in IDLE for 5000 ms (1000 ms backoff)
1201 connected (11000 ms), total 11000 ms connected
1205 in BACKOFF for 0 ms (0 ms backoff)
1206 1 successful connections out of 1 attempts, seqno 2
1207 not connected (0 ms), total 11000 ms connected
1209 # Start listening again.
1215 in LISTENING for 0 ms (0 ms backoff)