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