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
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)
129 disconnected for 500 ms
132 in ACTIVE for 0 ms (0 ms backoff)
133 created 1000, last received 1000, last connected 1500
134 1 successful connections out of 1 attempts, seqno 1
135 connected (0 ms), total 0 ms connected
136 disconnected for 0 ms
138 # Send inactivity probe.
143 in ACTIVE for 5000 ms (0 ms backoff)
144 connected (5000 ms), total 5000 ms connected
147 in IDLE for 0 ms (0 ms backoff)
149 # Idle timeout kills connection.
154 in IDLE for 5000 ms (0 ms backoff)
155 connected (10000 ms), total 10000 ms connected
159 in BACKOFF for 0 ms (1000 ms backoff)
160 1 successful connections out of 1 attempts, seqno 2
161 not connected (0 ms), total 10000 ms connected
162 disconnected at 11500 ms (0 ms ago)
165 ######################################################################
166 RECONNECT_CHECK([connect backs off],
169 # First connection attempt fails after 1000 ms.
177 # Back off for 1000 ms.
181 # Second connection attempt fails after 1000 ms.
187 # Back off for 2000 ms.
191 # Third connection attempt fails after 2000 ms.
197 # Back off for 4000 ms.
201 # Third connection attempt fails after 4000 ms.
207 # Back off for 8000 ms.
211 # Third connection attempt fails after 8000 ms.
217 # Back off for 8000 ms.
221 # Fourth connection attempt fails after 8000 ms.
229 in BACKOFF for 0 ms (0 ms backoff)
231 # First connection attempt fails after 1000 ms.
235 in CONNECTING for 0 ms (0 ms backoff)
241 in CONNECTING for 1000 ms (0 ms backoff)
242 disconnected for 1000 ms
246 in BACKOFF for 0 ms (1000 ms backoff)
247 0 successful connections out of 1 attempts, seqno 0
249 # Back off for 1000 ms.
254 in BACKOFF for 1000 ms (1000 ms backoff)
255 disconnected for 2000 ms
259 # Second connection attempt fails after 1000 ms.
261 in CONNECTING for 0 ms (1000 ms backoff)
266 in CONNECTING for 1000 ms (1000 ms backoff)
267 disconnected for 3000 ms
271 in BACKOFF for 0 ms (2000 ms backoff)
272 0 successful connections out of 2 attempts, seqno 0
274 # Back off for 2000 ms.
279 in BACKOFF for 2000 ms (2000 ms backoff)
280 disconnected for 5000 ms
284 # Third connection attempt fails after 2000 ms.
286 in CONNECTING for 0 ms (2000 ms backoff)
291 in CONNECTING for 2000 ms (2000 ms backoff)
292 disconnected for 7000 ms
296 in BACKOFF for 0 ms (4000 ms backoff)
297 0 successful connections out of 3 attempts, seqno 0
299 # Back off for 4000 ms.
304 in BACKOFF for 4000 ms (4000 ms backoff)
305 disconnected for 11000 ms
309 # Third connection attempt fails after 4000 ms.
311 in CONNECTING for 0 ms (4000 ms backoff)
316 in CONNECTING for 4000 ms (4000 ms backoff)
317 disconnected for 15000 ms
321 in BACKOFF for 0 ms (8000 ms backoff)
322 0 successful connections out of 4 attempts, seqno 0
324 # Back off for 8000 ms.
329 in BACKOFF for 8000 ms (8000 ms backoff)
330 disconnected for 23000 ms
334 # Third connection attempt fails after 8000 ms.
336 in CONNECTING for 0 ms (8000 ms backoff)
341 in CONNECTING for 8000 ms (8000 ms backoff)
342 disconnected for 31000 ms
346 in BACKOFF for 0 ms (8000 ms backoff)
347 0 successful connections out of 5 attempts, seqno 0
349 # Back off for 8000 ms.
354 in BACKOFF for 8000 ms (8000 ms backoff)
355 disconnected for 39000 ms
359 # Fourth connection attempt fails after 8000 ms.
361 in CONNECTING for 0 ms (8000 ms backoff)
366 in CONNECTING for 8000 ms (8000 ms backoff)
367 disconnected for 47000 ms
371 in BACKOFF for 0 ms (8000 ms backoff)
372 0 successful connections out of 6 attempts, seqno 0
375 ######################################################################
376 RECONNECT_CHECK([connections with no data preserve backoff],
379 # First connect, then idle timeout kills connection.
388 # Back off for 1000 ms.
392 # Second connect, then idle timeout kills connection.
401 # Back off for 2000 ms.
405 # Third connect, then idle timeout kills connection.
414 # Back off for 4000 ms.
418 in BACKOFF for 0 ms (0 ms backoff)
420 # First connect, then idle timeout kills connection.
424 in ACTIVE for 0 ms (0 ms backoff)
425 1 successful connections out of 1 attempts, seqno 1
426 connected (0 ms), total 0 ms connected
431 in ACTIVE for 5000 ms (0 ms backoff)
432 connected (5000 ms), total 5000 ms connected
435 in IDLE for 0 ms (0 ms backoff)
440 in IDLE for 5000 ms (0 ms backoff)
441 connected (10000 ms), total 10000 ms connected
445 in BACKOFF for 0 ms (1000 ms backoff)
446 1 successful connections out of 1 attempts, seqno 2
447 not connected (0 ms), total 10000 ms connected
448 disconnected at 11000 ms (0 ms ago)
450 # Back off for 1000 ms.
455 in BACKOFF for 1000 ms (1000 ms backoff)
456 disconnected for 1000 ms
460 # Second connect, then idle timeout kills connection.
464 in ACTIVE for 0 ms (1000 ms backoff)
465 created 1000, last received 1000, last connected 12000
466 2 successful connections out of 2 attempts, seqno 3
467 connected (0 ms), total 10000 ms connected
468 disconnected for 0 ms
473 in ACTIVE for 5000 ms (1000 ms backoff)
474 connected (5000 ms), total 15000 ms connected
477 in IDLE for 0 ms (1000 ms backoff)
482 in IDLE for 5000 ms (1000 ms backoff)
483 connected (10000 ms), total 20000 ms connected
487 in BACKOFF for 0 ms (2000 ms backoff)
488 2 successful connections out of 2 attempts, seqno 4
489 not connected (0 ms), total 20000 ms connected
490 disconnected at 22000 ms (0 ms ago)
492 # Back off for 2000 ms.
497 in BACKOFF for 2000 ms (2000 ms backoff)
498 disconnected for 2000 ms
502 # Third connect, then idle timeout kills connection.
506 in ACTIVE for 0 ms (2000 ms backoff)
507 created 1000, last received 1000, last connected 24000
508 3 successful connections out of 3 attempts, seqno 5
509 connected (0 ms), total 20000 ms connected
510 disconnected for 0 ms
515 in ACTIVE for 5000 ms (2000 ms backoff)
516 connected (5000 ms), total 25000 ms connected
519 in IDLE for 0 ms (2000 ms backoff)
524 in IDLE for 5000 ms (2000 ms backoff)
525 connected (10000 ms), total 30000 ms connected
529 in BACKOFF for 0 ms (4000 ms backoff)
530 3 successful connections out of 3 attempts, seqno 6
531 not connected (0 ms), total 30000 ms connected
532 disconnected at 34000 ms (0 ms ago)
534 # Back off for 4000 ms.
539 in BACKOFF for 4000 ms (4000 ms backoff)
540 disconnected for 4000 ms
543 ######################################################################
544 RECONNECT_CHECK([brief connection preserves backoff],
547 # First connection attempt fails after 1000 ms.
555 # Back off for 1000 ms.
559 # Second connection attempt fails after 1000 ms.
565 # Back off for 2000 ms.
569 # Third connection attempt succeeds after 500 ms.
575 # Connection drops after another 250 ms.
580 # Back off for 4000 ms.
585 in BACKOFF for 0 ms (0 ms backoff)
587 # First connection attempt fails after 1000 ms.
591 in CONNECTING for 0 ms (0 ms backoff)
597 in CONNECTING for 1000 ms (0 ms backoff)
598 disconnected for 1000 ms
602 in BACKOFF for 0 ms (1000 ms backoff)
603 0 successful connections out of 1 attempts, seqno 0
605 # Back off for 1000 ms.
610 in BACKOFF for 1000 ms (1000 ms backoff)
611 disconnected for 2000 ms
615 # Second connection attempt fails after 1000 ms.
617 in CONNECTING for 0 ms (1000 ms backoff)
622 in CONNECTING for 1000 ms (1000 ms backoff)
623 disconnected for 3000 ms
627 in BACKOFF for 0 ms (2000 ms backoff)
628 0 successful connections out of 2 attempts, seqno 0
630 # Back off for 2000 ms.
635 in BACKOFF for 2000 ms (2000 ms backoff)
636 disconnected for 5000 ms
640 # Third connection attempt succeeds after 500 ms.
642 in CONNECTING for 0 ms (2000 ms backoff)
646 in CONNECTING for 500 ms (2000 ms backoff)
647 disconnected for 5500 ms
650 in ACTIVE for 0 ms (2000 ms backoff)
651 created 1000, last received 1000, last connected 6500
652 1 successful connections out of 3 attempts, seqno 1
653 connected (0 ms), total 0 ms connected
654 disconnected for 0 ms
656 # Connection drops after another 250 ms.
660 in ACTIVE for 250 ms (2000 ms backoff)
661 connected (250 ms), total 250 ms connected
663 in BACKOFF for 0 ms (4000 ms backoff)
664 1 successful connections out of 3 attempts, seqno 2
665 not connected (0 ms), total 250 ms connected
666 disconnected at 6750 ms (0 ms ago)
669 # Back off for 4000 ms.
674 in BACKOFF for 4000 ms (4000 ms backoff)
675 disconnected for 4000 ms
680 ######################################################################
681 RECONNECT_CHECK([brief connection with data preserves backoff],
684 # First connection attempt fails after 1000 ms.
692 # Back off for 1000 ms.
696 # Second connection attempt fails after 1000 ms.
702 # Back off for 2000 ms.
706 # Third connection attempt succeeds after 500 ms.
712 # Connection receives 3 chunks of data spaced 250 ms apart.
727 # Back off for 4000 ms.
733 in BACKOFF for 0 ms (0 ms backoff)
735 # First connection attempt fails after 1000 ms.
739 in CONNECTING for 0 ms (0 ms backoff)
745 in CONNECTING for 1000 ms (0 ms backoff)
746 disconnected for 1000 ms
750 in BACKOFF for 0 ms (1000 ms backoff)
751 0 successful connections out of 1 attempts, seqno 0
753 # Back off for 1000 ms.
758 in BACKOFF for 1000 ms (1000 ms backoff)
759 disconnected for 2000 ms
763 # Second connection attempt fails after 1000 ms.
765 in CONNECTING for 0 ms (1000 ms backoff)
770 in CONNECTING for 1000 ms (1000 ms backoff)
771 disconnected for 3000 ms
775 in BACKOFF for 0 ms (2000 ms backoff)
776 0 successful connections out of 2 attempts, seqno 0
778 # Back off for 2000 ms.
783 in BACKOFF for 2000 ms (2000 ms backoff)
784 disconnected for 5000 ms
788 # Third connection attempt succeeds after 500 ms.
790 in CONNECTING for 0 ms (2000 ms backoff)
794 in CONNECTING for 500 ms (2000 ms backoff)
795 disconnected for 5500 ms
798 in ACTIVE for 0 ms (2000 ms backoff)
799 created 1000, last received 1000, last connected 6500
800 1 successful connections out of 3 attempts, seqno 1
801 connected (0 ms), total 0 ms connected
802 disconnected for 0 ms
804 # Connection receives 3 chunks of data spaced 250 ms apart.
808 in ACTIVE for 250 ms (2000 ms backoff)
809 connected (250 ms), total 250 ms connected
812 created 1000, last received 6750, last connected 6500
816 in ACTIVE for 500 ms (2000 ms backoff)
817 connected (500 ms), total 500 ms connected
820 created 1000, last received 7000, last connected 6500
824 in ACTIVE for 750 ms (2000 ms backoff)
825 connected (750 ms), total 750 ms connected
828 created 1000, last received 7250, last connected 6500
832 in BACKOFF for 0 ms (4000 ms backoff)
833 1 successful connections out of 3 attempts, seqno 2
834 not connected (0 ms), total 750 ms connected
835 disconnected at 7250 ms (0 ms ago)
838 # Back off for 4000 ms.
843 in BACKOFF for 4000 ms (4000 ms backoff)
844 disconnected for 4000 ms
849 ######################################################################
850 RECONNECT_CHECK([long connection resets backoff],
853 # First connection attempt fails after 1000 ms.
861 # Back off for 1000 ms.
865 # Second connection attempt fails after 1000 ms.
871 # Back off for 2000 ms.
875 # Third connection attempt succeeds after 500 ms.
881 # Connection receives 3 chunks of data spaced 2000 ms apart.
896 # Back off for 1000 ms.
902 in BACKOFF for 0 ms (0 ms backoff)
904 # First connection attempt fails after 1000 ms.
908 in CONNECTING for 0 ms (0 ms backoff)
914 in CONNECTING for 1000 ms (0 ms backoff)
915 disconnected for 1000 ms
919 in BACKOFF for 0 ms (1000 ms backoff)
920 0 successful connections out of 1 attempts, seqno 0
922 # Back off for 1000 ms.
927 in BACKOFF for 1000 ms (1000 ms backoff)
928 disconnected for 2000 ms
932 # Second connection attempt fails after 1000 ms.
934 in CONNECTING for 0 ms (1000 ms backoff)
939 in CONNECTING for 1000 ms (1000 ms backoff)
940 disconnected for 3000 ms
944 in BACKOFF for 0 ms (2000 ms backoff)
945 0 successful connections out of 2 attempts, seqno 0
947 # Back off for 2000 ms.
952 in BACKOFF for 2000 ms (2000 ms backoff)
953 disconnected for 5000 ms
957 # Third connection attempt succeeds after 500 ms.
959 in CONNECTING for 0 ms (2000 ms backoff)
963 in CONNECTING for 500 ms (2000 ms backoff)
964 disconnected for 5500 ms
967 in ACTIVE for 0 ms (2000 ms backoff)
968 created 1000, last received 1000, last connected 6500
969 1 successful connections out of 3 attempts, seqno 1
970 connected (0 ms), total 0 ms connected
971 disconnected for 0 ms
973 # Connection receives 3 chunks of data spaced 2000 ms apart.
977 in ACTIVE for 2000 ms (2000 ms backoff)
978 connected (2000 ms), total 2000 ms connected
981 created 1000, last received 8500, last connected 6500
985 in ACTIVE for 4000 ms (2000 ms backoff)
986 connected (4000 ms), total 4000 ms connected
989 created 1000, last received 10500, last connected 6500
993 in ACTIVE for 6000 ms (2000 ms backoff)
994 connected (6000 ms), total 6000 ms connected
997 created 1000, last received 12500, last connected 6500
1001 in BACKOFF for 0 ms (1000 ms backoff)
1002 1 successful connections out of 3 attempts, seqno 2
1003 not connected (0 ms), total 6000 ms connected
1004 disconnected at 12500 ms (0 ms ago)
1007 # Back off for 1000 ms.
1012 in BACKOFF for 1000 ms (1000 ms backoff)
1013 disconnected for 1000 ms
1018 ######################################################################
1019 RECONNECT_CHECK([connection attempt fails quickly],
1022 # Connection fails quickly.
1024 connect-failed ECONNREFUSED
1026 # Back off for 1000 ms.
1030 # Connection fails quickly again.
1032 connect-failed ECONNREFUSED
1034 # Back off for 2000 ms.
1040 in BACKOFF for 0 ms (0 ms backoff)
1042 # Connection fails quickly.
1045 connect-failed ECONNREFUSED
1046 in BACKOFF for 0 ms (1000 ms backoff)
1047 0 successful connections out of 1 attempts, seqno 0
1049 # Back off for 1000 ms.
1055 in BACKOFF for 1000 ms (1000 ms backoff)
1056 disconnected for 1000 ms
1058 # Connection fails quickly again.
1061 connect-failed ECONNREFUSED
1062 in BACKOFF for 0 ms (2000 ms backoff)
1063 0 successful connections out of 2 attempts, seqno 0
1065 # Back off for 2000 ms.
1071 in BACKOFF for 2000 ms (2000 ms backoff)
1072 disconnected for 3000 ms
1075 ######################################################################
1076 RECONNECT_CHECK([max-tries of 1 honored],
1080 # Connection succeeds.
1084 # Send inactivity probe.
1088 # Idle timeout kills connection.
1097 in BACKOFF for 0 ms (0 ms backoff)
1100 # Connection succeeds.
1104 in ACTIVE for 0 ms (0 ms backoff)
1105 1 successful connections out of 1 attempts, seqno 1
1106 connected (0 ms), total 0 ms connected
1108 # Send inactivity probe.
1113 in ACTIVE for 5000 ms (0 ms backoff)
1114 connected (5000 ms), total 5000 ms connected
1117 in IDLE for 0 ms (0 ms backoff)
1119 # Idle timeout kills connection.
1124 in IDLE for 5000 ms (0 ms backoff)
1125 connected (10000 ms), total 10000 ms connected
1129 in VOID for 0 ms (1000 ms backoff)
1130 1 successful connections out of 1 attempts, seqno 2
1131 not connected (0 ms), total 10000 ms connected
1132 disconnected at 11000 ms (0 ms ago)
1135 ######################################################################
1136 RECONNECT_CHECK([max-tries of 0 honored],
1151 ######################################################################
1152 RECONNECT_CHECK([passive mode],
1161 # Listening never times out.
1165 # Listening failed (accept() returned funny error?). Back off and try again.
1171 # Connection accepted.
1177 # Connection times out.
1184 # Start listening again.
1192 in BACKOFF for 0 ms (0 ms backoff)
1200 in LISTENING for 0 ms (0 ms backoff)
1202 # Listening never times out.
1207 # Listening failed (accept() returned funny error?). Back off and try again.
1209 in BACKOFF for 0 ms (1000 ms backoff)
1214 in BACKOFF for 1000 ms (1000 ms backoff)
1215 disconnected for 1000 ms
1219 in LISTENING for 0 ms (1000 ms backoff)
1221 # Connection accepted.
1223 in ACTIVE for 0 ms (1000 ms backoff)
1224 created 1000, last received 1000, last connected 2000
1225 1 successful connections out of 1 attempts, seqno 1
1226 connected (0 ms), total 0 ms connected
1227 disconnected for 0 ms
1229 created 1000, last received 2000, last connected 2000
1233 in ACTIVE for 1000 ms (1000 ms backoff)
1234 connected (1000 ms), total 1000 ms connected
1236 created 1000, last received 3000, last connected 2000
1238 # Connection times out.
1243 in ACTIVE for 6000 ms (1000 ms backoff)
1244 connected (6000 ms), total 6000 ms connected
1247 in IDLE for 0 ms (1000 ms backoff)
1252 in IDLE for 5000 ms (1000 ms backoff)
1253 connected (11000 ms), total 11000 ms connected
1257 in BACKOFF for 0 ms (0 ms backoff)
1258 1 successful connections out of 1 attempts, seqno 2
1259 not connected (0 ms), total 11000 ms connected
1260 disconnected at 13000 ms (0 ms ago)
1262 # Start listening again.
1268 in LISTENING for 0 ms (0 ms backoff)