Skip to content

Commit 132760c

Browse files
authored
Introduce delay in event route lifecycle test. (Azure#22752)
1 parent 5762543 commit 132760c

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

sdk/digitaltwins/Azure.DigitalTwins.Core/tests/E2eTestBase.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,5 +107,17 @@ protected static async Task CreateAndListModelsAsync(DigitalTwinsClient client,
107107
Console.WriteLine($"{model.Id}");
108108
}
109109
}
110+
111+
/// <summary>
112+
/// Injects delay in the process when the test mode is live.
113+
/// </summary>
114+
/// <param name="delayDuration">Delay duration.</param>
115+
protected async Task WaitIfLiveAsync(TimeSpan delayDuration)
116+
{
117+
if (TestEnvironment.Mode == RecordedTestMode.Live)
118+
{
119+
await Task.Delay(delayDuration);
120+
}
121+
}
110122
}
111123
}

sdk/digitaltwins/Azure.DigitalTwins.Core/tests/EventRouteTests.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ public EventRouteTests(bool isAsync)
2121

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

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

42+
// Wait certain amount of time to test if the issue is with propagation.
43+
// TODO: azabbasi: remove this logic once experiment is over.
44+
await WaitIfLiveAsync(_creationDelay);
45+
4146
// Test GetEventRoute
4247
DigitalTwinsEventRoute getEventRouteResult = await client.GetEventRouteAsync(eventRouteId);
4348
eventRoute.EndpointName.Should().Be(getEventRouteResult.EndpointName);

0 commit comments

Comments
 (0)