Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ADT e2e fix: Introduce delay in event route lifecycle test. #22752

Merged
merged 1 commit into from
Jul 20, 2021
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
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