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