diff --git a/e2e/test/iothub/service/RegistryManagerE2ETests.cs b/e2e/test/iothub/service/RegistryManagerE2ETests.cs index e9533c2526..6a730651e5 100644 --- a/e2e/test/iothub/service/RegistryManagerE2ETests.cs +++ b/e2e/test/iothub/service/RegistryManagerE2ETests.cs @@ -392,44 +392,26 @@ public async Task RegistryManager_ConfigurationOperations_Work() public async Task RegistryManager_Query_Works() { // arrange + using var registryManager = RegistryManager.CreateFromConnectionString(TestConfiguration.IoTHub.ConnectionString); - string deviceId = $"{_idPrefix}{Guid.NewGuid()}"; + string deviceId = TestConfiguration.IoTHub.X509ChainDeviceName; - try - { - Device device = await registryManager - .AddDeviceAsync(new Device(deviceId)) - .ConfigureAwait(false); + Device device = await registryManager + .GetDeviceAsync(deviceId) + .ConfigureAwait(false); + device.Should().NotBeNull($"Device {deviceId} should already exist in hub setup for E2E tests"); - // act - - IQuery query = null; - IEnumerable twins = null; - for (int i = 0; i < 30; ++i) - { - string queryText = $"select * from devices where deviceId = '{deviceId}'"; - query = registryManager.CreateQuery(queryText); + // act - twins = await query.GetNextAsTwinAsync().ConfigureAwait(false); + string queryText = $"select * from devices where deviceId = '{deviceId}'"; + IQuery query = registryManager.CreateQuery(queryText); + IEnumerable twins = await query.GetNextAsTwinAsync().ConfigureAwait(false); - if (twins.Any()) - { - break; - } + // assert - // A new device may not return immediately from a query, so give it some time and some retries to appear - await Task.Delay(250).ConfigureAwait(false); - } - - // assert - twins.Count().Should().Be(1, "only asked for 1 device by its Id"); - twins.First().DeviceId.Should().Be(deviceId, "The Id of the device returned should match"); - query.HasMoreResults.Should().BeFalse("We've processed the single, expected result"); - } - finally - { - await registryManager.RemoveDeviceAsync(deviceId).ConfigureAwait(false); - } + twins.Count().Should().Be(1, "only asked for 1 device by its Id"); + twins.First().DeviceId.Should().Be(deviceId, "The Id of the device returned should match"); + query.HasMoreResults.Should().BeFalse("We've processed the single, expected result"); } [LoggedTestMethod] diff --git a/e2e/test/iothub/service/RegistryManagerImportDevicesTests.cs b/e2e/test/iothub/service/RegistryManagerImportDevicesTests.cs index 2ccc77d349..4a7f0ba1e6 100644 --- a/e2e/test/iothub/service/RegistryManagerImportDevicesTests.cs +++ b/e2e/test/iothub/service/RegistryManagerImportDevicesTests.cs @@ -43,6 +43,7 @@ public class RegistryManagerImportDevicesTests : E2EMsTestBase [DataRow(StorageAuthenticationType.KeyBased, false)] [DataRow(StorageAuthenticationType.IdentityBased, false)] [DataRow(StorageAuthenticationType.IdentityBased, true)] + [Ignore("Waiting on IcM 279379774 to be resolved, estimated early Jan 2022")] public async Task RegistryManager_ImportDevices(StorageAuthenticationType storageAuthenticationType, bool isUserAssignedMsi) { // arrange