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 [ovstest test-reconnect < input],
20 [AT_SKIP_IF([test $HAVE_PYTHON = no])],
22 [$PYTHON $srcdir/test-reconnect.py < input],
26 [AT_SKIP_IF([test $HAVE_PYTHON3 = no])],
28 [$PYTHON3 $srcdir/test-reconnect.py < input],
31 ######################################################################
32 RECONNECT_CHECK([nothing happens if not enabled],
42 ######################################################################
43 RECONNECT_CHECK([quick connect, idle disconnect],
46 # Connection succeeds.
50 # Send inactivity probe.
54 # Idle timeout kills connection.
61 in BACKOFF for 0 ms (0 ms backoff)
63 # Connection succeeds.
67 in ACTIVE for 0 ms (0 ms backoff)
68 created 1000, last activity 1000, last connected 1000
69 1 successful connections out of 1 attempts, seqno 1
71 last connected 0 ms ago, connected 0 ms total
73 # Send inactivity probe.
78 in ACTIVE for 5000 ms (0 ms backoff)
81 in IDLE for 0 ms (0 ms backoff)
83 # Idle timeout kills connection.
88 in IDLE for 5000 ms (0 ms backoff)
92 in BACKOFF for 0 ms (1000 ms backoff)
93 1 successful connections out of 1 attempts, seqno 2
95 disconnected at 11000 ms (0 ms ago)
98 ######################################################################
99 RECONNECT_CHECK([slow connect, idle disconnect],
106 # Connect after 500 ms.
111 # Send inactivity probe.
115 # Idle timeout kills connection.
122 in BACKOFF for 0 ms (0 ms backoff)
128 in CONNECTING for 0 ms (0 ms backoff)
130 # Connect after 500 ms.
134 in CONNECTING for 500 ms (0 ms backoff)
137 in ACTIVE for 0 ms (0 ms backoff)
138 created 1000, last activity 1000, last connected 1500
139 1 successful connections out of 1 attempts, seqno 1
141 last connected 0 ms ago, connected 0 ms total
143 # Send inactivity probe.
148 in ACTIVE for 5000 ms (0 ms backoff)
151 in IDLE for 0 ms (0 ms backoff)
153 # Idle timeout kills connection.
158 in IDLE for 5000 ms (0 ms backoff)
162 in BACKOFF for 0 ms (1000 ms backoff)
163 1 successful connections out of 1 attempts, seqno 2
165 disconnected at 11500 ms (0 ms ago)
168 ######################################################################
169 RECONNECT_CHECK([connect backs off],
172 # First connection attempt fails after 1000 ms.
180 # Back off for 1000 ms.
184 # Second connection attempt fails after 1000 ms.
190 # Back off for 2000 ms.
194 # Third connection attempt fails after 2000 ms.
200 # Back off for 4000 ms.
204 # Third connection attempt fails after 4000 ms.
210 # Back off for 8000 ms.
214 # Third connection attempt fails after 8000 ms.
220 # Back off for 8000 ms.
224 # Fourth connection attempt fails after 8000 ms.
232 in BACKOFF for 0 ms (0 ms backoff)
234 # First connection attempt fails after 1000 ms.
238 in CONNECTING for 0 ms (0 ms backoff)
244 in CONNECTING for 1000 ms (0 ms backoff)
248 in BACKOFF for 0 ms (1000 ms backoff)
249 0 successful connections out of 1 attempts, seqno 0
251 # Back off for 1000 ms.
256 in BACKOFF for 1000 ms (1000 ms backoff)
260 # Second connection attempt fails after 1000 ms.
262 in CONNECTING for 0 ms (1000 ms backoff)
267 in CONNECTING for 1000 ms (1000 ms backoff)
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)
283 # Third connection attempt fails after 2000 ms.
285 in CONNECTING for 0 ms (2000 ms backoff)
290 in CONNECTING for 2000 ms (2000 ms backoff)
294 in BACKOFF for 0 ms (4000 ms backoff)
295 0 successful connections out of 3 attempts, seqno 0
297 # Back off for 4000 ms.
302 in BACKOFF for 4000 ms (4000 ms backoff)
306 # Third connection attempt fails after 4000 ms.
308 in CONNECTING for 0 ms (4000 ms backoff)
313 in CONNECTING for 4000 ms (4000 ms backoff)
317 in BACKOFF for 0 ms (8000 ms backoff)
318 0 successful connections out of 4 attempts, seqno 0
320 # Back off for 8000 ms.
325 in BACKOFF for 8000 ms (8000 ms backoff)
329 # Third connection attempt fails after 8000 ms.
331 in CONNECTING for 0 ms (8000 ms backoff)
336 in CONNECTING for 8000 ms (8000 ms backoff)
340 in BACKOFF for 0 ms (8000 ms backoff)
341 0 successful connections out of 5 attempts, seqno 0
343 # Back off for 8000 ms.
348 in BACKOFF for 8000 ms (8000 ms backoff)
352 # Fourth connection attempt fails after 8000 ms.
354 in CONNECTING for 0 ms (8000 ms backoff)
359 in CONNECTING for 8000 ms (8000 ms backoff)
363 in BACKOFF for 0 ms (8000 ms backoff)
364 0 successful connections out of 6 attempts, seqno 0
367 ######################################################################
368 RECONNECT_CHECK([connections with no data preserve backoff],
371 # First connect, then idle timeout kills connection.
380 # Back off for 1000 ms.
384 # Second connect, then idle timeout kills connection.
393 # Back off for 2000 ms.
397 # Third connect, then idle timeout kills connection.
406 # Back off for 4000 ms.
410 in BACKOFF for 0 ms (0 ms backoff)
412 # First connect, then idle timeout kills connection.
416 in ACTIVE for 0 ms (0 ms backoff)
417 created 1000, last activity 1000, last connected 1000
418 1 successful connections out of 1 attempts, seqno 1
420 last connected 0 ms ago, connected 0 ms total
425 in ACTIVE for 5000 ms (0 ms backoff)
428 in IDLE for 0 ms (0 ms backoff)
433 in IDLE for 5000 ms (0 ms backoff)
437 in BACKOFF for 0 ms (1000 ms backoff)
438 1 successful connections out of 1 attempts, seqno 2
440 disconnected at 11000 ms (0 ms ago)
442 # Back off for 1000 ms.
447 in BACKOFF for 1000 ms (1000 ms backoff)
448 last connected 11000 ms ago, connected 10000 ms total
452 # Second connect, then idle timeout kills connection.
456 in ACTIVE for 0 ms (1000 ms backoff)
457 created 1000, last activity 1000, last connected 12000
458 2 successful connections out of 2 attempts, seqno 3
460 last connected 0 ms ago, connected 10000 ms total
465 in ACTIVE for 5000 ms (1000 ms backoff)
468 in IDLE for 0 ms (1000 ms backoff)
473 in IDLE for 5000 ms (1000 ms backoff)
477 in BACKOFF for 0 ms (2000 ms backoff)
478 2 successful connections out of 2 attempts, seqno 4
480 disconnected at 22000 ms (0 ms ago)
482 # Back off for 2000 ms.
487 in BACKOFF for 2000 ms (2000 ms backoff)
488 last connected 12000 ms ago, connected 20000 ms total
492 # Third connect, then idle timeout kills connection.
496 in ACTIVE for 0 ms (2000 ms backoff)
497 created 1000, last activity 1000, last connected 24000
498 3 successful connections out of 3 attempts, seqno 5
500 last connected 0 ms ago, connected 20000 ms total
505 in ACTIVE for 5000 ms (2000 ms backoff)
508 in IDLE for 0 ms (2000 ms backoff)
513 in IDLE for 5000 ms (2000 ms backoff)
517 in BACKOFF for 0 ms (4000 ms backoff)
518 3 successful connections out of 3 attempts, seqno 6
520 disconnected at 34000 ms (0 ms ago)
522 # Back off for 4000 ms.
527 in BACKOFF for 4000 ms (4000 ms backoff)
528 last connected 14000 ms ago, connected 30000 ms total
531 ######################################################################
532 RECONNECT_CHECK([brief connection preserves backoff],
535 # First connection attempt fails after 1000 ms.
543 # Back off for 1000 ms.
547 # Second connection attempt fails after 1000 ms.
553 # Back off for 2000 ms.
557 # Third connection attempt succeeds after 500 ms.
563 # Connection drops after another 250 ms.
568 # Back off for 4000 ms.
573 in BACKOFF for 0 ms (0 ms backoff)
575 # First connection attempt fails after 1000 ms.
579 in CONNECTING for 0 ms (0 ms backoff)
585 in CONNECTING for 1000 ms (0 ms backoff)
589 in BACKOFF for 0 ms (1000 ms backoff)
590 0 successful connections out of 1 attempts, seqno 0
592 # Back off for 1000 ms.
597 in BACKOFF for 1000 ms (1000 ms backoff)
601 # Second connection attempt fails after 1000 ms.
603 in CONNECTING for 0 ms (1000 ms backoff)
608 in CONNECTING for 1000 ms (1000 ms backoff)
612 in BACKOFF for 0 ms (2000 ms backoff)
613 0 successful connections out of 2 attempts, seqno 0
615 # Back off for 2000 ms.
620 in BACKOFF for 2000 ms (2000 ms backoff)
624 # Third connection attempt succeeds after 500 ms.
626 in CONNECTING for 0 ms (2000 ms backoff)
630 in CONNECTING for 500 ms (2000 ms backoff)
633 in ACTIVE for 0 ms (2000 ms backoff)
634 created 1000, last activity 1000, last connected 6500
635 1 successful connections out of 3 attempts, seqno 1
637 last connected 0 ms ago, connected 0 ms total
639 # Connection drops after another 250 ms.
643 in ACTIVE for 250 ms (2000 ms backoff)
645 in BACKOFF for 0 ms (4000 ms backoff)
646 1 successful connections out of 3 attempts, seqno 2
648 disconnected at 6750 ms (0 ms ago)
651 # Back off for 4000 ms.
656 in BACKOFF for 4000 ms (4000 ms backoff)
657 last connected 4250 ms ago, connected 250 ms total
662 ######################################################################
663 RECONNECT_CHECK([brief connection with data preserves backoff],
666 # First connection attempt fails after 1000 ms.
674 # Back off for 1000 ms.
678 # Second connection attempt fails after 1000 ms.
684 # Back off for 2000 ms.
688 # Third connection attempt succeeds after 500 ms.
694 # Connection receives 3 chunks of data spaced 250 ms apart.
709 # Back off for 4000 ms.
715 in BACKOFF for 0 ms (0 ms backoff)
717 # First connection attempt fails after 1000 ms.
721 in CONNECTING for 0 ms (0 ms backoff)
727 in CONNECTING for 1000 ms (0 ms backoff)
731 in BACKOFF for 0 ms (1000 ms backoff)
732 0 successful connections out of 1 attempts, seqno 0
734 # Back off for 1000 ms.
739 in BACKOFF for 1000 ms (1000 ms backoff)
743 # Second connection attempt fails after 1000 ms.
745 in CONNECTING for 0 ms (1000 ms backoff)
750 in CONNECTING for 1000 ms (1000 ms backoff)
754 in BACKOFF for 0 ms (2000 ms backoff)
755 0 successful connections out of 2 attempts, seqno 0
757 # Back off for 2000 ms.
762 in BACKOFF for 2000 ms (2000 ms backoff)
766 # Third connection attempt succeeds after 500 ms.
768 in CONNECTING for 0 ms (2000 ms backoff)
772 in CONNECTING for 500 ms (2000 ms backoff)
775 in ACTIVE for 0 ms (2000 ms backoff)
776 created 1000, last activity 1000, last connected 6500
777 1 successful connections out of 3 attempts, seqno 1
779 last connected 0 ms ago, connected 0 ms total
781 # Connection receives 3 chunks of data spaced 250 ms apart.
785 in ACTIVE for 250 ms (2000 ms backoff)
788 created 1000, last activity 6750, last connected 6500
792 in ACTIVE for 500 ms (2000 ms backoff)
795 created 1000, last activity 7000, last connected 6500
799 in ACTIVE for 750 ms (2000 ms backoff)
802 created 1000, last activity 7250, last connected 6500
806 in BACKOFF for 0 ms (4000 ms backoff)
807 1 successful connections out of 3 attempts, seqno 2
809 disconnected at 7250 ms (0 ms ago)
812 # Back off for 4000 ms.
817 in BACKOFF for 4000 ms (4000 ms backoff)
818 last connected 4750 ms ago, connected 750 ms total
823 ######################################################################
824 RECONNECT_CHECK([long connection resets backoff],
827 # First connection attempt fails after 1000 ms.
835 # Back off for 1000 ms.
839 # Second connection attempt fails after 1000 ms.
845 # Back off for 2000 ms.
849 # Third connection attempt succeeds after 500 ms.
855 # Connection receives 3 chunks of data spaced 2000 ms apart.
870 # Back off for 1000 ms.
876 in BACKOFF for 0 ms (0 ms backoff)
878 # First connection attempt fails after 1000 ms.
882 in CONNECTING for 0 ms (0 ms backoff)
888 in CONNECTING for 1000 ms (0 ms backoff)
892 in BACKOFF for 0 ms (1000 ms backoff)
893 0 successful connections out of 1 attempts, seqno 0
895 # Back off for 1000 ms.
900 in BACKOFF for 1000 ms (1000 ms backoff)
904 # Second connection attempt fails after 1000 ms.
906 in CONNECTING for 0 ms (1000 ms backoff)
911 in CONNECTING for 1000 ms (1000 ms backoff)
915 in BACKOFF for 0 ms (2000 ms backoff)
916 0 successful connections out of 2 attempts, seqno 0
918 # Back off for 2000 ms.
923 in BACKOFF for 2000 ms (2000 ms backoff)
927 # Third connection attempt succeeds after 500 ms.
929 in CONNECTING for 0 ms (2000 ms backoff)
933 in CONNECTING for 500 ms (2000 ms backoff)
936 in ACTIVE for 0 ms (2000 ms backoff)
937 created 1000, last activity 1000, last connected 6500
938 1 successful connections out of 3 attempts, seqno 1
940 last connected 0 ms ago, connected 0 ms total
942 # Connection receives 3 chunks of data spaced 2000 ms apart.
946 in ACTIVE for 2000 ms (2000 ms backoff)
949 created 1000, last activity 8500, last connected 6500
953 in ACTIVE for 4000 ms (2000 ms backoff)
956 created 1000, last activity 10500, last connected 6500
960 in ACTIVE for 6000 ms (2000 ms backoff)
963 created 1000, last activity 12500, last connected 6500
967 in BACKOFF for 0 ms (1000 ms backoff)
968 1 successful connections out of 3 attempts, seqno 2
970 disconnected at 12500 ms (0 ms ago)
973 # Back off for 1000 ms.
978 in BACKOFF for 1000 ms (1000 ms backoff)
979 last connected 7000 ms ago, connected 6000 ms total
984 ######################################################################
985 RECONNECT_CHECK([connection attempt fails quickly],
988 # Connection fails quickly.
990 connect-failed ECONNREFUSED
992 # Back off for 1000 ms.
996 # Connection fails quickly again.
998 connect-failed ECONNREFUSED
1000 # Back off for 2000 ms.
1006 in BACKOFF for 0 ms (0 ms backoff)
1008 # Connection fails quickly.
1011 connect-failed ECONNREFUSED
1012 in BACKOFF for 0 ms (1000 ms backoff)
1013 0 successful connections out of 1 attempts, seqno 0
1015 # Back off for 1000 ms.
1021 in BACKOFF for 1000 ms (1000 ms backoff)
1023 # Connection fails quickly again.
1026 connect-failed ECONNREFUSED
1027 in BACKOFF for 0 ms (2000 ms backoff)
1028 0 successful connections out of 2 attempts, seqno 0
1030 # Back off for 2000 ms.
1036 in BACKOFF for 2000 ms (2000 ms backoff)
1039 ######################################################################
1040 RECONNECT_CHECK([max-tries of 1 honored],
1044 # Connection succeeds.
1048 # Send inactivity probe.
1052 # Idle timeout kills connection.
1061 in BACKOFF for 0 ms (0 ms backoff)
1064 # Connection succeeds.
1068 in ACTIVE for 0 ms (0 ms backoff)
1069 created 1000, last activity 1000, last connected 1000
1070 1 successful connections out of 1 attempts, seqno 1
1072 last connected 0 ms ago, connected 0 ms total
1074 # Send inactivity probe.
1079 in ACTIVE for 5000 ms (0 ms backoff)
1082 in IDLE for 0 ms (0 ms backoff)
1084 # Idle timeout kills connection.
1089 in IDLE for 5000 ms (0 ms backoff)
1093 in VOID for 0 ms (1000 ms backoff)
1094 1 successful connections out of 1 attempts, seqno 2
1096 disconnected at 11000 ms (0 ms ago)
1099 ######################################################################
1100 RECONNECT_CHECK([max-tries of 0 honored],
1115 ######################################################################
1116 RECONNECT_CHECK([passive mode],
1125 # Listening never times out.
1129 # Listening failed (accept() returned funny error?). Back off and try again.
1135 # Connection accepted.
1141 # Connection times out.
1148 # Start listening again.
1156 in BACKOFF for 0 ms (0 ms backoff)
1164 in LISTENING for 0 ms (0 ms backoff)
1166 # Listening never times out.
1171 # Listening failed (accept() returned funny error?). Back off and try again.
1173 in BACKOFF for 0 ms (1000 ms backoff)
1178 in BACKOFF for 1000 ms (1000 ms backoff)
1182 in LISTENING for 0 ms (1000 ms backoff)
1184 # Connection accepted.
1186 in ACTIVE for 0 ms (1000 ms backoff)
1187 created 1000, last activity 1000, last connected 2000
1188 1 successful connections out of 1 attempts, seqno 1
1190 last connected 0 ms ago, connected 0 ms total
1192 created 1000, last activity 2000, last connected 2000
1196 in ACTIVE for 1000 ms (1000 ms backoff)
1198 created 1000, last activity 3000, last connected 2000
1200 # Connection times out.
1205 in ACTIVE for 6000 ms (1000 ms backoff)
1208 in IDLE for 0 ms (1000 ms backoff)
1213 in IDLE for 5000 ms (1000 ms backoff)
1217 in BACKOFF for 0 ms (0 ms backoff)
1218 1 successful connections out of 1 attempts, seqno 2
1220 disconnected at 13000 ms (0 ms ago)
1222 # Start listening again.
1228 in LISTENING for 0 ms (0 ms backoff)