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

[Internal] Pipelines: Fixes FaultInjection Release Pipelines #4913

Merged
Show file tree
Hide file tree
Changes from 7 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
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ namespace Microsoft.Azure.Cosmos.FaultInjection.Tests
using Microsoft.Azure.Cosmos.Routing;
using Microsoft.Azure.Documents;
using static Microsoft.Azure.Cosmos.FaultInjection.Tests.Utils.TestCommon;
using ConsistencyLevel = ConsistencyLevel;
using CosmosSystemTextJsonSerializer = Utils.TestCommon.CosmosSystemTextJsonSerializer;
using Database = Database;
using PartitionKey = PartitionKey;
Expand Down Expand Up @@ -69,7 +70,7 @@ public async Task Initialize()

CosmosClientOptions cosmosClientOptions = new CosmosClientOptions()
{
ConnectionMode = ConnectionMode.Gateway,
ConsistencyLevel = ConsistencyLevel.Session,
Serializer = this.serializer,
};

Expand Down Expand Up @@ -157,6 +158,7 @@ public async Task FaultInjectionServerErrorRule_OperationTypeTest(int operation)

CosmosClientOptions cosmosClientOptions = new CosmosClientOptions()
{
ConsistencyLevel = ConsistencyLevel.Session,
FaultInjector = faultInjector,
Serializer = this.serializer
};
Expand Down Expand Up @@ -330,6 +332,7 @@ public async Task FaultInjectionServerErrorRule_OperationTypeAddressTest(int ope

CosmosClientOptions cosmosClientOptions = new CosmosClientOptions()
{
ConsistencyLevel = ConsistencyLevel.Session,
ApplicationPreferredRegions = preferredRegions,
FaultInjector = faultInjector,
Serializer = this.serializer
Expand Down Expand Up @@ -454,6 +457,7 @@ public async Task FaultInjectionServerErrorRule_RegionTest()

CosmosClientOptions cosmosClientOptions = new CosmosClientOptions()
{
ConsistencyLevel = ConsistencyLevel.Session,
FaultInjector = faultInjector,
Serializer = this.serializer
};
Expand Down Expand Up @@ -555,6 +559,7 @@ public async Task FaultInjectionServerErrorRule_PartitionTest()

CosmosClientOptions cosmosClientOptions = new CosmosClientOptions()
{
ConsistencyLevel = ConsistencyLevel.Session,
FaultInjector = faultInjector,
Serializer = this.serializer,
MaxRetryAttemptsOnRateLimitedRequests = 0,
Expand Down Expand Up @@ -635,6 +640,7 @@ public async Task FaultInjectionServerErrorRule_ServerSendDelay()

CosmosClientOptions cosmosClientOptions = new CosmosClientOptions()
{
ConsistencyLevel = ConsistencyLevel.Session,
FaultInjector = faultInjector,
Serializer = this.serializer,
EnableContentResponseOnWrite = true,
Expand Down Expand Up @@ -727,6 +733,7 @@ public async Task FaultInjectionServerErrorRule_ServerResponseDelay()

CosmosClientOptions cosmosClientOptions = new CosmosClientOptions()
{
ConsistencyLevel = ConsistencyLevel.Session,
FaultInjector = faultInjector,
Serializer = this.serializer,
EnableContentResponseOnWrite = true,
Expand Down Expand Up @@ -821,6 +828,7 @@ public async Task FaultInjectionServerErrorRule_ServerTimeout()

CosmosClientOptions cosmosClientOptions = new CosmosClientOptions()
{
ConsistencyLevel = ConsistencyLevel.Session,
FaultInjector = faultInjector,
Serializer = this.serializer
};
Expand Down Expand Up @@ -904,6 +912,7 @@ public async Task FaultInjectionServerErrorRule_ConnecitonTimeout()

CosmosClientOptions cosmosClientOptions = new CosmosClientOptions()
{
ConsistencyLevel = ConsistencyLevel.Session,
FaultInjector = faultInjector,
Serializer = this.serializer,
EnableContentResponseOnWrite = true,
Expand Down Expand Up @@ -984,6 +993,7 @@ public async Task FaultInjectionServerErrorRule_ConnecitonDelay()

CosmosClientOptions cosmosClientOptions = new CosmosClientOptions()
{
ConsistencyLevel = ConsistencyLevel.Session,
FaultInjector = faultInjector,
Serializer = this.serializer,
EnableContentResponseOnWrite = true,
Expand Down Expand Up @@ -1091,6 +1101,7 @@ public async Task FaultInjectionServerErrorRule_ServerErrorResponseTest(

CosmosClientOptions cosmosClientOptions = new CosmosClientOptions()
{
ConsistencyLevel = ConsistencyLevel.Session,
FaultInjector = faultInjector,
Serializer = this.serializer,
};
Expand Down Expand Up @@ -1171,6 +1182,7 @@ public async Task FaultInjectionServerErrorRule_HitCountTest()

CosmosClientOptions cosmosClientOptions = new CosmosClientOptions()
{
ConsistencyLevel = ConsistencyLevel.Session,
FaultInjector = faultInjector,
Serializer = this.serializer
};
Expand Down Expand Up @@ -1266,6 +1278,7 @@ public async Task FaultInjectionServerErrorRule_IncludePrimaryTest()

CosmosClientOptions cosmosClientOptions = new CosmosClientOptions()
{
ConsistencyLevel = ConsistencyLevel.Session,
FaultInjector = faultInjector,
Serializer = this.serializer
};
Expand Down Expand Up @@ -1339,6 +1352,7 @@ public async Task FaultInjectionServerErrorRule_InjectionRateTest()

CosmosClientOptions cosmosClientOptions = new CosmosClientOptions()
{
ConsistencyLevel = ConsistencyLevel.Session,
FaultInjector = faultInjector,
Serializer = this.serializer
};
Expand Down Expand Up @@ -1424,6 +1438,7 @@ public async Task FaultInjectionConnectionErrorRule_Test()

CosmosClientOptions cosmosClientOptions = new CosmosClientOptions()
{
ConsistencyLevel = ConsistencyLevel.Session,
FaultInjector = faultInjector,
Serializer = this.serializer
};
Expand All @@ -1437,21 +1452,29 @@ public async Task FaultInjectionConnectionErrorRule_Test()
ChaosInterceptor interceptor = faultInjector.GetChaosInterceptor() as ChaosInterceptor;
Assert.IsNotNull(interceptor);

await this.PerformDocumentOperationAndCheckApplication(
this.fiContainer,
OperationType.Create,
createdItem,
connectionErrorRule,
0,
0);
try
{
await this.fiContainer.CreateItemAsync<FaultInjectionTestObject>(createdItem);
}
catch
{
//ignore
}

FaultInjectionDynamicChannelStore channelStore = interceptor.GetChannelStore();
Assert.IsTrue(channelStore.GetAllChannels().Count > 0);
List<Guid> channelGuids = channelStore.GetAllChannelIds();

await Task.Delay(TimeSpan.FromSeconds(2));
try
{
await Task.Delay(TimeSpan.FromSeconds(2));

await this.fiContainer.CreateItemAsync<FaultInjectionTestObject>(createdItem2);
await this.fiContainer.CreateItemAsync<FaultInjectionTestObject>(createdItem2);
}
catch
{
//ignore
}

Assert.IsTrue(connectionErrorRule.GetHitCount() >= 1);

Expand Down Expand Up @@ -1547,6 +1570,7 @@ public async Task FaultInjectionServerErrorRule_ReadFeedTest()

CosmosClientOptions cosmosClientOptions = new CosmosClientOptions()
{
ConsistencyLevel = ConsistencyLevel.Session,
FaultInjector = faultInjector,
Serializer = this.serializer
};
Expand Down Expand Up @@ -1832,6 +1856,7 @@ private void ValidateFaultInjectionRuleApplication(
FaultInjectionRule rule)
{
string diagnosticsString = diagnostics.ToString();
Console.WriteLine(diagnostics.ToString());
Assert.IsTrue(1 <= rule.GetHitCount());
Assert.IsTrue(1 <= diagnostics.GetFailedRequestCount());
Assert.IsTrue(diagnosticsString.Contains(statusCode.ToString()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ namespace Microsoft.Azure.Cosmos.FaultInjection.Tests
using Microsoft.Azure.Cosmos.Routing;
using Microsoft.Azure.Documents;
using static Microsoft.Azure.Cosmos.FaultInjection.Tests.Utils.TestCommon;
using ConsistencyLevel = ConsistencyLevel;
using CosmosSystemTextJsonSerializer = Utils.TestCommon.CosmosSystemTextJsonSerializer;
using Database = Database;
using PartitionKey = PartitionKey;
Expand Down Expand Up @@ -60,6 +61,7 @@ public async Task Initialize()

CosmosClientOptions cosmosClientOptions = new CosmosClientOptions()
{
ConsistencyLevel = ConsistencyLevel.Session,
ConnectionMode = ConnectionMode.Gateway,
Serializer = this.serializer,
};
Expand All @@ -79,8 +81,8 @@ public async Task Cleanup()
{
await this.highThroughputContainer.DeleteContainerAsync();
}
this.client.Dispose();
this.fiClient.Dispose();
this.client?.Dispose();
this.fiClient?.Dispose();
}

//<summary>
Expand Down Expand Up @@ -150,6 +152,7 @@ public async Task FIGatewayRegion()

CosmosClientOptions cosmosClientOptions = new CosmosClientOptions()
{
ConsistencyLevel = ConsistencyLevel.Session,
ConnectionMode = ConnectionMode.Gateway,
Serializer = this.serializer
};
Expand Down Expand Up @@ -182,6 +185,15 @@ public async Task FIGatewayRegion()
(int)HttpStatusCode.Gone,
localRegionRule);
}
catch (CosmosException ex)
{
this.ValidateHitCount(localRegionRule, 1);
this.ValidateHitCount(remoteRegionRule, 0);
this.ValidateFaultInjectionRuleApplication(
ex,
(int)HttpStatusCode.Gone,
localRegionRule);
}
}
finally
{
Expand Down Expand Up @@ -256,6 +268,7 @@ public async Task FIGatewayPartitionTest()

CosmosClientOptions cosmosClientOptions = new CosmosClientOptions()
{
ConsistencyLevel = ConsistencyLevel.Session,
ConnectionMode = ConnectionMode.Gateway,
Serializer = this.serializer,
MaxRetryAttemptsOnRateLimitedRequests = 0,
Expand Down Expand Up @@ -392,6 +405,7 @@ public async Task FIGatewayResponseDelay()

CosmosClientOptions cosmosClientOptions = new CosmosClientOptions()
{
ConsistencyLevel = ConsistencyLevel.Session,
ConnectionMode = ConnectionMode.Gateway,
Serializer = this.serializer,
EnableContentResponseOnWrite = true,
Expand Down Expand Up @@ -486,6 +500,7 @@ public async Task FIGatewaySendDelay()

CosmosClientOptions cosmosClientOptions = new CosmosClientOptions()
{
ConsistencyLevel = ConsistencyLevel.Session,
ConnectionMode = ConnectionMode.Gateway,
Serializer = this.serializer,
EnableContentResponseOnWrite = true,
Expand Down Expand Up @@ -557,13 +572,13 @@ public async Task FIGatewaySendDelay()
[DataRow(FaultInjectionOperationType.ReadItem, FaultInjectionServerErrorType.Timeout, (int)StatusCodes.RequestTimeout, (int)SubStatusCodes.Unknown, DisplayName = "Timeout")]
[DataRow(FaultInjectionOperationType.ReadItem, FaultInjectionServerErrorType.PartitionIsMigrating, (int)StatusCodes.Gone, (int)SubStatusCodes.CompletingPartitionMigration, DisplayName = "PartitionIsMigrating")]
[DataRow(FaultInjectionOperationType.ReadItem, FaultInjectionServerErrorType.PartitionIsSplitting, (int)StatusCodes.Gone, (int)SubStatusCodes.CompletingSplit, DisplayName = "PartitionIsSplitting")]
[DataRow(FaultInjectionOperationType.CreateItem, FaultInjectionServerErrorType.Gone, (int)StatusCodes.Gone, (int)SubStatusCodes.ServerGenerated410, DisplayName = "Gone")]
[DataRow(FaultInjectionOperationType.CreateItem, FaultInjectionServerErrorType.InternalServerError, (int)StatusCodes.InternalServerError, (int)SubStatusCodes.Unknown, DisplayName = "InternalServerError")]
[DataRow(FaultInjectionOperationType.CreateItem, FaultInjectionServerErrorType.TooManyRequests, (int)StatusCodes.TooManyRequests, (int)SubStatusCodes.RUBudgetExceeded, DisplayName = "TooManyRequests")]
[DataRow(FaultInjectionOperationType.CreateItem, FaultInjectionServerErrorType.ReadSessionNotAvailable, (int)SubStatusCodes.ReadSessionNotAvailable, DisplayName = "ReadSessionNotAvailable")]
[DataRow(FaultInjectionOperationType.CreateItem, FaultInjectionServerErrorType.Timeout, (int)StatusCodes.RequestTimeout, (int)SubStatusCodes.Unknown, DisplayName = "Timeout")]
[DataRow(FaultInjectionOperationType.CreateItem, FaultInjectionServerErrorType.PartitionIsMigrating, (int)StatusCodes.Gone, (int)SubStatusCodes.CompletingPartitionMigration, DisplayName = "PartitionIsMigrating")]
[DataRow(FaultInjectionOperationType.CreateItem, FaultInjectionServerErrorType.PartitionIsSplitting, (int)StatusCodes.Gone, (int)SubStatusCodes.CompletingSplit, DisplayName = "PartitionIsSplitting")]
[DataRow(FaultInjectionOperationType.CreateItem, FaultInjectionServerErrorType.Gone, (int)StatusCodes.Gone, (int)SubStatusCodes.ServerGenerated410, DisplayName = "Gone - write")]
[DataRow(FaultInjectionOperationType.CreateItem, FaultInjectionServerErrorType.InternalServerError, (int)StatusCodes.InternalServerError, (int)SubStatusCodes.Unknown, DisplayName = "InternalServerError - write")]
[DataRow(FaultInjectionOperationType.CreateItem, FaultInjectionServerErrorType.TooManyRequests, (int)StatusCodes.TooManyRequests, (int)SubStatusCodes.RUBudgetExceeded, DisplayName = "TooManyRequests - write")]
[DataRow(FaultInjectionOperationType.CreateItem, FaultInjectionServerErrorType.ReadSessionNotAvailable, (int)StatusCodes.NotFound, (int)SubStatusCodes.ReadSessionNotAvailable, DisplayName = "ReadSessionNotAvailable - write")]
[DataRow(FaultInjectionOperationType.CreateItem, FaultInjectionServerErrorType.Timeout, (int)StatusCodes.RequestTimeout, (int)SubStatusCodes.Unknown, DisplayName = "Timeout - write")]
[DataRow(FaultInjectionOperationType.CreateItem, FaultInjectionServerErrorType.PartitionIsMigrating, (int)StatusCodes.Gone, (int)SubStatusCodes.CompletingPartitionMigration, DisplayName = "PartitionIsMigrating - write")]
[DataRow(FaultInjectionOperationType.CreateItem, FaultInjectionServerErrorType.PartitionIsSplitting, (int)StatusCodes.Gone, (int)SubStatusCodes.CompletingSplit, DisplayName = "PartitionIsSplitting - write")]
public async Task FIGatewayServerResponse(
FaultInjectionOperationType faultInjectionOperationType,
FaultInjectionServerErrorType faultInjectionServerErrorType,
Expand Down Expand Up @@ -596,6 +611,7 @@ public async Task FIGatewayServerResponse(

CosmosClientOptions cosmosClientOptions = new CosmosClientOptions()
{
ConsistencyLevel = ConsistencyLevel.Session,
ConnectionMode = ConnectionMode.Gateway,
Serializer = this.serializer,
MaxRetryAttemptsOnRateLimitedRequests = 0,
Expand Down Expand Up @@ -722,6 +738,7 @@ public async Task FIGatewayHitLimit()

CosmosClientOptions cosmosClientOptions = new CosmosClientOptions()
{
ConsistencyLevel = ConsistencyLevel.Session,
ConnectionMode = ConnectionMode.Gateway,
Serializer = this.serializer
};
Expand Down Expand Up @@ -756,6 +773,11 @@ public async Task FIGatewayHitLimit()
this.ValidateFaultInjectionRuleApplication(ex, (int)HttpStatusCode.Gone, hitCountRule);
this.ValidateHitCount(hitCountRule, i + 1);
}
catch (CosmosException ex)
{
this.ValidateFaultInjectionRuleApplication(ex, (int)HttpStatusCode.Gone, hitCountRule);
this.ValidateHitCount(hitCountRule, i + 1);
}
}
}
finally
Expand Down Expand Up @@ -798,6 +820,7 @@ public async Task FIGatewayInjectionRate()

CosmosClientOptions cosmosClientOptions = new CosmosClientOptions()
{
ConsistencyLevel = ConsistencyLevel.Session,
ConnectionMode = ConnectionMode.Gateway,
Serializer = this.serializer
};
Expand Down Expand Up @@ -867,6 +890,7 @@ public async Task FIOnlyGateway()

CosmosClientOptions cosmosClientOptions = new CosmosClientOptions()
{
ConsistencyLevel = ConsistencyLevel.Session,
ConnectionMode = ConnectionMode.Direct,
Serializer = this.serializer
};
Expand All @@ -893,6 +917,7 @@ public async Task FIOnlyGateway()
//Test on gateway mode client
cosmosClientOptions = new CosmosClientOptions()
{
ConsistencyLevel = ConsistencyLevel.Session,
ConnectionMode = ConnectionMode.Gateway,
Serializer = this.serializer
};
Expand Down
14 changes: 7 additions & 7 deletions azure-pipelines-faultinjection.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@ stages:
BuildConfiguration: '${{ variables.BuildConfiguration }}'
VmImage: '${{ variables.VmImage }}'

- template: templates/build-fault-injection-test.yml
parameters:
BuildConfiguration: '${{ variables.BuildConfiguration }}'
Arguments: '${{ variables.ReleaseArguments }}'
VmImage: '${{ variables.VmImage }}'
MultiRegionConnectionString: $(COSMOSDB_MULTI_REGION)
# - template: templates/build-fault-injection-test.yml
# parameters:
# BuildConfiguration: '${{ variables.BuildConfiguration }}'
# Arguments: '${{ variables.ReleaseArguments }}'
# VmImage: '${{ variables.VmImage }}'
# MultiRegionConnectionString: $(COSMOSDB_MULTI_REGION)

- job:
displayName: FaultInjection Integration Tests ${{ variables.BuildConfiguration }}
Expand Down Expand Up @@ -58,7 +58,7 @@ stages:
publishTestResults: true
testRunTitle: FaultInjectionTests
env:
COSMOSDB_ACCOUNT_CONNECTION_STRING: $(COSMOSDB_ACCOUNT_CONNECTION_STRING) # Real Account Connection String used by Integration Tests while running as part of release pipeline
COSMOSDB_MULTI_REGION: $(COSMOSDB_MULTI_REGION) # Real Account Connection String used by Integration Tests while running as part of release pipeline

- stage:
displayName: Publish
Expand Down
Loading
Loading