示例#1
0
        public async Task RetryCustomHandlerFailTest()
        {
            var retryOptions = new RetryOptions(TimeSpan.FromSeconds(3), 3);

            retryOptions.Handle = e =>
            {
                Assert.IsInstanceOfType(e, typeof(TaskFailedException), "Exception is not TaskFailedException.");
                var taskFailed = (TaskFailedException)e;

                return(taskFailed.InnerException is ArgumentNullException);
            };

            var retryTask = new RetryTask(2);

            await this.taskHub.AddTaskOrchestrations(new TestObjectCreator <TaskOrchestration>(RetryName, RetryVersion,
                                                                                               () => new RetryOrchestration(retryOptions)))
            .AddTaskActivitiesFromInterface <IRetryTask>(retryTask)
            .StartAsync();

            RetryOrchestration.Result = null;
            OrchestrationInstance id = await this.client.CreateOrchestrationInstanceAsync(RetryName, RetryVersion, false);

            bool isCompleted = await TestHelpers.WaitForInstanceAsync(this.client, id, 90);

            Assert.IsTrue(isCompleted, TestHelpers.GetInstanceNotCompletedMessage(this.client, id, 90));
            Assert.AreEqual("DoWork Failed. RetryCount is: 1", RetryOrchestration.Result,
                            "Orchestration Result is wrong!!!");
            Assert.AreEqual(1, retryTask.RetryCount, "Retry Count is wrong");
        }
示例#2
0
        public async Task MessageCompressionToNoCompressionTest()
        {
            await this.taskHub.AddTaskOrchestrations(typeof(MessageCompressionCompatTest))
            .AddTaskActivities(typeof(AlternatingPayloadTask))
            .StartAsync();

            OrchestrationInstance id =
                await this.clientNoCompression.CreateOrchestrationInstanceAsync(typeof(MessageCompressionCompatTest), null);

            await Task.Delay(2000);

            await this.taskHub.StopAsync(true);

            await this.taskHubNoCompression.AddTaskOrchestrations(typeof(MessageCompressionCompatTest))
            .AddTaskActivities(typeof(AlternatingPayloadTask))
            .StartAsync();

            bool isCompleted = await TestHelpers.WaitForInstanceAsync(this.client, id, 60);

            Assert.IsTrue(isCompleted, TestHelpers.GetInstanceNotCompletedMessage(this.client, id, 60));

            OrchestrationState state = await this.client.GetOrchestrationStateAsync(id);

            Assert.AreEqual(OrchestrationStatus.Completed, state.OrchestrationStatus);
        }
        public async Task ConcurrentSubOrchestrationsTest()
        {
            var c1 = new NameValueObjectCreator <TaskOrchestration>("UberOrchestration",
                                                                    "V1", typeof(UberOrchestration));

            var c2 = new NameValueObjectCreator <TaskOrchestration>("SleeperSubOrchestration",
                                                                    "V1", typeof(SleeperSubOrchestration));

            await taskHub.AddTaskOrchestrations(c1, c2)
            .StartAsync();

            int numSubOrchestrations = 60;

            OrchestrationInstance instance = await client.CreateOrchestrationInstanceAsync(
                "UberOrchestration",
                "V1",
                "TestInstance",
                new TestOrchestrationInput { Iterations = numSubOrchestrations, Payload = TestUtils.GenerateRandomString(90 * 1024) });

            // Waiting for 60 seconds guarantees that to pass the orchestrations must run in parallel
            bool isCompleted = await TestHelpers.WaitForInstanceAsync(client, instance, 60);

            Assert.IsTrue(isCompleted, TestHelpers.GetInstanceNotCompletedMessage(client, instance, 60));
            Assert.AreEqual(numSubOrchestrations, UberOrchestration.Result, "Orchestration Result is wrong!!!");
        }
示例#4
0
        public async Task RetryOnReasonCustomHandlerTest()
        {
            var retryOptions = new RetryOptions(TimeSpan.FromSeconds(3), 3);

            retryOptions.Handle = e =>
            {
                Assert.IsInstanceOfType(e, typeof(TaskFailedException), "Exception is not TaskFailedException.");
                var taskFailed = (TaskFailedException)e;
                Assert.IsInstanceOfType(taskFailed.InnerException, typeof(InvalidOperationException),
                                        "InnerException is not InvalidOperationException.");
                return(e.Message.StartsWith("DoWork Failed. RetryCount is:"));
            };

            var retryTask = new RetryTask(2);

            await this.taskHub.AddTaskOrchestrations(new TestObjectCreator <TaskOrchestration>(RetryName, RetryVersion,
                                                                                               () => new RetryOrchestration(retryOptions)))
            .AddTaskActivitiesFromInterface <IRetryTask>(retryTask)
            .StartAsync();

            this.taskHub.TaskActivityDispatcher.IncludeDetails = true;

            RetryOrchestration.Result = null;
            OrchestrationInstance id = await this.client.CreateOrchestrationInstanceAsync(RetryName, RetryVersion, false);

            bool isCompleted = await TestHelpers.WaitForInstanceAsync(this.client, id, 90);

            Assert.IsTrue(isCompleted, TestHelpers.GetInstanceNotCompletedMessage(this.client, id, 90));
            Assert.AreEqual("DoWork Succeeded. Attempts: 2", RetryOrchestration.Result,
                            "Orchestration Result is wrong!!!");
            Assert.AreEqual(2, retryTask.RetryCount, "Retry Count is wrong");
        }
        public async Task GenerationSubFailedTest()
        {
            await taskHub.AddTaskOrchestrations(typeof(GenerationSubFailedParentOrchestration),
                                                typeof(GenerationSubFailedChildOrchestration))
            .AddTaskActivities(new GenerationBasicTask())
            .StartAsync();

            taskHub.TaskOrchestrationDispatcher.IncludeDetails = true;

            GenerationSubFailedChildOrchestration.Count   = 0;
            GenerationSubFailedParentOrchestration.Result = null;
            OrchestrationInstance id =
                await client.CreateOrchestrationInstanceAsync(typeof(GenerationSubFailedParentOrchestration), true);

            bool isCompleted = await TestHelpers.WaitForInstanceAsync(client, id, 60);

            Assert.IsTrue(isCompleted, TestHelpers.GetInstanceNotCompletedMessage(client, id, 60));

            Assert.AreEqual("Test", GenerationSubFailedParentOrchestration.Result, "Orchestration Result is wrong!!!");
            Assert.AreEqual(1, GenerationSubFailedChildOrchestration.Count, "Child Workflow Count invalid.");

            GenerationSubFailedChildOrchestration.Count   = 0;
            GenerationSubFailedParentOrchestration.Result = null;
            id = await client.CreateOrchestrationInstanceAsync(typeof(GenerationSubFailedParentOrchestration), false);

            isCompleted = await TestHelpers.WaitForInstanceAsync(client, id, 60);

            Assert.IsTrue(isCompleted, TestHelpers.GetInstanceNotCompletedMessage(client, id, 60));
            Assert.AreEqual("Test", GenerationSubFailedParentOrchestration.Result, "Orchestration Result is wrong!!!");
            Assert.AreEqual(5, GenerationSubFailedChildOrchestration.Count, "Child Workflow Count invalid.");
        }
示例#6
0
        public async Task RetryTimeoutTest()
        {
            var retryOptions = new RetryOptions(TimeSpan.FromSeconds(5), 10);

            retryOptions.BackoffCoefficient = 2;
            retryOptions.RetryTimeout       = TimeSpan.FromSeconds(10);

            var retryTask = new RetryTask(3);

            await this.taskHub.AddTaskOrchestrations(new TestObjectCreator <TaskOrchestration>(RetryName, RetryVersion,
                                                                                               () => new RetryOrchestration(retryOptions)))
            .AddTaskActivitiesFromInterface <IRetryTask>(retryTask)
            .StartAsync();

            RetryOrchestration.Result = null;
            OrchestrationInstance id = await this.client.CreateOrchestrationInstanceAsync(RetryName, RetryVersion, false);

            bool isCompleted = await TestHelpers.WaitForInstanceAsync(this.client, id, 60);

            Assert.IsNotNull(RetryOrchestration.Result);
            Assert.IsTrue(isCompleted, TestHelpers.GetInstanceNotCompletedMessage(this.client, id, 60));
            Assert.IsTrue(RetryOrchestration.Result.StartsWith("DoWork Failed. RetryCount is:"),
                          "Orchestration Result is wrong!!!. Result: " + RetryOrchestration.Result);
            Assert.IsTrue(retryTask.RetryCount < 4, "Retry Count is wrong. Count: " + retryTask.RetryCount);
        }
示例#7
0
        public async Task RetryMaxIntervalTest()
        {
            var retryOptions = new RetryOptions(TimeSpan.FromSeconds(3), 3);

            retryOptions.BackoffCoefficient = 10;
            retryOptions.MaxRetryInterval   = TimeSpan.FromSeconds(5);

            var retryTask = new RetryTask(2);

            await this.taskHub.AddTaskOrchestrations(new TestObjectCreator <TaskOrchestration>(RetryName, RetryVersion,
                                                                                               () => new RetryOrchestration(retryOptions)))
            .AddTaskActivitiesFromInterface <IRetryTask>(retryTask)
            .StartAsync();

            RetryOrchestration.Result = null;
            OrchestrationInstance id = await this.client.CreateOrchestrationInstanceAsync(RetryName, RetryVersion, false);

            bool isCompleted = await TestHelpers.WaitForInstanceAsync(this.client, id, 90);

            Assert.IsNotNull(RetryOrchestration.Result);
            Assert.IsTrue(isCompleted, TestHelpers.GetInstanceNotCompletedMessage(this.client, id, 90));
            Assert.AreEqual("DoWork Succeeded. Attempts: 2", RetryOrchestration.Result,
                            "Orchestration Result is wrong!!!");
            Assert.AreEqual(2, retryTask.RetryCount, "Retry Count is wrong");
        }
        public async Task BasicInstanceStoreTest()
        {
            await taskHub.AddTaskOrchestrations(typeof(InstanceStoreTestOrchestration))
            .AddTaskActivities(new Activity1())
            .StartAsync();

            OrchestrationInstance id = await client.CreateOrchestrationInstanceAsync(typeof(InstanceStoreTestOrchestration),
                                                                                     "DONT_THROW");

            bool isCompleted = await TestHelpers.WaitForInstanceAsync(client, id, 60);

            Assert.IsTrue(isCompleted, TestHelpers.GetInstanceNotCompletedMessage(client, id, 60));
            OrchestrationState runtimeState = await client.GetOrchestrationStateAsync(id);

            Assert.AreEqual(runtimeState.OrchestrationStatus, OrchestrationStatus.Completed);
            Assert.AreEqual(runtimeState.OrchestrationInstance.InstanceId, id.InstanceId);
            Assert.AreEqual(runtimeState.OrchestrationInstance.ExecutionId, id.ExecutionId);
            Assert.AreEqual("DurableTask.ServiceBus.Tests.OrchestrationHubTableClientTests+InstanceStoreTestOrchestration", runtimeState.Name);
            Assert.AreEqual(runtimeState.Version, string.Empty);
            Assert.AreEqual(runtimeState.Input, "\"DONT_THROW\"");
            Assert.AreEqual(runtimeState.Output, "\"Spartacus\"");

            string history = await client.GetOrchestrationHistoryAsync(id);

            Assert.IsTrue(!string.IsNullOrEmpty(history));
            Assert.IsTrue(history.Contains("ExecutionStartedEvent"));
        }
示例#9
0
        public async Task BasicSubOrchestrationRetryTest()
        {
            var parentRetryOptions = new RetryOptions(TimeSpan.FromSeconds(3), 2)
            {
                BackoffCoefficient = 2.0,
                MaxRetryInterval   = TimeSpan.FromSeconds(4),
            };
            var retryOptions = new RetryOptions(TimeSpan.FromSeconds(3), 3);
            var retryTask    = new RetryTask(4);

            RetryOrchestration.RethrowException = true;

            await this.taskHub.AddTaskOrchestrations(new TestObjectCreator <TaskOrchestration>(RetryName, RetryVersion,
                                                                                               () => new RetryOrchestration(retryOptions)))
            .AddTaskOrchestrations(new TestObjectCreator <TaskOrchestration>(RetryParentName, RetryParentVersion,
                                                                             () => new ParentOrchestration(parentRetryOptions)))
            .AddTaskActivitiesFromInterface <IRetryTask>(retryTask)
            .StartAsync();

            ParentOrchestration.Result = null;
            RetryOrchestration.Result  = null;
            OrchestrationInstance id = await this.client.CreateOrchestrationInstanceAsync(RetryParentName, RetryParentVersion, false);

            bool isCompleted = await TestHelpers.WaitForInstanceAsync(this.client, id, 90);

            Assert.IsNotNull(RetryOrchestration.Result);
            Assert.IsTrue(isCompleted, TestHelpers.GetInstanceNotCompletedMessage(this.client, id, 90));
            Assert.AreEqual("DoWork Succeeded. Attempts: 4", ParentOrchestration.Result,
                            "Orchestration Result is wrong!!!");
        }
        public async Task IntermediateStateInstanceStoreTest()
        {
            await taskHub.AddTaskOrchestrations(typeof(InstanceStoreTestOrchestration))
            .AddTaskActivities(new Activity1())
            .StartAsync();

            OrchestrationInstance id = await client.CreateOrchestrationInstanceAsync(typeof(InstanceStoreTestOrchestration),
                                                                                     "WAIT");

            await TestHelpers.WaitForInstanceAsync(client, id, 60, false);

            OrchestrationState runtimeState = await client.GetOrchestrationStateAsync(id);

            Assert.IsNotNull(runtimeState);
            Assert.AreEqual(OrchestrationStatus.Pending, runtimeState.OrchestrationStatus);
            Assert.AreEqual(id.InstanceId, runtimeState.OrchestrationInstance.InstanceId);
            Assert.AreEqual(id.ExecutionId, runtimeState.OrchestrationInstance.ExecutionId);
            Assert.AreEqual("DurableTask.ServiceBus.Tests.OrchestrationHubTableClientTests+InstanceStoreTestOrchestration", runtimeState.Name);
            Assert.AreEqual(runtimeState.Version, string.Empty);
            Assert.AreEqual(runtimeState.Input, "\"WAIT\"");
            Assert.AreEqual(runtimeState.Output, null);

            bool isCompleted = await TestHelpers.WaitForInstanceAsync(client, id, 60);

            Assert.IsTrue(isCompleted, TestHelpers.GetInstanceNotCompletedMessage(client, id, 60));
            runtimeState = await client.GetOrchestrationStateAsync(id);

            Assert.AreEqual(runtimeState.OrchestrationStatus, OrchestrationStatus.Completed);
        }
示例#11
0
        public async Task SubOrchestrationFailedTest()
        {
            await taskHub.AddTaskOrchestrations(typeof(ParentWorkflow2), typeof(ChildWorkflow2))
            .StartAsync();

            taskHub.TaskOrchestrationDispatcher.IncludeDetails = true;

            ChildWorkflow2.Count   = 0;
            ParentWorkflow2.Result = null;
            OrchestrationInstance id = await client.CreateOrchestrationInstanceAsync(typeof(ParentWorkflow2), true);

            bool isCompleted = await TestHelpers.WaitForInstanceAsync(client, id, 60);

            Assert.IsTrue(isCompleted, TestHelpers.GetInstanceNotCompletedMessage(client, id, 60));

            Assert.AreEqual("Test", ParentWorkflow2.Result, "Orchestration Result is wrong!!!");
            Assert.AreEqual(1, ChildWorkflow2.Count, "Child Workflow Count invalid.");

            ChildWorkflow2.Count   = 0;
            ParentWorkflow2.Result = null;
            id = await client.CreateOrchestrationInstanceAsync(typeof(ParentWorkflow2), false);

            isCompleted = await TestHelpers.WaitForInstanceAsync(client, id, 60);

            Assert.IsTrue(isCompleted, TestHelpers.GetInstanceNotCompletedMessage(client, id, 60));
            Assert.AreEqual("Test", ParentWorkflow2.Result, "Orchestration Result is wrong!!!");
            Assert.AreEqual(5, ChildWorkflow2.Count, "Child Workflow Count invalid.");
        }
示例#12
0
        ////[TestMethod]
        // Disabled until bug https://github.com/Azure/durabletask/issues/47 is fixed
        // Also the test does not work as expected due to debug mode suppressing UnobservedTaskException's
        public async Task ParallelInterfaceExceptionsTest()
        {
            var failureClient = new FailureClient();
            var unobservedTaskExceptionThrown = false;

            TaskScheduler.UnobservedTaskException += (sender, eventArgs) =>
            {
                var    t       = (Task)sender;
                string message = $"id:{t.Id}; {sender.GetType()}; {t.AsyncState}; {t.Status}";
                Trace.TraceError($"UnobservedTaskException caught: {message}");

                eventArgs.SetObserved();
                unobservedTaskExceptionThrown = true;
            };

            await this.taskHub
            .AddTaskOrchestrations(typeof(FailureClientOrchestration))
            .AddTaskActivitiesFromInterface <IFailureClient>(failureClient)
            .StartAsync();

            ParentOrchestration.Result = null;
            RetryOrchestration.Result  = null;
            OrchestrationInstance id = await this.client.CreateOrchestrationInstanceAsync(typeof(FailureClientOrchestration), "test");

            bool isCompleted = await TestHelpers.WaitForInstanceAsync(this.client, id, 90);

            Assert.IsTrue(isCompleted, TestHelpers.GetInstanceNotCompletedMessage(this.client, id, 90));
            Assert.IsFalse(unobservedTaskExceptionThrown, "UnobservedTaskException should not be thrown");
        }
示例#13
0
        public async Task TagsSubOrchestrationTest()
        {
            var c1 = new NameValueObjectCreator <TaskOrchestration>("ParentWorkflow",
                                                                    "V1", typeof(ParentWorkflow));

            var c2 = new NameValueObjectCreator <TaskOrchestration>("ChildWorkflow",
                                                                    "V1", typeof(ChildWorkflow));

            await taskHub.AddTaskOrchestrations(c1, c2)
            .StartAsync();

            OrchestrationInstance instance = await client.CreateOrchestrationInstanceAsync(
                "ParentWorkflow",
                "V1",
                "TestInstance",
                true,
                new Dictionary <string, string>(2) {
                { ParentWorkflow.ParentTagName, ParentWorkflow.ParentTagValue },
                { ParentWorkflow.SharedTagName, ParentWorkflow.ParentTagValue }
            });

            OrchestrationState state = await client.WaitForOrchestrationAsync(instance, TimeSpan.FromMinutes(1), CancellationToken.None);

            bool isCompleted = (state?.OrchestrationStatus == OrchestrationStatus.Completed);

            Assert.IsTrue(isCompleted, TestHelpers.GetInstanceNotCompletedMessage(client, instance, 60));
            Assert.AreEqual("Child completed.", ParentWorkflow.Result, "Orchestration Result is wrong!!!");

            IDictionary <string, string> returnedTags = state.Tags;
            string returnedValue;

            // Check for parent tag untouched
            Assert.IsTrue(returnedTags.TryGetValue(ParentWorkflow.ParentTagName, out returnedValue));
            Assert.AreEqual(ParentWorkflow.ParentTagValue, returnedValue);
            // Check for shared tag on parent with parent value
            Assert.IsTrue(returnedTags.TryGetValue(ParentWorkflow.SharedTagName, out returnedValue));
            Assert.AreEqual(ParentWorkflow.ParentTagValue, returnedValue);

            // Get child state and check completion
            OrchestrationState childState = await client.GetOrchestrationStateAsync(ParentWorkflow.ChildWorkflowId);

            isCompleted = (childState?.OrchestrationStatus == OrchestrationStatus.Completed);
            Assert.IsTrue(isCompleted, TestHelpers.GetInstanceNotCompletedMessage(client, instance, 60));

            returnedTags = childState.Tags;
            // Check for parent tag untouched
            Assert.IsTrue(returnedTags.TryGetValue(ParentWorkflow.ParentTagName, out returnedValue));
            Assert.AreEqual(ParentWorkflow.ParentTagValue, returnedValue);
            // Check for shared tag on with child value
            Assert.IsTrue(returnedTags.TryGetValue(ParentWorkflow.SharedTagName, out returnedValue));
            Assert.AreEqual(ParentWorkflow.ChildTagValue, returnedValue);
            // Check for child tag
            Assert.IsTrue(returnedTags.TryGetValue(ParentWorkflow.ChildTagName, out returnedValue));
            Assert.AreEqual(ParentWorkflow.ChildTagValue, returnedValue);
        }
示例#14
0
        public async Task BadOrchestrationTest()
        {
            await taskHub.AddTaskOrchestrations(typeof(BadOrchestration))
            .StartAsync();

            OrchestrationInstance id = await client.CreateOrchestrationInstanceAsync(typeof(BadOrchestration), null);

            bool isCompleted = await TestHelpers.WaitForInstanceAsync(client, id, 60);

            Assert.IsTrue(isCompleted, TestHelpers.GetInstanceNotCompletedMessage(client, id, 60));
        }
示例#15
0
        public async Task GreetingsTest()
        {
            await taskHub.AddTaskOrchestrations(typeof(GreetingsOrchestration))
            .AddTaskActivities(typeof(GetUserTask), typeof(SendGreetingTask))
            .StartAsync();

            OrchestrationInstance id = await client.CreateOrchestrationInstanceAsync(typeof(GreetingsOrchestration), null);

            bool isCompleted = await TestHelpers.WaitForInstanceAsync(client, id, 60);

            Assert.IsTrue(isCompleted, TestHelpers.GetInstanceNotCompletedMessage(client, id, 60));
            Assert.AreEqual("Greeting send to Gabbar", GreetingsOrchestration.Result, "Orchestration Result is wrong!!!");
        }
示例#16
0
        public async Task GenericInterfaceMethodTests()
        {
            await this.taskHub.AddTaskOrchestrations(typeof(GenericMethodInterfaceOrchestration))
            .AddTaskActivitiesFromInterface <IGenericMethodInterface>(new GenericMethodImplementation())
            .StartAsync();

            OrchestrationInstance id = await this.client.CreateOrchestrationInstanceAsync(typeof(GenericMethodInterfaceOrchestration),
                                                                                          new GenericInterfaceOrchestrationInput { Property = 3.142f });

            bool isCompleted = await TestHelpers.WaitForInstanceAsync(this.client, id, 60);

            Assert.IsTrue(isCompleted, TestHelpers.GetInstanceNotCompletedMessage(this.client, id, 60));
        }
示例#17
0
        public async Task SubOrchestrationExplicitIdTest()
        {
            SimpleChildWorkflow.ChildInstanceId = null;
            await taskHub.AddTaskOrchestrations(typeof(SimpleParentWorkflow), typeof(SimpleChildWorkflow))
            .StartAsync();

            OrchestrationInstance id = await client.CreateOrchestrationInstanceAsync(typeof(SimpleParentWorkflow), null);

            bool isCompleted = await TestHelpers.WaitForInstanceAsync(client, id, 60);

            Assert.IsTrue(isCompleted, TestHelpers.GetInstanceNotCompletedMessage(client, id, 60));
            Assert.AreEqual("foo_instance", SimpleChildWorkflow.ChildInstanceId);
        }
示例#18
0
        public async Task MaxMessagesLimitTest()
        {
            await this.taskHub.AddTaskOrchestrations(typeof(MaxMessagesLimitOrchestration))
            .AddTaskActivities(new MaxMessagesLimitTask())
            .StartAsync();

            OrchestrationInstance id = await this.client.CreateOrchestrationInstanceAsync(typeof(MaxMessagesLimitOrchestration), null);

            bool isCompleted = await TestHelpers.WaitForInstanceAsync(this.client, id, 120);

            Assert.IsTrue(isCompleted, TestHelpers.GetInstanceNotCompletedMessage(this.client, id, 120));

            Assert.AreEqual(19900, MaxMessagesLimitOrchestration.Result, "Orchestration Result is wrong!!!");
        }
示例#19
0
        public async Task EventConversation()
        {
            await this.taskHub
            .AddTaskOrchestrations(typeof(Test.Orchestrations.EventConversationOrchestration),
                                   typeof(Test.Orchestrations.EventConversationOrchestration.Responder))
            .StartAsync();

            OrchestrationInstance id = await this.client.CreateOrchestrationInstanceAsync(typeof(Test.Orchestrations.EventConversationOrchestration), "false");

            bool isCompleted = await TestHelpers.WaitForInstanceAsync(this.client, id, 60);

            Assert.IsTrue(isCompleted, TestHelpers.GetInstanceNotCompletedMessage(this.client, id, 60));
            Assert.IsTrue(Test.Orchestrations.EventConversationOrchestration.OkResult, "Orchestration did not finish ok!!!");
        }
示例#20
0
        public async Task MessageOverflowTest()
        {
            await taskHub.AddTaskOrchestrations(typeof(LargeInputOutputOrchestration)).StartAsync();

            // generate a large string as the orchestration input;
            // make it random so that it won't be compressed too much.
            var largeInput           = TestUtils.GenerateRandomString(1000 * 1024);
            OrchestrationInstance id = await client.CreateOrchestrationInstanceAsync(typeof(LargeInputOutputOrchestration), largeInput);

            bool isCompleted = await TestHelpers.WaitForInstanceAsync(client, id, 60);

            Assert.IsTrue(isCompleted, TestHelpers.GetInstanceNotCompletedMessage(client, id, 60));
            Assert.AreEqual($"output-{largeInput}", LargeInputOutputOrchestration.Result, "Orchestration Result is wrong!!!");
        }
示例#21
0
        public async Task AverageCalculatorTest()
        {
            await taskHub.AddTaskOrchestrations(typeof(AverageCalculatorOrchestration))
            .AddTaskActivities(typeof(ComputeSumTask))
            .StartAsync();

            OrchestrationInstance id = await client.CreateOrchestrationInstanceAsync(
                typeof(AverageCalculatorOrchestration),
                new[] { 1, 50, 10 });

            bool isCompleted = await TestHelpers.WaitForInstanceAsync(client, id, 60);

            Assert.IsTrue(isCompleted, TestHelpers.GetInstanceNotCompletedMessage(client, id, 60));
            Assert.AreEqual(25, AverageCalculatorOrchestration.Result, "Orchestration Result is wrong!!!");
        }
示例#22
0
        public async Task AverageCalculatorDynamicProxyTest()
        {
            await taskHub.AddTaskOrchestrations(typeof(AverageCalculatorOrchestration))
            .AddTaskActivities(new NameValueObjectCreator <TaskActivity>(COMPUTE_SUM_NAME, COMPUTE_SUM_VERSION,
                                                                         new ComputeSumTask()))
            .StartAsync();

            OrchestrationInstance id = await client.CreateOrchestrationInstanceAsync(typeof(AverageCalculatorOrchestration),
                                                                                     new[] { 1, 50, 10 });

            bool isCompleted = await TestHelpers.WaitForInstanceAsync(client, id, 60);

            Assert.IsTrue(isCompleted, TestHelpers.GetInstanceNotCompletedMessage(client, id, 60));
            Assert.AreEqual(25, AverageCalculatorOrchestration.Result, "Orchestration Result is wrong!!!");
        }
        public async Task MoreParamsOrchestrationTest()
        {
            await this.taskHub.AddTaskOrchestrations(typeof(MoreParamsOrchestration))
            .AddTaskActivitiesFromInterface <IMoreParamsActivities>(new MoreParamsActivities())
            .StartAsync();

            OrchestrationInstance id = await this.client.CreateOrchestrationInstanceAsync(typeof(MoreParamsOrchestration),
                                                                                          new MoreParamsOrchestrationInput { Str = "Hello" });

            bool isCompleted = await TestHelpers.WaitForInstanceAsync(this.client, id, 60);

            Assert.IsTrue(isCompleted, TestHelpers.GetInstanceNotCompletedMessage(this.client, id, 60));

            Assert.AreEqual("Hello00Hello1015", MoreParamsOrchestration.Result);
        }
示例#24
0
        public async Task GenerationSignalOrchestrationTest()
        {
            await taskHub.AddTaskOrchestrations(typeof(GenerationSignalOrchestration))
            .StartAsync();

            OrchestrationInstance id = await client.CreateOrchestrationInstanceAsync(typeof(GenerationSignalOrchestration), 5);

            var signalId = new OrchestrationInstance {
                InstanceId = id.InstanceId
            };

            await Task.Delay(2 *1000);

            await client.RaiseEventAsync(signalId, "Count", "1");

            GenerationSignalOrchestration.signal.Set();

            await Task.Delay(2 *1000);

            GenerationSignalOrchestration.signal.Reset();
            await client.RaiseEventAsync(signalId, "Count", "2");

            await Task.Delay(2 *1000);

            await client.RaiseEventAsync(signalId, "Count", "3"); // will be recieved by next generation

            GenerationSignalOrchestration.signal.Set();

            await Task.Delay(2 *1000);

            GenerationSignalOrchestration.signal.Reset();
            await client.RaiseEventAsync(signalId, "Count", "4");

            await Task.Delay(2 *1000);

            await client.RaiseEventAsync(signalId, "Count", "5"); // will be recieved by next generation

            await client.RaiseEventAsync(signalId, "Count", "6"); // lost

            await client.RaiseEventAsync(signalId, "Count", "7"); // lost

            GenerationSignalOrchestration.signal.Set();

            bool isCompleted = await TestHelpers.WaitForInstanceAsync(client, signalId, 60);

            Assert.IsTrue(isCompleted, TestHelpers.GetInstanceNotCompletedMessage(client, id, 60));
            Assert.AreEqual("5", GenerationSignalOrchestration.Result, "Orchestration Result is wrong!!!");
        }
        public async Task FailingInstanceStoreTest()
        {
            await taskHub.AddTaskOrchestrations(typeof(InstanceStoreTestOrchestration))
            .AddTaskActivities(new Activity1())
            .StartAsync();

            OrchestrationInstance id = await client.CreateOrchestrationInstanceAsync(typeof(InstanceStoreTestOrchestration),
                                                                                     "THROW");

            bool isCompleted = await TestHelpers.WaitForInstanceAsync(client, id, 60);

            Assert.IsTrue(isCompleted, TestHelpers.GetInstanceNotCompletedMessage(client, id, 60));
            var status = await client.GetOrchestrationStateAsync(id);

            Assert.IsTrue(status.OrchestrationStatus == OrchestrationStatus.Failed);
        }
示例#26
0
        public async Task GenerationBasicTest()
        {
            GenerationBasicOrchestration.Result = 0;
            GenerationBasicTask.GenerationCount = 0;

            await taskHub.AddTaskOrchestrations(typeof(GenerationBasicOrchestration))
            .AddTaskActivities(new GenerationBasicTask())
            .StartAsync();

            OrchestrationInstance id = await client.CreateOrchestrationInstanceAsync(typeof(GenerationBasicOrchestration), 4);

            bool isCompleted = await TestHelpers.WaitForInstanceAsync(client, id, 60);

            Assert.IsTrue(isCompleted, TestHelpers.GetInstanceNotCompletedMessage(client, id, 60));
            Assert.AreEqual(4, GenerationBasicOrchestration.Result, "Orchestration Result is wrong!!!");
        }
示例#27
0
        public async Task GreetingsDynamicProxyTest()
        {
            await taskHub.AddTaskOrchestrations(typeof(GreetingsOrchestration))
            .AddTaskActivities(
                new NameValueObjectCreator <TaskActivity>(GET_USER_NAME, GET_USER_VERSION, new GetUserTask()),
                new NameValueObjectCreator <TaskActivity>(SEND_GREETING_NAME, SEND_GREETING_VERSION,
                                                          new SendGreetingTask()))
            .StartAsync();

            OrchestrationInstance id = await client.CreateOrchestrationInstanceAsync(typeof(GreetingsOrchestration), null);

            bool isCompleted = await TestHelpers.WaitForInstanceAsync(client, id, 60);

            Assert.IsTrue(isCompleted, TestHelpers.GetInstanceNotCompletedMessage(client, id, 60));
            Assert.AreEqual("Greeting send to Gabbar", GreetingsOrchestration.Result, "Orchestration Result is wrong!!!");
        }
示例#28
0
        public async Task ErrorHandlingTest()
        {
            await taskHub.AddTaskOrchestrations(typeof(ErrorHandlingOrchestration))
            .AddTaskActivities(typeof(GoodTask), typeof(BadTask), typeof(CleanupTask))
            .StartAsync();

            taskHub.TaskActivityDispatcher.IncludeDetails = true;

            OrchestrationInstance id = await client.CreateOrchestrationInstanceAsync(typeof(ErrorHandlingOrchestration), null);

            bool isCompleted = await TestHelpers.WaitForInstanceAsync(client, id, 60);

            Assert.IsTrue(isCompleted, TestHelpers.GetInstanceNotCompletedMessage(client, id, 60));
            Assert.AreEqual("CleanupResult", ErrorHandlingOrchestration.Result,
                            "Orchestration Result is wrong!!!");
        }
示例#29
0
        public async Task SubOrchestrationRetryExhaustedTest()
        {
            ArgumentException argumentException = null;

            try
            {
                // ReSharper disable once ObjectCreationAsStatement
                new RetryOptions(TimeSpan.Zero, 10);
            }
            catch (ArgumentException ex)
            {
                argumentException = ex;
            }

            Assert.IsNotNull(argumentException);
            Assert.AreEqual(
                "Invalid interval.  Specify a TimeSpan value greater then TimeSpan.Zero.\r\nParameter name: firstRetryInterval",
                argumentException.Message);

            var parentRetryOptions = new RetryOptions(TimeSpan.FromSeconds(3), 2)
            {
                BackoffCoefficient = 2.0,
                MaxRetryInterval   = TimeSpan.FromSeconds(4),
            };
            var retryOptions = new RetryOptions(TimeSpan.FromSeconds(3), 2);
            var retryTask    = new RetryTask(4);

            RetryOrchestration.RethrowException = true;

            await this.taskHub.AddTaskOrchestrations(new TestObjectCreator <TaskOrchestration>(RetryName, RetryVersion,
                                                                                               () => new RetryOrchestration(retryOptions)))
            .AddTaskOrchestrations(new TestObjectCreator <TaskOrchestration>(RetryParentName, RetryParentVersion,
                                                                             () => new ParentOrchestration(parentRetryOptions)))
            .AddTaskActivitiesFromInterface <IRetryTask>(retryTask)
            .StartAsync();

            ParentOrchestration.Result = null;
            RetryOrchestration.Result  = null;
            OrchestrationInstance id = await this.client.CreateOrchestrationInstanceAsync(RetryParentName, RetryParentVersion, false);

            bool isCompleted = await TestHelpers.WaitForInstanceAsync(this.client, id, 90);

            Assert.IsTrue(isCompleted, TestHelpers.GetInstanceNotCompletedMessage(this.client, id, 90));
            Assert.AreEqual("DoWork Failed. RetryCount is: 4", ParentOrchestration.Result,
                            "Orchestration Result is wrong!!!");
        }
        public async Task SimplestGreetingsJumpStartDelayTest()
        {
            var    sbService = (ServiceBusOrchestrationService)taskHub.orchestrationService;
            string name      = NameVersionHelper.GetDefaultName(typeof(SimplestGreetingsOrchestration));
            string version   = NameVersionHelper.GetDefaultVersion(typeof(SimplestGreetingsOrchestration));

            await taskHub.AddTaskOrchestrations(typeof(SimplestGreetingsOrchestration))
            .AddTaskActivities(typeof(SimplestGetUserTask), typeof(SimplestSendGreetingTask))
            .StartAsync();

            OrchestrationInstance id = await TestHelpers.CreateOrchestrationInstanceAsync(sbService, name, version, null, null, true, false);

            // Wait only 8 seconds, the jumptstartinterval is set to 10
            bool isCompleted = await TestHelpers.WaitForInstanceAsync(client, id, 8);

            Assert.IsFalse(isCompleted, TestHelpers.GetInstanceNotCompletedMessage(client, id, 8));
        }