Skip to content
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
Adding in new test for parallel raise events in workflow (#1155)
* 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>
  • Loading branch information
RyanLettieri authored and halspang committed Oct 6, 2023
commit e4537e8d76a5fbbacc17370bb350c1f460a25925
5 changes: 5 additions & 0 deletions test/Dapr.E2E.Test.App/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,11 @@ public void ConfigureServices(IServiceCollection services)

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
Expand Down
12 changes: 10 additions & 2 deletions test/Dapr.E2E.Test/Workflows/WorkflowTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,16 @@ public async Task TestWorkflows()
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));
Expand Down