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

Add test for recovery after quota being exceeded #3050

Merged
merged 1 commit into from
Jan 4, 2023
Merged
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
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();
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/// <exception cref="ArgumentException"><paramref name="propertyKey"/> already exists in the collection.</exception>

Copy link
Member Author

@abhipsaMisra abhipsaMisra Jan 3, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Property key being added needs to always be unique. Force-add is no longer supported.

string propValue = Guid.NewGuid().ToString();
props[propName] = propValue;

Expand Down