Esempio n. 1
0
        public async Task SegmentedQueryUnequalCountsTest()
        {
            await taskHub.AddTaskOrchestrations(typeof(InstanceStoreTestOrchestration),
                                                typeof(InstanceStoreTestOrchestration2))
            .AddTaskActivities(new Activity1())
            .StartAsync();

            for (int i = 0; i < 15; i++)
            {
                string instanceId = "apiservice" + i;
                await client.CreateOrchestrationInstanceAsync(
                    i % 2 == 0?typeof(InstanceStoreTestOrchestration) : typeof(InstanceStoreTestOrchestration2),
                    instanceId, "DONTTHROW");
            }

            Thread.Sleep(TimeSpan.FromSeconds(30));

            var query = new OrchestrationStateQuery();

            OrchestrationStateQuerySegment seg = null;

            var results = new List <OrchestrationState>();

            seg = await queryClient.QueryOrchestrationStatesSegmentedAsync(query, null, 2);

            results.AddRange(seg.Results);
            Assert.AreEqual(2, results.Count);

            seg = await queryClient.QueryOrchestrationStatesSegmentedAsync(query, seg.ContinuationToken, 5);

            results.AddRange(seg.Results);
            Assert.AreEqual(7, results.Count);

            seg = await queryClient.QueryOrchestrationStatesSegmentedAsync(query, seg.ContinuationToken, 10);

            results.AddRange(seg.Results);
            Assert.AreEqual(15, results.Count);
            Assert.IsNull(seg.ContinuationToken);
        }
        public async Task SegmentedQueryTest()
        {
            await this.taskHub.AddTaskOrchestrations(typeof(InstanceStoreTestOrchestration),
                                                     typeof(InstanceStoreTestOrchestration2))
            .AddTaskActivities(new Activity1())
            .StartAsync();

            for (var i = 0; i < 15; i++)
            {
                string instanceId = "apiservice" + i;
                await this.client.CreateOrchestrationInstanceAsync(
                    i % 2 == 0?typeof(InstanceStoreTestOrchestration) : typeof(InstanceStoreTestOrchestration2),
                    instanceId, "DONTTHROW");
            }

            Thread.Sleep(TimeSpan.FromSeconds(60));

            var query = new OrchestrationStateQuery();

            OrchestrationStateQuerySegment seg = null;
            var results = new List <OrchestrationState>();

            do
            {
                seg = await this.queryClient.QueryOrchestrationStatesSegmentedAsync(query, seg?.ContinuationToken, 2);

                results.AddRange(seg.Results);
            } while (seg.ContinuationToken != null);

            Assert.AreEqual(15, results.Count);

            query = new OrchestrationStateQuery()
                    .AddInstanceFilter("apiservice", true)
                    .AddNameVersionFilter("DurableTask.ServiceBus.Tests.InstanceStoreQueryTests+InstanceStoreTestOrchestration");

            seg     = null;
            results = new List <OrchestrationState>();
            do
            {
                seg = await this.queryClient.QueryOrchestrationStatesSegmentedAsync(query, seg?.ContinuationToken, 2);

                results.AddRange(seg.Results);
            } while (seg.ContinuationToken != null);

            Assert.AreEqual(8, results.Count);

            query = new OrchestrationStateQuery()
                    .AddInstanceFilter("apiservice", true)
                    .AddNameVersionFilter("DurableTask.ServiceBus.Tests.InstanceStoreQueryTests+InstanceStoreTestOrchestration2");

            seg     = null;
            results = new List <OrchestrationState>();
            do
            {
                seg = await this.queryClient.QueryOrchestrationStatesSegmentedAsync(query, seg?.ContinuationToken, 2);

                results.AddRange(seg.Results);
            } while (seg.ContinuationToken != null);

            Assert.AreEqual(7, results.Count);

            query = new OrchestrationStateQuery()
                    .AddInstanceFilter("apiservice", true)
                    .AddNameVersionFilter("DurableTask.ServiceBus.Tests.InstanceStoreQueryTests+InstanceStoreTestOrchestration2");

            seg = await this.queryClient.QueryOrchestrationStatesSegmentedAsync(query, null);

            Assert.IsTrue(seg.ContinuationToken == null);
            Assert.AreEqual(7, seg.Results.Count());
        }
        public void SegmentedQueryTest()
        {
            taskHub.AddTaskOrchestrations(typeof(InstanceStoreTestOrchestration),
                                          typeof(InstanceStoreTestOrchestration2))
            .AddTaskActivities(new Activity1())
            .Start();

            for (int i = 0; i < 15; i++)
            {
                string instanceId = "apiservice" + i;
                client.CreateOrchestrationInstance(
                    i % 2 == 0 ? typeof(InstanceStoreTestOrchestration) : typeof(InstanceStoreTestOrchestration2),
                    instanceId, "DONTTHROW");
            }

            Thread.Sleep(TimeSpan.FromSeconds(30));

            var query = new OrchestrationStateQuery();

            OrchestrationStateQuerySegment seg = null;

            var results = new List <OrchestrationState>();

            do
            {
                seg =
                    client.QueryOrchestrationStatesSegmentedAsync(query, seg == null ? null : seg.ContinuationToken, 2)
                    .Result;
                results.AddRange(seg.Results);
            } while (seg.ContinuationToken != null);

            Assert.AreEqual(15, results.Count);

            query = new OrchestrationStateQuery()
                    .AddInstanceFilter("apiservice", true)
                    .AddNameVersionFilter("FrameworkUnitTests.InstanceStoreQueryTests+InstanceStoreTestOrchestration");

            results = new List <OrchestrationState>();
            do
            {
                seg =
                    client.QueryOrchestrationStatesSegmentedAsync(query, seg == null ? null : seg.ContinuationToken, 2)
                    .Result;
                results.AddRange(seg.Results);
            } while (seg.ContinuationToken != null);
            Assert.AreEqual(8, results.Count);

            query = new OrchestrationStateQuery()
                    .AddInstanceFilter("apiservice", true)
                    .AddNameVersionFilter("FrameworkUnitTests.InstanceStoreQueryTests+InstanceStoreTestOrchestration2");

            results = new List <OrchestrationState>();
            do
            {
                seg =
                    client.QueryOrchestrationStatesSegmentedAsync(query, seg == null ? null : seg.ContinuationToken, 2)
                    .Result;
                results.AddRange(seg.Results);
            } while (seg.ContinuationToken != null);
            Assert.AreEqual(7, results.Count);

            query = new OrchestrationStateQuery()
                    .AddInstanceFilter("apiservice", true)
                    .AddNameVersionFilter("FrameworkUnitTests.InstanceStoreQueryTests+InstanceStoreTestOrchestration2");

            seg =
                client.QueryOrchestrationStatesSegmentedAsync(query, seg == null ? null : seg.ContinuationToken).Result;

            Assert.IsTrue(seg.ContinuationToken == null);
            Assert.AreEqual(7, seg.Results.Count());
        }