mirror of https://github.com/dapr/dotnet-sdk.git
* 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:
parent
99d874a2b1
commit
b0992c306b
|
@ -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
|
||||
|
|
|
@ -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));
|
||||
|
|
Loading…
Reference in New Issue