Skip to content

Patch regression in ExternalEvent History-search #857

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Sep 7, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/DurableSDK/Tasks/ExternalEventTask.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ internal override HistoryEvent GetCompletedHistoryEvent(OrchestrationContext con
return context.History.FirstOrDefault(
e => e.EventType == HistoryEventType.EventRaised &&
e.Name == ExternalEventName &&
e.IsPlayed == processed);
e.IsProcessed == processed);
}

internal override OrchestrationAction CreateOrchestrationAction()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,67 @@ public async Task OrchestratationContextHasAllExpectedProperties()
}
}


[Fact]
public async Task ComplexExternalEventReturnsData()
{
var initialResponse = await Utilities.GetHttpTriggerResponse("DurableClient", queryString: "?FunctionName=DurableOrchestratorComplexRaiseEvent");
Assert.Equal(HttpStatusCode.Accepted, initialResponse.StatusCode);

var initialResponseBody = await initialResponse.Content.ReadAsStringAsync();
dynamic initialResponseBodyObject = JsonConvert.DeserializeObject(initialResponseBody);
var statusQueryGetUri = (string)initialResponseBodyObject.statusQueryGetUri;
var raiseEventUri = (string)initialResponseBodyObject.sendEventPostUri;

raiseEventUri = raiseEventUri.Replace("{eventName}", "TESTEVENTNAME");

var startTime = DateTime.UtcNow;

using (var httpClient = new HttpClient())
{
while (true)
{
// Send external event payload
var json = JsonConvert.SerializeObject("helloWorld!");
var httpContent = new StringContent(json, Encoding.UTF8, "application/json");
await httpClient.PostAsync(raiseEventUri, httpContent);

var statusResponse = await httpClient.GetAsync(statusQueryGetUri);
switch (statusResponse.StatusCode)
{
case HttpStatusCode.Accepted:
{
var statusResponseBody = await GetResponseBodyAsync(statusResponse);
var runtimeStatus = (string)statusResponseBody.runtimeStatus;
Assert.True(
runtimeStatus == "Running" || runtimeStatus == "Pending",
$"Unexpected runtime status: {runtimeStatus}");

if (DateTime.UtcNow > startTime + _orchestrationCompletionTimeout)
{
Assert.True(false, $"The orchestration has not completed after {_orchestrationCompletionTimeout}");
}

await Task.Delay(TimeSpan.FromSeconds(2));
break;
}

case HttpStatusCode.OK:
{
var statusResponseBody = await GetResponseBodyAsync(statusResponse);
Assert.Equal("Completed", (string)statusResponseBody.runtimeStatus);
Assert.Contains("helloWorld!", statusResponseBody.output.ToString());
return;
}

default:
Assert.True(false, $"Unexpected orchestration status code: {statusResponse.StatusCode}");
break;
}
}
}
}

[Fact]
public async Task ExternalEventReturnsData()
{
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"bindings": [
{
"name": "Context",
"type": "orchestrationTrigger",
"direction": "in"
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
param($Context)

$output = @()

Invoke-DurableActivity -FunctionName "DurableActivity" -Input "Tokyo"
Invoke-DurableActivity -FunctionName "DurableActivity" -Input "Seattle"
$output += Start-DurableExternalEventListener -EventName "TESTEVENTNAME"
Invoke-DurableActivity -FunctionName "DurableActivity" -Input "London"

$output