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