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 created 1000, last activity 1000, last connected 1000
63 1 successful connections out of 1 attempts, seqno 1
65 last connected 0 ms ago, connected 0 ms total
67 # Send inactivity probe.
72 in ACTIVE for 5000 ms (0 ms backoff)
75 in IDLE for 0 ms (0 ms backoff)
77 # Idle timeout kills connection.
82 in IDLE for 5000 ms (0 ms backoff)
86 in BACKOFF for 0 ms (1000 ms backoff)
87 1 successful connections out of 1 attempts, seqno 2
89 disconnected at 11000 ms (0 ms ago)
92 ######################################################################
93 RECONNECT_CHECK([slow connect, idle disconnect],
100 # Connect after 500 ms.
105 # Send inactivity probe.
109 # Idle timeout kills connection.
116 in BACKOFF for 0 ms (0 ms backoff)
122 in CONNECTING for 0 ms (0 ms backoff)
124 # Connect after 500 ms.
128 in CONNECTING for 500 ms (0 ms backoff)
131 in ACTIVE for 0 ms (0 ms backoff)
132 created 1000, last activity 1000, last connected 1500
133 1 successful connections out of 1 attempts, seqno 1
135 last connected 0 ms ago, connected 0 ms total
137 # Send inactivity probe.
142 in ACTIVE for 5000 ms (0 ms backoff)
145 in IDLE for 0 ms (0 ms backoff)
147 # Idle timeout kills connection.
152 in IDLE for 5000 ms (0 ms backoff)
156 in BACKOFF for 0 ms (1000 ms backoff)
157 1 successful connections out of 1 attempts, seqno 2
159 disconnected at 11500 ms (0 ms ago)
162 ######################################################################
163 RECONNECT_CHECK([connect backs off],
166 # First connection attempt fails after 1000 ms.
174 # Back off for 1000 ms.
178 # Second connection attempt fails after 1000 ms.
184 # Back off for 2000 ms.
188 # Third connection attempt fails after 2000 ms.
194 # Back off for 4000 ms.
198 # Third connection attempt fails after 4000 ms.
204 # Back off for 8000 ms.
208 # Third connection attempt fails after 8000 ms.
214 # Back off for 8000 ms.
218 # Fourth connection attempt fails after 8000 ms.
226 in BACKOFF for 0 ms (0 ms backoff)
228 # First connection attempt fails after 1000 ms.
232 in CONNECTING for 0 ms (0 ms backoff)
238 in CONNECTING for 1000 ms (0 ms backoff)
242 in BACKOFF for 0 ms (1000 ms backoff)
243 0 successful connections out of 1 attempts, seqno 0
245 # Back off for 1000 ms.
250 in BACKOFF for 1000 ms (1000 ms backoff)
254 # Second connection attempt fails after 1000 ms.
256 in CONNECTING for 0 ms (1000 ms backoff)
261 in CONNECTING for 1000 ms (1000 ms backoff)
265 in BACKOFF for 0 ms (2000 ms backoff)
266 0 successful connections out of 2 attempts, seqno 0
268 # Back off for 2000 ms.
273 in BACKOFF for 2000 ms (2000 ms backoff)
277 # Third connection attempt fails after 2000 ms.
279 in CONNECTING for 0 ms (2000 ms backoff)
284 in CONNECTING for 2000 ms (2000 ms backoff)
288 in BACKOFF for 0 ms (4000 ms backoff)
289 0 successful connections out of 3 attempts, seqno 0
291 # Back off for 4000 ms.
296 in BACKOFF for 4000 ms (4000 ms backoff)
300 # Third connection attempt fails after 4000 ms.
302 in CONNECTING for 0 ms (4000 ms backoff)
307 in CONNECTING for 4000 ms (4000 ms backoff)
311 in BACKOFF for 0 ms (8000 ms backoff)
312 0 successful connections out of 4 attempts, seqno 0
314 # Back off for 8000 ms.
319 in BACKOFF for 8000 ms (8000 ms backoff)
323 # Third connection attempt fails after 8000 ms.
325 in CONNECTING for 0 ms (8000 ms backoff)
330 in CONNECTING for 8000 ms (8000 ms backoff)
334 in BACKOFF for 0 ms (8000 ms backoff)
335 0 successful connections out of 5 attempts, seqno 0
337 # Back off for 8000 ms.
342 in BACKOFF for 8000 ms (8000 ms backoff)
346 # Fourth connection attempt fails after 8000 ms.
348 in CONNECTING for 0 ms (8000 ms backoff)
353 in CONNECTING for 8000 ms (8000 ms backoff)
357 in BACKOFF for 0 ms (8000 ms backoff)
358 0 successful connections out of 6 attempts, seqno 0
361 ######################################################################
362 RECONNECT_CHECK([connections with no data preserve backoff],
365 # First connect, then idle timeout kills connection.
374 # Back off for 1000 ms.
378 # Second connect, then idle timeout kills connection.
387 # Back off for 2000 ms.
391 # Third connect, then idle timeout kills connection.
400 # Back off for 4000 ms.
404 in BACKOFF for 0 ms (0 ms backoff)
406 # First connect, then idle timeout kills connection.
410 in ACTIVE for 0 ms (0 ms backoff)
411 created 1000, last activity 1000, last connected 1000
412 1 successful connections out of 1 attempts, seqno 1
414 last connected 0 ms ago, connected 0 ms total
419 in ACTIVE for 5000 ms (0 ms backoff)
422 in IDLE for 0 ms (0 ms backoff)
427 in IDLE for 5000 ms (0 ms backoff)
431 in BACKOFF for 0 ms (1000 ms backoff)
432 1 successful connections out of 1 attempts, seqno 2
434 disconnected at 11000 ms (0 ms ago)
436 # Back off for 1000 ms.
441 in BACKOFF for 1000 ms (1000 ms backoff)
442 last connected 11000 ms ago, connected 10000 ms total
446 # Second connect, then idle timeout kills connection.
450 in ACTIVE for 0 ms (1000 ms backoff)
451 created 1000, last activity 1000, last connected 12000
452 2 successful connections out of 2 attempts, seqno 3
454 last connected 0 ms ago, connected 10000 ms total
459 in ACTIVE for 5000 ms (1000 ms backoff)
462 in IDLE for 0 ms (1000 ms backoff)
467 in IDLE for 5000 ms (1000 ms backoff)
471 in BACKOFF for 0 ms (2000 ms backoff)
472 2 successful connections out of 2 attempts, seqno 4
474 disconnected at 22000 ms (0 ms ago)
476 # Back off for 2000 ms.
481 in BACKOFF for 2000 ms (2000 ms backoff)
482 last connected 12000 ms ago, connected 20000 ms total
486 # Third connect, then idle timeout kills connection.
490 in ACTIVE for 0 ms (2000 ms backoff)
491 created 1000, last activity 1000, last connected 24000
492 3 successful connections out of 3 attempts, seqno 5
494 last connected 0 ms ago, connected 20000 ms total
499 in ACTIVE for 5000 ms (2000 ms backoff)
502 in IDLE for 0 ms (2000 ms backoff)
507 in IDLE for 5000 ms (2000 ms backoff)
511 in BACKOFF for 0 ms (4000 ms backoff)
512 3 successful connections out of 3 attempts, seqno 6
514 disconnected at 34000 ms (0 ms ago)
516 # Back off for 4000 ms.
521 in BACKOFF for 4000 ms (4000 ms backoff)
522 last connected 14000 ms ago, connected 30000 ms total
525 ######################################################################
526 RECONNECT_CHECK([brief connection preserves backoff],
529 # First connection attempt fails after 1000 ms.
537 # Back off for 1000 ms.
541 # Second connection attempt fails after 1000 ms.
547 # Back off for 2000 ms.
551 # Third connection attempt succeeds after 500 ms.
557 # Connection drops after another 250 ms.
562 # Back off for 4000 ms.
567 in BACKOFF for 0 ms (0 ms backoff)
569 # First connection attempt fails after 1000 ms.
573 in CONNECTING for 0 ms (0 ms backoff)
579 in CONNECTING for 1000 ms (0 ms backoff)
583 in BACKOFF for 0 ms (1000 ms backoff)
584 0 successful connections out of 1 attempts, seqno 0
586 # Back off for 1000 ms.
591 in BACKOFF for 1000 ms (1000 ms backoff)
595 # Second connection attempt fails after 1000 ms.
597 in CONNECTING for 0 ms (1000 ms backoff)
602 in CONNECTING for 1000 ms (1000 ms backoff)
606 in BACKOFF for 0 ms (2000 ms backoff)
607 0 successful connections out of 2 attempts, seqno 0
609 # Back off for 2000 ms.
614 in BACKOFF for 2000 ms (2000 ms backoff)
618 # Third connection attempt succeeds after 500 ms.
620 in CONNECTING for 0 ms (2000 ms backoff)
624 in CONNECTING for 500 ms (2000 ms backoff)
627 in ACTIVE for 0 ms (2000 ms backoff)
628 created 1000, last activity 1000, last connected 6500
629 1 successful connections out of 3 attempts, seqno 1
631 last connected 0 ms ago, connected 0 ms total
633 # Connection drops after another 250 ms.
637 in ACTIVE for 250 ms (2000 ms backoff)
639 in BACKOFF for 0 ms (4000 ms backoff)
640 1 successful connections out of 3 attempts, seqno 2
642 disconnected at 6750 ms (0 ms ago)
645 # Back off for 4000 ms.
650 in BACKOFF for 4000 ms (4000 ms backoff)
651 last connected 4250 ms ago, connected 250 ms total
656 ######################################################################
657 RECONNECT_CHECK([brief connection with data preserves backoff],
660 # First connection attempt fails after 1000 ms.
668 # Back off for 1000 ms.
672 # Second connection attempt fails after 1000 ms.
678 # Back off for 2000 ms.
682 # Third connection attempt succeeds after 500 ms.
688 # Connection receives 3 chunks of data spaced 250 ms apart.
703 # Back off for 4000 ms.
709 in BACKOFF for 0 ms (0 ms backoff)
711 # First connection attempt fails after 1000 ms.
715 in CONNECTING for 0 ms (0 ms backoff)
721 in CONNECTING for 1000 ms (0 ms backoff)
725 in BACKOFF for 0 ms (1000 ms backoff)
726 0 successful connections out of 1 attempts, seqno 0
728 # Back off for 1000 ms.
733 in BACKOFF for 1000 ms (1000 ms backoff)
737 # Second connection attempt fails after 1000 ms.
739 in CONNECTING for 0 ms (1000 ms backoff)
744 in CONNECTING for 1000 ms (1000 ms backoff)
748 in BACKOFF for 0 ms (2000 ms backoff)
749 0 successful connections out of 2 attempts, seqno 0
751 # Back off for 2000 ms.
756 in BACKOFF for 2000 ms (2000 ms backoff)
760 # Third connection attempt succeeds after 500 ms.
762 in CONNECTING for 0 ms (2000 ms backoff)
766 in CONNECTING for 500 ms (2000 ms backoff)
769 in ACTIVE for 0 ms (2000 ms backoff)
770 created 1000, last activity 1000, last connected 6500
771 1 successful connections out of 3 attempts, seqno 1
773 last connected 0 ms ago, connected 0 ms total
775 # Connection receives 3 chunks of data spaced 250 ms apart.
779 in ACTIVE for 250 ms (2000 ms backoff)
782 created 1000, last activity 6750, last connected 6500
786 in ACTIVE for 500 ms (2000 ms backoff)
789 created 1000, last activity 7000, last connected 6500
793 in ACTIVE for 750 ms (2000 ms backoff)
796 created 1000, last activity 7250, last connected 6500
800 in BACKOFF for 0 ms (4000 ms backoff)
801 1 successful connections out of 3 attempts, seqno 2
803 disconnected at 7250 ms (0 ms ago)
806 # Back off for 4000 ms.
811 in BACKOFF for 4000 ms (4000 ms backoff)
812 last connected 4750 ms ago, connected 750 ms total
817 ######################################################################
818 RECONNECT_CHECK([long connection resets backoff],
821 # First connection attempt fails after 1000 ms.
829 # Back off for 1000 ms.
833 # Second connection attempt fails after 1000 ms.
839 # Back off for 2000 ms.
843 # Third connection attempt succeeds after 500 ms.
849 # Connection receives 3 chunks of data spaced 2000 ms apart.
864 # Back off for 1000 ms.
870 in BACKOFF for 0 ms (0 ms backoff)
872 # First connection attempt fails after 1000 ms.
876 in CONNECTING for 0 ms (0 ms backoff)
882 in CONNECTING for 1000 ms (0 ms backoff)
886 in BACKOFF for 0 ms (1000 ms backoff)
887 0 successful connections out of 1 attempts, seqno 0
889 # Back off for 1000 ms.
894 in BACKOFF for 1000 ms (1000 ms backoff)
898 # Second connection attempt fails after 1000 ms.
900 in CONNECTING for 0 ms (1000 ms backoff)
905 in CONNECTING for 1000 ms (1000 ms backoff)
909 in BACKOFF for 0 ms (2000 ms backoff)
910 0 successful connections out of 2 attempts, seqno 0
912 # Back off for 2000 ms.
917 in BACKOFF for 2000 ms (2000 ms backoff)
921 # Third connection attempt succeeds after 500 ms.
923 in CONNECTING for 0 ms (2000 ms backoff)
927 in CONNECTING for 500 ms (2000 ms backoff)
930 in ACTIVE for 0 ms (2000 ms backoff)
931 created 1000, last activity 1000, last connected 6500
932 1 successful connections out of 3 attempts, seqno 1
934 last connected 0 ms ago, connected 0 ms total
936 # Connection receives 3 chunks of data spaced 2000 ms apart.
940 in ACTIVE for 2000 ms (2000 ms backoff)
943 created 1000, last activity 8500, last connected 6500
947 in ACTIVE for 4000 ms (2000 ms backoff)
950 created 1000, last activity 10500, last connected 6500
954 in ACTIVE for 6000 ms (2000 ms backoff)
957 created 1000, last activity 12500, last connected 6500
961 in BACKOFF for 0 ms (1000 ms backoff)
962 1 successful connections out of 3 attempts, seqno 2
964 disconnected at 12500 ms (0 ms ago)
967 # Back off for 1000 ms.
972 in BACKOFF for 1000 ms (1000 ms backoff)
973 last connected 7000 ms ago, connected 6000 ms total
978 ######################################################################
979 RECONNECT_CHECK([connection attempt fails quickly],
982 # Connection fails quickly.
984 connect-failed ECONNREFUSED
986 # Back off for 1000 ms.
990 # Connection fails quickly again.
992 connect-failed ECONNREFUSED
994 # Back off for 2000 ms.
1000 in BACKOFF for 0 ms (0 ms backoff)
1002 # Connection fails quickly.
1005 connect-failed ECONNREFUSED
1006 in BACKOFF for 0 ms (1000 ms backoff)
1007 0 successful connections out of 1 attempts, seqno 0
1009 # Back off for 1000 ms.
1015 in BACKOFF for 1000 ms (1000 ms backoff)
1017 # Connection fails quickly again.
1020 connect-failed ECONNREFUSED
1021 in BACKOFF for 0 ms (2000 ms backoff)
1022 0 successful connections out of 2 attempts, seqno 0
1024 # Back off for 2000 ms.
1030 in BACKOFF for 2000 ms (2000 ms backoff)
1033 ######################################################################
1034 RECONNECT_CHECK([max-tries of 1 honored],
1038 # Connection succeeds.
1042 # Send inactivity probe.
1046 # Idle timeout kills connection.
1055 in BACKOFF for 0 ms (0 ms backoff)
1058 # Connection succeeds.
1062 in ACTIVE for 0 ms (0 ms backoff)
1063 created 1000, last activity 1000, last connected 1000
1064 1 successful connections out of 1 attempts, seqno 1
1066 last connected 0 ms ago, connected 0 ms total
1068 # Send inactivity probe.
1073 in ACTIVE for 5000 ms (0 ms backoff)
1076 in IDLE for 0 ms (0 ms backoff)
1078 # Idle timeout kills connection.
1083 in IDLE for 5000 ms (0 ms backoff)
1087 in VOID for 0 ms (1000 ms backoff)
1088 1 successful connections out of 1 attempts, seqno 2
1090 disconnected at 11000 ms (0 ms ago)
1093 ######################################################################
1094 RECONNECT_CHECK([max-tries of 0 honored],
1109 ######################################################################
1110 RECONNECT_CHECK([passive mode],
1119 # Listening never times out.
1123 # Listening failed (accept() returned funny error?). Back off and try again.
1129 # Connection accepted.
1135 # Connection times out.
1142 # Start listening again.
1150 in BACKOFF for 0 ms (0 ms backoff)
1158 in LISTENING for 0 ms (0 ms backoff)
1160 # Listening never times out.
1165 # Listening failed (accept() returned funny error?). Back off and try again.
1167 in BACKOFF for 0 ms (1000 ms backoff)
1172 in BACKOFF for 1000 ms (1000 ms backoff)
1176 in LISTENING for 0 ms (1000 ms backoff)
1178 # Connection accepted.
1180 in ACTIVE for 0 ms (1000 ms backoff)
1181 created 1000, last activity 1000, last connected 2000
1182 1 successful connections out of 1 attempts, seqno 1
1184 last connected 0 ms ago, connected 0 ms total
1186 created 1000, last activity 2000, last connected 2000
1190 in ACTIVE for 1000 ms (1000 ms backoff)
1192 created 1000, last activity 3000, last connected 2000
1194 # Connection times out.
1199 in ACTIVE for 6000 ms (1000 ms backoff)
1202 in IDLE for 0 ms (1000 ms backoff)
1207 in IDLE for 5000 ms (1000 ms backoff)
1211 in BACKOFF for 0 ms (0 ms backoff)
1212 1 successful connections out of 1 attempts, seqno 2
1214 disconnected at 13000 ms (0 ms ago)
1216 # Start listening again.
1222 in LISTENING for 0 ms (0 ms backoff)