]> git.proxmox.com Git - mirror_ovs.git/blob - tests/reconnect.at
reconnect: Add ability to do a number of retries without backoff.
[mirror_ovs.git] / tests / reconnect.at
1 AT_BANNER([reconnect library])
2
3 m4_define([__RECONNECT_CHECK],
4 [AT_SETUP([$1])
5 $2
6 AT_KEYWORDS([reconnect])
7 AT_DATA([input], [$3])
8 AT_CHECK([$4], [0], [$5])
9 AT_CLEANUP])
10
11 m4_define([RECONNECT_CHECK],
12 [__RECONNECT_CHECK(
13 [$1 - C],
14 [],
15 [$2],
16 [ovstest test-reconnect < input],
17 [$3])
18 __RECONNECT_CHECK(
19 [$1 - Python2],
20 [AT_SKIP_IF([test $HAVE_PYTHON = no])],
21 [$2],
22 [$PYTHON $srcdir/test-reconnect.py < input],
23 [$3])
24 __RECONNECT_CHECK(
25 [$1 - Python3],
26 [AT_SKIP_IF([test $HAVE_PYTHON3 = no])],
27 [$2],
28 [$PYTHON3 $srcdir/test-reconnect.py < input],
29 [$3])])
30
31 ######################################################################
32 RECONNECT_CHECK([nothing happens if not enabled],
33 [run
34 timeout
35 ],
36 [### t=1000 ###
37 run
38 timeout
39 no timeout
40 ])
41
42 ######################################################################
43 RECONNECT_CHECK([quick connect, idle disconnect],
44 [enable
45
46 # Connection succeeds.
47 run
48 connected
49
50 # Send inactivity probe.
51 timeout
52 run
53
54 # Idle timeout kills connection.
55 timeout
56 run
57 disconnected
58 ],
59 [### t=1000 ###
60 enable
61 in BACKOFF for 0 ms (0 ms backoff)
62
63 # Connection succeeds.
64 run
65 should connect
66 connected
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
70 connected
71 last connected 0 ms ago, connected 0 ms total
72
73 # Send inactivity probe.
74 timeout
75 advance 5000 ms
76
77 ### t=6000 ###
78 in ACTIVE for 5000 ms (0 ms backoff)
79 run
80 should send probe
81 in IDLE for 0 ms (0 ms backoff)
82
83 # Idle timeout kills connection.
84 timeout
85 advance 5000 ms
86
87 ### t=11000 ###
88 in IDLE for 5000 ms (0 ms backoff)
89 run
90 should disconnect
91 disconnected
92 in BACKOFF for 0 ms (1000 ms backoff)
93 1 successful connections out of 1 attempts, seqno 2
94 disconnected
95 disconnected at 11000 ms (0 ms ago)
96 ])
97
98 ######################################################################
99 RECONNECT_CHECK([slow connect, idle disconnect],
100 [enable
101
102 # Start connecting.
103 run
104 connecting
105
106 # Connect after 500 ms.
107 advance 500
108 run
109 connected
110
111 # Send inactivity probe.
112 timeout
113 run
114
115 # Idle timeout kills connection.
116 timeout
117 run
118 disconnected
119 ],
120 [### t=1000 ###
121 enable
122 in BACKOFF for 0 ms (0 ms backoff)
123
124 # Start connecting.
125 run
126 should connect
127 connecting
128 in CONNECTING for 0 ms (0 ms backoff)
129
130 # Connect after 500 ms.
131 advance 500
132
133 ### t=1500 ###
134 in CONNECTING for 500 ms (0 ms backoff)
135 run
136 connected
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
140 connected
141 last connected 0 ms ago, connected 0 ms total
142
143 # Send inactivity probe.
144 timeout
145 advance 5000 ms
146
147 ### t=6500 ###
148 in ACTIVE for 5000 ms (0 ms backoff)
149 run
150 should send probe
151 in IDLE for 0 ms (0 ms backoff)
152
153 # Idle timeout kills connection.
154 timeout
155 advance 5000 ms
156
157 ### t=11500 ###
158 in IDLE for 5000 ms (0 ms backoff)
159 run
160 should disconnect
161 disconnected
162 in BACKOFF for 0 ms (1000 ms backoff)
163 1 successful connections out of 1 attempts, seqno 2
164 disconnected
165 disconnected at 11500 ms (0 ms ago)
166 ])
167
168 ######################################################################
169 RECONNECT_CHECK([connect backs off],
170 [enable
171
172 # First connection attempt fails after 1000 ms.
173 run
174 connecting
175 run
176 timeout
177 run
178 connect-failed
179
180 # Back off for 1000 ms.
181 timeout
182 run
183
184 # Second connection attempt fails after 1000 ms.
185 connecting
186 timeout
187 run
188 connect-failed
189
190 # Back off for 2000 ms.
191 timeout
192 run
193
194 # Third connection attempt fails after 2000 ms.
195 connecting
196 timeout
197 run
198 connect-failed
199
200 # Back off for 4000 ms.
201 timeout
202 run
203
204 # Third connection attempt fails after 4000 ms.
205 connecting
206 timeout
207 run
208 connect-failed
209
210 # Back off for 8000 ms.
211 timeout
212 run
213
214 # Third connection attempt fails after 8000 ms.
215 connecting
216 timeout
217 run
218 connect-failed
219
220 # Back off for 8000 ms.
221 timeout
222 run
223
224 # Fourth connection attempt fails after 8000 ms.
225 connecting
226 timeout
227 run
228 connect-failed
229 ],
230 [### t=1000 ###
231 enable
232 in BACKOFF for 0 ms (0 ms backoff)
233
234 # First connection attempt fails after 1000 ms.
235 run
236 should connect
237 connecting
238 in CONNECTING for 0 ms (0 ms backoff)
239 run
240 timeout
241 advance 1000 ms
242
243 ### t=2000 ###
244 in CONNECTING for 1000 ms (0 ms backoff)
245 run
246 should disconnect
247 connect-failed
248 in BACKOFF for 0 ms (1000 ms backoff)
249 0 successful connections out of 1 attempts, seqno 0
250
251 # Back off for 1000 ms.
252 timeout
253 advance 1000 ms
254
255 ### t=3000 ###
256 in BACKOFF for 1000 ms (1000 ms backoff)
257 run
258 should connect
259
260 # Second connection attempt fails after 1000 ms.
261 connecting
262 in CONNECTING for 0 ms (1000 ms backoff)
263 timeout
264 advance 1000 ms
265
266 ### t=4000 ###
267 in CONNECTING for 1000 ms (1000 ms backoff)
268 run
269 should disconnect
270 connect-failed
271 in BACKOFF for 0 ms (2000 ms backoff)
272 0 successful connections out of 2 attempts, seqno 0
273
274 # Back off for 2000 ms.
275 timeout
276 advance 2000 ms
277
278 ### t=6000 ###
279 in BACKOFF for 2000 ms (2000 ms backoff)
280 run
281 should connect
282
283 # Third connection attempt fails after 2000 ms.
284 connecting
285 in CONNECTING for 0 ms (2000 ms backoff)
286 timeout
287 advance 2000 ms
288
289 ### t=8000 ###
290 in CONNECTING for 2000 ms (2000 ms backoff)
291 run
292 should disconnect
293 connect-failed
294 in BACKOFF for 0 ms (4000 ms backoff)
295 0 successful connections out of 3 attempts, seqno 0
296
297 # Back off for 4000 ms.
298 timeout
299 advance 4000 ms
300
301 ### t=12000 ###
302 in BACKOFF for 4000 ms (4000 ms backoff)
303 run
304 should connect
305
306 # Third connection attempt fails after 4000 ms.
307 connecting
308 in CONNECTING for 0 ms (4000 ms backoff)
309 timeout
310 advance 4000 ms
311
312 ### t=16000 ###
313 in CONNECTING for 4000 ms (4000 ms backoff)
314 run
315 should disconnect
316 connect-failed
317 in BACKOFF for 0 ms (8000 ms backoff)
318 0 successful connections out of 4 attempts, seqno 0
319
320 # Back off for 8000 ms.
321 timeout
322 advance 8000 ms
323
324 ### t=24000 ###
325 in BACKOFF for 8000 ms (8000 ms backoff)
326 run
327 should connect
328
329 # Third connection attempt fails after 8000 ms.
330 connecting
331 in CONNECTING for 0 ms (8000 ms backoff)
332 timeout
333 advance 8000 ms
334
335 ### t=32000 ###
336 in CONNECTING for 8000 ms (8000 ms backoff)
337 run
338 should disconnect
339 connect-failed
340 in BACKOFF for 0 ms (8000 ms backoff)
341 0 successful connections out of 5 attempts, seqno 0
342
343 # Back off for 8000 ms.
344 timeout
345 advance 8000 ms
346
347 ### t=40000 ###
348 in BACKOFF for 8000 ms (8000 ms backoff)
349 run
350 should connect
351
352 # Fourth connection attempt fails after 8000 ms.
353 connecting
354 in CONNECTING for 0 ms (8000 ms backoff)
355 timeout
356 advance 8000 ms
357
358 ### t=48000 ###
359 in CONNECTING for 8000 ms (8000 ms backoff)
360 run
361 should disconnect
362 connect-failed
363 in BACKOFF for 0 ms (8000 ms backoff)
364 0 successful connections out of 6 attempts, seqno 0
365 ])
366
367 ######################################################################
368 RECONNECT_CHECK([connections with no data preserve backoff],
369 [enable
370
371 # First connect, then idle timeout kills connection.
372 run
373 connected
374 timeout
375 run
376 timeout
377 run
378 disconnected
379
380 # Back off for 1000 ms.
381 timeout
382 run
383
384 # Second connect, then idle timeout kills connection.
385 run
386 connected
387 timeout
388 run
389 timeout
390 run
391 disconnected
392
393 # Back off for 2000 ms.
394 timeout
395 run
396
397 # Third connect, then idle timeout kills connection.
398 run
399 connected
400 timeout
401 run
402 timeout
403 run
404 disconnected
405
406 # Back off for 4000 ms.
407 timeout
408 ], [### t=1000 ###
409 enable
410 in BACKOFF for 0 ms (0 ms backoff)
411
412 # First connect, then idle timeout kills connection.
413 run
414 should connect
415 connected
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
419 connected
420 last connected 0 ms ago, connected 0 ms total
421 timeout
422 advance 5000 ms
423
424 ### t=6000 ###
425 in ACTIVE for 5000 ms (0 ms backoff)
426 run
427 should send probe
428 in IDLE for 0 ms (0 ms backoff)
429 timeout
430 advance 5000 ms
431
432 ### t=11000 ###
433 in IDLE for 5000 ms (0 ms backoff)
434 run
435 should disconnect
436 disconnected
437 in BACKOFF for 0 ms (1000 ms backoff)
438 1 successful connections out of 1 attempts, seqno 2
439 disconnected
440 disconnected at 11000 ms (0 ms ago)
441
442 # Back off for 1000 ms.
443 timeout
444 advance 1000 ms
445
446 ### t=12000 ###
447 in BACKOFF for 1000 ms (1000 ms backoff)
448 last connected 11000 ms ago, connected 10000 ms total
449 run
450 should connect
451
452 # Second connect, then idle timeout kills connection.
453 run
454 should connect
455 connected
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
459 connected
460 last connected 0 ms ago, connected 10000 ms total
461 timeout
462 advance 5000 ms
463
464 ### t=17000 ###
465 in ACTIVE for 5000 ms (1000 ms backoff)
466 run
467 should send probe
468 in IDLE for 0 ms (1000 ms backoff)
469 timeout
470 advance 5000 ms
471
472 ### t=22000 ###
473 in IDLE for 5000 ms (1000 ms backoff)
474 run
475 should disconnect
476 disconnected
477 in BACKOFF for 0 ms (2000 ms backoff)
478 2 successful connections out of 2 attempts, seqno 4
479 disconnected
480 disconnected at 22000 ms (0 ms ago)
481
482 # Back off for 2000 ms.
483 timeout
484 advance 2000 ms
485
486 ### t=24000 ###
487 in BACKOFF for 2000 ms (2000 ms backoff)
488 last connected 12000 ms ago, connected 20000 ms total
489 run
490 should connect
491
492 # Third connect, then idle timeout kills connection.
493 run
494 should connect
495 connected
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
499 connected
500 last connected 0 ms ago, connected 20000 ms total
501 timeout
502 advance 5000 ms
503
504 ### t=29000 ###
505 in ACTIVE for 5000 ms (2000 ms backoff)
506 run
507 should send probe
508 in IDLE for 0 ms (2000 ms backoff)
509 timeout
510 advance 5000 ms
511
512 ### t=34000 ###
513 in IDLE for 5000 ms (2000 ms backoff)
514 run
515 should disconnect
516 disconnected
517 in BACKOFF for 0 ms (4000 ms backoff)
518 3 successful connections out of 3 attempts, seqno 6
519 disconnected
520 disconnected at 34000 ms (0 ms ago)
521
522 # Back off for 4000 ms.
523 timeout
524 advance 4000 ms
525
526 ### t=38000 ###
527 in BACKOFF for 4000 ms (4000 ms backoff)
528 last connected 14000 ms ago, connected 30000 ms total
529 ])
530
531 ######################################################################
532 RECONNECT_CHECK([brief connection preserves backoff],
533 [enable
534
535 # First connection attempt fails after 1000 ms.
536 run
537 connecting
538 run
539 timeout
540 run
541 connect-failed
542
543 # Back off for 1000 ms.
544 timeout
545 run
546
547 # Second connection attempt fails after 1000 ms.
548 connecting
549 timeout
550 run
551 connect-failed
552
553 # Back off for 2000 ms.
554 timeout
555 run
556
557 # Third connection attempt succeeds after 500 ms.
558 connecting
559 advance 500
560 run
561 connected
562
563 # Connection drops after another 250 ms.
564 advance 250
565 disconnected
566 run
567
568 # Back off for 4000 ms.
569 timeout
570 run
571 ], [### t=1000 ###
572 enable
573 in BACKOFF for 0 ms (0 ms backoff)
574
575 # First connection attempt fails after 1000 ms.
576 run
577 should connect
578 connecting
579 in CONNECTING for 0 ms (0 ms backoff)
580 run
581 timeout
582 advance 1000 ms
583
584 ### t=2000 ###
585 in CONNECTING for 1000 ms (0 ms backoff)
586 run
587 should disconnect
588 connect-failed
589 in BACKOFF for 0 ms (1000 ms backoff)
590 0 successful connections out of 1 attempts, seqno 0
591
592 # Back off for 1000 ms.
593 timeout
594 advance 1000 ms
595
596 ### t=3000 ###
597 in BACKOFF for 1000 ms (1000 ms backoff)
598 run
599 should connect
600
601 # Second connection attempt fails after 1000 ms.
602 connecting
603 in CONNECTING for 0 ms (1000 ms backoff)
604 timeout
605 advance 1000 ms
606
607 ### t=4000 ###
608 in CONNECTING for 1000 ms (1000 ms backoff)
609 run
610 should disconnect
611 connect-failed
612 in BACKOFF for 0 ms (2000 ms backoff)
613 0 successful connections out of 2 attempts, seqno 0
614
615 # Back off for 2000 ms.
616 timeout
617 advance 2000 ms
618
619 ### t=6000 ###
620 in BACKOFF for 2000 ms (2000 ms backoff)
621 run
622 should connect
623
624 # Third connection attempt succeeds after 500 ms.
625 connecting
626 in CONNECTING for 0 ms (2000 ms backoff)
627 advance 500
628
629 ### t=6500 ###
630 in CONNECTING for 500 ms (2000 ms backoff)
631 run
632 connected
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
636 connected
637 last connected 0 ms ago, connected 0 ms total
638
639 # Connection drops after another 250 ms.
640 advance 250
641
642 ### t=6750 ###
643 in ACTIVE for 250 ms (2000 ms backoff)
644 disconnected
645 in BACKOFF for 0 ms (4000 ms backoff)
646 1 successful connections out of 3 attempts, seqno 2
647 disconnected
648 disconnected at 6750 ms (0 ms ago)
649 run
650
651 # Back off for 4000 ms.
652 timeout
653 advance 4000 ms
654
655 ### t=10750 ###
656 in BACKOFF for 4000 ms (4000 ms backoff)
657 last connected 4250 ms ago, connected 250 ms total
658 run
659 should connect
660 ])
661
662 ######################################################################
663 RECONNECT_CHECK([brief connection with data preserves backoff],
664 [enable
665
666 # First connection attempt fails after 1000 ms.
667 run
668 connecting
669 run
670 timeout
671 run
672 connect-failed
673
674 # Back off for 1000 ms.
675 timeout
676 run
677
678 # Second connection attempt fails after 1000 ms.
679 connecting
680 timeout
681 run
682 connect-failed
683
684 # Back off for 2000 ms.
685 timeout
686 run
687
688 # Third connection attempt succeeds after 500 ms.
689 connecting
690 advance 500
691 run
692 connected
693
694 # Connection receives 3 chunks of data spaced 250 ms apart.
695 advance 250
696 run
697 activity
698 advance 250
699 run
700 activity
701 advance 250
702 run
703 activity
704
705 # Connection drops.
706 disconnected
707 run
708
709 # Back off for 4000 ms.
710 timeout
711 run
712 ],
713 [### t=1000 ###
714 enable
715 in BACKOFF for 0 ms (0 ms backoff)
716
717 # First connection attempt fails after 1000 ms.
718 run
719 should connect
720 connecting
721 in CONNECTING for 0 ms (0 ms backoff)
722 run
723 timeout
724 advance 1000 ms
725
726 ### t=2000 ###
727 in CONNECTING for 1000 ms (0 ms backoff)
728 run
729 should disconnect
730 connect-failed
731 in BACKOFF for 0 ms (1000 ms backoff)
732 0 successful connections out of 1 attempts, seqno 0
733
734 # Back off for 1000 ms.
735 timeout
736 advance 1000 ms
737
738 ### t=3000 ###
739 in BACKOFF for 1000 ms (1000 ms backoff)
740 run
741 should connect
742
743 # Second connection attempt fails after 1000 ms.
744 connecting
745 in CONNECTING for 0 ms (1000 ms backoff)
746 timeout
747 advance 1000 ms
748
749 ### t=4000 ###
750 in CONNECTING for 1000 ms (1000 ms backoff)
751 run
752 should disconnect
753 connect-failed
754 in BACKOFF for 0 ms (2000 ms backoff)
755 0 successful connections out of 2 attempts, seqno 0
756
757 # Back off for 2000 ms.
758 timeout
759 advance 2000 ms
760
761 ### t=6000 ###
762 in BACKOFF for 2000 ms (2000 ms backoff)
763 run
764 should connect
765
766 # Third connection attempt succeeds after 500 ms.
767 connecting
768 in CONNECTING for 0 ms (2000 ms backoff)
769 advance 500
770
771 ### t=6500 ###
772 in CONNECTING for 500 ms (2000 ms backoff)
773 run
774 connected
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
778 connected
779 last connected 0 ms ago, connected 0 ms total
780
781 # Connection receives 3 chunks of data spaced 250 ms apart.
782 advance 250
783
784 ### t=6750 ###
785 in ACTIVE for 250 ms (2000 ms backoff)
786 run
787 activity
788 created 1000, last activity 6750, last connected 6500
789 advance 250
790
791 ### t=7000 ###
792 in ACTIVE for 500 ms (2000 ms backoff)
793 run
794 activity
795 created 1000, last activity 7000, last connected 6500
796 advance 250
797
798 ### t=7250 ###
799 in ACTIVE for 750 ms (2000 ms backoff)
800 run
801 activity
802 created 1000, last activity 7250, last connected 6500
803
804 # Connection drops.
805 disconnected
806 in BACKOFF for 0 ms (4000 ms backoff)
807 1 successful connections out of 3 attempts, seqno 2
808 disconnected
809 disconnected at 7250 ms (0 ms ago)
810 run
811
812 # Back off for 4000 ms.
813 timeout
814 advance 4000 ms
815
816 ### t=11250 ###
817 in BACKOFF for 4000 ms (4000 ms backoff)
818 last connected 4750 ms ago, connected 750 ms total
819 run
820 should connect
821 ])
822
823 ######################################################################
824 RECONNECT_CHECK([long connection resets backoff],
825 [enable
826
827 # First connection attempt fails after 1000 ms.
828 run
829 connecting
830 run
831 timeout
832 run
833 connect-failed
834
835 # Back off for 1000 ms.
836 timeout
837 run
838
839 # Second connection attempt fails after 1000 ms.
840 connecting
841 timeout
842 run
843 connect-failed
844
845 # Back off for 2000 ms.
846 timeout
847 run
848
849 # Third connection attempt succeeds after 500 ms.
850 connecting
851 advance 500
852 run
853 connected
854
855 # Connection receives 3 chunks of data spaced 2000 ms apart.
856 advance 2000
857 run
858 activity
859 advance 2000
860 run
861 activity
862 advance 2000
863 run
864 activity
865
866 # Connection drops.
867 disconnected
868 run
869
870 # Back off for 1000 ms.
871 timeout
872 run
873 ],
874 [### t=1000 ###
875 enable
876 in BACKOFF for 0 ms (0 ms backoff)
877
878 # First connection attempt fails after 1000 ms.
879 run
880 should connect
881 connecting
882 in CONNECTING for 0 ms (0 ms backoff)
883 run
884 timeout
885 advance 1000 ms
886
887 ### t=2000 ###
888 in CONNECTING for 1000 ms (0 ms backoff)
889 run
890 should disconnect
891 connect-failed
892 in BACKOFF for 0 ms (1000 ms backoff)
893 0 successful connections out of 1 attempts, seqno 0
894
895 # Back off for 1000 ms.
896 timeout
897 advance 1000 ms
898
899 ### t=3000 ###
900 in BACKOFF for 1000 ms (1000 ms backoff)
901 run
902 should connect
903
904 # Second connection attempt fails after 1000 ms.
905 connecting
906 in CONNECTING for 0 ms (1000 ms backoff)
907 timeout
908 advance 1000 ms
909
910 ### t=4000 ###
911 in CONNECTING for 1000 ms (1000 ms backoff)
912 run
913 should disconnect
914 connect-failed
915 in BACKOFF for 0 ms (2000 ms backoff)
916 0 successful connections out of 2 attempts, seqno 0
917
918 # Back off for 2000 ms.
919 timeout
920 advance 2000 ms
921
922 ### t=6000 ###
923 in BACKOFF for 2000 ms (2000 ms backoff)
924 run
925 should connect
926
927 # Third connection attempt succeeds after 500 ms.
928 connecting
929 in CONNECTING for 0 ms (2000 ms backoff)
930 advance 500
931
932 ### t=6500 ###
933 in CONNECTING for 500 ms (2000 ms backoff)
934 run
935 connected
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
939 connected
940 last connected 0 ms ago, connected 0 ms total
941
942 # Connection receives 3 chunks of data spaced 2000 ms apart.
943 advance 2000
944
945 ### t=8500 ###
946 in ACTIVE for 2000 ms (2000 ms backoff)
947 run
948 activity
949 created 1000, last activity 8500, last connected 6500
950 advance 2000
951
952 ### t=10500 ###
953 in ACTIVE for 4000 ms (2000 ms backoff)
954 run
955 activity
956 created 1000, last activity 10500, last connected 6500
957 advance 2000
958
959 ### t=12500 ###
960 in ACTIVE for 6000 ms (2000 ms backoff)
961 run
962 activity
963 created 1000, last activity 12500, last connected 6500
964
965 # Connection drops.
966 disconnected
967 in BACKOFF for 0 ms (1000 ms backoff)
968 1 successful connections out of 3 attempts, seqno 2
969 disconnected
970 disconnected at 12500 ms (0 ms ago)
971 run
972
973 # Back off for 1000 ms.
974 timeout
975 advance 1000 ms
976
977 ### t=13500 ###
978 in BACKOFF for 1000 ms (1000 ms backoff)
979 last connected 7000 ms ago, connected 6000 ms total
980 run
981 should connect
982 ])
983
984 ######################################################################
985 RECONNECT_CHECK([connection attempt fails quickly],
986 [enable
987
988 # Connection fails quickly.
989 run
990 connect-failed ECONNREFUSED
991
992 # Back off for 1000 ms.
993 run
994 timeout
995
996 # Connection fails quickly again.
997 run
998 connect-failed ECONNREFUSED
999
1000 # Back off for 2000 ms.
1001 run
1002 timeout
1003 ],
1004 [### t=1000 ###
1005 enable
1006 in BACKOFF for 0 ms (0 ms backoff)
1007
1008 # Connection fails quickly.
1009 run
1010 should connect
1011 connect-failed ECONNREFUSED
1012 in BACKOFF for 0 ms (1000 ms backoff)
1013 0 successful connections out of 1 attempts, seqno 0
1014
1015 # Back off for 1000 ms.
1016 run
1017 timeout
1018 advance 1000 ms
1019
1020 ### t=2000 ###
1021 in BACKOFF for 1000 ms (1000 ms backoff)
1022
1023 # Connection fails quickly again.
1024 run
1025 should connect
1026 connect-failed ECONNREFUSED
1027 in BACKOFF for 0 ms (2000 ms backoff)
1028 0 successful connections out of 2 attempts, seqno 0
1029
1030 # Back off for 2000 ms.
1031 run
1032 timeout
1033 advance 2000 ms
1034
1035 ### t=4000 ###
1036 in BACKOFF for 2000 ms (2000 ms backoff)
1037 ])
1038
1039 ######################################################################
1040 RECONNECT_CHECK([backoff-free tries work],
1041 [set-backoff-free-tries 2
1042 enable
1043
1044 # Connection fails quickly.
1045 run
1046 connect-failed ECONNREFUSED
1047
1048 # No backoff.
1049 run
1050 timeout
1051
1052 # Connection fails quickly again.
1053 run
1054 connect-failed ECONNREFUSED
1055
1056 # Back off for 1000 ms.
1057 run
1058 timeout
1059 ],
1060 [### t=1000 ###
1061 set-backoff-free-tries 2
1062 enable
1063 in BACKOFF for 0 ms (0 ms backoff)
1064
1065 # Connection fails quickly.
1066 run
1067 should connect
1068 connect-failed ECONNREFUSED
1069 0 successful connections out of 1 attempts, seqno 0
1070
1071 # No backoff.
1072 run
1073 should connect
1074 timeout
1075 advance 0 ms
1076
1077 # Connection fails quickly again.
1078 run
1079 should connect
1080 connect-failed ECONNREFUSED
1081 in BACKOFF for 0 ms (1000 ms backoff)
1082 0 successful connections out of 2 attempts, seqno 0
1083
1084 # Back off for 1000 ms.
1085 run
1086 timeout
1087 advance 1000 ms
1088
1089 ### t=2000 ###
1090 in BACKOFF for 1000 ms (1000 ms backoff)
1091 ])
1092
1093 ######################################################################
1094 RECONNECT_CHECK([max-tries of 1 honored],
1095 [set-max-tries 1
1096 enable
1097
1098 # Connection succeeds.
1099 run
1100 connected
1101
1102 # Send inactivity probe.
1103 timeout
1104 run
1105
1106 # Idle timeout kills connection.
1107 timeout
1108 run
1109 disconnected
1110 ],
1111 [### t=1000 ###
1112 set-max-tries 1
1113 1 tries left
1114 enable
1115 in BACKOFF for 0 ms (0 ms backoff)
1116 0 tries left
1117
1118 # Connection succeeds.
1119 run
1120 should connect
1121 connected
1122 in ACTIVE for 0 ms (0 ms backoff)
1123 created 1000, last activity 1000, last connected 1000
1124 1 successful connections out of 1 attempts, seqno 1
1125 connected
1126 last connected 0 ms ago, connected 0 ms total
1127
1128 # Send inactivity probe.
1129 timeout
1130 advance 5000 ms
1131
1132 ### t=6000 ###
1133 in ACTIVE for 5000 ms (0 ms backoff)
1134 run
1135 should send probe
1136 in IDLE for 0 ms (0 ms backoff)
1137
1138 # Idle timeout kills connection.
1139 timeout
1140 advance 5000 ms
1141
1142 ### t=11000 ###
1143 in IDLE for 5000 ms (0 ms backoff)
1144 run
1145 should disconnect
1146 disconnected
1147 in VOID for 0 ms (0 ms backoff)
1148 1 successful connections out of 1 attempts, seqno 2
1149 disconnected
1150 disconnected at 11000 ms (0 ms ago)
1151 ])
1152
1153 ######################################################################
1154 RECONNECT_CHECK([max-tries of 0 honored],
1155 [set-max-tries 0
1156 enable
1157 run
1158 timeout
1159 ],
1160 [### t=1000 ###
1161 set-max-tries 0
1162 0 tries left
1163 enable
1164 run
1165 timeout
1166 no timeout
1167 ])
1168
1169 ######################################################################
1170 RECONNECT_CHECK([passive mode],
1171 [passive
1172 enable
1173
1174 # Start listening.
1175 timeout
1176 run
1177 listening
1178
1179 # Listening never times out.
1180 timeout
1181 run
1182
1183 # Listening failed (accept() returned funny error?). Back off and try again.
1184 listen-error 0
1185 timeout
1186 run
1187 listening
1188
1189 # Connection accepted.
1190 connected
1191 activity
1192 advance 1000
1193 activity
1194
1195 # Connection times out.
1196 timeout
1197 run
1198 timeout
1199 run
1200 disconnected
1201
1202 # Start listening again.
1203 timeout
1204 run
1205 listening
1206 ],
1207 [### t=1000 ###
1208 passive
1209 enable
1210 in BACKOFF for 0 ms (0 ms backoff)
1211
1212 # Start listening.
1213 timeout
1214 advance 0 ms
1215 run
1216 should connect
1217 listening
1218 in LISTENING for 0 ms (0 ms backoff)
1219
1220 # Listening never times out.
1221 timeout
1222 no timeout
1223 run
1224
1225 # Listening failed (accept() returned funny error?). Back off and try again.
1226 listen-error 0
1227 in BACKOFF for 0 ms (1000 ms backoff)
1228 timeout
1229 advance 1000 ms
1230
1231 ### t=2000 ###
1232 in BACKOFF for 1000 ms (1000 ms backoff)
1233 run
1234 should connect
1235 listening
1236 in LISTENING for 0 ms (1000 ms backoff)
1237
1238 # Connection accepted.
1239 connected
1240 in ACTIVE for 0 ms (1000 ms backoff)
1241 created 1000, last activity 1000, last connected 2000
1242 1 successful connections out of 1 attempts, seqno 1
1243 connected
1244 last connected 0 ms ago, connected 0 ms total
1245 activity
1246 created 1000, last activity 2000, last connected 2000
1247 advance 1000
1248
1249 ### t=3000 ###
1250 in ACTIVE for 1000 ms (1000 ms backoff)
1251 activity
1252 created 1000, last activity 3000, last connected 2000
1253
1254 # Connection times out.
1255 timeout
1256 advance 5000 ms
1257
1258 ### t=8000 ###
1259 in ACTIVE for 6000 ms (1000 ms backoff)
1260 run
1261 should send probe
1262 in IDLE for 0 ms (1000 ms backoff)
1263 timeout
1264 advance 5000 ms
1265
1266 ### t=13000 ###
1267 in IDLE for 5000 ms (1000 ms backoff)
1268 run
1269 should disconnect
1270 disconnected
1271 in BACKOFF for 0 ms (0 ms backoff)
1272 1 successful connections out of 1 attempts, seqno 2
1273 disconnected
1274 disconnected at 13000 ms (0 ms ago)
1275
1276 # Start listening again.
1277 timeout
1278 advance 0 ms
1279 run
1280 should connect
1281 listening
1282 in LISTENING for 0 ms (0 ms backoff)
1283 ])