From cb0eb713ba1e1f01d9196df94e4c0d0609ffae7f Mon Sep 17 00:00:00 2001 From: Azad Abbasi Date: Tue, 20 Jul 2021 11:11:18 -0700 Subject: [PATCH] Introduce delay in event route lifecycle test. --- .../Azure.DigitalTwins.Core/tests/E2eTestBase.cs | 12 ++++++++++++ .../Azure.DigitalTwins.Core/tests/EventRouteTests.cs | 5 +++++ 2 files changed, 17 insertions(+) diff --git a/sdk/digitaltwins/Azure.DigitalTwins.Core/tests/E2eTestBase.cs b/sdk/digitaltwins/Azure.DigitalTwins.Core/tests/E2eTestBase.cs index 9f662cb47c446..85b69e9b301aa 100644 --- a/sdk/digitaltwins/Azure.DigitalTwins.Core/tests/E2eTestBase.cs +++ b/sdk/digitaltwins/Azure.DigitalTwins.Core/tests/E2eTestBase.cs @@ -107,5 +107,17 @@ protected static async Task CreateAndListModelsAsync(DigitalTwinsClient client, Console.WriteLine($"{model.Id}"); } } + + /// + /// Injects delay in the process when the test mode is live. + /// + /// Delay duration. + protected async Task WaitIfLiveAsync(TimeSpan delayDuration) + { + if (TestEnvironment.Mode == RecordedTestMode.Live) + { + await Task.Delay(delayDuration); + } + } } } diff --git a/sdk/digitaltwins/Azure.DigitalTwins.Core/tests/EventRouteTests.cs b/sdk/digitaltwins/Azure.DigitalTwins.Core/tests/EventRouteTests.cs index 07d3b591a9474..977cd865ad992 100644 --- a/sdk/digitaltwins/Azure.DigitalTwins.Core/tests/EventRouteTests.cs +++ b/sdk/digitaltwins/Azure.DigitalTwins.Core/tests/EventRouteTests.cs @@ -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() @@ -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);