|
12 | 12 | // limitations under the License.
|
13 | 13 |
|
14 | 14 | using System;
|
15 |
| -using NATS.Client; |
| 15 | +using System.Collections.Generic; |
| 16 | +using System.Diagnostics; |
16 | 17 | using System.Text;
|
17 | 18 | using System.Threading;
|
18 | 19 | using System.Threading.Tasks;
|
19 |
| -using System.Diagnostics; |
20 |
| -using System.Collections.Generic; |
| 20 | +using NATS.Client; |
21 | 21 | using Xunit;
|
22 | 22 |
|
23 | 23 | namespace IntegrationTests
|
@@ -644,6 +644,37 @@ public void TestReconnectDelayJitterOptions()
|
644 | 644 | Assert.True(opts.ReconnectJitter == Defaults.ReconnectJitter);
|
645 | 645 | Assert.True(opts.ReconnectJitterTLS == Defaults.ReconnectJitterTLS);
|
646 | 646 | }
|
| 647 | + |
| 648 | + |
| 649 | + [Fact] |
| 650 | + public void TestMaxReconnectOnConnect() |
| 651 | + { |
| 652 | + Options opts = Context.GetTestOptions(Context.Server1.Port); |
| 653 | + opts.AllowReconnect = true; |
| 654 | + opts.MaxReconnect = 60; |
| 655 | + |
| 656 | + CountdownEvent latch = new CountdownEvent(1); |
| 657 | + IConnection connection = null; |
| 658 | + Thread t = new Thread(() => |
| 659 | + { |
| 660 | + Assert.Null(connection); |
| 661 | + Thread.Sleep(2000); |
| 662 | + Assert.Null(connection); |
| 663 | + |
| 664 | + using (NATSServer s1 = NATSServer.Create(Context.Server1.Port)) |
| 665 | + { |
| 666 | + latch.Wait(2000); |
| 667 | + Assert.NotNull(connection); |
| 668 | + Assert.Equal(ConnState.CONNECTED, connection.State); |
| 669 | + } |
| 670 | + }); |
| 671 | + t.Start(); |
| 672 | + |
| 673 | + connection = Context.ConnectionFactory.CreateConnection(opts, true); |
| 674 | + latch.Signal(); |
| 675 | + |
| 676 | + t.Join(5000); |
| 677 | + } |
647 | 678 | }
|
648 | 679 |
|
649 | 680 | public class TestPublishErrorsDuringReconnect : TestSuite<PublishErrorsDuringReconnectSuiteContext>
|
|
0 commit comments