1 AT_BANNER([reconnect library])
3 ######################################################################
4 AT_SETUP([nothing happens if not enabled])
5 AT_KEYWORDS([reconnect])
9 AT_CHECK([test-reconnect < input], [0],
17 ######################################################################
18 AT_SETUP([quick connect, idle disconnect])
19 AT_KEYWORDS([reconnect])
20 AT_DATA([input], [enable
22 # Connection succeeds.
26 # Send inactivity probe.
30 # Idle timeout kills connection.
35 AT_CHECK([test-reconnect < input], [0],
38 in BACKOFF for 0 ms (0 ms backoff)
40 # Connection succeeds.
44 in ACTIVE for 0 ms (0 ms backoff)
45 1 successful connections out of 1 attempts, seqno 1
46 connected (0 ms), total 0 ms connected
48 # Send inactivity probe.
53 in ACTIVE for 5000 ms (0 ms backoff)
54 connected (5000 ms), total 5000 ms connected
57 in IDLE for 0 ms (0 ms backoff)
59 # Idle timeout kills connection.
64 in IDLE for 5000 ms (0 ms backoff)
65 connected (10000 ms), total 10000 ms connected
69 in BACKOFF for 0 ms (1000 ms backoff)
70 1 successful connections out of 1 attempts, seqno 2
71 not connected (0 ms), total 10000 ms connected
75 ######################################################################
76 AT_SETUP([slow connect, idle disconnect])
77 AT_KEYWORDS([reconnect])
78 AT_DATA([input], [enable
84 # Connect after 500 ms.
89 # Send inactivity probe.
93 # Idle timeout kills connection.
98 AT_CHECK([test-reconnect < input], [0],
101 in BACKOFF for 0 ms (0 ms backoff)
107 in CONNECT_IN_PROGRESS for 0 ms (0 ms backoff)
109 # Connect after 500 ms.
113 in CONNECT_IN_PROGRESS for 500 ms (0 ms backoff)
116 in ACTIVE for 0 ms (0 ms backoff)
117 created 1000, last received 1000, last connected 1500
118 1 successful connections out of 1 attempts, seqno 1
119 connected (0 ms), total 0 ms connected
121 # Send inactivity probe.
126 in ACTIVE for 5000 ms (0 ms backoff)
127 connected (5000 ms), total 5000 ms connected
130 in IDLE for 0 ms (0 ms backoff)
132 # Idle timeout kills connection.
137 in IDLE for 5000 ms (0 ms backoff)
138 connected (10000 ms), total 10000 ms connected
142 in BACKOFF for 0 ms (1000 ms backoff)
143 1 successful connections out of 1 attempts, seqno 2
144 not connected (0 ms), total 10000 ms connected
148 ######################################################################
149 AT_SETUP([connect backs off])
150 AT_KEYWORDS([reconnect])
151 AT_DATA([input], [enable
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.
211 AT_CHECK([test-reconnect < input], [0],
214 in BACKOFF for 0 ms (0 ms backoff)
216 # First connection attempt fails after 1000 ms.
220 in CONNECT_IN_PROGRESS for 0 ms (0 ms backoff)
226 in CONNECT_IN_PROGRESS for 1000 ms (0 ms backoff)
230 in BACKOFF for 0 ms (1000 ms backoff)
231 0 successful connections out of 1 attempts, seqno 0
233 # Back off for 1000 ms.
238 in BACKOFF for 1000 ms (1000 ms backoff)
242 # Second connection attempt fails after 1000 ms.
244 in CONNECT_IN_PROGRESS for 0 ms (1000 ms backoff)
249 in CONNECT_IN_PROGRESS for 1000 ms (1000 ms backoff)
253 in BACKOFF for 0 ms (2000 ms backoff)
254 0 successful connections out of 2 attempts, seqno 0
256 # Back off for 2000 ms.
261 in BACKOFF for 2000 ms (2000 ms backoff)
265 # Third connection attempt fails after 2000 ms.
267 in CONNECT_IN_PROGRESS for 0 ms (2000 ms backoff)
272 in CONNECT_IN_PROGRESS for 2000 ms (2000 ms backoff)
276 in BACKOFF for 0 ms (4000 ms backoff)
277 0 successful connections out of 3 attempts, seqno 0
279 # Back off for 4000 ms.
284 in BACKOFF for 4000 ms (4000 ms backoff)
288 # Third connection attempt fails after 4000 ms.
290 in CONNECT_IN_PROGRESS for 0 ms (4000 ms backoff)
295 in CONNECT_IN_PROGRESS for 4000 ms (4000 ms backoff)
299 in BACKOFF for 0 ms (8000 ms backoff)
300 0 successful connections out of 4 attempts, seqno 0
302 # Back off for 8000 ms.
307 in BACKOFF for 8000 ms (8000 ms backoff)
311 # Third connection attempt fails after 8000 ms.
313 in CONNECT_IN_PROGRESS for 0 ms (8000 ms backoff)
318 in CONNECT_IN_PROGRESS for 8000 ms (8000 ms backoff)
322 in BACKOFF for 0 ms (8000 ms backoff)
323 0 successful connections out of 5 attempts, seqno 0
325 # Back off for 8000 ms.
330 in BACKOFF for 8000 ms (8000 ms backoff)
334 # Fourth connection attempt fails after 8000 ms.
336 in CONNECT_IN_PROGRESS for 0 ms (8000 ms backoff)
341 in CONNECT_IN_PROGRESS for 8000 ms (8000 ms backoff)
345 in BACKOFF for 0 ms (8000 ms backoff)
346 0 successful connections out of 6 attempts, seqno 0
350 ######################################################################
351 AT_SETUP([connections with no data preserve backoff])
352 AT_KEYWORDS([reconnect])
353 AT_DATA([input], [enable
355 # First connect, then idle timeout kills connection.
364 # Back off for 1000 ms.
368 # Second connect, then idle timeout kills connection.
377 # Back off for 2000 ms.
381 # Third connect, then idle timeout kills connection.
390 # Back off for 4000 ms.
394 in BACKOFF for 0 ms (0 ms backoff)
396 # First connect, then idle timeout kills connection.
400 in ACTIVE for 0 ms (0 ms backoff)
401 1 successful connections out of 1 attempts, seqno 1
402 connected (0 ms), total 0 ms connected
407 in ACTIVE for 5000 ms (0 ms backoff)
408 connected (5000 ms), total 5000 ms connected
411 in IDLE for 0 ms (0 ms backoff)
416 in IDLE for 5000 ms (0 ms backoff)
417 connected (10000 ms), total 10000 ms connected
421 in BACKOFF for 0 ms (1000 ms backoff)
422 1 successful connections out of 1 attempts, seqno 2
423 not connected (0 ms), total 10000 ms connected
425 # Back off for 1000 ms.
430 in BACKOFF for 1000 ms (1000 ms backoff)
434 # Second connect, then idle timeout kills connection.
438 in ACTIVE for 0 ms (1000 ms backoff)
439 created 1000, last received 1000, last connected 12000
440 2 successful connections out of 2 attempts, seqno 3
441 connected (0 ms), total 10000 ms connected
446 in ACTIVE for 5000 ms (1000 ms backoff)
447 connected (5000 ms), total 15000 ms connected
450 in IDLE for 0 ms (1000 ms backoff)
455 in IDLE for 5000 ms (1000 ms backoff)
456 connected (10000 ms), total 20000 ms connected
460 in BACKOFF for 0 ms (2000 ms backoff)
461 2 successful connections out of 2 attempts, seqno 4
462 not connected (0 ms), total 20000 ms connected
464 # Back off for 2000 ms.
469 in BACKOFF for 2000 ms (2000 ms backoff)
473 # Third connect, then idle timeout kills connection.
477 in ACTIVE for 0 ms (2000 ms backoff)
478 created 1000, last received 1000, last connected 24000
479 3 successful connections out of 3 attempts, seqno 5
480 connected (0 ms), total 20000 ms connected
485 in ACTIVE for 5000 ms (2000 ms backoff)
486 connected (5000 ms), total 25000 ms connected
489 in IDLE for 0 ms (2000 ms backoff)
494 in IDLE for 5000 ms (2000 ms backoff)
495 connected (10000 ms), total 30000 ms connected
499 in BACKOFF for 0 ms (4000 ms backoff)
500 3 successful connections out of 3 attempts, seqno 6
501 not connected (0 ms), total 30000 ms connected
503 # Back off for 4000 ms.
508 in BACKOFF for 4000 ms (4000 ms backoff)
513 ######################################################################
514 AT_SETUP([brief connection preserves backoff])
515 AT_KEYWORDS([reconnect])
516 AT_DATA([input], [enable
518 # First connection attempt fails after 1000 ms.
526 # Back off for 1000 ms.
530 # Second connection attempt fails after 1000 ms.
536 # Back off for 2000 ms.
540 # Third connection attempt succeeds after 500 ms.
546 # Connection drops after another 250 ms.
551 # Back off for 4000 ms.
555 AT_CHECK([test-reconnect < input], [0],
558 in BACKOFF for 0 ms (0 ms backoff)
560 # First connection attempt fails after 1000 ms.
564 in CONNECT_IN_PROGRESS for 0 ms (0 ms backoff)
570 in CONNECT_IN_PROGRESS for 1000 ms (0 ms backoff)
574 in BACKOFF for 0 ms (1000 ms backoff)
575 0 successful connections out of 1 attempts, seqno 0
577 # Back off for 1000 ms.
582 in BACKOFF for 1000 ms (1000 ms backoff)
586 # Second connection attempt fails after 1000 ms.
588 in CONNECT_IN_PROGRESS for 0 ms (1000 ms backoff)
593 in CONNECT_IN_PROGRESS for 1000 ms (1000 ms backoff)
597 in BACKOFF for 0 ms (2000 ms backoff)
598 0 successful connections out of 2 attempts, seqno 0
600 # Back off for 2000 ms.
605 in BACKOFF for 2000 ms (2000 ms backoff)
609 # Third connection attempt succeeds after 500 ms.
611 in CONNECT_IN_PROGRESS for 0 ms (2000 ms backoff)
615 in CONNECT_IN_PROGRESS for 500 ms (2000 ms backoff)
618 in ACTIVE for 0 ms (2000 ms backoff)
619 created 1000, last received 1000, last connected 6500
620 1 successful connections out of 3 attempts, seqno 1
621 connected (0 ms), total 0 ms connected
623 # Connection drops after another 250 ms.
627 in ACTIVE for 250 ms (2000 ms backoff)
628 connected (250 ms), total 250 ms connected
630 in BACKOFF for 0 ms (4000 ms backoff)
631 1 successful connections out of 3 attempts, seqno 2
632 not connected (0 ms), total 250 ms connected
635 # Back off for 4000 ms.
640 in BACKOFF for 4000 ms (4000 ms backoff)
646 ######################################################################
647 AT_SETUP([brief connection with data preserves backoff])
648 AT_KEYWORDS([reconnect])
649 AT_DATA([input], [enable
651 # First connection attempt fails after 1000 ms.
659 # Back off for 1000 ms.
663 # Second connection attempt fails after 1000 ms.
669 # Back off for 2000 ms.
673 # Third connection attempt succeeds after 500 ms.
679 # Connection receives 3 chunks of data spaced 250 ms apart.
694 # Back off for 4000 ms.
698 AT_CHECK([test-reconnect < input], [0],
701 in BACKOFF for 0 ms (0 ms backoff)
703 # First connection attempt fails after 1000 ms.
707 in CONNECT_IN_PROGRESS for 0 ms (0 ms backoff)
713 in CONNECT_IN_PROGRESS for 1000 ms (0 ms backoff)
717 in BACKOFF for 0 ms (1000 ms backoff)
718 0 successful connections out of 1 attempts, seqno 0
720 # Back off for 1000 ms.
725 in BACKOFF for 1000 ms (1000 ms backoff)
729 # Second connection attempt fails after 1000 ms.
731 in CONNECT_IN_PROGRESS for 0 ms (1000 ms backoff)
736 in CONNECT_IN_PROGRESS for 1000 ms (1000 ms backoff)
740 in BACKOFF for 0 ms (2000 ms backoff)
741 0 successful connections out of 2 attempts, seqno 0
743 # Back off for 2000 ms.
748 in BACKOFF for 2000 ms (2000 ms backoff)
752 # Third connection attempt succeeds after 500 ms.
754 in CONNECT_IN_PROGRESS for 0 ms (2000 ms backoff)
758 in CONNECT_IN_PROGRESS for 500 ms (2000 ms backoff)
761 in ACTIVE for 0 ms (2000 ms backoff)
762 created 1000, last received 1000, last connected 6500
763 1 successful connections out of 3 attempts, seqno 1
764 connected (0 ms), total 0 ms connected
766 # Connection receives 3 chunks of data spaced 250 ms apart.
770 in ACTIVE for 250 ms (2000 ms backoff)
771 connected (250 ms), total 250 ms connected
774 created 1000, last received 6750, last connected 6500
778 in ACTIVE for 500 ms (2000 ms backoff)
779 connected (500 ms), total 500 ms connected
782 created 1000, last received 7000, last connected 6500
786 in ACTIVE for 750 ms (2000 ms backoff)
787 connected (750 ms), total 750 ms connected
790 created 1000, last received 7250, last connected 6500
794 in BACKOFF for 0 ms (4000 ms backoff)
795 1 successful connections out of 3 attempts, seqno 2
796 not connected (0 ms), total 750 ms connected
799 # Back off for 4000 ms.
804 in BACKOFF for 4000 ms (4000 ms backoff)
810 ######################################################################
811 AT_SETUP([long connection resets backoff])
812 AT_KEYWORDS([reconnect])
813 AT_DATA([input], [enable
815 # First connection attempt fails after 1000 ms.
823 # Back off for 1000 ms.
827 # Second connection attempt fails after 1000 ms.
833 # Back off for 2000 ms.
837 # Third connection attempt succeeds after 500 ms.
843 # Connection receives 3 chunks of data spaced 2000 ms apart.
858 # Back off for 1000 ms.
862 AT_CHECK([test-reconnect < input], [0],
865 in BACKOFF for 0 ms (0 ms backoff)
867 # First connection attempt fails after 1000 ms.
871 in CONNECT_IN_PROGRESS for 0 ms (0 ms backoff)
877 in CONNECT_IN_PROGRESS for 1000 ms (0 ms backoff)
881 in BACKOFF for 0 ms (1000 ms backoff)
882 0 successful connections out of 1 attempts, seqno 0
884 # Back off for 1000 ms.
889 in BACKOFF for 1000 ms (1000 ms backoff)
893 # Second connection attempt fails after 1000 ms.
895 in CONNECT_IN_PROGRESS for 0 ms (1000 ms backoff)
900 in CONNECT_IN_PROGRESS for 1000 ms (1000 ms backoff)
904 in BACKOFF for 0 ms (2000 ms backoff)
905 0 successful connections out of 2 attempts, seqno 0
907 # Back off for 2000 ms.
912 in BACKOFF for 2000 ms (2000 ms backoff)
916 # Third connection attempt succeeds after 500 ms.
918 in CONNECT_IN_PROGRESS for 0 ms (2000 ms backoff)
922 in CONNECT_IN_PROGRESS for 500 ms (2000 ms backoff)
925 in ACTIVE for 0 ms (2000 ms backoff)
926 created 1000, last received 1000, last connected 6500
927 1 successful connections out of 3 attempts, seqno 1
928 connected (0 ms), total 0 ms connected
930 # Connection receives 3 chunks of data spaced 2000 ms apart.
934 in ACTIVE for 2000 ms (2000 ms backoff)
935 connected (2000 ms), total 2000 ms connected
938 created 1000, last received 8500, last connected 6500
942 in ACTIVE for 4000 ms (2000 ms backoff)
943 connected (4000 ms), total 4000 ms connected
946 created 1000, last received 10500, last connected 6500
950 in ACTIVE for 6000 ms (2000 ms backoff)
951 connected (6000 ms), total 6000 ms connected
954 created 1000, last received 12500, last connected 6500
958 in BACKOFF for 0 ms (1000 ms backoff)
959 1 successful connections out of 3 attempts, seqno 2
960 not connected (0 ms), total 6000 ms connected
963 # Back off for 1000 ms.
968 in BACKOFF for 1000 ms (1000 ms backoff)
974 ######################################################################
975 AT_SETUP([connection attempt fails quickly])
976 AT_KEYWORDS([reconnect])
977 AT_DATA([input], [enable
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.
995 AT_CHECK([test-reconnect < input], [0],
998 in BACKOFF for 0 ms (0 ms backoff)
1000 # Connection fails quickly.
1003 connect-failed ECONNREFUSED
1004 in BACKOFF for 0 ms (1000 ms backoff)
1005 0 successful connections out of 1 attempts, seqno 0
1007 # Back off for 1000 ms.
1013 in BACKOFF for 1000 ms (1000 ms backoff)
1015 # Connection fails quickly again.
1018 connect-failed ECONNREFUSED
1019 in BACKOFF for 0 ms (2000 ms backoff)
1020 0 successful connections out of 2 attempts, seqno 0
1022 # Back off for 2000 ms.
1028 in BACKOFF for 2000 ms (2000 ms backoff)
1032 ######################################################################
1033 AT_SETUP([max-tries of 1 honored])
1034 AT_KEYWORDS([reconnect])
1035 AT_DATA([input], [set-max-tries 1
1038 # Connection succeeds.
1042 # Send inactivity probe.
1046 # Idle timeout kills connection.
1051 AT_CHECK([test-reconnect < input], [0],
1056 in BACKOFF for 0 ms (0 ms backoff)
1059 # Connection succeeds.
1063 in ACTIVE for 0 ms (0 ms backoff)
1064 1 successful connections out of 1 attempts, seqno 1
1065 connected (0 ms), total 0 ms connected
1067 # Send inactivity probe.
1072 in ACTIVE for 5000 ms (0 ms backoff)
1073 connected (5000 ms), total 5000 ms connected
1076 in IDLE for 0 ms (0 ms backoff)
1078 # Idle timeout kills connection.
1083 in IDLE for 5000 ms (0 ms backoff)
1084 connected (10000 ms), total 10000 ms connected
1088 in VOID for 0 ms (1000 ms backoff)
1089 1 successful connections out of 1 attempts, seqno 2
1090 not connected (0 ms), total 10000 ms connected
1094 ######################################################################
1095 AT_SETUP([max-tries of 0 honored])
1096 AT_KEYWORDS([reconnect])
1097 AT_DATA([input], [set-max-tries 0
1102 AT_CHECK([test-reconnect < input], [0],