From f4a44bdb70574f109d8e14e02d9e886c53f93b66 Mon Sep 17 00:00:00 2001 From: Nalu Tripician Date: Tue, 23 Apr 2024 13:06:36 -0700 Subject: [PATCH 1/5] initial commit --- .../src/FaultInjectionOperationType.cs | 5 + .../FaultInjectionRuleProcessor.cs | 1 + .../tests/FaultInjectionDirectModeTests.cs | 91 +++++++++++++++++++ .../FaultInjection/tests/Utils/TestCommon.cs | 11 ++- 4 files changed, 104 insertions(+), 4 deletions(-) diff --git a/Microsoft.Azure.Cosmos.Samples/Tools/FaultInjection/src/FaultInjectionOperationType.cs b/Microsoft.Azure.Cosmos.Samples/Tools/FaultInjection/src/FaultInjectionOperationType.cs index 675e33f4bb..ea8b3d19d1 100644 --- a/Microsoft.Azure.Cosmos.Samples/Tools/FaultInjection/src/FaultInjectionOperationType.cs +++ b/Microsoft.Azure.Cosmos.Samples/Tools/FaultInjection/src/FaultInjectionOperationType.cs @@ -48,6 +48,11 @@ public enum FaultInjectionOperationType /// Batch, + /// + /// Read Feed operations for ChangeFeed. + /// + ReadFeed, + /// /// All operation types. Default value. /// diff --git a/Microsoft.Azure.Cosmos.Samples/Tools/FaultInjection/src/implementataion/FaultInjectionRuleProcessor.cs b/Microsoft.Azure.Cosmos.Samples/Tools/FaultInjection/src/implementataion/FaultInjectionRuleProcessor.cs index a9ebdf9b73..4ef98d4c71 100644 --- a/Microsoft.Azure.Cosmos.Samples/Tools/FaultInjection/src/implementataion/FaultInjectionRuleProcessor.cs +++ b/Microsoft.Azure.Cosmos.Samples/Tools/FaultInjection/src/implementataion/FaultInjectionRuleProcessor.cs @@ -214,6 +214,7 @@ private OperationType GetEffectiveOperationType(FaultInjectionOperationType faul FaultInjectionOperationType.DeleteItem => OperationType.Delete, FaultInjectionOperationType.PatchItem => OperationType.Patch, FaultInjectionOperationType.Batch => OperationType.Batch, + FaultInjectionOperationType.ReadFeed => OperationType.ReadFeed, _ => throw new ArgumentException($"FaultInjectionOperationType: {faultInjectionOperationType} is not supported"), }; } diff --git a/Microsoft.Azure.Cosmos.Samples/Tools/FaultInjection/tests/FaultInjectionDirectModeTests.cs b/Microsoft.Azure.Cosmos.Samples/Tools/FaultInjection/tests/FaultInjectionDirectModeTests.cs index 0996b0ab76..fb53a86e6f 100644 --- a/Microsoft.Azure.Cosmos.Samples/Tools/FaultInjection/tests/FaultInjectionDirectModeTests.cs +++ b/Microsoft.Azure.Cosmos.Samples/Tools/FaultInjection/tests/FaultInjectionDirectModeTests.cs @@ -9,8 +9,10 @@ namespace Microsoft.Azure.Cosmos.FaultInjection.Tests using System.Linq; using System.Net; using System.Net.Sockets; + using System.Threading; using System.Threading.Tasks; using Microsoft.Azure.Cosmos; + using Microsoft.Azure.Cosmos.Diagnostics; using Microsoft.Azure.Cosmos.FaultInjection.Tests.Utils; using Microsoft.Azure.Cosmos.Routing; using Microsoft.Azure.Documents; @@ -1109,6 +1111,95 @@ private async Task Timeout_FaultInjectionConnectionErrorRule_Test() Assert.IsTrue(disposedChannel); } + [TestMethod] + [Owner("nalutripician")] + [Description("Tests ReadFeed FaultInjection")] + public void FaultInjectionServerErrorRule_ReadFeedTest() + { + if (!this.Timeout_FaultInjectionServerErrorRule_ReadFeedTest().Wait(Timeout)) + { + Assert.Fail("Test timed out"); + } + } + + private async Task Timeout_FaultInjectionServerErrorRule_ReadFeedTest() + { + string readFeedId = "readFeadGoneRule-" + Guid.NewGuid().ToString(); + FaultInjectionRule readFeedRule = new FaultInjectionRuleBuilder( + id: readFeedId, + condition: + new FaultInjectionConditionBuilder() + .WithOperationType(FaultInjectionOperationType.ReadFeed) + .Build(), + result: + FaultInjectionResultBuilder.GetResultBuilder(FaultInjectionServerErrorType.Gone) + .Build()) + .WithDuration(TimeSpan.FromMinutes(5)) + .Build(); + + readFeedRule.Disable(); + + List ruleList = new List { readFeedRule }; + FaultInjector faultInjector = new FaultInjector(ruleList); + + await this.Initialize(faultInjector, false); + + try + { + string changeFeedContainerName = "changeFeedContainer-" + Guid.NewGuid().ToString(); + ContainerProperties containerProperties = new ContainerProperties + { + Id = changeFeedContainerName, + PartitionKeyPath = "/partitionKey" + }; + if (this.database != null && this.container != null) + { + Container? leaseContainer = await this.database.CreateContainerIfNotExistsAsync(containerProperties, 400); + + ChangeFeedProcessor changeFeedProcessor = this.container.GetChangeFeedProcessorBuilder( + processorName: "FaultInjectionTest", + onChangesDelegate: HandleChangesAsync) + .WithInstanceName("test") + .WithLeaseContainer(leaseContainer) + .Build(); + await changeFeedProcessor.StartAsync(); + await Task.Delay(1000); + + JObject createdItem = JObject.FromObject(new { id = Guid.NewGuid().ToString(), Pk = Guid.NewGuid().ToString() }); + + ItemResponse? itemResponse = this.container != null + ? await this.container.CreateItemAsync(createdItem) + : null; + Assert.IsNotNull(itemResponse); + + readFeedRule.Enable(); + + await Task.Delay(5000); + } + } + finally + { + readFeedRule.Disable(); + } + } + + private static async Task HandleChangesAsync( + ChangeFeedProcessorContext context, + IReadOnlyCollection changes, + CancellationToken cancellationToken) + { + if (context.Diagnostics.GetClientElapsedTime() > TimeSpan.FromSeconds(1)) + { + Assert.Fail("Change Feed Processor took too long"); + } + + CosmosTraceDiagnostics? traceDiagnostic = context.Diagnostics as CosmosTraceDiagnostics; + Assert.IsNotNull(traceDiagnostic); + Assert.IsTrue(traceDiagnostic.Value.Data.TryGetValue("StatusCode", out object? statusCode)); + Assert.AreEqual((int)StatusCodes.Gone, (int)statusCode); + await Task.Delay(1); + } + private async Task PerformDocumentOperation(Container testContainer, OperationType operationType, JObject item) { try diff --git a/Microsoft.Azure.Cosmos.Samples/Tools/FaultInjection/tests/Utils/TestCommon.cs b/Microsoft.Azure.Cosmos.Samples/Tools/FaultInjection/tests/Utils/TestCommon.cs index 902bb7fe54..310e4c0049 100644 --- a/Microsoft.Azure.Cosmos.Samples/Tools/FaultInjection/tests/Utils/TestCommon.cs +++ b/Microsoft.Azure.Cosmos.Samples/Tools/FaultInjection/tests/Utils/TestCommon.cs @@ -6,8 +6,6 @@ internal static class TestCommon { - public const string Endpoint = ""; - public const string AuthKey = ""; public const string EndpointMultiRegion = ""; public const string AuthKeyMultiRegion = ""; @@ -59,8 +57,13 @@ internal static CosmosClientBuilder GetDefaultConfiguration( { CosmosClientBuilder clientBuilder = new CosmosClientBuilder( accountEndpoint: accountEndpointOverride - ?? (multiRegion ? EndpointMultiRegion : Endpoint), - authKeyOrResourceToken: multiRegion ? AuthKeyMultiRegion : AuthKey); + ?? EndpointMultiRegion, + authKeyOrResourceToken: AuthKeyMultiRegion); + + if (!multiRegion) + { + return clientBuilder.WithApplicationPreferredRegions(new List { "Central US" }); + } return clientBuilder; } From d109e0f3763ca455712f7e1c21907988577f8a09 Mon Sep 17 00:00:00 2001 From: Nalu Tripician Date: Thu, 25 Apr 2024 14:42:04 -0700 Subject: [PATCH 2/5] fixed tests --- ...FaultInjectionServerErrorResultInternal.cs | 24 +++- .../tests/FaultInjectionDirectModeTests.cs | 111 ++++++++++-------- 2 files changed, 79 insertions(+), 56 deletions(-) diff --git a/Microsoft.Azure.Cosmos.Samples/Tools/FaultInjection/src/implementataion/FaultInjectionServerErrorResultInternal.cs b/Microsoft.Azure.Cosmos.Samples/Tools/FaultInjection/src/implementataion/FaultInjectionServerErrorResultInternal.cs index e903d61ca5..d4f1a2407b 100644 --- a/Microsoft.Azure.Cosmos.Samples/Tools/FaultInjection/src/implementataion/FaultInjectionServerErrorResultInternal.cs +++ b/Microsoft.Azure.Cosmos.Samples/Tools/FaultInjection/src/implementataion/FaultInjectionServerErrorResultInternal.cs @@ -123,12 +123,14 @@ public FaultInjectionServerErrorType GetInjectedServerErrorType() public StoreResponse GetInjectedServerError(ChannelCallArguments args, string ruleId) { StoreResponse storeResponse; + string lsn = args.RequestHeaders.Get(WFConstants.BackendHeaders.LSN) ?? "0"; switch (this.serverErrorType) { case FaultInjectionServerErrorType.Gone: INameValueCollection goneHeaders = args.RequestHeaders; goneHeaders.Set(WFConstants.BackendHeaders.SubStatus, ((int)SubStatusCodes.ServerGenerated410).ToString(CultureInfo.InvariantCulture)); + goneHeaders.Set(WFConstants.BackendHeaders.LocalLSN, lsn); storeResponse = new StoreResponse() { Status = 410, @@ -139,10 +141,12 @@ public StoreResponse GetInjectedServerError(ChannelCallArguments args, string ru return storeResponse; case FaultInjectionServerErrorType.RetryWith: + INameValueCollection retryWithHeaders = args.RequestHeaders; + retryWithHeaders.Set(WFConstants.BackendHeaders.LocalLSN, lsn); storeResponse = new StoreResponse() { Status = 449, - Headers = args.RequestHeaders, + Headers = retryWithHeaders, ResponseBody = new MemoryStream(Encoding.UTF8.GetBytes($"Fault Injection Server Error: Retry With, rule: {ruleId}")) }; @@ -152,6 +156,7 @@ public StoreResponse GetInjectedServerError(ChannelCallArguments args, string ru INameValueCollection tooManyRequestsHeaders = args.RequestHeaders; tooManyRequestsHeaders.Set(HttpConstants.HttpHeaders.RetryAfterInMilliseconds, "500"); tooManyRequestsHeaders.Set(WFConstants.BackendHeaders.SubStatus, ((int)SubStatusCodes.RUBudgetExceeded).ToString(CultureInfo.InvariantCulture)); + tooManyRequestsHeaders.Set(WFConstants.BackendHeaders.LocalLSN, lsn); storeResponse = new StoreResponse() { @@ -163,21 +168,26 @@ public StoreResponse GetInjectedServerError(ChannelCallArguments args, string ru return storeResponse; case FaultInjectionServerErrorType.Timeout: + INameValueCollection timeoutHeaders = args.RequestHeaders; + timeoutHeaders.Set(WFConstants.BackendHeaders.LocalLSN, lsn); storeResponse = new StoreResponse() { Status = 408, - Headers = args.RequestHeaders, + Headers = timeoutHeaders, ResponseBody = new MemoryStream(Encoding.UTF8.GetBytes($"Fault Injection Server Error: Timeout, rule: {ruleId}")) }; return storeResponse; case FaultInjectionServerErrorType.InternalServerEror: + INameValueCollection internalServerErrorHeaders = args.RequestHeaders; + internalServerErrorHeaders.Set(WFConstants.BackendHeaders.LocalLSN, lsn); + storeResponse = new StoreResponse() { Status = 500, - Headers = args.RequestHeaders, + Headers = internalServerErrorHeaders, ResponseBody = new MemoryStream(Encoding.UTF8.GetBytes($"Fault Injection Server Error: Internal Server Error, rule: {ruleId}")) }; @@ -190,6 +200,7 @@ public StoreResponse GetInjectedServerError(ChannelCallArguments args, string ru INameValueCollection readSessionHeaders = args.RequestHeaders; readSessionHeaders.Set(WFConstants.BackendHeaders.SubStatus, ((int)SubStatusCodes.ReadSessionNotAvailable).ToString(CultureInfo.InvariantCulture)); readSessionHeaders.Set(HttpConstants.HttpHeaders.SessionToken, badSesstionToken); + readSessionHeaders.Set(WFConstants.BackendHeaders.LocalLSN, lsn); storeResponse = new StoreResponse() { @@ -203,6 +214,7 @@ public StoreResponse GetInjectedServerError(ChannelCallArguments args, string ru case FaultInjectionServerErrorType.PartitionIsMigrating: INameValueCollection partitionMigrationHeaders = args.RequestHeaders; partitionMigrationHeaders.Set(WFConstants.BackendHeaders.SubStatus, ((int)SubStatusCodes.CompletingPartitionMigration).ToString(CultureInfo.InvariantCulture)); + partitionMigrationHeaders.Set(WFConstants.BackendHeaders.LocalLSN, lsn); storeResponse = new StoreResponse() { @@ -216,6 +228,7 @@ public StoreResponse GetInjectedServerError(ChannelCallArguments args, string ru case FaultInjectionServerErrorType.PartitionIsSplitting: INameValueCollection partitionSplitting = args.RequestHeaders; partitionSplitting.Set(WFConstants.BackendHeaders.SubStatus, ((int)SubStatusCodes.CompletingSplit).ToString(CultureInfo.InvariantCulture)); + partitionSplitting.Set(WFConstants.BackendHeaders.LocalLSN, lsn); storeResponse = new StoreResponse() { @@ -226,10 +239,13 @@ public StoreResponse GetInjectedServerError(ChannelCallArguments args, string ru return storeResponse; case FaultInjectionServerErrorType.ServiceUnavailable: + INameValueCollection serviceUnavailableHeaders = args.RequestHeaders; + serviceUnavailableHeaders.Set(WFConstants.BackendHeaders.LocalLSN, lsn); + storeResponse = new StoreResponse() { Status = 503, - Headers = args.RequestHeaders, + Headers = serviceUnavailableHeaders, ResponseBody = new MemoryStream(Encoding.UTF8.GetBytes($"Fault Injection Server Error: Service Unavailable, rule: {ruleId}")) }; diff --git a/Microsoft.Azure.Cosmos.Samples/Tools/FaultInjection/tests/FaultInjectionDirectModeTests.cs b/Microsoft.Azure.Cosmos.Samples/Tools/FaultInjection/tests/FaultInjectionDirectModeTests.cs index fb53a86e6f..cde07f3a3f 100644 --- a/Microsoft.Azure.Cosmos.Samples/Tools/FaultInjection/tests/FaultInjectionDirectModeTests.cs +++ b/Microsoft.Azure.Cosmos.Samples/Tools/FaultInjection/tests/FaultInjectionDirectModeTests.cs @@ -1116,15 +1116,16 @@ private async Task Timeout_FaultInjectionConnectionErrorRule_Test() [Description("Tests ReadFeed FaultInjection")] public void FaultInjectionServerErrorRule_ReadFeedTest() { - if (!this.Timeout_FaultInjectionServerErrorRule_ReadFeedTest().Wait(Timeout)) - { - Assert.Fail("Test timed out"); - } + this.Timeout_FaultInjectionServerErrorRule_ReadFeedTest().Wait(); + //if (!this.Timeout_FaultInjectionServerErrorRule_ReadFeedTest().Wait(Timeout)) + //{ + // Assert.Fail("Test timed out"); + //} } private async Task Timeout_FaultInjectionServerErrorRule_ReadFeedTest() { - string readFeedId = "readFeadGoneRule-" + Guid.NewGuid().ToString(); + string readFeedId = "readFeadRule-" + Guid.NewGuid().ToString(); FaultInjectionRule readFeedRule = new FaultInjectionRuleBuilder( id: readFeedId, condition: @@ -1132,7 +1133,7 @@ private async Task Timeout_FaultInjectionServerErrorRule_ReadFeedTest() .WithOperationType(FaultInjectionOperationType.ReadFeed) .Build(), result: - FaultInjectionResultBuilder.GetResultBuilder(FaultInjectionServerErrorType.Gone) + FaultInjectionResultBuilder.GetResultBuilder(FaultInjectionServerErrorType.ServiceUnavailable) .Build()) .WithDuration(TimeSpan.FromMinutes(5)) .Build(); @@ -1144,61 +1145,67 @@ private async Task Timeout_FaultInjectionServerErrorRule_ReadFeedTest() await this.Initialize(faultInjector, false); - try + string changeFeedContainerName = "changeFeedContainer-" + Guid.NewGuid().ToString(); + ContainerProperties containerProperties = new ContainerProperties { - string changeFeedContainerName = "changeFeedContainer-" + Guid.NewGuid().ToString(); - ContainerProperties containerProperties = new ContainerProperties - { - Id = changeFeedContainerName, - PartitionKeyPath = "/partitionKey" - }; - if (this.database != null && this.container != null) - { - Container? leaseContainer = await this.database.CreateContainerIfNotExistsAsync(containerProperties, 400); + Id = changeFeedContainerName, + PartitionKeyPath = "/partitionKey" + }; - ChangeFeedProcessor changeFeedProcessor = this.container.GetChangeFeedProcessorBuilder( - processorName: "FaultInjectionTest", - onChangesDelegate: HandleChangesAsync) - .WithInstanceName("test") - .WithLeaseContainer(leaseContainer) - .Build(); - await changeFeedProcessor.StartAsync(); - await Task.Delay(1000); + if (this.database != null && this.container != null) + { + JObject createdItem = JObject.FromObject(new { id = Guid.NewGuid().ToString(), Pk = Guid.NewGuid().ToString() }); + ItemResponse? itemResponse = await this.container.CreateItemAsync(createdItem); - JObject createdItem = JObject.FromObject(new { id = Guid.NewGuid().ToString(), Pk = Guid.NewGuid().ToString() }); + readFeedRule.Enable(); - ItemResponse? itemResponse = this.container != null - ? await this.container.CreateItemAsync(createdItem) - : null; - Assert.IsNotNull(itemResponse); + Container? leaseContainer = await this.database.CreateContainerIfNotExistsAsync(containerProperties, 400); - readFeedRule.Enable(); + ManualResetEvent changeFeedRan = new ManualResetEvent(false); - await Task.Delay(5000); - } - } - finally - { - readFeedRule.Disable(); - } - } + ChangeFeedProcessor changeFeedProcessor; + changeFeedProcessor = this.container.GetChangeFeedProcessorBuilder( + "FaultInjectionTest", + (ChangeFeedProcessorContext context, IReadOnlyCollection docs, CancellationToken token) => + { + Assert.Fail("Change Feed Should Fail"); + return Task.CompletedTask; + }) + .WithInstanceName("test") + .WithLeaseContainer(leaseContainer) + .WithStartFromBeginning() + .WithErrorNotification((string lease, Exception exception) => + { + if (exception is CosmosException cosmosException) + { + Assert.AreEqual(HttpStatusCode.ServiceUnavailable, cosmosException.StatusCode); + } + else + { + Assert.Fail("Unexpected Exception"); + } - private static async Task HandleChangesAsync( - ChangeFeedProcessorContext context, - IReadOnlyCollection changes, - CancellationToken cancellationToken) - { - if (context.Diagnostics.GetClientElapsedTime() > TimeSpan.FromSeconds(1)) - { - Assert.Fail("Change Feed Processor took too long"); - } + changeFeedRan.Set(); + return Task.CompletedTask; + }) + .Build(); - CosmosTraceDiagnostics? traceDiagnostic = context.Diagnostics as CosmosTraceDiagnostics; - Assert.IsNotNull(traceDiagnostic); - Assert.IsTrue(traceDiagnostic.Value.Data.TryGetValue("StatusCode", out object? statusCode)); - Assert.AreEqual((int)StatusCodes.Gone, (int)statusCode); - await Task.Delay(1); + await changeFeedProcessor.StartAsync(); + await Task.Delay(1000); + + try + { + bool wasProcessed = changeFeedRan.WaitOne(60000); + Assert.IsTrue(wasProcessed, "Timed out waiting for handler to execute"); + } + finally + { + await changeFeedProcessor.StopAsync(); + readFeedRule.Disable(); + } + } } + private async Task PerformDocumentOperation(Container testContainer, OperationType operationType, JObject item) { From 968a417b6955d7b13f6962082525300e37d4473d Mon Sep 17 00:00:00 2001 From: Nalu Tripician Date: Thu, 25 Apr 2024 14:45:45 -0700 Subject: [PATCH 3/5] nits --- .../tests/FaultInjectionDirectModeTests.cs | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/Microsoft.Azure.Cosmos.Samples/Tools/FaultInjection/tests/FaultInjectionDirectModeTests.cs b/Microsoft.Azure.Cosmos.Samples/Tools/FaultInjection/tests/FaultInjectionDirectModeTests.cs index cde07f3a3f..66fc20d3c8 100644 --- a/Microsoft.Azure.Cosmos.Samples/Tools/FaultInjection/tests/FaultInjectionDirectModeTests.cs +++ b/Microsoft.Azure.Cosmos.Samples/Tools/FaultInjection/tests/FaultInjectionDirectModeTests.cs @@ -1116,11 +1116,10 @@ private async Task Timeout_FaultInjectionConnectionErrorRule_Test() [Description("Tests ReadFeed FaultInjection")] public void FaultInjectionServerErrorRule_ReadFeedTest() { - this.Timeout_FaultInjectionServerErrorRule_ReadFeedTest().Wait(); - //if (!this.Timeout_FaultInjectionServerErrorRule_ReadFeedTest().Wait(Timeout)) - //{ - // Assert.Fail("Test timed out"); - //} + if (!this.Timeout_FaultInjectionServerErrorRule_ReadFeedTest().Wait(Timeout)) + { + Assert.Fail("Test timed out"); + } } private async Task Timeout_FaultInjectionServerErrorRule_ReadFeedTest() From 07fdf51cdaad7879fa66f01b95a275a2279dd622 Mon Sep 17 00:00:00 2001 From: Nalu Tripician Date: Thu, 25 Apr 2024 15:32:55 -0700 Subject: [PATCH 4/5] small fixes --- .../FaultInjection/tests/FaultInjectionDirectModeTests.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Microsoft.Azure.Cosmos.Samples/Tools/FaultInjection/tests/FaultInjectionDirectModeTests.cs b/Microsoft.Azure.Cosmos.Samples/Tools/FaultInjection/tests/FaultInjectionDirectModeTests.cs index 66fc20d3c8..30398679f5 100644 --- a/Microsoft.Azure.Cosmos.Samples/Tools/FaultInjection/tests/FaultInjectionDirectModeTests.cs +++ b/Microsoft.Azure.Cosmos.Samples/Tools/FaultInjection/tests/FaultInjectionDirectModeTests.cs @@ -1162,8 +1162,7 @@ private async Task Timeout_FaultInjectionServerErrorRule_ReadFeedTest() ManualResetEvent changeFeedRan = new ManualResetEvent(false); - ChangeFeedProcessor changeFeedProcessor; - changeFeedProcessor = this.container.GetChangeFeedProcessorBuilder( + ChangeFeedProcessor changeFeedProcessor = this.container.GetChangeFeedProcessorBuilder( "FaultInjectionTest", (ChangeFeedProcessorContext context, IReadOnlyCollection docs, CancellationToken token) => { From 47dd2d1a9af91ce22e881931212d4cfd098966a9 Mon Sep 17 00:00:00 2001 From: Nalu Tripician Date: Fri, 26 Apr 2024 10:07:14 -0700 Subject: [PATCH 5/5] fixed test --- .../tests/FaultInjectionDirectModeTests.cs | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/Microsoft.Azure.Cosmos.Samples/Tools/FaultInjection/tests/FaultInjectionDirectModeTests.cs b/Microsoft.Azure.Cosmos.Samples/Tools/FaultInjection/tests/FaultInjectionDirectModeTests.cs index 30398679f5..10d573e127 100644 --- a/Microsoft.Azure.Cosmos.Samples/Tools/FaultInjection/tests/FaultInjectionDirectModeTests.cs +++ b/Microsoft.Azure.Cosmos.Samples/Tools/FaultInjection/tests/FaultInjectionDirectModeTests.cs @@ -1112,17 +1112,10 @@ private async Task Timeout_FaultInjectionConnectionErrorRule_Test() } [TestMethod] + [Timeout(Timeout)] [Owner("nalutripician")] [Description("Tests ReadFeed FaultInjection")] - public void FaultInjectionServerErrorRule_ReadFeedTest() - { - if (!this.Timeout_FaultInjectionServerErrorRule_ReadFeedTest().Wait(Timeout)) - { - Assert.Fail("Test timed out"); - } - } - - private async Task Timeout_FaultInjectionServerErrorRule_ReadFeedTest() + public async Task FaultInjectionServerErrorRule_ReadFeedTest() { string readFeedId = "readFeadRule-" + Guid.NewGuid().ToString(); FaultInjectionRule readFeedRule = new FaultInjectionRuleBuilder(