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