Ejemplo n.º 1
0
        public void ValidateTask_Throws_WhenActivityFunctionHasNoProperBinding(
            string bindingType, BindingInfo.Types.Direction bindingDirection)
        {
            var history = CreateHistory(scheduled: false, completed: false, output: InvocationResultJson);
            var orchestrationContext = new OrchestrationContext {
                History = history
            };

            var loadedFunctions = new[]
            {
                DurableTestUtilities.CreateFakeAzFunctionInfo(FunctionName, "fakeTriggerBindingName", bindingType, bindingDirection)
            };

            var durableTaskHandler = new DurableTaskHandler();

            var exception =
                Assert.Throws <InvalidOperationException>(
                    () => ActivityInvocationTask.ValidateTask(
                        new ActivityInvocationTask(FunctionName, FunctionInput), loadedFunctions));

            Assert.Contains(FunctionName, exception.Message);
            Assert.Contains(ActivityTriggerBindingType, exception.Message);

            DurableTestUtilities.VerifyNoActionAdded(orchestrationContext);
        }
Ejemplo n.º 2
0
        public void GetCompletedHistoryEvent_ReturnsTaskCompletedOrTaskFailed(bool succeeded)
        {
            var history = CreateHistory(scheduled: true, completed: succeeded, failed: !succeeded, output: InvocationResultJson);
            var orchestrationContext = new OrchestrationContext {
                History = history
            };

            var task           = new ActivityInvocationTask(FunctionName, FunctionInput);
            var scheduledEvent = task.GetScheduledHistoryEvent(orchestrationContext);
            var completedEvent = task.GetCompletedHistoryEvent(orchestrationContext, scheduledEvent);

            Assert.Equal(scheduledEvent.EventId, completedEvent.TaskScheduledId);
        }
Ejemplo n.º 3
0
        protected override void EndProcessing()
        {
            var privateData     = (Hashtable)MyInvocation.MyCommand.Module.PrivateData;
            var context         = (OrchestrationContext)privateData[SetFunctionInvocationContextCommand.ContextKey];
            var loadedFunctions = FunctionLoader.GetLoadedFunctions();

            var task = new ActivityInvocationTask(FunctionName, Input, RetryOptions);

            ActivityInvocationTask.ValidateTask(task, loadedFunctions);

            _durableTaskHandler.StopAndInitiateDurableTaskOrReplay(
                task, context, NoWait.IsPresent,
                output: WriteObject,
                onFailure: failureReason => DurableActivityErrorHandler.Handle(this, failureReason),
                retryOptions: RetryOptions);
        }
        public void WaitAny_OutputsEarliestCompletedTask_WhenAnyTaskCompleted(bool completed)
        {
            var history = DurableTestUtilities.MergeHistories(
                CreateOrchestratorStartedHistory(date: _startTime, isProcessed: true),
                CreateActivityHistory("FunctionA", scheduled: true, restartTime: _restartTime, completed: completed, output: "\"Result1\"", orchestratorStartedIsProcessed: false),
                CreateActivityHistory("FunctionA", scheduled: false, completed: false, output: "\"Result2\""),
                CreateDurableTimerHistory(timerCreated: true, timerFired: true, fireAt: _fireAt, restartTime: _restartTime, orchestratorStartedIsProcessed: false)
                );

            var orchestrationContext = new OrchestrationContext {
                History = history
            };
            var firedTimer        = new DurableTimerTask(_fireAt);
            var completedActivity = new ActivityInvocationTask("FunctionA", FunctionInput);
            var tasksToWaitFor    =
                new ReadOnlyCollection <DurableTask>(
                    new DurableTask[] {
                completedActivity,
                new ActivityInvocationTask("FunctionA", FunctionInput),
                firedTimer
            });

            var allOutput = new List <object>();

            var durableTaskHandler = new DurableTaskHandler();

            durableTaskHandler.WaitAny(tasksToWaitFor, orchestrationContext, output => { allOutput.Add(output); });

            if (completed)
            {
                Assert.Equal(new[] { completedActivity }, allOutput);
            }
            else
            {
                Assert.Equal(new[] { firedTimer }, allOutput);
            }
            VerifyNoOrchestrationActionAdded(orchestrationContext);
        }