-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
CSHARP-3678: Convert transactions spec tests to unified test format #1586
base: main
Are you sure you want to change the base?
Conversation
SpinWait.SpinUntil(() => _server.Description.State == ServerState.Connected, 1000); | ||
if (!SpinWait.SpinUntil(() => _server.Description.State == ServerState.Connected, 1000)) | ||
{ | ||
throw new InvalidOperationException("Server is not connected."); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's better to throw here, to avoid getting cryptic exception ("pool is in paused state").
throw new SkipException("Skipped because CSharp Driver has an issue with handling read timeout for sync code-path."); | ||
} | ||
|
||
if (CoreTestConfiguration.Cluster.Description.Type == ClusterType.Sharded && |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Have to skip these tests for MongoDB sharded cluster 4.2, as they are not compatible with it. Confirmed with Java team, they have to skip them as well: https://github.com/mongodb/mongo-java-driver/blob/08880c810b76f8c8d165f6ce66c83060c7bc93c5/driver-sync/src/test/functional/com/mongodb/client/unified/UnifiedTestModifications.java#L244
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add a comment stating that these tests are not compatible with MongoDB 4.2. Otherwise it is not clear why we only run them for 4.4+.
{ | ||
if (testCase.Name.Contains("add RetryableWriteError and UnknownTransactionCommitResult labels to connection errors")) | ||
{ | ||
throw new SkipException("Skipped because CSharp Driver has an issue with handling read timeout for sync code-path."); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is test that is failing in sync path because authors of the test trying to emulate network error, by setting fail point that blocks connection for longer then read timeout - so driver should abort the connection and get network error. That test works as expected for ASYNC path because we manually apply read timeout, but not for SYNC path. It worth to investigate and do the same for sync path as well, but as discussed with Boris - we probably will postpone it and will do in scope of CSOT implementation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reasonable. I would file a CSHARP ticket and note its number here so that we don't lose it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably related to https://jira.mongodb.org/browse/CSHARP-3662
@@ -1,24 +0,0 @@ | |||
/* Copyright 2020-present MongoDB Inc. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This interface was used to have a special case for failpoint operations to store them in a specialized collection for later disposal. This PR introducing a new method in EntityMap that let register any IDisposable for disposal after test execution.
var creator = new UnifiedEntityMapCreator(eventFormatters, loggingSettings); | ||
return new UnifiedEntityMap(creator, async); | ||
} | ||
=> new(eventFormatters, loggingSettings, async); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We use to have EntityMap kind of immutable (we created a new EntityMap for each CreateEntity operation, and in case of nested create entities operations - we merge them together), but in this PR I've run into a situation when CreateEntity operation inside of test references entities created by another CreateEntity operation. So it should have access to entity map created earlier... I've decided to let CreateEntity operation instead of creating and merging to simply modify single entity map.
{ | ||
var cluster = _client.GetClusterInternal(); | ||
var session = NoCoreSession.NewHandle(); | ||
|
||
failPoint = FailPoint.Configure(cluster, session, _failPointCommand, _async); | ||
var failPoint = FailPoint.Configure(cluster, session, _failPointCommand, _async); | ||
_entityMap.RegisterForDispose(failPoint); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We register created failpoint for disposal together with entityMap, instead of returning it and letting test runner dispose them.
{ | ||
var pinnedServer = _session?.WrappedCoreSession?.CurrentTransaction?.PinnedServer; | ||
var pinnedServer = _session?.WrappedCoreSession?.CurrentTransaction?.PinnedServer.EndPoint; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We cannot use the same cluster as provided session, because in several test cases we setup failPoint for hello
command, which will turn cluster to be disconnected so disposal of the failPoint will throw (connection pool is paused state error). So have to use another client to configure failPoints.
if (pinnedServer == null) | ||
{ | ||
throw new InvalidOperationException("UnifiedTargetedFailPointOperation requires a pinned server."); | ||
} | ||
|
||
var client = DriverTestConfiguration.CreateMongoClient(useMultipleShardRouters: true); | ||
_entityMap.RegisterForDispose(client); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Have to register for disposal both: created client and failPoint itself.
@@ -161,13 +159,6 @@ public void Dispose() | |||
{ | |||
_logger.LogDebug("Disposing"); | |||
|
|||
if (_failPoints != null) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Disposed together with entityMap.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Minor comments for your consideration but nothing blocking.
{ | ||
if (testCase.Name.Contains("add RetryableWriteError and UnknownTransactionCommitResult labels to connection errors")) | ||
{ | ||
throw new SkipException("Skipped because CSharp Driver has an issue with handling read timeout for sync code-path."); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reasonable. I would file a CSHARP ticket and note its number here so that we don't lose it.
throw new SkipException("Skipped because CSharp Driver has an issue with handling read timeout for sync code-path."); | ||
} | ||
|
||
if (CoreTestConfiguration.Cluster.Description.Type == ClusterType.Sharded && |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add a comment stating that these tests are not compatible with MongoDB 4.2. Otherwise it is not clear why we only run them for 4.4+.
{ | ||
var result = _session == null | ||
? _collection.Count(_filter, _options, cancellationToken) | ||
: _collection.Count(_session, _filter, _options, cancellationToken); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMongoCollection<T>.Count
is obsolete. We should be using IMongoCollection<T>.CountDocuments
instead.
{ | ||
var result = _session == null | ||
? await _collection.CountAsync(_filter, _options, cancellationToken) | ||
: await _collection.CountAsync(_session, _filter, _options, cancellationToken); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as above except CountDocumentsAsync
.
This PR will close the following Jira tickets:
NOTICE: Some spec tests contains changes done locally, that has to be processed to spec repository at first. I'm discussing the changes with spec owners and will create PR to spec repo shortly.