Skip to content

Commit

Permalink
Introduce delay in event route lifecycle test. (#22752)
Browse files Browse the repository at this point in the history
  • Loading branch information
azabbasi authored Jul 20, 2021
1 parent 5762543 commit 132760c
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
12 changes: 12 additions & 0 deletions sdk/digitaltwins/Azure.DigitalTwins.Core/tests/E2eTestBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -107,5 +107,17 @@ protected static async Task CreateAndListModelsAsync(DigitalTwinsClient client,
Console.WriteLine($"{model.Id}");
}
}

/// <summary>
/// Injects delay in the process when the test mode is live.
/// </summary>
/// <param name="delayDuration">Delay duration.</param>
protected async Task WaitIfLiveAsync(TimeSpan delayDuration)
{
if (TestEnvironment.Mode == RecordedTestMode.Live)
{
await Task.Delay(delayDuration);
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ public EventRouteTests(bool isAsync)

// Infrastructure setup script uses this hard-coded value when linking the test eventhub to the test digital twins instance
private const string EndpointName = "someEventHubEndpoint";
private readonly TimeSpan _creationDelay = TimeSpan.FromSeconds(10);

[Test]
public async Task EventRoutes_Lifecycle()
Expand All @@ -38,6 +39,10 @@ public async Task EventRoutes_Lifecycle()
Response createEventRouteResponse = await client.CreateOrReplaceEventRouteAsync(eventRouteId, eventRoute).ConfigureAwait(false);
createEventRouteResponse.Status.Should().Be((int)HttpStatusCode.NoContent);

// Wait certain amount of time to test if the issue is with propagation.
// TODO: azabbasi: remove this logic once experiment is over.
await WaitIfLiveAsync(_creationDelay);

// Test GetEventRoute
DigitalTwinsEventRoute getEventRouteResult = await client.GetEventRouteAsync(eventRouteId);
eventRoute.EndpointName.Should().Be(getEventRouteResult.EndpointName);
Expand Down

0 comments on commit 132760c

Please sign in to comment.