public void GetStateStoreNotExist()
        {
            var source = new CancellationTokenSource();
            var config = new StreamConfig <StringSerDes, StringSerDes>();

            config.ApplicationId = "test-config";

            var topicConfiguration = config.Clone();

            topicConfiguration.ApplicationId = $"test-driver-{config.ApplicationId}";


            var builder = new StreamBuilder();

            builder.Stream <string, string>("test").To("test2");

            var driver = new ClusterInMemoryTopologyDriver("client", builder.Build().Builder, config, topicConfiguration, source.Token);

            driver.StartDriver();
            driver.CreateInputTopic("test", new StringSerDes(), new StringSerDes());
            var store = driver.GetStateStore <string, string>("store");

            Assert.IsNull(store);
            source.Cancel();
            driver.Dispose();
        }
        public void GetStateStoreExist()
        {
            var source = new CancellationTokenSource();
            var config = new StreamConfig <StringSerDes, StringSerDes>();

            config.ApplicationId = "test-config";
            var topicConfiguration = config.Clone();

            topicConfiguration.ApplicationId = $"test-driver-{config.ApplicationId}";

            var builder = new StreamBuilder();

            builder.Table <string, string>("test", InMemory <string, string> .As("store"));
            var driver = new ClusterInMemoryTopologyDriver("client", builder.Build().Builder, config, topicConfiguration, TimeSpan.FromSeconds(1), source.Token);

            driver.StartDriver();
            var input = driver.CreateInputTopic("test", new StringSerDes(), new StringSerDes());
            var store = driver.GetStateStore <string, string>("store");

            Assert.IsNotNull(store);
            Assert.IsInstanceOf <MockReadOnlyKeyValueStore <string, string> >(store);
            input.PipeInput("coucou", "1");
            Thread.Sleep(100);

            Assert.AreEqual(1, ((MockReadOnlyKeyValueStore <string, string>)store).All().Count());
            Assert.AreEqual("1", ((MockReadOnlyKeyValueStore <string, string>)store).Get("coucou"));
            source.Cancel();
            driver.Dispose();
        }
Example #3
0
        public void JoinGlobakKTable()
        {
            var source = new CancellationTokenSource();
            var config = new StreamConfig <StringSerDes, StringSerDes>();

            config.ApplicationId = "test-config";
            config.PollMs        = 10;
            var topicConfiguration = config.Clone();

            topicConfiguration.ApplicationId = $"test-driver-{config.ApplicationId}";

            var builder = new StreamBuilder();

            var globalktable = builder.GlobalTable("test", InMemory <string, string> .As("global-store"));

            builder.Stream <string, string>("source")
            .Join(globalktable,
                  (k, v) => k,
                  (v1, v2) => $"{v1}-{v2}")
            .To("sink");

            var driver = new ClusterInMemoryTopologyDriver("client", builder.Build().Builder, config, topicConfiguration, TimeSpan.FromSeconds(1), source.Token);

            driver.StartDriver();

            var inputTest   = driver.CreateInputTopic("test", new StringSerDes(), new StringSerDes());
            var inputSource = driver.CreateInputTopic("source", new StringSerDes(), new StringSerDes());
            var output      = driver.CreateOutputTopic("sink", TimeSpan.FromSeconds(1), new StringSerDes(), new StringSerDes());

            inputTest.PipeInput("coucou", "Sylvain");
            Thread.Sleep(100);
            inputSource.PipeInput("coucou", "Coucou");
            Thread.Sleep(300);

            var records = IntegrationTestUtils.WaitUntilMinKeyValueRecordsReceived(output, 1);

            Assert.AreEqual(1, records.Count);
            Assert.AreEqual("Coucou-Sylvain", records.First().Message.Value);
            source.Cancel();
            driver.Dispose();
        }