public async Task WaitForOrchestration_Returns_State_When_Orchestration_Already_Finished() { var input = new TestOrchestrationData() { NumberOfParallelTasks = 0, NumberOfSerialTasks = 1, MaxDelay = 0, MinDelay = 0, DelayUnit = TimeSpan.FromMilliseconds(1), UseTimeoutTask = false, }; var instance = await this.taskHubClient.CreateOrchestrationInstanceAsync(typeof(TestOrchestration), input); await this.taskHubClient.WaitForOrchestrationAsync(instance, TimeSpan.FromMinutes(1)); //Wait till orchestration is finished var waitTime = TimeSpan.FromMilliseconds(100); //Let this be very low for the test to be effective. OrchestrationState result = null; var time = await Utilities.MeasureAsync(async() => { result = await this.taskHubClient.WaitForOrchestrationAsync(instance, waitTime); }); Assert.IsNotNull(result); Assert.AreEqual(OrchestrationStatus.Completed, result.OrchestrationStatus); Assert.IsTrue(time < waitTime); Console.WriteLine($"Full WaitTime : {waitTime}, Actual time taken for Wait {time}, Actual Time taken for Orchestration : {result.CompletedTime - result.CreatedTime}"); }
public async Task WaitForOrchestration_Waits_And_Returns_State_When_Orchestration_IsRunning() { var waitTime = TimeSpan.FromMinutes(1); var orchestrationTimeInSeconds = 5; var input = new TestOrchestrationData() { NumberOfParallelTasks = 0, NumberOfSerialTasks = 1, MaxDelay = orchestrationTimeInSeconds, MinDelay = orchestrationTimeInSeconds, DelayUnit = TimeSpan.FromSeconds(1), UseTimeoutTask = false, }; var instance = await this.taskHubClient.CreateOrchestrationInstanceAsync(typeof(TestOrchestration), input); OrchestrationState result = null; var time = await Utilities.MeasureAsync(async() => { result = await this.taskHubClient.WaitForOrchestrationAsync(instance, waitTime); }); Assert.IsNotNull(result); Assert.AreEqual(OrchestrationStatus.Completed, result.OrchestrationStatus); Assert.IsTrue(time < waitTime); Assert.IsTrue(time > TimeSpan.FromSeconds(orchestrationTimeInSeconds)); Console.WriteLine($"Full WaitTime : {waitTime}, Actual time taken for Wait : {time}, Expected Minimum time for orchestration : {orchestrationTimeInSeconds} seconds, Actual Time taken for Orchestration : {result.CompletedTime - result.CreatedTime}"); }
public async Task WaitForOrchestration_Returns_Null_When_Orchestration_Not_Started() { var instance = new OrchestrationInstance() { InstanceId = "NonExisting", ExecutionId = "NonExisting" }; OrchestrationState result = null; var waitTime = TimeSpan.FromMinutes(1); var time = await Utilities.MeasureAsync(async() => { result = await this.taskHubClient.WaitForOrchestrationAsync(instance, waitTime); }); Assert.IsNull(result); Assert.IsTrue(time < waitTime + waitTime); Console.WriteLine($"Full WaitTime : {waitTime}, Actual time taken for Wait {time}"); }