Skip to content

Commit 1d7fe34

Browse files
committed
Small corrections
1 parent 9a8a207 commit 1d7fe34

File tree

2 files changed

+24
-26
lines changed

2 files changed

+24
-26
lines changed

src/MongoDB.Driver/Core/Operations/RetryableWriteOperationExecutor.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ public static TResult Execute<TResult>(OperationContext operationContext, IRetry
8181
//TODO I should throw if backoff exceeeds timeout
8282
}
8383

84-
deprioritizedServers ??= new HashSet<ServerDescription>();
84+
deprioritizedServers ??= [];
8585
deprioritizedServers.Add(context.LastAcquiredServer);
8686
}
8787
}
@@ -143,7 +143,7 @@ public static async Task<TResult> ExecuteAsync<TResult>(OperationContext operati
143143
await Task.Delay(backoff, operationContext.CancellationToken).ConfigureAwait(false);
144144
}
145145

146-
deprioritizedServers ??= new HashSet<ServerDescription>();
146+
deprioritizedServers ??= [];
147147
deprioritizedServers.Add(context.LastAcquiredServer);
148148
}
149149
}
@@ -175,7 +175,7 @@ private static bool ShouldRetry(OperationContext operationContext,
175175
}
176176

177177
var isRetryableWriteException = RetryabilityHelper.IsRetryableWriteException(exception);
178-
var isRetryableWrites = AreRetriesAllowed(writeConcern, context, context.ChannelSource.ServerDescription) && isRetryableWriteException;
178+
var isRetryableWrites = AreRetriesAllowed(writeConcern, context, context.LastAcquiredServer) && isRetryableWriteException;
179179

180180
var isRetryableReadOrWrite = isRetryableRead || isRetryableWrites;
181181

tests/MongoDB.Driver.Tests/Specifications/UnifiedTestSpecRunner.cs

Lines changed: 21 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -51,37 +51,27 @@ public UnifiedTestSpecRunner(ITestOutputHelper testOutputHelper)
5151
[UnifiedTestsTheory("client_side_operations_timeout.tests")]
5252
public void ClientSideOperationsTimeout(JsonDrivenTestCase testCase)
5353
{
54-
SkipNotSupportedTestCases("dropIndexes");
55-
SkipNotSupportedTestCases("findOne");
56-
SkipNotSupportedTestCases("listIndexNames");
54+
SkipNotSupportedTestCases(testCase, "dropIndexes");
55+
SkipNotSupportedTestCases(testCase, "findOne");
56+
SkipNotSupportedTestCases(testCase, "listIndexNames");
5757
// TODO: CSOT: further skipped tests should be unblocked by upcoming fixes
58-
SkipNotSupportedTestCases("with only 1 RTT"); // blocked by CSHARP-5627
59-
SkipNotSupportedTestCases("createChangeStream"); // TODO: CSOT not implemented yet, CSHARP-3539
60-
SkipNotSupportedTestCases("runCommand"); // TODO: CSOT: TimeoutMS is not implemented yet for runCommand
61-
SkipNotSupportedTestCases("timeoutMS applies to whole operation, not individual attempts"); // blocked by DRIVERS-3247
62-
SkipNotSupportedTestCases("WaitQueueTimeoutError does not clear the pool"); // TODO: CSOT: TimeoutMS is not implemented yet for runCommand
63-
SkipNotSupportedTestCases("write concern error MaxTimeMSExpired is transformed"); // TODO: CSOT: investigate error transformation, implementing the requirement might be breaking change
64-
SkipNotSupportedTestCases("operation succeeds after one socket timeout - listDatabases on client"); // TODO: listDatabases is not retryable in CSharp Driver, CSHARP-5714
58+
SkipNotSupportedTestCases(testCase, "with only 1 RTT"); // blocked by CSHARP-5627
59+
SkipNotSupportedTestCases(testCase, "createChangeStream"); // TODO: CSOT not implemented yet, CSHARP-3539
60+
SkipNotSupportedTestCases(testCase, "runCommand"); // TODO: CSOT: TimeoutMS is not implemented yet for runCommand
61+
SkipNotSupportedTestCases(testCase, "timeoutMS applies to whole operation, not individual attempts"); // blocked by DRIVERS-3247
62+
SkipNotSupportedTestCases(testCase, "WaitQueueTimeoutError does not clear the pool"); // TODO: CSOT: TimeoutMS is not implemented yet for runCommand
63+
SkipNotSupportedTestCases(testCase, "write concern error MaxTimeMSExpired is transformed"); // TODO: CSOT: investigate error transformation, implementing the requirement might be breaking change
64+
SkipNotSupportedTestCases(testCase, "operation succeeds after one socket timeout - listDatabases on client"); // TODO: listDatabases is not retryable in CSharp Driver, CSHARP-5714
6565

6666
Run(testCase);
67-
68-
void SkipNotSupportedTestCases(string operationName)
69-
{
70-
if (testCase.Name.Contains(operationName))
71-
{
72-
throw new SkipException($"Test skipped because {operationName} is not supported.");
73-
}
74-
}
7567
}
7668

7769
[UnifiedTestsTheory("client_backpressure.tests")]
7870
public void ClientBackpressure(JsonDrivenTestCase testCase)
7971
{
80-
//TODO Do we want to do something about these operations?
81-
if (testCase.Name.Contains("findOne ") || testCase.Name.Contains("dropIndexes ") || testCase.Name.Contains("listIndexNames "))
82-
{
83-
throw new SkipException($"Test skipped because operation is not supported.");
84-
}
72+
SkipNotSupportedTestCases(testCase, "dropIndexes");
73+
SkipNotSupportedTestCases(testCase, "findOne");
74+
SkipNotSupportedTestCases(testCase, "listIndexNames");
8575

8676
Run(testCase);
8777
}
@@ -268,6 +258,14 @@ private void Run(JsonDrivenTestCase testCase, Predicate<LogEntry> loggingFilter
268258
private static void RequireKmsMock() =>
269259
RequireEnvironment.Check().EnvironmentVariable("KMS_MOCK_SERVERS_ENABLED");
270260

261+
private static void SkipNotSupportedTestCases(JsonDrivenTestCase testCase, string operationName)
262+
{
263+
if (testCase.Name.Contains(operationName))
264+
{
265+
throw new SkipException($"Test skipped because {operationName} is not supported.");
266+
}
267+
}
268+
271269
// used by SkippedTestsProvider property in UnifiedTests attribute.
272270
private static readonly HashSet<string> __ignoredTests = new(
273271
[

0 commit comments

Comments
 (0)