Adding in new test for parallel raise events in workflow (#1155) (#1157)

* Adding in new test for parallel raise events in workflow

Signed-off-by: Ryan Lettieri <ryanLettieri@microsoft.com>
Signed-off-by: Hal Spang <halspang@microsoft.com>
Co-authored-by: Ryan Lettieri <67934986+RyanLettieri@users.noreply.github.com>
This commit is contained in:
halspang 2023-10-06 13:13:02 -07:00 committed by GitHub
parent 99d874a2b1
commit b0992c306b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 2 deletions

View File

@ -70,6 +70,11 @@ namespace Dapr.E2E.Test
var itemToPurchase = input;
// There are 5 of the same event to test that multiple similarly-named events can be raised in parallel
await context.WaitForExternalEventAsync<string>("ChangePurchaseItem");
await context.WaitForExternalEventAsync<string>("ChangePurchaseItem");
await context.WaitForExternalEventAsync<string>("ChangePurchaseItem");
await context.WaitForExternalEventAsync<string>("ChangePurchaseItem");
itemToPurchase = await context.WaitForExternalEventAsync<string>("ChangePurchaseItem");
// In real life there are other steps related to placing an order, like reserving

View File

@ -93,8 +93,16 @@ namespace Dapr.E2E.Test
input: input,
workflowOptions: workflowOptions);
// RAISE EVENT TEST
await daprClient.RaiseWorkflowEventAsync(instanceId2, workflowComponent, "ChangePurchaseItem", "computers");
// PARALLEL RAISE EVENT TEST
var event1 = daprClient.RaiseWorkflowEventAsync(instanceId2, workflowComponent, "ChangePurchaseItem", "computers");
var event2 = daprClient.RaiseWorkflowEventAsync(instanceId2, workflowComponent, "ChangePurchaseItem", "computers");
var event3 = daprClient.RaiseWorkflowEventAsync(instanceId2, workflowComponent, "ChangePurchaseItem", "computers");
var event4 = daprClient.RaiseWorkflowEventAsync(instanceId2, workflowComponent, "ChangePurchaseItem", "computers");
var event5 = daprClient.RaiseWorkflowEventAsync(instanceId2, workflowComponent, "ChangePurchaseItem", "computers");
var externalEvents = Task.WhenAll(event1, event2, event3, event4, event5);
var winner = await Task.WhenAny(externalEvents, Task.Delay(TimeSpan.FromSeconds(30)));
externalEvents.IsCompletedSuccessfully.Should().BeTrue($"Unsuccessful at raising events. Status of events: {externalEvents.IsCompletedSuccessfully}");
// Wait up to 30 seconds for the workflow to complete and check the output
using var cts = new CancellationTokenSource(delay: TimeSpan.FromSeconds(30));