Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Next Next commit
init commit
  • Loading branch information
NaluTripician committed Apr 3, 2025
commit 77ed0145fcfa741d1fd7a1a44487d5928c122400
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,9 @@ private void ValidateGatewayConnection()
{
if (serverErrorResult?.GetServerErrorType() != FaultInjectionServerErrorType.TooManyRequests
&& serverErrorResult?.GetServerErrorType() != FaultInjectionServerErrorType.ResponseDelay
&& serverErrorResult?.GetServerErrorType() != FaultInjectionServerErrorType.SendDelay)
&& serverErrorResult?.GetServerErrorType() != FaultInjectionServerErrorType.SendDelay
&& serverErrorResult?.GetServerErrorType() != FaultInjectionServerErrorType.DatabaseAccountNotFound
&& serverErrorResult?.GetServerErrorType() != FaultInjectionServerErrorType.ServiceUnavailable)
{
throw new ArgumentException($"{serverErrorResult?.GetServerErrorType()} is not supported for metadata requests.");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public enum FaultInjectionServerErrorType
ServiceUnavailable,

/// <summary>
/// 404:1008 Database account not found from gateway
/// 403:1008 Database account not found from gateway
/// </summary>
DatabaseAccountNotFound,
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -470,7 +470,7 @@ public HttpResponseMessage GetInjectedServerError(DocumentServiceRequest dsr, st

httpResponse = new HttpResponseMessage
{
StatusCode = HttpStatusCode.NotFound,
StatusCode = HttpStatusCode.Forbidden,
Content = new FauntInjectionHttpContent(
new MemoryStream(
FaultInjectionResponseEncoding.GetBytes($"Fault Injection Server Error: DatabaseAccountNotFound, rule: {ruleId}"))),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
using System.Text.Json.Serialization;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.Azure.Cosmos.Diagnostics;
using Microsoft.Azure.Cosmos.FaultInjection;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using static Microsoft.Azure.Cosmos.Routing.GlobalPartitionEndpointManagerCore;
Expand Down Expand Up @@ -149,6 +150,67 @@ public async Task ReadMany2UnreachablePartitionsTest()
}
}

[TestMethod]
[TestCategory("MultiRegion")]
public async Task Sev1Repro()
{
FaultInjectionRule pkRangeBad = new FaultInjectionRuleBuilder(
id: "pkrange",
condition: new FaultInjectionConditionBuilder()
.WithOperationType(FaultInjectionOperationType.MetadataPartitionKeyRange)
.WithRegion(region1)
.Build(),
result: new FaultInjectionServerErrorResultBuilder(FaultInjectionServerErrorType.ServiceUnavailable)
.Build())
.Build();

pkRangeBad.Disable();

FaultInjector faultInjector = new FaultInjector(new List<FaultInjectionRule> { pkRangeBad });

CosmosClientOptions cosmosClientOptions = new CosmosClientOptions()
{
ConsistencyLevel = ConsistencyLevel.Session,
ConnectionMode = ConnectionMode.Direct,
Serializer = this.cosmosSystemTextJsonSerializer,
FaultInjector = faultInjector,
};

using (CosmosClient fiClient = new CosmosClient(
connectionString: this.connectionString,
clientOptions: cosmosClientOptions))
{
Database fidb = fiClient.GetDatabase(MultiRegionSetupHelpers.dbName);
Container fic = fidb.GetContainer(MultiRegionSetupHelpers.containerName);

pkRangeBad.Enable();

try
{
FeedIterator<CosmosIntegrationTestObject> frTest = fic.GetItemQueryIterator<CosmosIntegrationTestObject>("SELECT * FROM c");

while (frTest.HasMoreResults)
{
FeedResponse<CosmosIntegrationTestObject> feedres = await frTest.ReadNextAsync();
Console.WriteLine(feedres.Diagnostics);
}
}
catch (CosmosException ex)
{
Console.WriteLine("EX");
Console.WriteLine(ex.Message);
Console.WriteLine(ex.Diagnostics);
throw;
}
finally
{
Console.WriteLine(pkRangeBad.GetHitCount());
pkRangeBad.Disable();
fiClient.Dispose();
}
}
}

[TestMethod]
[TestCategory("MultiRegion")]
public async Task AddressRefreshTimeoutTest()
Expand Down