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],
11 [__RECONNECT_CHECK([$1], [$2], [test-reconnect < input], [$3])])
13 ######################################################################
14 RECONNECT_CHECK([nothing happens if not enabled],
24 ######################################################################
25 RECONNECT_CHECK([quick connect, idle disconnect],
28 # Connection succeeds.
32 # Send inactivity probe.
36 # Idle timeout kills connection.
43 in BACKOFF for 0 ms (0 ms backoff)
45 # Connection succeeds.
49 in ACTIVE for 0 ms (0 ms backoff)
50 1 successful connections out of 1 attempts, seqno 1
51 connected (0 ms), total 0 ms connected
53 # Send inactivity probe.
58 in ACTIVE for 5000 ms (0 ms backoff)
59 connected (5000 ms), total 5000 ms connected
62 in IDLE for 0 ms (0 ms backoff)
64 # Idle timeout kills connection.
69 in IDLE for 5000 ms (0 ms backoff)
70 connected (10000 ms), total 10000 ms connected
74 in BACKOFF for 0 ms (1000 ms backoff)
75 1 successful connections out of 1 attempts, seqno 2
76 not connected (0 ms), total 10000 ms connected
79 ######################################################################
80 RECONNECT_CHECK([slow connect, idle disconnect],
87 # Connect after 500 ms.
92 # Send inactivity probe.
96 # Idle timeout kills connection.
103 in BACKOFF for 0 ms (0 ms backoff)
109 in CONNECT_IN_PROGRESS for 0 ms (0 ms backoff)
111 # Connect after 500 ms.
115 in CONNECT_IN_PROGRESS for 500 ms (0 ms backoff)
118 in ACTIVE for 0 ms (0 ms backoff)
119 created 1000, last received 1000, last connected 1500
120 1 successful connections out of 1 attempts, seqno 1
121 connected (0 ms), total 0 ms connected
123 # Send inactivity probe.
128 in ACTIVE for 5000 ms (0 ms backoff)
129 connected (5000 ms), total 5000 ms connected
132 in IDLE for 0 ms (0 ms backoff)
134 # Idle timeout kills connection.
139 in IDLE for 5000 ms (0 ms backoff)
140 connected (10000 ms), total 10000 ms connected
144 in BACKOFF for 0 ms (1000 ms backoff)
145 1 successful connections out of 1 attempts, seqno 2
146 not connected (0 ms), total 10000 ms connected
149 ######################################################################
150 RECONNECT_CHECK([connect backs off],
153 # First connection attempt fails after 1000 ms.
161 # Back off for 1000 ms.
165 # Second connection attempt fails after 1000 ms.
171 # Back off for 2000 ms.
175 # Third connection attempt fails after 2000 ms.
181 # Back off for 4000 ms.
185 # Third connection attempt fails after 4000 ms.
191 # Back off for 8000 ms.
195 # Third connection attempt fails after 8000 ms.
201 # Back off for 8000 ms.
205 # Fourth connection attempt fails after 8000 ms.
213 in BACKOFF for 0 ms (0 ms backoff)
215 # First connection attempt fails after 1000 ms.
219 in CONNECT_IN_PROGRESS for 0 ms (0 ms backoff)
225 in CONNECT_IN_PROGRESS for 1000 ms (0 ms backoff)
229 in BACKOFF for 0 ms (1000 ms backoff)
230 0 successful connections out of 1 attempts, seqno 0
232 # Back off for 1000 ms.
237 in BACKOFF for 1000 ms (1000 ms backoff)
241 # Second connection attempt fails after 1000 ms.
243 in CONNECT_IN_PROGRESS for 0 ms (1000 ms backoff)
248 in CONNECT_IN_PROGRESS for 1000 ms (1000 ms backoff)
252 in BACKOFF for 0 ms (2000 ms backoff)
253 0 successful connections out of 2 attempts, seqno 0
255 # Back off for 2000 ms.
260 in BACKOFF for 2000 ms (2000 ms backoff)
264 # Third connection attempt fails after 2000 ms.
266 in CONNECT_IN_PROGRESS for 0 ms (2000 ms backoff)
271 in CONNECT_IN_PROGRESS for 2000 ms (2000 ms backoff)
275 in BACKOFF for 0 ms (4000 ms backoff)
276 0 successful connections out of 3 attempts, seqno 0
278 # Back off for 4000 ms.
283 in BACKOFF for 4000 ms (4000 ms backoff)
287 # Third connection attempt fails after 4000 ms.
289 in CONNECT_IN_PROGRESS for 0 ms (4000 ms backoff)
294 in CONNECT_IN_PROGRESS for 4000 ms (4000 ms backoff)
298 in BACKOFF for 0 ms (8000 ms backoff)
299 0 successful connections out of 4 attempts, seqno 0
301 # Back off for 8000 ms.
306 in BACKOFF for 8000 ms (8000 ms backoff)
310 # Third connection attempt fails after 8000 ms.
312 in CONNECT_IN_PROGRESS for 0 ms (8000 ms backoff)
317 in CONNECT_IN_PROGRESS for 8000 ms (8000 ms backoff)
321 in BACKOFF for 0 ms (8000 ms backoff)
322 0 successful connections out of 5 attempts, seqno 0
324 # Back off for 8000 ms.
329 in BACKOFF for 8000 ms (8000 ms backoff)
333 # Fourth connection attempt fails after 8000 ms.
335 in CONNECT_IN_PROGRESS for 0 ms (8000 ms backoff)
340 in CONNECT_IN_PROGRESS for 8000 ms (8000 ms backoff)
344 in BACKOFF for 0 ms (8000 ms backoff)
345 0 successful connections out of 6 attempts, seqno 0
348 ######################################################################
349 RECONNECT_CHECK([connections with no data preserve backoff],
352 # First connect, then idle timeout kills connection.
361 # Back off for 1000 ms.
365 # Second connect, then idle timeout kills connection.
374 # Back off for 2000 ms.
378 # Third connect, then idle timeout kills connection.
387 # Back off for 4000 ms.
391 in BACKOFF for 0 ms (0 ms backoff)
393 # First connect, then idle timeout kills connection.
397 in ACTIVE for 0 ms (0 ms backoff)
398 1 successful connections out of 1 attempts, seqno 1
399 connected (0 ms), total 0 ms connected
404 in ACTIVE for 5000 ms (0 ms backoff)
405 connected (5000 ms), total 5000 ms connected
408 in IDLE for 0 ms (0 ms backoff)
413 in IDLE for 5000 ms (0 ms backoff)
414 connected (10000 ms), total 10000 ms connected
418 in BACKOFF for 0 ms (1000 ms backoff)
419 1 successful connections out of 1 attempts, seqno 2
420 not connected (0 ms), total 10000 ms connected
422 # Back off for 1000 ms.
427 in BACKOFF for 1000 ms (1000 ms backoff)
431 # Second connect, then idle timeout kills connection.
435 in ACTIVE for 0 ms (1000 ms backoff)
436 created 1000, last received 1000, last connected 12000
437 2 successful connections out of 2 attempts, seqno 3
438 connected (0 ms), total 10000 ms connected
443 in ACTIVE for 5000 ms (1000 ms backoff)
444 connected (5000 ms), total 15000 ms connected
447 in IDLE for 0 ms (1000 ms backoff)
452 in IDLE for 5000 ms (1000 ms backoff)
453 connected (10000 ms), total 20000 ms connected
457 in BACKOFF for 0 ms (2000 ms backoff)
458 2 successful connections out of 2 attempts, seqno 4
459 not connected (0 ms), total 20000 ms connected
461 # Back off for 2000 ms.
466 in BACKOFF for 2000 ms (2000 ms backoff)
470 # Third connect, then idle timeout kills connection.
474 in ACTIVE for 0 ms (2000 ms backoff)
475 created 1000, last received 1000, last connected 24000
476 3 successful connections out of 3 attempts, seqno 5
477 connected (0 ms), total 20000 ms connected
482 in ACTIVE for 5000 ms (2000 ms backoff)
483 connected (5000 ms), total 25000 ms connected
486 in IDLE for 0 ms (2000 ms backoff)
491 in IDLE for 5000 ms (2000 ms backoff)
492 connected (10000 ms), total 30000 ms connected
496 in BACKOFF for 0 ms (4000 ms backoff)
497 3 successful connections out of 3 attempts, seqno 6
498 not connected (0 ms), total 30000 ms connected
500 # Back off for 4000 ms.
505 in BACKOFF for 4000 ms (4000 ms backoff)
508 ######################################################################
509 RECONNECT_CHECK([brief connection preserves backoff],
512 # First connection attempt fails after 1000 ms.
520 # Back off for 1000 ms.
524 # Second connection attempt fails after 1000 ms.
530 # Back off for 2000 ms.
534 # Third connection attempt succeeds after 500 ms.
540 # Connection drops after another 250 ms.
545 # Back off for 4000 ms.
550 in BACKOFF for 0 ms (0 ms backoff)
552 # First connection attempt fails after 1000 ms.
556 in CONNECT_IN_PROGRESS for 0 ms (0 ms backoff)
562 in CONNECT_IN_PROGRESS for 1000 ms (0 ms backoff)
566 in BACKOFF for 0 ms (1000 ms backoff)
567 0 successful connections out of 1 attempts, seqno 0
569 # Back off for 1000 ms.
574 in BACKOFF for 1000 ms (1000 ms backoff)
578 # Second connection attempt fails after 1000 ms.
580 in CONNECT_IN_PROGRESS for 0 ms (1000 ms backoff)
585 in CONNECT_IN_PROGRESS for 1000 ms (1000 ms backoff)
589 in BACKOFF for 0 ms (2000 ms backoff)
590 0 successful connections out of 2 attempts, seqno 0
592 # Back off for 2000 ms.
597 in BACKOFF for 2000 ms (2000 ms backoff)
601 # Third connection attempt succeeds after 500 ms.
603 in CONNECT_IN_PROGRESS for 0 ms (2000 ms backoff)
607 in CONNECT_IN_PROGRESS for 500 ms (2000 ms backoff)
610 in ACTIVE for 0 ms (2000 ms backoff)
611 created 1000, last received 1000, last connected 6500
612 1 successful connections out of 3 attempts, seqno 1
613 connected (0 ms), total 0 ms connected
615 # Connection drops after another 250 ms.
619 in ACTIVE for 250 ms (2000 ms backoff)
620 connected (250 ms), total 250 ms connected
622 in BACKOFF for 0 ms (4000 ms backoff)
623 1 successful connections out of 3 attempts, seqno 2
624 not connected (0 ms), total 250 ms connected
627 # Back off for 4000 ms.
632 in BACKOFF for 4000 ms (4000 ms backoff)
637 ######################################################################
638 RECONNECT_CHECK([brief connection with data preserves backoff],
641 # First connection attempt fails after 1000 ms.
649 # Back off for 1000 ms.
653 # Second connection attempt fails after 1000 ms.
659 # Back off for 2000 ms.
663 # Third connection attempt succeeds after 500 ms.
669 # Connection receives 3 chunks of data spaced 250 ms apart.
684 # Back off for 4000 ms.
690 in BACKOFF for 0 ms (0 ms backoff)
692 # First connection attempt fails after 1000 ms.
696 in CONNECT_IN_PROGRESS for 0 ms (0 ms backoff)
702 in CONNECT_IN_PROGRESS for 1000 ms (0 ms backoff)
706 in BACKOFF for 0 ms (1000 ms backoff)
707 0 successful connections out of 1 attempts, seqno 0
709 # Back off for 1000 ms.
714 in BACKOFF for 1000 ms (1000 ms backoff)
718 # Second connection attempt fails after 1000 ms.
720 in CONNECT_IN_PROGRESS for 0 ms (1000 ms backoff)
725 in CONNECT_IN_PROGRESS for 1000 ms (1000 ms backoff)
729 in BACKOFF for 0 ms (2000 ms backoff)
730 0 successful connections out of 2 attempts, seqno 0
732 # Back off for 2000 ms.
737 in BACKOFF for 2000 ms (2000 ms backoff)
741 # Third connection attempt succeeds after 500 ms.
743 in CONNECT_IN_PROGRESS for 0 ms (2000 ms backoff)
747 in CONNECT_IN_PROGRESS for 500 ms (2000 ms backoff)
750 in ACTIVE for 0 ms (2000 ms backoff)
751 created 1000, last received 1000, last connected 6500
752 1 successful connections out of 3 attempts, seqno 1
753 connected (0 ms), total 0 ms connected
755 # Connection receives 3 chunks of data spaced 250 ms apart.
759 in ACTIVE for 250 ms (2000 ms backoff)
760 connected (250 ms), total 250 ms connected
763 created 1000, last received 6750, last connected 6500
767 in ACTIVE for 500 ms (2000 ms backoff)
768 connected (500 ms), total 500 ms connected
771 created 1000, last received 7000, last connected 6500
775 in ACTIVE for 750 ms (2000 ms backoff)
776 connected (750 ms), total 750 ms connected
779 created 1000, last received 7250, last connected 6500
783 in BACKOFF for 0 ms (4000 ms backoff)
784 1 successful connections out of 3 attempts, seqno 2
785 not connected (0 ms), total 750 ms connected
788 # Back off for 4000 ms.
793 in BACKOFF for 4000 ms (4000 ms backoff)
798 ######################################################################
799 RECONNECT_CHECK([long connection resets backoff],
802 # First connection attempt fails after 1000 ms.
810 # Back off for 1000 ms.
814 # Second connection attempt fails after 1000 ms.
820 # Back off for 2000 ms.
824 # Third connection attempt succeeds after 500 ms.
830 # Connection receives 3 chunks of data spaced 2000 ms apart.
845 # Back off for 1000 ms.
851 in BACKOFF for 0 ms (0 ms backoff)
853 # First connection attempt fails after 1000 ms.
857 in CONNECT_IN_PROGRESS for 0 ms (0 ms backoff)
863 in CONNECT_IN_PROGRESS for 1000 ms (0 ms backoff)
867 in BACKOFF for 0 ms (1000 ms backoff)
868 0 successful connections out of 1 attempts, seqno 0
870 # Back off for 1000 ms.
875 in BACKOFF for 1000 ms (1000 ms backoff)
879 # Second connection attempt fails after 1000 ms.
881 in CONNECT_IN_PROGRESS for 0 ms (1000 ms backoff)
886 in CONNECT_IN_PROGRESS for 1000 ms (1000 ms backoff)
890 in BACKOFF for 0 ms (2000 ms backoff)
891 0 successful connections out of 2 attempts, seqno 0
893 # Back off for 2000 ms.
898 in BACKOFF for 2000 ms (2000 ms backoff)
902 # Third connection attempt succeeds after 500 ms.
904 in CONNECT_IN_PROGRESS for 0 ms (2000 ms backoff)
908 in CONNECT_IN_PROGRESS for 500 ms (2000 ms backoff)
911 in ACTIVE for 0 ms (2000 ms backoff)
912 created 1000, last received 1000, last connected 6500
913 1 successful connections out of 3 attempts, seqno 1
914 connected (0 ms), total 0 ms connected
916 # Connection receives 3 chunks of data spaced 2000 ms apart.
920 in ACTIVE for 2000 ms (2000 ms backoff)
921 connected (2000 ms), total 2000 ms connected
924 created 1000, last received 8500, last connected 6500
928 in ACTIVE for 4000 ms (2000 ms backoff)
929 connected (4000 ms), total 4000 ms connected
932 created 1000, last received 10500, last connected 6500
936 in ACTIVE for 6000 ms (2000 ms backoff)
937 connected (6000 ms), total 6000 ms connected
940 created 1000, last received 12500, last connected 6500
944 in BACKOFF for 0 ms (1000 ms backoff)
945 1 successful connections out of 3 attempts, seqno 2
946 not connected (0 ms), total 6000 ms connected
949 # Back off for 1000 ms.
954 in BACKOFF for 1000 ms (1000 ms backoff)
959 ######################################################################
960 RECONNECT_CHECK([connection attempt fails quickly],
963 # Connection fails quickly.
965 connect-failed ECONNREFUSED
967 # Back off for 1000 ms.
971 # Connection fails quickly again.
973 connect-failed ECONNREFUSED
975 # Back off for 2000 ms.
981 in BACKOFF for 0 ms (0 ms backoff)
983 # Connection fails quickly.
986 connect-failed ECONNREFUSED
987 in BACKOFF for 0 ms (1000 ms backoff)
988 0 successful connections out of 1 attempts, seqno 0
990 # Back off for 1000 ms.
996 in BACKOFF for 1000 ms (1000 ms backoff)
998 # Connection fails quickly again.
1001 connect-failed ECONNREFUSED
1002 in BACKOFF for 0 ms (2000 ms backoff)
1003 0 successful connections out of 2 attempts, seqno 0
1005 # Back off for 2000 ms.
1011 in BACKOFF for 2000 ms (2000 ms backoff)
1014 ######################################################################
1015 RECONNECT_CHECK([max-tries of 1 honored],
1019 # Connection succeeds.
1023 # Send inactivity probe.
1027 # Idle timeout kills connection.
1036 in BACKOFF for 0 ms (0 ms backoff)
1039 # Connection succeeds.
1043 in ACTIVE for 0 ms (0 ms backoff)
1044 1 successful connections out of 1 attempts, seqno 1
1045 connected (0 ms), total 0 ms connected
1047 # Send inactivity probe.
1052 in ACTIVE for 5000 ms (0 ms backoff)
1053 connected (5000 ms), total 5000 ms connected
1056 in IDLE for 0 ms (0 ms backoff)
1058 # Idle timeout kills connection.
1063 in IDLE for 5000 ms (0 ms backoff)
1064 connected (10000 ms), total 10000 ms connected
1068 in VOID for 0 ms (1000 ms backoff)
1069 1 successful connections out of 1 attempts, seqno 2
1070 not connected (0 ms), total 10000 ms connected
1073 ######################################################################
1074 RECONNECT_CHECK([max-tries of 0 honored],
1089 ######################################################################
1090 RECONNECT_CHECK([passive mode],
1099 # Listening never times out.
1103 # Listening failed (accept() returned funny error?). Back off and try again.
1109 # Connection accepted.
1115 # Connection times out.
1122 # Start listening again.
1130 in BACKOFF for 0 ms (0 ms backoff)
1138 in LISTENING for 0 ms (0 ms backoff)
1140 # Listening never times out.
1145 # Listening failed (accept() returned funny error?). Back off and try again.
1147 in BACKOFF for 0 ms (1000 ms backoff)
1152 in BACKOFF for 1000 ms (1000 ms backoff)
1156 in LISTENING for 0 ms (1000 ms backoff)
1158 # Connection accepted.
1160 in ACTIVE for 0 ms (1000 ms backoff)
1161 created 1000, last received 1000, last connected 2000
1162 1 successful connections out of 1 attempts, seqno 1
1163 connected (0 ms), total 0 ms connected
1165 created 1000, last received 2000, last connected 2000
1169 in ACTIVE for 1000 ms (1000 ms backoff)
1170 connected (1000 ms), total 1000 ms connected
1172 created 1000, last received 3000, last connected 2000
1174 # Connection times out.
1179 in ACTIVE for 6000 ms (1000 ms backoff)
1180 connected (6000 ms), total 6000 ms connected
1183 in IDLE for 0 ms (1000 ms backoff)
1188 in IDLE for 5000 ms (1000 ms backoff)
1189 connected (11000 ms), total 11000 ms connected
1193 in BACKOFF for 0 ms (0 ms backoff)
1194 1 successful connections out of 1 attempts, seqno 2
1195 not connected (0 ms), total 11000 ms connected
1197 # Start listening again.
1203 in LISTENING for 0 ms (0 ms backoff)