Skip to content

Commit 89ae08b

Browse files
author
David R. Williamson
authored
Last device leaks (#3152)
1 parent 397c66a commit 89ae08b

File tree

2 files changed

+11
-11
lines changed

2 files changed

+11
-11
lines changed

e2e/test/iothub/device/MethodE2ECustomPayloadTests.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -113,8 +113,8 @@ private async Task SendMethodAndRespondAsync(
113113
{
114114
await using TestDevice testDevice = await TestDevice.GetTestDeviceAsync(_devicePrefix).ConfigureAwait(false);
115115
var options = new IotHubClientOptions(transportSettings);
116-
await using var deviceClient = new IotHubDeviceClient(testDevice.ConnectionString, options);
117-
await TestDevice.OpenWithRetryAsync(deviceClient).ConfigureAwait(false);
116+
IotHubDeviceClient deviceClient = testDevice.CreateDeviceClient(options);
117+
await testDevice.OpenWithRetryAsync().ConfigureAwait(false);
118118

119119
Task methodReceivedTask = await setDeviceReceiveMethod(deviceClient, MethodName).ConfigureAwait(false);
120120
Task serviceSendTask = ServiceSendMethodAndVerifyResponseAsync(
@@ -136,7 +136,7 @@ public static async Task ServiceSendMethodAndVerifyResponseAsync<T>(
136136
TimeSpan responseTimeout = default,
137137
IotHubServiceClientOptions serviceClientTransportSettings = default)
138138
{
139-
var serviceClient = TestDevice.ServiceClient;
139+
IotHubServiceClient serviceClient = TestDevice.ServiceClient;
140140
TimeSpan methodTimeout = responseTimeout == default ? s_defaultMethodTimeoutMinutes : responseTimeout;
141141
VerboseTestLogger.WriteLine($"{nameof(ServiceSendMethodAndVerifyResponseAsync)}: Invoke method {methodName}.");
142142

e2e/test/provisioning/ProvisioningE2ETests.cs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -583,7 +583,7 @@ await ProvisioningDeviceClientInvalidGlobalAddressRegisterFailAsync(
583583

584584
#endregion InvalidGlobalAddress
585585

586-
public async Task ProvisioningDeviceClient_ValidRegistrationId_Register_Ok(
586+
private async Task ProvisioningDeviceClient_ValidRegistrationId_Register_Ok(
587587
IotHubClientTransportSettings transportSettings,
588588
AttestationMechanismType attestationType,
589589
EnrollmentType? enrollmentType,
@@ -605,7 +605,7 @@ await ProvisioningDeviceClientValidRegistrationIdRegisterOkAsync(
605605
.ConfigureAwait(false);
606606
}
607607

608-
public async Task ProvisioningDeviceClient_ValidRegistrationId_Register_Ok(
608+
private async Task ProvisioningDeviceClient_ValidRegistrationId_Register_Ok(
609609
IotHubClientTransportSettings transportSettings,
610610
AttestationMechanismType attestationType,
611611
EnrollmentType? enrollmentType,
@@ -694,7 +694,7 @@ private async Task ProvisioningDeviceClientValidRegistrationIdRegisterOkAsync(
694694
try
695695
{
696696
result = await provClient.RegisterAsync(cts.Token).ConfigureAwait(false);
697-
deviceId = result.DeviceId;
697+
deviceId = result.DeviceId;
698698
break;
699699
}
700700
// Catching all ProvisioningClientException as the status code is not the same for Mqtt, Amqp and Http.
@@ -722,17 +722,17 @@ private async Task ProvisioningDeviceClientValidRegistrationIdRegisterOkAsync(
722722
{
723723
VerboseTestLogger.WriteLine($"Deleting test enrollment type {attestationType}-{enrollmentType} with registration Id {auth.GetRegistrationId()}.");
724724
await DeleteCreatedEnrollmentAsync(enrollmentType, auth, groupId).ConfigureAwait(false);
725-
if (deviceId != null)
726-
{
727-
VerboseTestLogger.WriteLine($"Deleting device {deviceId}...");
728-
await TestDevice.ServiceClient.Devices.DeleteAsync(deviceId).ConfigureAwait(false);
729-
}
730725
}
731726
else
732727
{
733728
VerboseTestLogger.WriteLine($"The test enrollment type {attestationType}-{enrollmentType} with group Id {groupId} is currently hardcoded - do not delete.");
734729
}
735730

731+
if (deviceId != null)
732+
{
733+
await TestDevice.ServiceClient.Devices.DeleteAsync(deviceId).ConfigureAwait(false);
734+
}
735+
736736
if (authMethod is AuthenticationProviderX509 x509Auth)
737737
{
738738
X509Certificate2 deviceCertificate = x509Auth.ClientCertificate;

0 commit comments

Comments
 (0)