Skip to content

Commit

Permalink
Add test for recovery after quota being exceeded (#3050)
Browse files Browse the repository at this point in the history
  • Loading branch information
abhipsaMisra authored and schoims committed Jan 31, 2023
1 parent b3ff69b commit d8c2c67
Showing 1 changed file with 58 additions and 10 deletions.
68 changes: 58 additions & 10 deletions e2e/test/iothub/device/TwinFaultInjectionTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public class TwinFaultInjectionTests : E2EMsTestBase
[Timeout(TestTimeoutMilliseconds)]
public async Task Twin_DeviceReportedPropertiesTcpConnRecovery_Mqtt()
{
await Twin_DeviceReportedPropertiesRecovery(
await Twin_DeviceReportedPropertiesRecoveryAsync(
new IotHubClientMqttSettings(),
FaultInjectionConstants.FaultType_Tcp,
FaultInjectionConstants.FaultCloseReason_Boom)
Expand All @@ -38,7 +38,7 @@ await Twin_DeviceReportedPropertiesRecovery(
[TestCategory("FaultInjection")]
public async Task Twin_DeviceReportedPropertiesTcpConnRecovery_MqttWs()
{
await Twin_DeviceReportedPropertiesRecovery(
await Twin_DeviceReportedPropertiesRecoveryAsync(
new IotHubClientMqttSettings(IotHubClientTransportProtocol.WebSocket),
FaultInjectionConstants.FaultType_Tcp,
FaultInjectionConstants.FaultCloseReason_Boom)
Expand All @@ -52,7 +52,7 @@ await Twin_DeviceReportedPropertiesRecovery(
[Timeout(TestTimeoutMilliseconds)]
public async Task Twin_DeviceReportedPropertiesTcpConnRecovery_Amqp()
{
await Twin_DeviceReportedPropertiesRecovery(
await Twin_DeviceReportedPropertiesRecoveryAsync(
new IotHubClientAmqpSettings(),
FaultInjectionConstants.FaultType_Tcp,
FaultInjectionConstants.FaultCloseReason_Boom)
Expand All @@ -64,7 +64,7 @@ await Twin_DeviceReportedPropertiesRecovery(
[TestCategory("FaultInjection")]
public async Task Twin_DeviceReportedPropertiesTcpConnRecovery_AmqpWs()
{
await Twin_DeviceReportedPropertiesRecovery(
await Twin_DeviceReportedPropertiesRecoveryAsync(
new IotHubClientAmqpSettings(IotHubClientTransportProtocol.WebSocket),
FaultInjectionConstants.FaultType_Tcp,
FaultInjectionConstants.FaultCloseReason_Boom)
Expand All @@ -78,7 +78,7 @@ await Twin_DeviceReportedPropertiesRecovery(
[Timeout(TestTimeoutMilliseconds)]
public async Task Twin_DeviceReportedPropertiesGracefulShutdownRecovery_Mqtt()
{
await Twin_DeviceReportedPropertiesRecovery(
await Twin_DeviceReportedPropertiesRecoveryAsync(
new IotHubClientMqttSettings(),
FaultInjectionConstants.FaultType_GracefulShutdownMqtt,
FaultInjectionConstants.FaultCloseReason_Bye)
Expand All @@ -90,7 +90,7 @@ await Twin_DeviceReportedPropertiesRecovery(
[TestCategory("FaultInjection")]
public async Task Twin_DeviceReportedPropertiesGracefulShutdownRecovery_MqttWs()
{
await Twin_DeviceReportedPropertiesRecovery(
await Twin_DeviceReportedPropertiesRecoveryAsync(
new IotHubClientMqttSettings(IotHubClientTransportProtocol.WebSocket),
FaultInjectionConstants.FaultType_GracefulShutdownMqtt,
FaultInjectionConstants.FaultCloseReason_Bye)
Expand All @@ -104,7 +104,7 @@ await Twin_DeviceReportedPropertiesRecovery(
[Timeout(TestTimeoutMilliseconds)]
public async Task Twin_DeviceReportedPropertiesGracefulShutdownRecovery_Amqp()
{
await Twin_DeviceReportedPropertiesRecovery(
await Twin_DeviceReportedPropertiesRecoveryAsync(
new IotHubClientAmqpSettings(),
FaultInjectionConstants.FaultType_GracefulShutdownAmqp,
FaultInjectionConstants.FaultCloseReason_Bye)
Expand All @@ -116,7 +116,7 @@ await Twin_DeviceReportedPropertiesRecovery(
[TestCategory("FaultInjection")]
public async Task Twin_DeviceReportedPropertiesGracefulShutdownRecovery_AmqpWs()
{
await Twin_DeviceReportedPropertiesRecovery(
await Twin_DeviceReportedPropertiesRecoveryAsync(
new IotHubClientAmqpSettings(IotHubClientTransportProtocol.WebSocket),
FaultInjectionConstants.FaultType_GracefulShutdownAmqp,
FaultInjectionConstants.FaultCloseReason_Bye)
Expand Down Expand Up @@ -219,13 +219,60 @@ await Twin_DeviceDesiredPropertyUpdateRecoveryAsync(
.ConfigureAwait(false);
}

private async Task Twin_DeviceReportedPropertiesRecovery(
[TestMethod]
[Timeout(TestTimeoutMilliseconds)]
[DoNotParallelize]
public async Task Twin_DeviceDesiredPropertyUpdateQuotaExceededRecovery_Amqp()
{
await Twin_DeviceDesiredPropertyUpdateRecoveryAsync(
new IotHubClientAmqpSettings(IotHubClientTransportProtocol.Tcp),
FaultInjectionConstants.FaultType_QuotaExceeded,
FaultInjectionConstants.FaultCloseReason_Boom)
.ConfigureAwait(false);
}

[TestMethod]
[Timeout(TestTimeoutMilliseconds)]
[DoNotParallelize]
public async Task Twin_DeviceDesiredPropertyUpdateQuotaExceededRecovery_AmqpWs()
{
await Twin_DeviceDesiredPropertyUpdateRecoveryAsync(
new IotHubClientAmqpSettings(IotHubClientTransportProtocol.WebSocket),
FaultInjectionConstants.FaultType_QuotaExceeded,
FaultInjectionConstants.FaultCloseReason_Boom)
.ConfigureAwait(false);
}

[TestMethod]
[Timeout(TestTimeoutMilliseconds)]
[DoNotParallelize]
public async Task Twin_DeviceReportedPropertiesQuotaExceededRecovery_Amqp()
{
await Twin_DeviceReportedPropertiesRecoveryAsync(
new IotHubClientAmqpSettings(IotHubClientTransportProtocol.Tcp),
FaultInjectionConstants.FaultType_QuotaExceeded,
FaultInjectionConstants.FaultCloseReason_Boom)
.ConfigureAwait(false);
}

[TestMethod]
[Timeout(TestTimeoutMilliseconds)]
[DoNotParallelize]
public async Task Twin_DeviceReportedPropertiesQuotaExceededRecovery_AmqpWs()
{
await Twin_DeviceReportedPropertiesRecoveryAsync(
new IotHubClientAmqpSettings(IotHubClientTransportProtocol.WebSocket),
FaultInjectionConstants.FaultType_QuotaExceeded,
FaultInjectionConstants.FaultCloseReason_Boom)
.ConfigureAwait(false);
}

private async Task Twin_DeviceReportedPropertiesRecoveryAsync(
IotHubClientTransportSettings transportSettings,
string faultType,
string reason,
string proxyAddress = null)
{
string propName = Guid.NewGuid().ToString();
var props = new ReportedProperties();

async Task InitAsync(IotHubDeviceClient deviceClient, TestDevice testDevice)
Expand All @@ -235,6 +282,7 @@ async Task InitAsync(IotHubDeviceClient deviceClient, TestDevice testDevice)

async Task TestOperationAsync(IotHubDeviceClient deviceClient, TestDevice testDevice)
{
string propName = Guid.NewGuid().ToString();
string propValue = Guid.NewGuid().ToString();
props[propName] = propValue;

Expand Down

0 comments on commit d8c2c67

Please sign in to comment.