Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tests/usage of mirroring and stream sourcing #634

Open
mtmk opened this issue Sep 19, 2024 · 0 comments
Open

Tests/usage of mirroring and stream sourcing #634

mtmk opened this issue Sep 19, 2024 · 0 comments
Assignees
Labels

Comments

@mtmk
Copy link
Collaborator

mtmk commented Sep 19, 2024

          Due to the difficulty of automating leaf node testing below are examples of tests/usage of mirroring and stream sourcing.
   [Fact]
   public async Task Test_LeafStreamMirrorDomain()
   {
       await using var natsLeaf = new NatsConnection(new NatsOpts { Url = "nats://leaf:4223/", AuthOpts = new NatsAuthOpts { Username = "leaf", Password = "leaf" } });
       await natsLeaf.ConnectAsync();

       var jsContext = new NatsJSContext(natsLeaf);

       var mirroredStream = await jsContext.CreateStreamAsync(new StreamConfig()
       {
           Name = "mirroredStream",
           Mirror = new StreamSource
           {
               Name = "sourceStream1",
               Domain = "hub",
           },
       });
   }

   [Fact]
   public async Task Test_LeafStreamMultiSourceDomain()
   {
       await using var natsLeaf = new NatsConnection(new NatsOpts { Url = "nats://leaf:4223/", AuthOpts = new NatsAuthOpts { Username = "leaf", Password = "leaf" } });
       await natsLeaf.ConnectAsync();

       var jsContext = new NatsJSContext(natsLeaf);

       var mirroredStream = await jsContext.CreateStreamAsync(new StreamConfig()
       {
           Name = "mirroredStreamMulti",
           Sources = [
                   new StreamSource { Name = "sourceStream1", Domain = "hub" },
                   new StreamSource { Name = "sourceStream2", Domain = "hub" }
               ],
       });
   }

   [Fact]
   public async Task Test_LeafKVMirrorDomain()
   {
       await using var natsLeaf = new NatsConnection(new NatsOpts { Url = "nats://leaf:4223/", AuthOpts = new NatsAuthOpts { Username = "leaf", Password = "leaf" } });
       await natsLeaf.ConnectAsync();

       var jsContext = new NatsJSContext(natsLeaf);
       var kvContext = new NatsKVContext(jsContext);

       var mirroredStore = await kvContext.CreateStoreAsync(new NatsKVConfig("mirroredKvTestMirror")
       {
           Mirror = new StreamSource
           {
               Name = "kvTest",
               Domain = "hub",
           },
       });
   }

   [Fact]
   public async Task Test_LeafKVMirrorSourcesDomain()
   {
       await using var natsLeaf = new NatsConnection(new NatsOpts { Url = "nats://leaf:4223/", AuthOpts = new NatsAuthOpts { Username = "leaf", Password = "leaf" } });
       await natsLeaf.ConnectAsync();

       var jsContext = new NatsJSContext(natsLeaf);
       var kvContext = new NatsKVContext(jsContext);

       var mirroredStore = await kvContext.CreateStoreAsync(new NatsKVConfig("mirroredKvTestSources")
       {
           Sources = [
                   new StreamSource { Name = "kvTest", Domain = "hub" },
           ],
       });
   }

Originally posted by @darkwatchuk in #631 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants