From d62c9541d1bc99cdb2ead42809d42ed80b3ab417 Mon Sep 17 00:00:00 2001 From: Jeff Yemin Date: Tue, 13 May 2025 09:51:30 -0400 Subject: [PATCH 1/4] Simplify test assumptions for 4.2 minimum server support --- .../AggregatesFunctionalSpecification.groovy | 22 ---- .../FiltersFunctionalSpecification.groovy | 10 -- .../mql/TypeMqlValuesFunctionalTest.java | 5 - ...amSha256AuthenticationSpecification.groovy | 3 +- .../AggregateOperationSpecification.groovy | 18 +-- ...eToCollectionOperationSpecification.groovy | 66 +---------- ...reamOperationProseTestSpecification.groovy | 14 +-- .../ChangeStreamOperationSpecification.groovy | 8 +- ...ountDocumentsOperationSpecification.groovy | 5 - ...ateCollectionOperationSpecification.groovy | 36 +----- ...CreateIndexesOperationSpecification.groovy | 23 +--- .../CreateViewOperationSpecification.groovy | 24 +--- .../DistinctOperationSpecification.groovy | 3 - ...ropCollectionOperationSpecification.groovy | 3 +- .../DropDatabaseOperationSpecification.groovy | 17 +-- .../DropIndexOperationSpecification.groovy | 3 +- ...FindAndDeleteOperationSpecification.groovy | 8 +- ...indAndReplaceOperationSpecification.groovy | 9 +- ...FindAndUpdateOperationSpecification.groovy | 15 +-- .../FindOperationSpecification.groovy | 13 +-- ...stCollectionsOperationSpecification.groovy | 50 --------- ...eToCollectionOperationSpecification.groovy | 4 +- ...InlineResultsOperationSpecification.groovy | 3 - ...ixedBulkWriteOperationSpecification.groovy | 106 +----------------- ...ameCollectionOperationSpecification.groovy | 3 +- ...DBCollectionFunctionalSpecification.groovy | 41 +------ .../com/mongodb/DBCollectionTest.java | 86 ++++---------- .../DBCursorFunctionalSpecification.groovy | 33 ------ .../mongodb/DBFunctionalSpecification.groovy | 20 ++-- ...ixedBulkWriteOperationSpecification.groovy | 3 +- .../MongoClientSessionSpecification.groovy | 16 +-- ...cryptionBsonSizeLimitsSpecification.groovy | 2 - .../reactivestreams/client/ExplainTest.java | 7 -- .../MongoClientSessionSpecification.groovy | 15 +-- .../client/RetryableWritesProseTest.java | 54 --------- .../client/SmokeTestSpecification.groovy | 5 +- .../client/TransactionFailureTest.java | 59 ---------- .../client/WriteConcernProseTest.java | 3 +- .../client/internal/BatchCursorFluxTest.java | 3 +- ...ctionsSurvivePrimaryStepDownProseTest.java | 2 +- .../documentation/TransactionExample.java | 4 +- .../mongodb/client/AbstractExplainTest.java | 28 ----- .../mongodb/client/ChangeStreamProseTest.java | 78 ------------- ...cryptionBsonSizeLimitsSpecification.groovy | 2 - ...yptionExternalKeyVaultSpecification.groovy | 2 - ...ctionsSurvivePrimaryStepDownProseTest.java | 2 +- .../com/mongodb/client/CrudProseTest.java | 2 +- .../MongoClientSessionSpecification.groovy | 16 +-- .../client/RetryableWritesProseTest.java | 46 -------- .../client/TransactionFailureTest.java | 51 --------- .../client/WithTransactionProseTest.java | 4 +- .../GridFSBucketSmokeTestSpecification.groovy | 3 - 52 files changed, 91 insertions(+), 967 deletions(-) delete mode 100644 driver-reactive-streams/src/test/functional/com/mongodb/reactivestreams/client/TransactionFailureTest.java delete mode 100644 driver-sync/src/test/functional/com/mongodb/client/TransactionFailureTest.java diff --git a/driver-core/src/test/functional/com/mongodb/client/model/AggregatesFunctionalSpecification.groovy b/driver-core/src/test/functional/com/mongodb/client/model/AggregatesFunctionalSpecification.groovy index 388736a9a82..e27f888f548 100644 --- a/driver-core/src/test/functional/com/mongodb/client/model/AggregatesFunctionalSpecification.groovy +++ b/driver-core/src/test/functional/com/mongodb/client/model/AggregatesFunctionalSpecification.groovy @@ -144,7 +144,6 @@ class AggregatesFunctionalSpecification extends OperationFunctionalSpecification new Document('_id', 3).append('x', 3).append('c', 'c')] } - @IgnoreIf({ serverVersionLessThan(3, 4) }) def '$project an exclusion'() { expect: aggregate([project(exclude('a', 'a1', 'z', 'o'))]) == [new Document('_id', 1).append('x', 1).append('y', 'a'), @@ -178,7 +177,6 @@ class AggregatesFunctionalSpecification extends OperationFunctionalSpecification new Document('a', 6)] } - @IgnoreIf({ serverVersionLessThan(3, 2) }) def '$unwind with UnwindOptions'() { given: getCollectionHelper().drop() @@ -226,7 +224,6 @@ class AggregatesFunctionalSpecification extends OperationFunctionalSpecification new Document('_id', false).append('acc', [false])]) } - @IgnoreIf({ serverVersionLessThan(3, 6) }) def '$group with $mergeObjects'() { aggregate([group(null, mergeObjects('acc', '$o'))]).containsAll( [new Document('_id', null).append('acc', new Document('a', 1).append('b', 2).append('c', 3))]) @@ -322,7 +319,6 @@ class AggregatesFunctionalSpecification extends OperationFunctionalSpecification getCollectionHelper(new MongoNamespace(outDatabaseName, outCollectionName)).find() == [a, b, c] } - @IgnoreIf({ serverVersionLessThan(4, 2) }) def '$merge'() { given: def outCollectionName = getCollectionName() + '.out' @@ -408,7 +404,6 @@ class AggregatesFunctionalSpecification extends OperationFunctionalSpecification getCollectionHelper(new MongoNamespace(getDatabaseName(), outCollectionName)).find() == [a, b, c] } - @IgnoreIf({ serverVersionLessThan(3, 2) }) def '$stdDev'() { when: def results = aggregate([group(null, stdDevPop('stdDevPop', '$x'), stdDevSamp('stdDevSamp', '$x'))]).first() @@ -420,14 +415,12 @@ class AggregatesFunctionalSpecification extends OperationFunctionalSpecification results.get('stdDevSamp') == 1.0 } - @IgnoreIf({ serverVersionLessThan(3, 2) }) def '$sample'() { expect: containsAny([a, b, c], aggregate([sample(1)]).first()) } - @IgnoreIf({ serverVersionLessThan(3, 2) }) def '$lookup'() { given: def fromCollectionName = 'lookupCollection' @@ -455,7 +448,6 @@ class AggregatesFunctionalSpecification extends OperationFunctionalSpecification fromHelper?.drop() } - @IgnoreIf({ serverVersionLessThan(3, 6) }) def '$lookup with pipeline'() { given: def fromCollectionName = 'warehouses' @@ -500,7 +492,6 @@ class AggregatesFunctionalSpecification extends OperationFunctionalSpecification fromHelper?.drop() } - @IgnoreIf({ serverVersionLessThan(3, 6) }) def '$lookup with pipeline without variables'() { given: def fromCollectionName = 'holidays' @@ -555,7 +546,6 @@ class AggregatesFunctionalSpecification extends OperationFunctionalSpecification fromCollection?.drop() } - @IgnoreIf({ serverVersionLessThan(3, 4) }) def '$facet'() { given: def helper = getCollectionHelper() @@ -612,7 +602,6 @@ class AggregatesFunctionalSpecification extends OperationFunctionalSpecification helper?.drop() } - @IgnoreIf({ serverVersionLessThan(3, 4) }) def '$graphLookup'() { given: def fromCollectionName = 'contacts' @@ -651,7 +640,6 @@ class AggregatesFunctionalSpecification extends OperationFunctionalSpecification fromHelper?.drop() } - @IgnoreIf({ serverVersionLessThan(3, 4) }) def '$graphLookup with depth options'() { given: def fromCollectionName = 'contacts' @@ -692,7 +680,6 @@ class AggregatesFunctionalSpecification extends OperationFunctionalSpecification fromHelper?.drop() } - @IgnoreIf({ serverVersionLessThan(3, 4) }) def '$graphLookup with query filter option'() { given: def fromCollectionName = 'contacts' @@ -743,7 +730,6 @@ class AggregatesFunctionalSpecification extends OperationFunctionalSpecification fromHelper?.drop() } - @IgnoreIf({ serverVersionLessThan(3, 4) }) def '$bucket'() { given: def helper = getCollectionHelper() @@ -777,7 +763,6 @@ class AggregatesFunctionalSpecification extends OperationFunctionalSpecification helper?.drop() } - @IgnoreIf({ serverVersionLessThan(3, 4) }) def '$bucketAuto'() { given: def helper = getCollectionHelper() @@ -811,7 +796,6 @@ class AggregatesFunctionalSpecification extends OperationFunctionalSpecification helper?.drop() } - @IgnoreIf({ serverVersionLessThan(3, 4) }) def '$bucketAuto with options'() { given: def helper = getCollectionHelper() @@ -837,7 +821,6 @@ class AggregatesFunctionalSpecification extends OperationFunctionalSpecification helper?.drop() } - @IgnoreIf({ serverVersionLessThan(3, 4) }) def '$count'() { given: def helper = getCollectionHelper() @@ -873,7 +856,6 @@ class AggregatesFunctionalSpecification extends OperationFunctionalSpecification helper?.drop() } - @IgnoreIf({ serverVersionLessThan(3, 4) }) def '$sortByCount'() { given: def helper = getCollectionHelper() @@ -952,7 +934,6 @@ class AggregatesFunctionalSpecification extends OperationFunctionalSpecification helper?.drop() } - @IgnoreIf({ serverVersionLessThan(3, 4) }) def '$addFields'() { given: def helper = getCollectionHelper() @@ -1026,7 +1007,6 @@ class AggregatesFunctionalSpecification extends OperationFunctionalSpecification helper?.drop() } - @IgnoreIf({ serverVersionLessThan(4, 2) }) def '$set'() { expect: aggregate([set(new Field('c', '$y'))]) == [new Document(a).append('c', 'a'), @@ -1034,7 +1014,6 @@ class AggregatesFunctionalSpecification extends OperationFunctionalSpecification new Document(c).append('c', 'c')] } - @IgnoreIf({ serverVersionLessThan(3, 4) }) def '$replaceRoot'() { given: def helper = getCollectionHelper() @@ -1065,7 +1044,6 @@ class AggregatesFunctionalSpecification extends OperationFunctionalSpecification results == [Document.parse('{b: 1, _id: 7}')] } - @IgnoreIf({ serverVersionLessThan(4, 2) }) def '$replaceWith'() { given: def helper = getCollectionHelper() diff --git a/driver-core/src/test/functional/com/mongodb/client/model/FiltersFunctionalSpecification.groovy b/driver-core/src/test/functional/com/mongodb/client/model/FiltersFunctionalSpecification.groovy index 777bcb7545c..ae24f4f7d6d 100644 --- a/driver-core/src/test/functional/com/mongodb/client/model/FiltersFunctionalSpecification.groovy +++ b/driver-core/src/test/functional/com/mongodb/client/model/FiltersFunctionalSpecification.groovy @@ -21,11 +21,9 @@ import com.mongodb.OperationFunctionalSpecification import org.bson.BsonType import org.bson.Document import org.bson.conversions.Bson -import spock.lang.IgnoreIf import java.util.regex.Pattern -import static com.mongodb.ClusterFixture.serverVersionLessThan import static com.mongodb.client.model.Filters.all import static com.mongodb.client.model.Filters.and import static com.mongodb.client.model.Filters.bitsAllClear @@ -228,7 +226,6 @@ class FiltersFunctionalSpecification extends OperationFunctionalSpecification { find(size('a', 4)) == [b] } - @IgnoreIf({ serverVersionLessThan(3, 2) }) def 'should render $bitsAllClear'() { when: def bitDoc = Document.parse('{_id: 1, bits: 20}') @@ -239,7 +236,6 @@ class FiltersFunctionalSpecification extends OperationFunctionalSpecification { find(bitsAllClear('bits', 35)) == [bitDoc] } - @IgnoreIf({ serverVersionLessThan(3, 2) }) def 'should render $bitsAllSet'() { when: def bitDoc = Document.parse('{_id: 1, bits: 54}') @@ -250,7 +246,6 @@ class FiltersFunctionalSpecification extends OperationFunctionalSpecification { find(bitsAllSet('bits', 50)) == [bitDoc] } - @IgnoreIf({ serverVersionLessThan(3, 2) }) def 'should render $bitsAnyClear'() { when: def bitDoc = Document.parse('{_id: 1, bits: 50}') @@ -261,7 +256,6 @@ class FiltersFunctionalSpecification extends OperationFunctionalSpecification { find(bitsAnyClear('bits', 20)) == [bitDoc] } - @IgnoreIf({ serverVersionLessThan(3, 2) }) def 'should render $bitsAnySet'() { when: def bitDoc = Document.parse('{_id: 1, bits: 20}') @@ -278,7 +272,6 @@ class FiltersFunctionalSpecification extends OperationFunctionalSpecification { find(type('x', BsonType.ARRAY)) == [] } - @IgnoreIf({ serverVersionLessThan(3, 2) }) def 'should render $type with a string type representation'() { expect: find(type('x', 'number')) == [a, b, c] @@ -299,7 +292,6 @@ class FiltersFunctionalSpecification extends OperationFunctionalSpecification { find(text('GIANT', new TextSearchOptions().language('english'))) == [textDocument] } - @IgnoreIf({ serverVersionLessThan(3, 2) }) def 'should render $text with 3.2 options'() { given: collectionHelper.drop() @@ -331,14 +323,12 @@ class FiltersFunctionalSpecification extends OperationFunctionalSpecification { find(where('Array.isArray(this.a)')) == [a, b] } - @IgnoreIf({ serverVersionLessThan(3, 6) }) def '$expr'() { expect: find(expr(Document.parse('{ $eq: [ "$x" , 3 ] } '))) == [c] } - @IgnoreIf({ serverVersionLessThan(3, 6) }) def '$jsonSchema'() { expect: find(jsonSchema(Document.parse('{ bsonType : "object", properties: { x : {type : "number", minimum : 2} } } '))) == [b, c] diff --git a/driver-core/src/test/functional/com/mongodb/client/model/mql/TypeMqlValuesFunctionalTest.java b/driver-core/src/test/functional/com/mongodb/client/model/mql/TypeMqlValuesFunctionalTest.java index 7df9748da1f..9083001cf99 100644 --- a/driver-core/src/test/functional/com/mongodb/client/model/mql/TypeMqlValuesFunctionalTest.java +++ b/driver-core/src/test/functional/com/mongodb/client/model/mql/TypeMqlValuesFunctionalTest.java @@ -173,7 +173,6 @@ public void isMapOrTest() { @Test public void asStringTest() { - assumeTrue(serverVersionAtLeast(4, 0)); // https://www.mongodb.com/docs/manual/reference/operator/aggregation/toString/ // asString, since toString conflicts assertExpression("false", of(false).asString(), "{'$toString': [false]}"); @@ -199,7 +198,6 @@ public void asStringTest() { @Test public void dateAsStringTest() { - assumeTrue(serverVersionAtLeast(4, 0)); // https://www.mongodb.com/docs/manual/reference/operator/aggregation/dateToString/ final Instant instant = Instant.parse("2007-12-03T10:15:30.005Z"); MqlDate date = of(instant); @@ -231,7 +229,6 @@ public void dateAsStringTest() { @Test public void parseDateTest() { - assumeTrue(serverVersionAtLeast(4, 0)); // https://www.mongodb.com/docs/manual/reference/operator/aggregation/dateToString/ String dateString = "2007-12-03T10:15:30.005Z"; assertExpression( @@ -270,7 +267,6 @@ public void parseDateTest() { @Test public void parseIntegerTest() { - assumeTrue(serverVersionAtLeast(4, 0)); // https://www.mongodb.com/docs/manual/reference/operator/aggregation/toInt/ // https://www.mongodb.com/docs/manual/reference/operator/aggregation/toLong/ assertExpression( @@ -310,7 +306,6 @@ public void parseIntegerTest() { @Test public void millisecondsToDateTest() { - assumeTrue(serverVersionAtLeast(4, 0)); // https://www.mongodb.com/docs/manual/reference/operator/aggregation/toDate/ assertExpression( Instant.ofEpochMilli(1234), diff --git a/driver-core/src/test/functional/com/mongodb/internal/connection/ScramSha256AuthenticationSpecification.groovy b/driver-core/src/test/functional/com/mongodb/internal/connection/ScramSha256AuthenticationSpecification.groovy index faffded597e..4901872c1fc 100644 --- a/driver-core/src/test/functional/com/mongodb/internal/connection/ScramSha256AuthenticationSpecification.groovy +++ b/driver-core/src/test/functional/com/mongodb/internal/connection/ScramSha256AuthenticationSpecification.groovy @@ -38,12 +38,11 @@ import static com.mongodb.ClusterFixture.createAsyncCluster import static com.mongodb.ClusterFixture.createCluster import static com.mongodb.ClusterFixture.getBinding import static com.mongodb.ClusterFixture.isAuthenticated -import static com.mongodb.ClusterFixture.serverVersionLessThan import static com.mongodb.MongoCredential.createCredential import static com.mongodb.MongoCredential.createScramSha1Credential import static com.mongodb.MongoCredential.createScramSha256Credential -@IgnoreIf({ serverVersionLessThan(4, 0) || !isAuthenticated() }) +@IgnoreIf({ (!isAuthenticated()) }) class ScramSha256AuthenticationSpecification extends Specification { static MongoCredential sha1Implicit = createCredential('sha1', 'admin', 'sha1'.toCharArray()) diff --git a/driver-core/src/test/functional/com/mongodb/internal/operation/AggregateOperationSpecification.groovy b/driver-core/src/test/functional/com/mongodb/internal/operation/AggregateOperationSpecification.groovy index 1f6d0f99e55..b0b6c360083 100644 --- a/driver-core/src/test/functional/com/mongodb/internal/operation/AggregateOperationSpecification.groovy +++ b/driver-core/src/test/functional/com/mongodb/internal/operation/AggregateOperationSpecification.groovy @@ -16,7 +16,6 @@ package com.mongodb.internal.operation - import com.mongodb.MongoNamespace import com.mongodb.OperationFunctionalSpecification import com.mongodb.ReadConcern @@ -25,7 +24,6 @@ import com.mongodb.ServerAddress import com.mongodb.WriteConcern import com.mongodb.client.model.Collation import com.mongodb.client.model.CreateCollectionOptions -import com.mongodb.client.model.Filters import com.mongodb.connection.ClusterId import com.mongodb.connection.ConnectionDescription import com.mongodb.connection.ConnectionId @@ -50,7 +48,6 @@ import org.bson.codecs.BsonDocumentCodec import org.bson.codecs.DocumentCodec import spock.lang.IgnoreIf -import static TestOperationHelper.getKeyPattern import static com.mongodb.ClusterFixture.OPERATION_CONTEXT import static com.mongodb.ClusterFixture.collectCursorResults import static com.mongodb.ClusterFixture.executeAsync @@ -59,13 +56,12 @@ import static com.mongodb.ClusterFixture.getBinding import static com.mongodb.ClusterFixture.getCluster import static com.mongodb.ClusterFixture.isSharded import static com.mongodb.ClusterFixture.isStandalone -import static com.mongodb.ClusterFixture.serverVersionAtLeast -import static com.mongodb.ClusterFixture.serverVersionLessThan import static com.mongodb.ExplainVerbosity.QUERY_PLANNER import static com.mongodb.connection.ServerType.STANDALONE import static com.mongodb.internal.connection.ServerHelper.waitForLastRelease import static com.mongodb.internal.operation.OperationReadConcernHelper.appendReadConcernToCommand import static com.mongodb.internal.operation.ServerVersionHelper.UNKNOWN_WIRE_VERSION +import static com.mongodb.internal.operation.TestOperationHelper.getKeyPattern class AggregateOperationSpecification extends OperationFunctionalSpecification { @@ -160,7 +156,6 @@ class AggregateOperationSpecification extends OperationFunctionalSpecification { async << [true, false] } - @IgnoreIf({ !serverVersionAtLeast(3, 4) }) def 'should support collation'() { given: def document = BsonDocument.parse('{_id: 1, str: "foo"}') @@ -179,13 +174,12 @@ class AggregateOperationSpecification extends OperationFunctionalSpecification { async << [true, false] } - @IgnoreIf({ !(serverVersionAtLeast(3, 6) && !isStandalone()) }) + @IgnoreIf({ isStandalone() }) def 'should support changeStreams'() { given: def expected = [createExpectedChangeNotification(namespace, 0), createExpectedChangeNotification(namespace, 1)] def pipeline = ['{$changeStream: {}}', '{$project: {"_id.clusterTime": 0, "_id.uuid": 0}}'].collect { BsonDocument.parse(it) } def operation = new AggregateOperation(namespace, pipeline, new BsonDocumentCodec()) - def helper = getCollectionHelper() when: helper.create(helper.getNamespace().getCollectionName(), new CreateCollectionOptions()) @@ -224,7 +218,6 @@ class AggregateOperationSpecification extends OperationFunctionalSpecification { async << [true, false] } - @IgnoreIf({ serverVersionLessThan(3, 4) }) def 'should be able to aggregate on a view'() { given: def viewSuffix = '-view' @@ -291,7 +284,6 @@ class AggregateOperationSpecification extends OperationFunctionalSpecification { batchSize << [null, 0, 10] } - @IgnoreIf({ serverVersionLessThan(3, 6) }) def 'should be able to explain an empty pipeline'() { given: def operation = new AggregateOperation(getNamespace(), [], new BsonDocumentCodec()) @@ -308,7 +300,6 @@ class AggregateOperationSpecification extends OperationFunctionalSpecification { async << [true, false] } - @IgnoreIf({ serverVersionLessThan(3, 4) }) def 'should be able to aggregate with collation'() { when: AggregateOperation operation = new AggregateOperation(getNamespace(), @@ -326,7 +317,6 @@ class AggregateOperationSpecification extends OperationFunctionalSpecification { } // Explain output keeps changing so only testing this in the range where the assertion still works - @IgnoreIf({ serverVersionLessThan(3, 6) || serverVersionAtLeast(4, 2) }) def 'should apply $hint'() { given: def index = new BsonDocument('a', new BsonInt32(1)) @@ -340,13 +330,13 @@ class AggregateOperationSpecification extends OperationFunctionalSpecification { BsonDocument explainPlan = execute(operation.asExplainableOperation(QUERY_PLANNER, new BsonDocumentCodec()), async) then: - getKeyPattern(explainPlan.getArray('stages').get(0).asDocument().getDocument('$cursor')) == index + getKeyPattern(explainPlan) == index where: [async, hint] << [[true, false], [BsonDocument.parse('{a: 1}'), new BsonString('a_1')]].combinations() } - @IgnoreIf({ isSharded() || serverVersionLessThan(3, 6) }) + @IgnoreIf({ isSharded() }) def 'should apply comment'() { given: def profileCollectionHelper = getCollectionHelper(new MongoNamespace(getDatabaseName(), 'system.profile')) diff --git a/driver-core/src/test/functional/com/mongodb/internal/operation/AggregateToCollectionOperationSpecification.groovy b/driver-core/src/test/functional/com/mongodb/internal/operation/AggregateToCollectionOperationSpecification.groovy index 496e7311949..d8a4f375ec6 100644 --- a/driver-core/src/test/functional/com/mongodb/internal/operation/AggregateToCollectionOperationSpecification.groovy +++ b/driver-core/src/test/functional/com/mongodb/internal/operation/AggregateToCollectionOperationSpecification.groovy @@ -16,17 +16,14 @@ package com.mongodb.internal.operation -import com.mongodb.MongoCommandException + import com.mongodb.MongoNamespace -import com.mongodb.MongoWriteConcernException import com.mongodb.OperationFunctionalSpecification import com.mongodb.ReadConcern import com.mongodb.ReadPreference import com.mongodb.WriteConcern import com.mongodb.client.model.Aggregates -import com.mongodb.client.model.CreateCollectionOptions import com.mongodb.client.model.Filters -import com.mongodb.client.model.ValidationOptions import com.mongodb.client.test.CollectionHelper import com.mongodb.internal.client.model.AggregationLevel import org.bson.BsonArray @@ -41,11 +38,8 @@ import org.bson.codecs.DocumentCodec import spock.lang.IgnoreIf import static com.mongodb.ClusterFixture.getBinding -import static com.mongodb.ClusterFixture.isDiscoverableReplicaSet import static com.mongodb.ClusterFixture.isSharded -import static com.mongodb.ClusterFixture.serverVersionLessThan import static com.mongodb.WriteConcern.ACKNOWLEDGED -import static com.mongodb.client.model.Filters.gte import static org.bson.codecs.configuration.CodecRegistries.fromProviders class AggregateToCollectionOperationSpecification extends OperationFunctionalSpecification { @@ -134,7 +128,6 @@ class AggregateToCollectionOperationSpecification extends OperationFunctionalSpe async << [true, false] } - @IgnoreIf({ serverVersionLessThan(4, 2) }) def 'should be able to merge into a collection'() { when: AggregateToCollectionOperation operation = createOperation(getNamespace(), @@ -162,60 +155,6 @@ class AggregateToCollectionOperationSpecification extends OperationFunctionalSpe async << [true, false] } - @IgnoreIf({ serverVersionLessThan(3, 4) || !isDiscoverableReplicaSet() }) - def 'should throw on write concern error'() { - given: - AggregateToCollectionOperation operation = createOperation(getNamespace(), - [new BsonDocument('$out', new BsonString(aggregateCollectionNamespace.collectionName))], - new WriteConcern(5)) - - when: - execute(operation, async) - - then: - def ex = thrown(MongoWriteConcernException) - ex.writeConcernError.code == 100 - ex.writeResult.wasAcknowledged() - - where: - async << [true, false] - } - - @IgnoreIf({ serverVersionLessThan(3, 2) }) - def 'should support bypassDocumentValidation'() { - given: - def collectionOutHelper = getCollectionHelper(new MongoNamespace(getDatabaseName(), 'collectionOut')) - collectionOutHelper.create('collectionOut', new CreateCollectionOptions().validationOptions( - new ValidationOptions().validator(gte('level', 10)))) - getCollectionHelper().insertDocuments(BsonDocument.parse('{ level: 9 }')) - - when: - AggregateToCollectionOperation operation = createOperation(getNamespace(), - [BsonDocument.parse('{$out: "collectionOut"}')], ACKNOWLEDGED) - execute(operation, async) - - then: - thrown(MongoCommandException) - - when: - execute(operation.bypassDocumentValidation(false), async) - - then: - thrown(MongoCommandException) - - when: - execute(operation.bypassDocumentValidation(true), async) - - then: - notThrown(MongoCommandException) - - cleanup: - collectionOutHelper?.drop() - - where: - async << [true, false] - } - def 'should create the expected command'() { when: def pipeline = [BsonDocument.parse('{$out: "collectionOut"}')] @@ -256,7 +195,6 @@ class AggregateToCollectionOperationSpecification extends OperationFunctionalSpe [3, 6, 0] | true | true | true | true | false | true | false } - @IgnoreIf({ serverVersionLessThan(3, 4) }) def 'should support collation'() { given: getCollectionHelper().insertDocuments(BsonDocument.parse('{_id: 1, str: "foo"}')) @@ -275,7 +213,7 @@ class AggregateToCollectionOperationSpecification extends OperationFunctionalSpe async << [true, false] } - @IgnoreIf({ isSharded() || serverVersionLessThan(3, 6) }) + @IgnoreIf({ isSharded() }) def 'should apply comment'() { given: def profileCollectionHelper = getCollectionHelper(new MongoNamespace(getDatabaseName(), 'system.profile')) diff --git a/driver-core/src/test/functional/com/mongodb/internal/operation/ChangeStreamOperationProseTestSpecification.groovy b/driver-core/src/test/functional/com/mongodb/internal/operation/ChangeStreamOperationProseTestSpecification.groovy index 7e3a66f9a1f..c7d3314b5b7 100644 --- a/driver-core/src/test/functional/com/mongodb/internal/operation/ChangeStreamOperationProseTestSpecification.groovy +++ b/driver-core/src/test/functional/com/mongodb/internal/operation/ChangeStreamOperationProseTestSpecification.groovy @@ -16,7 +16,7 @@ package com.mongodb.internal.operation -import com.mongodb.MongoChangeStreamException + import com.mongodb.MongoException import com.mongodb.MongoQueryException import com.mongodb.OperationFunctionalSpecification @@ -37,13 +37,11 @@ import static com.mongodb.ClusterFixture.getAsyncCluster import static com.mongodb.ClusterFixture.getCluster import static com.mongodb.ClusterFixture.isDiscoverableReplicaSet import static com.mongodb.ClusterFixture.isStandalone -import static com.mongodb.ClusterFixture.serverVersionAtLeast -import static com.mongodb.ClusterFixture.serverVersionLessThan import static com.mongodb.internal.connection.ServerHelper.waitForLastRelease import static java.util.Arrays.asList // See https://github.com/mongodb/specifications/tree/master/source/change-streams/tests/README.md#prose-tests -@IgnoreIf({ !(serverVersionAtLeast(3, 6) && !isStandalone()) }) +@IgnoreIf({ isStandalone() }) class ChangeStreamOperationProseTestSpecification extends OperationFunctionalSpecification { // @@ -65,11 +63,7 @@ class ChangeStreamOperationProseTestSpecification extends OperationFunctionalSpe def exception = thrown(MongoException) then: - if (serverVersionAtLeast(4, 2)) { - exception instanceof MongoQueryException - } else { - exception instanceof MongoChangeStreamException - } + exception instanceof MongoQueryException cleanup: cursor?.close() @@ -83,7 +77,7 @@ class ChangeStreamOperationProseTestSpecification extends OperationFunctionalSpe // Test that the ChangeStream will automatically resume one time on a resumable error (including not master) // with the initial pipeline and options, except for the addition/update of a resumeToken. // - @IgnoreIf({ serverVersionLessThan(4, 0) || !isDiscoverableReplicaSet() }) + @IgnoreIf({ !isDiscoverableReplicaSet() }) def 'should resume after single getMore Error'() { given: def helper = getHelper() diff --git a/driver-core/src/test/functional/com/mongodb/internal/operation/ChangeStreamOperationSpecification.groovy b/driver-core/src/test/functional/com/mongodb/internal/operation/ChangeStreamOperationSpecification.groovy index 48ce1ae6888..9134375ffec 100644 --- a/driver-core/src/test/functional/com/mongodb/internal/operation/ChangeStreamOperationSpecification.groovy +++ b/driver-core/src/test/functional/com/mongodb/internal/operation/ChangeStreamOperationSpecification.groovy @@ -56,14 +56,13 @@ import static com.mongodb.ClusterFixture.OPERATION_CONTEXT import static com.mongodb.ClusterFixture.getAsyncCluster import static com.mongodb.ClusterFixture.getCluster import static com.mongodb.ClusterFixture.isStandalone -import static com.mongodb.ClusterFixture.serverVersionAtLeast import static com.mongodb.ClusterFixture.serverVersionLessThan import static com.mongodb.client.model.changestream.ChangeStreamDocument.createCodec import static com.mongodb.internal.connection.ServerHelper.waitForLastRelease import static com.mongodb.internal.operation.OperationUnitSpecification.getMaxWireVersionForServerVersion import static org.bson.codecs.configuration.CodecRegistries.fromProviders -@IgnoreIf({ !(serverVersionAtLeast(3, 6) && !isStandalone()) }) +@IgnoreIf({ isStandalone() }) class ChangeStreamOperationSpecification extends OperationFunctionalSpecification { def 'should have the correct defaults'() { @@ -323,7 +322,6 @@ class ChangeStreamOperationSpecification extends OperationFunctionalSpecificatio waitForLastRelease(getCluster()) } - @IgnoreIf({ serverVersionLessThan(4, 0) }) def 'should decode drop to ChangeStreamDocument '() { given: def helper = getHelper() @@ -352,7 +350,6 @@ class ChangeStreamOperationSpecification extends OperationFunctionalSpecificatio waitForLastRelease(getCluster()) } - @IgnoreIf({ serverVersionLessThan(4, 0) }) def 'should decode dropDatabase to ChangeStreamDocument '() { given: def helper = getHelper() @@ -382,7 +379,6 @@ class ChangeStreamOperationSpecification extends OperationFunctionalSpecificatio waitForLastRelease(getCluster()) } - @IgnoreIf({ serverVersionLessThan(4, 0) }) def 'should decode rename to ChangeStreamDocument '() { given: def helper = getHelper() @@ -505,7 +501,6 @@ class ChangeStreamOperationSpecification extends OperationFunctionalSpecificatio async << [true, false] } - @IgnoreIf({ serverVersionLessThan(4, 0) }) def 'should work with a startAtOperationTime'() { given: def helper = getHelper() @@ -584,7 +579,6 @@ class ChangeStreamOperationSpecification extends OperationFunctionalSpecificatio async << [true, false] } - @IgnoreIf({ serverVersionLessThan(4, 2) }) def 'should work with a startAfter resumeToken'() { given: def helper = getHelper() diff --git a/driver-core/src/test/functional/com/mongodb/internal/operation/CountDocumentsOperationSpecification.groovy b/driver-core/src/test/functional/com/mongodb/internal/operation/CountDocumentsOperationSpecification.groovy index 564b2f96e26..8d13cba9f61 100644 --- a/driver-core/src/test/functional/com/mongodb/internal/operation/CountDocumentsOperationSpecification.groovy +++ b/driver-core/src/test/functional/com/mongodb/internal/operation/CountDocumentsOperationSpecification.groovy @@ -42,12 +42,10 @@ import org.bson.BsonString import org.bson.BsonTimestamp import org.bson.Document import org.bson.codecs.DocumentCodec -import spock.lang.IgnoreIf import static com.mongodb.ClusterFixture.OPERATION_CONTEXT import static com.mongodb.ClusterFixture.executeAsync import static com.mongodb.ClusterFixture.getBinding -import static com.mongodb.ClusterFixture.serverVersionAtLeast import static com.mongodb.connection.ServerType.STANDALONE import static com.mongodb.internal.operation.OperationReadConcernHelper.appendReadConcernToCommand import static com.mongodb.internal.operation.ServerVersionHelper.UNKNOWN_WIRE_VERSION @@ -150,7 +148,6 @@ class CountDocumentsOperationSpecification extends OperationFunctionalSpecificat async << [true, false] } - @IgnoreIf({ !serverVersionAtLeast(3, 6) }) def 'should use hint with the count'() { given: def indexDefinition = new BsonDocument('y', new BsonInt32(1)) @@ -168,7 +165,6 @@ class CountDocumentsOperationSpecification extends OperationFunctionalSpecificat async << [true, false] } - @IgnoreIf({ !serverVersionAtLeast(3, 6) }) def 'should support hints that are bson documents or strings'() { expect: execute(new CountDocumentsOperation(getNamespace()).hint(hint), async) == 5 @@ -240,7 +236,6 @@ class CountDocumentsOperationSpecification extends OperationFunctionalSpecificat [async, hint] << [[true, false], [new BsonString('hint_1'), BsonDocument.parse('{hint: 1}')]].combinations() } - @IgnoreIf({ !serverVersionAtLeast(3, 4) }) def 'should support collation'() { given: getCollectionHelper().insertDocuments(BsonDocument.parse('{str: "foo"}')) diff --git a/driver-core/src/test/functional/com/mongodb/internal/operation/CreateCollectionOperationSpecification.groovy b/driver-core/src/test/functional/com/mongodb/internal/operation/CreateCollectionOperationSpecification.groovy index cddb1925b64..b33ec785094 100644 --- a/driver-core/src/test/functional/com/mongodb/internal/operation/CreateCollectionOperationSpecification.groovy +++ b/driver-core/src/test/functional/com/mongodb/internal/operation/CreateCollectionOperationSpecification.groovy @@ -30,7 +30,6 @@ import spock.lang.IgnoreIf import static com.mongodb.ClusterFixture.getBinding import static com.mongodb.ClusterFixture.isDiscoverableReplicaSet -import static com.mongodb.ClusterFixture.serverVersionAtLeast import static com.mongodb.ClusterFixture.serverVersionLessThan import static java.util.Collections.singletonList @@ -53,7 +52,6 @@ class CreateCollectionOperationSpecification extends OperationFunctionalSpecific operation.getCollation() == null } - @IgnoreIf({ serverVersionLessThan(3, 0) }) def 'should set optional values correctly'(){ given: def storageEngineOptions = BsonDocument.parse('{ wiredTiger : {}}') @@ -101,13 +99,9 @@ class CreateCollectionOperationSpecification extends OperationFunctionalSpecific async << [true, false] } - @IgnoreIf({ serverVersionLessThan(3, 0) }) def 'should pass through storage engine options'() { given: def storageEngineOptions = new BsonDocument('wiredTiger', new BsonDocument('configString', new BsonString('block_compressor=zlib'))) - if (serverVersionLessThan(4, 2)) { - storageEngineOptions.append('mmapv1', new BsonDocument()) - } def operation = createOperation() .storageEngineOptions(storageEngineOptions) @@ -123,13 +117,9 @@ class CreateCollectionOperationSpecification extends OperationFunctionalSpecific async << [true, false] } - @IgnoreIf({ serverVersionLessThan(4, 2) }) def 'should pass through storage engine options- zstd compression'() { given: def storageEngineOptions = new BsonDocument('wiredTiger', new BsonDocument('configString', new BsonString('block_compressor=zstd'))) - if (serverVersionLessThan(4, 2)) { - storageEngineOptions.append('mmapv1', new BsonDocument()) - } def operation = createOperation() .storageEngineOptions(storageEngineOptions) @@ -172,28 +162,6 @@ class CreateCollectionOperationSpecification extends OperationFunctionalSpecific async << [true, false] } - @IgnoreIf({ serverVersionAtLeast(4, 0) }) - def 'should create collection in respect to the autoIndex option'() { - given: - assert !collectionNameExists(getCollectionName()) - def operation = createOperation() - .autoIndex(autoIndex) - - when: - execute(operation, async) - - then: - storageStats().getInt32('nindexes').intValue() == expectedNumberOfIndexes - - where: - autoIndex | expectedNumberOfIndexes | async - true | 1 | true - true | 1 | false - false | 0 | true - false | 0 | false - } - - @IgnoreIf({ serverVersionLessThan(3, 2) }) def 'should allow indexOptionDefaults'() { given: assert !collectionNameExists(getCollectionName()) @@ -212,7 +180,6 @@ class CreateCollectionOperationSpecification extends OperationFunctionalSpecific } - @IgnoreIf({ serverVersionLessThan(3, 2) }) def 'should allow validator'() { given: assert !collectionNameExists(getCollectionName()) @@ -242,7 +209,7 @@ class CreateCollectionOperationSpecification extends OperationFunctionalSpecific async << [true, false] } - @IgnoreIf({ serverVersionLessThan(3, 4) || !isDiscoverableReplicaSet() }) + @IgnoreIf({ !isDiscoverableReplicaSet() }) def 'should throw on write concern error'() { given: assert !collectionNameExists(getCollectionName()) @@ -260,7 +227,6 @@ class CreateCollectionOperationSpecification extends OperationFunctionalSpecific async << [true, false] } - @IgnoreIf({ serverVersionLessThan(3, 4) }) def 'should be able to create a collection with a collation'() { given: def operation = createOperation().collation(defaultCollation) diff --git a/driver-core/src/test/functional/com/mongodb/internal/operation/CreateIndexesOperationSpecification.groovy b/driver-core/src/test/functional/com/mongodb/internal/operation/CreateIndexesOperationSpecification.groovy index 389f4388b54..78a9914e022 100644 --- a/driver-core/src/test/functional/com/mongodb/internal/operation/CreateIndexesOperationSpecification.groovy +++ b/driver-core/src/test/functional/com/mongodb/internal/operation/CreateIndexesOperationSpecification.groovy @@ -177,22 +177,6 @@ class CreateIndexesOperationSpecification extends OperationFunctionalSpecificati async << [true, false] } - @IgnoreIf({ serverVersionAtLeast(3, 0) }) - def 'should drop duplicates'() { - given: - getCollectionHelper().insertDocuments(new DocumentCodec(), x1, x1) - def operation = createOperation([new IndexRequest(new BsonDocument('x', new BsonInt32(1))).unique(true).dropDups(true)]) - - when: - execute(operation, async) - - then: - getCollectionHelper().count() == 1 - - where: - async << [true, false] - } - def 'should throw when trying to build an invalid index'() { given: def operation = createOperation([new IndexRequest(new BsonDocument())]) @@ -376,7 +360,6 @@ class CreateIndexesOperationSpecification extends OperationFunctionalSpecificati async << [true, false] } - @IgnoreIf({ serverVersionLessThan(3, 0) }) def 'should pass through storage engine options'() { given: def storageEngineOptions = new Document('wiredTiger', new Document('configString', 'block_compressor=zlib')) @@ -393,7 +376,6 @@ class CreateIndexesOperationSpecification extends OperationFunctionalSpecificati async << [true, false] } - @IgnoreIf({ serverVersionLessThan(3, 2) }) def 'should be able to create a partially filtered index'() { given: def partialFilterExpression = new Document('a', new Document('$gte', 10)) @@ -411,7 +393,7 @@ class CreateIndexesOperationSpecification extends OperationFunctionalSpecificati async << [true, false] } - @IgnoreIf({ serverVersionLessThan(3, 4) || !isDiscoverableReplicaSet() }) + @IgnoreIf({ !isDiscoverableReplicaSet() }) def 'should throw on write concern error'() { given: def keys = new BsonDocument('field', new BsonInt32(1)) @@ -429,7 +411,6 @@ class CreateIndexesOperationSpecification extends OperationFunctionalSpecificati async << [true, false] } - @IgnoreIf({ serverVersionLessThan(3, 4) }) def 'should be able to create an index with collation'() { given: def operation = createOperation([new IndexRequest(new BsonDocument('a', new BsonInt32(1))).collation(defaultCollation)]) @@ -446,7 +427,6 @@ class CreateIndexesOperationSpecification extends OperationFunctionalSpecificati async << [true, false] } - @IgnoreIf({ serverVersionLessThan(4, 2) }) def 'should be able to create wildcard indexes'() { given: def operation = createOperation([new IndexRequest(new BsonDocument('$**', new BsonInt32(1))), @@ -463,7 +443,6 @@ class CreateIndexesOperationSpecification extends OperationFunctionalSpecificati async << [true, false] } - @IgnoreIf({ serverVersionLessThan(4, 2) }) def 'should be able to create wildcard index with projection'() { given: def operation = createOperation([new IndexRequest(new BsonDocument('$**', new BsonInt32(1))) diff --git a/driver-core/src/test/functional/com/mongodb/internal/operation/CreateViewOperationSpecification.groovy b/driver-core/src/test/functional/com/mongodb/internal/operation/CreateViewOperationSpecification.groovy index 52ad4334493..07a35800242 100644 --- a/driver-core/src/test/functional/com/mongodb/internal/operation/CreateViewOperationSpecification.groovy +++ b/driver-core/src/test/functional/com/mongodb/internal/operation/CreateViewOperationSpecification.groovy @@ -16,7 +16,7 @@ package com.mongodb.internal.operation -import com.mongodb.MongoClientException + import com.mongodb.MongoNamespace import com.mongodb.MongoWriteConcernException import com.mongodb.OperationFunctionalSpecification @@ -31,12 +31,9 @@ import spock.lang.IgnoreIf import static com.mongodb.ClusterFixture.getBinding import static com.mongodb.ClusterFixture.isDiscoverableReplicaSet -import static com.mongodb.ClusterFixture.serverVersionAtLeast -import static com.mongodb.ClusterFixture.serverVersionLessThan class CreateViewOperationSpecification extends OperationFunctionalSpecification { - @IgnoreIf({ serverVersionLessThan(3, 4) }) def 'should create view'() { given: def viewOn = getCollectionName() @@ -70,7 +67,6 @@ class CreateViewOperationSpecification extends OperationFunctionalSpecification async << [true, false] } - @IgnoreIf({ serverVersionLessThan(3, 4) }) def 'should create view with collation'() { given: def viewOn = getCollectionName() @@ -99,23 +95,7 @@ class CreateViewOperationSpecification extends OperationFunctionalSpecification async << [true, false] } - @IgnoreIf({ serverVersionAtLeast(3, 4) }) - def 'should throw if server version is not 3.4 or greater'() { - given: - def operation = new CreateViewOperation(getDatabaseName(), getCollectionName() + '-view', - getCollectionName(), [], WriteConcern.ACKNOWLEDGED) - - when: - execute(operation, async) - - then: - thrown(MongoClientException) - - where: - async << [true, false] - } - - @IgnoreIf({ serverVersionLessThan(3, 4) || !isDiscoverableReplicaSet() }) + @IgnoreIf({ !isDiscoverableReplicaSet() }) def 'should throw on write concern error'() { given: def viewName = getCollectionName() + '-view' diff --git a/driver-core/src/test/functional/com/mongodb/internal/operation/DistinctOperationSpecification.groovy b/driver-core/src/test/functional/com/mongodb/internal/operation/DistinctOperationSpecification.groovy index 27f9507def4..726a3723df5 100644 --- a/driver-core/src/test/functional/com/mongodb/internal/operation/DistinctOperationSpecification.groovy +++ b/driver-core/src/test/functional/com/mongodb/internal/operation/DistinctOperationSpecification.groovy @@ -49,11 +49,9 @@ import org.bson.codecs.DocumentCodecProvider import org.bson.codecs.StringCodec import org.bson.codecs.ValueCodecProvider import org.bson.types.ObjectId -import spock.lang.IgnoreIf import static com.mongodb.ClusterFixture.OPERATION_CONTEXT import static com.mongodb.ClusterFixture.executeAsync -import static com.mongodb.ClusterFixture.serverVersionLessThan import static com.mongodb.connection.ServerType.STANDALONE import static com.mongodb.internal.operation.OperationReadConcernHelper.appendReadConcernToCommand import static com.mongodb.internal.operation.ServerVersionHelper.UNKNOWN_WIRE_VERSION @@ -207,7 +205,6 @@ class DistinctOperationSpecification extends OperationFunctionalSpecification { async << [false, false] } - @IgnoreIf({ serverVersionLessThan(3, 4) }) def 'should support collation'() { given: def document = Document.parse('{str: "foo"}') diff --git a/driver-core/src/test/functional/com/mongodb/internal/operation/DropCollectionOperationSpecification.groovy b/driver-core/src/test/functional/com/mongodb/internal/operation/DropCollectionOperationSpecification.groovy index 67124fecf30..164dc66d654 100644 --- a/driver-core/src/test/functional/com/mongodb/internal/operation/DropCollectionOperationSpecification.groovy +++ b/driver-core/src/test/functional/com/mongodb/internal/operation/DropCollectionOperationSpecification.groovy @@ -27,7 +27,6 @@ import spock.lang.IgnoreIf import static com.mongodb.ClusterFixture.executeAsync import static com.mongodb.ClusterFixture.getBinding import static com.mongodb.ClusterFixture.isDiscoverableReplicaSet -import static com.mongodb.ClusterFixture.serverVersionLessThan class DropCollectionOperationSpecification extends OperationFunctionalSpecification { @@ -79,7 +78,7 @@ class DropCollectionOperationSpecification extends OperationFunctionalSpecificat !collectionNameExists('nonExistingCollection') } - @IgnoreIf({ serverVersionLessThan(3, 4) || !isDiscoverableReplicaSet() }) + @IgnoreIf({ !isDiscoverableReplicaSet() }) def 'should throw on write concern error'() { given: getCollectionHelper().insertDocuments(new DocumentCodec(), new Document('documentTo', 'createTheCollection')) diff --git a/driver-core/src/test/functional/com/mongodb/internal/operation/DropDatabaseOperationSpecification.groovy b/driver-core/src/test/functional/com/mongodb/internal/operation/DropDatabaseOperationSpecification.groovy index 61648c1daec..f1464e22160 100644 --- a/driver-core/src/test/functional/com/mongodb/internal/operation/DropDatabaseOperationSpecification.groovy +++ b/driver-core/src/test/functional/com/mongodb/internal/operation/DropDatabaseOperationSpecification.groovy @@ -16,7 +16,6 @@ package com.mongodb.internal.operation - import com.mongodb.MongoWriteConcernException import com.mongodb.OperationFunctionalSpecification import com.mongodb.WriteConcern @@ -30,8 +29,6 @@ import static com.mongodb.ClusterFixture.executeAsync import static com.mongodb.ClusterFixture.getBinding import static com.mongodb.ClusterFixture.isDiscoverableReplicaSet import static com.mongodb.ClusterFixture.isSharded -import static com.mongodb.ClusterFixture.serverVersionAtLeast -import static com.mongodb.ClusterFixture.serverVersionLessThan class DropDatabaseOperationSpecification extends OperationFunctionalSpecification { @@ -66,20 +63,18 @@ class DropDatabaseOperationSpecification extends OperationFunctionalSpecificatio async << [true, false] } - @IgnoreIf({ serverVersionLessThan(3, 4) || !isDiscoverableReplicaSet() }) + @IgnoreIf({ !isDiscoverableReplicaSet() }) def 'should throw on write concern error'() { given: getCollectionHelper().insertDocuments(new DocumentCodec(), new Document('documentTo', 'createTheCollection')) // On servers older than 4.0 that don't support this failpoint, use a crazy w value instead - def w = serverVersionAtLeast(4, 0) ? 2 : 5 + def w = 2 def operation = new DropDatabaseOperation(databaseName, new WriteConcern(w)) - if (serverVersionAtLeast(4, 0)) { - configureFailPoint(BsonDocument.parse('{ configureFailPoint: "failCommand", ' + - 'mode : {times : 1}, ' + - 'data : {failCommands : ["dropDatabase"], ' + - 'writeConcernError : {code : 100, errmsg : "failed"}}}')) - } + configureFailPoint(BsonDocument.parse('{ configureFailPoint: "failCommand", ' + + 'mode : {times : 1}, ' + + 'data : {failCommands : ["dropDatabase"], ' + + 'writeConcernError : {code : 100, errmsg : "failed"}}}')) when: async ? executeAsync(operation) : operation.execute(getBinding()) diff --git a/driver-core/src/test/functional/com/mongodb/internal/operation/DropIndexOperationSpecification.groovy b/driver-core/src/test/functional/com/mongodb/internal/operation/DropIndexOperationSpecification.groovy index a051231af7e..611c0197faf 100644 --- a/driver-core/src/test/functional/com/mongodb/internal/operation/DropIndexOperationSpecification.groovy +++ b/driver-core/src/test/functional/com/mongodb/internal/operation/DropIndexOperationSpecification.groovy @@ -31,7 +31,6 @@ import spock.lang.Unroll import static com.mongodb.ClusterFixture.getBinding import static com.mongodb.ClusterFixture.isDiscoverableReplicaSet -import static com.mongodb.ClusterFixture.serverVersionLessThan class DropIndexOperationSpecification extends OperationFunctionalSpecification { @@ -135,7 +134,7 @@ class DropIndexOperationSpecification extends OperationFunctionalSpecification { async << [true, false] } - @IgnoreIf({ serverVersionLessThan(3, 4) || !isDiscoverableReplicaSet() }) + @IgnoreIf({ !isDiscoverableReplicaSet() }) def 'should throw on write concern error'() { given: collectionHelper.createIndex(new BsonDocument('theField', new BsonInt32(1))) diff --git a/driver-core/src/test/functional/com/mongodb/internal/operation/FindAndDeleteOperationSpecification.groovy b/driver-core/src/test/functional/com/mongodb/internal/operation/FindAndDeleteOperationSpecification.groovy index ccc9614d1fb..64c6123a84b 100644 --- a/driver-core/src/test/functional/com/mongodb/internal/operation/FindAndDeleteOperationSpecification.groovy +++ b/driver-core/src/test/functional/com/mongodb/internal/operation/FindAndDeleteOperationSpecification.groovy @@ -39,7 +39,6 @@ import static com.mongodb.ClusterFixture.disableFailPoint import static com.mongodb.ClusterFixture.disableOnPrimaryTransactionalWriteFailPoint import static com.mongodb.ClusterFixture.enableOnPrimaryTransactionalWriteFailPoint import static com.mongodb.ClusterFixture.isDiscoverableReplicaSet -import static com.mongodb.ClusterFixture.serverVersionLessThan import static com.mongodb.WriteConcern.ACKNOWLEDGED import static com.mongodb.WriteConcern.UNACKNOWLEDGED import static com.mongodb.WriteConcern.W1 @@ -127,7 +126,7 @@ class FindAndDeleteOperationSpecification extends OperationFunctionalSpecificati } - @IgnoreIf({ serverVersionLessThan(3, 2) || !isDiscoverableReplicaSet() }) + @IgnoreIf({ !isDiscoverableReplicaSet() }) def 'should throw on write concern error'() { given: CollectionHelper helper = new CollectionHelper(documentCodec, getNamespace()) @@ -151,7 +150,7 @@ class FindAndDeleteOperationSpecification extends OperationFunctionalSpecificati async << [true, false] } - @IgnoreIf({ serverVersionLessThan(3, 8) || !isDiscoverableReplicaSet() }) + @IgnoreIf({ !isDiscoverableReplicaSet() }) def 'should throw on write concern error on multiple failpoint'() { given: CollectionHelper helper = new CollectionHelper(documentCodec, getNamespace()) @@ -236,7 +235,7 @@ class FindAndDeleteOperationSpecification extends OperationFunctionalSpecificati ].combinations() } - @IgnoreIf({ serverVersionLessThan(3, 6) || !isDiscoverableReplicaSet() }) + @IgnoreIf({ !isDiscoverableReplicaSet() }) def 'should support retryable writes'() { given: Document pete = new Document('name', 'Pete').append('job', 'handyman') @@ -303,7 +302,6 @@ class FindAndDeleteOperationSpecification extends OperationFunctionalSpecificati async << [false] } - @IgnoreIf({ serverVersionLessThan(3, 4) }) def 'should support collation'() { given: def document = Document.parse('{_id: 1, str: "foo"}') diff --git a/driver-core/src/test/functional/com/mongodb/internal/operation/FindAndReplaceOperationSpecification.groovy b/driver-core/src/test/functional/com/mongodb/internal/operation/FindAndReplaceOperationSpecification.groovy index 4c334fa0ea0..50dd68fa810 100644 --- a/driver-core/src/test/functional/com/mongodb/internal/operation/FindAndReplaceOperationSpecification.groovy +++ b/driver-core/src/test/functional/com/mongodb/internal/operation/FindAndReplaceOperationSpecification.groovy @@ -45,7 +45,6 @@ import static com.mongodb.ClusterFixture.disableFailPoint import static com.mongodb.ClusterFixture.disableOnPrimaryTransactionalWriteFailPoint import static com.mongodb.ClusterFixture.enableOnPrimaryTransactionalWriteFailPoint import static com.mongodb.ClusterFixture.isDiscoverableReplicaSet -import static com.mongodb.ClusterFixture.serverVersionLessThan import static com.mongodb.WriteConcern.ACKNOWLEDGED import static com.mongodb.WriteConcern.UNACKNOWLEDGED import static com.mongodb.WriteConcern.W1 @@ -197,7 +196,6 @@ class FindAndReplaceOperationSpecification extends OperationFunctionalSpecificat async << [true, false] } - @IgnoreIf({ serverVersionLessThan(3, 2) }) def 'should support bypassDocumentValidation'() { given: def namespace = new MongoNamespace(getDatabaseName(), 'collectionOut') @@ -237,7 +235,7 @@ class FindAndReplaceOperationSpecification extends OperationFunctionalSpecificat async << [true, false] } - @IgnoreIf({ serverVersionLessThan(3, 2) || !isDiscoverableReplicaSet() }) + @IgnoreIf({ !isDiscoverableReplicaSet() }) def 'should throw on write concern error'() { given: CollectionHelper helper = new CollectionHelper(documentCodec, getNamespace()) @@ -279,7 +277,7 @@ class FindAndReplaceOperationSpecification extends OperationFunctionalSpecificat } - @IgnoreIf({ serverVersionLessThan(3, 8) || !isDiscoverableReplicaSet() }) + @IgnoreIf({ !isDiscoverableReplicaSet() }) def 'should throw on write concern error on multiple failpoint'() { CollectionHelper helper = new CollectionHelper(documentCodec, getNamespace()) Document pete = new Document('name', 'Pete').append('job', 'handyman') @@ -366,7 +364,7 @@ class FindAndReplaceOperationSpecification extends OperationFunctionalSpecificat ].combinations() } - @IgnoreIf({ serverVersionLessThan(3, 6) || !isDiscoverableReplicaSet() }) + @IgnoreIf({ !isDiscoverableReplicaSet() }) def 'should support retryable writes'() { given: CollectionHelper helper = new CollectionHelper(documentCodec, getNamespace()) @@ -441,7 +439,6 @@ class FindAndReplaceOperationSpecification extends OperationFunctionalSpecificat async << [true, false] } - @IgnoreIf({ serverVersionLessThan(3, 4) }) def 'should support collation'() { given: def document = Document.parse('{_id: 1, str: "foo"}') diff --git a/driver-core/src/test/functional/com/mongodb/internal/operation/FindAndUpdateOperationSpecification.groovy b/driver-core/src/test/functional/com/mongodb/internal/operation/FindAndUpdateOperationSpecification.groovy index 821eacbee6e..292d5bb471e 100644 --- a/driver-core/src/test/functional/com/mongodb/internal/operation/FindAndUpdateOperationSpecification.groovy +++ b/driver-core/src/test/functional/com/mongodb/internal/operation/FindAndUpdateOperationSpecification.groovy @@ -46,7 +46,6 @@ import static com.mongodb.ClusterFixture.disableFailPoint import static com.mongodb.ClusterFixture.disableOnPrimaryTransactionalWriteFailPoint import static com.mongodb.ClusterFixture.enableOnPrimaryTransactionalWriteFailPoint import static com.mongodb.ClusterFixture.isDiscoverableReplicaSet -import static com.mongodb.ClusterFixture.serverVersionLessThan import static com.mongodb.WriteConcern.ACKNOWLEDGED import static com.mongodb.WriteConcern.UNACKNOWLEDGED import static com.mongodb.WriteConcern.W1 @@ -77,7 +76,6 @@ class FindAndUpdateOperationSpecification extends OperationFunctionalSpecificati operation.getCollation() == null } - @IgnoreIf({ serverVersionLessThan(4, 2) }) def 'should have the correct defaults and passed values using update pipelines'() { when: def updatePipeline = new BsonArray(singletonList(new BsonDocument('update', new BsonInt32(1)))) @@ -121,7 +119,6 @@ class FindAndUpdateOperationSpecification extends OperationFunctionalSpecificati operation.getCollation() == defaultCollation } - @IgnoreIf({ serverVersionLessThan(4, 2) }) def 'should set optional values correctly when using update pipelines'(){ given: def filter = new BsonDocument('filter', new BsonInt32(1)) @@ -183,7 +180,6 @@ class FindAndUpdateOperationSpecification extends OperationFunctionalSpecificati async << [true, false] } - @IgnoreIf({ serverVersionLessThan(4, 2) }) def 'should add field using update pipeline'() { given: CollectionHelper helper = new CollectionHelper(documentCodec, getNamespace()) @@ -250,7 +246,6 @@ class FindAndUpdateOperationSpecification extends OperationFunctionalSpecificati async << [true, false] } - @IgnoreIf({ serverVersionLessThan(4, 2) }) def 'should update using pipeline when using custom codecs'() { given: CollectionHelper helper = new CollectionHelper(documentCodec, getNamespace()) @@ -305,7 +300,6 @@ class FindAndUpdateOperationSpecification extends OperationFunctionalSpecificati async << [true, false] } - @IgnoreIf({ serverVersionLessThan(4, 2) }) def 'should throw an exception if update pipeline contains operations that are not supported'() { when: def update = new BsonArray(singletonList(new BsonDocument('$foo', new BsonDocument('x', new BsonInt32(1))))) @@ -327,7 +321,6 @@ class FindAndUpdateOperationSpecification extends OperationFunctionalSpecificati async << [true, false] } - @IgnoreIf({ serverVersionLessThan(3, 2) }) def 'should support bypassDocumentValidation'() { given: def namespace = new MongoNamespace(getDatabaseName(), 'collectionOut') @@ -367,7 +360,7 @@ class FindAndUpdateOperationSpecification extends OperationFunctionalSpecificati async << [true, false] } - @IgnoreIf({ serverVersionLessThan(3, 2) || !isDiscoverableReplicaSet() }) + @IgnoreIf({ !isDiscoverableReplicaSet() }) def 'should throw on write concern error'() { given: getCollectionHelper().insertDocuments(new DocumentCodec(), new Document('name', 'Pete')) @@ -404,7 +397,7 @@ class FindAndUpdateOperationSpecification extends OperationFunctionalSpecificati async << [true, false] } - @IgnoreIf({ serverVersionLessThan(3, 8) || !isDiscoverableReplicaSet() }) + @IgnoreIf({ !isDiscoverableReplicaSet() }) def 'should throw on write concern error on multiple failpoint'() { given: CollectionHelper helper = new CollectionHelper(documentCodec, getNamespace()) @@ -492,7 +485,7 @@ class FindAndUpdateOperationSpecification extends OperationFunctionalSpecificati ].combinations() } - @IgnoreIf({ serverVersionLessThan(3, 6) || !isDiscoverableReplicaSet() }) + @IgnoreIf({ !isDiscoverableReplicaSet() }) def 'should support retryable writes'() { given: CollectionHelper helper = new CollectionHelper(documentCodec, getNamespace()) @@ -568,7 +561,6 @@ class FindAndUpdateOperationSpecification extends OperationFunctionalSpecificati async << [true, false] } - @IgnoreIf({ serverVersionLessThan(3, 4) }) def 'should support collation'() { given: def document = Document.parse('{_id: 1, str: "foo"}') @@ -589,7 +581,6 @@ class FindAndUpdateOperationSpecification extends OperationFunctionalSpecificati async << [true, false] } - @IgnoreIf({ serverVersionLessThan(3, 6) }) def 'should support array filters'() { given: def documentOne = Document.parse('{_id: 1, y: [ {b: 3}, {b: 1}]}') diff --git a/driver-core/src/test/functional/com/mongodb/internal/operation/FindOperationSpecification.groovy b/driver-core/src/test/functional/com/mongodb/internal/operation/FindOperationSpecification.groovy index df1fae76bc4..f61ab70f2ae 100644 --- a/driver-core/src/test/functional/com/mongodb/internal/operation/FindOperationSpecification.groovy +++ b/driver-core/src/test/functional/com/mongodb/internal/operation/FindOperationSpecification.groovy @@ -60,7 +60,6 @@ import static com.mongodb.ClusterFixture.getAsyncCluster import static com.mongodb.ClusterFixture.getBinding import static com.mongodb.ClusterFixture.getCluster import static com.mongodb.ClusterFixture.isSharded -import static com.mongodb.ClusterFixture.serverVersionAtLeast import static com.mongodb.ClusterFixture.serverVersionLessThan import static com.mongodb.CursorType.NonTailable import static com.mongodb.CursorType.Tailable @@ -362,7 +361,6 @@ class FindOperationSpecification extends OperationFunctionalSpecification { async << [true, false] } - @IgnoreIf({ serverVersionLessThan(3, 2) }) def 'should apply $hint'() { given: def index = new BsonDocument('a', new BsonInt32(1)) @@ -398,13 +396,7 @@ class FindOperationSpecification extends OperationFunctionalSpecification { then: Document profileDocument = profileCollectionHelper.find().get(0) - if (serverVersionAtLeast(3, 6)) { - assertEquals(expectedComment, ((Document) profileDocument.get('command')).get('comment')) - } else if (serverVersionAtLeast(3, 2)) { - assertEquals(expectedComment, ((Document) profileDocument.get('query')).get('comment')) - } else { - assertEquals(expectedComment, ((Document) profileDocument.get('query')).get('$comment')) - } + assertEquals(expectedComment, ((Document) profileDocument.get('command')).get('comment')) cleanup: new CommandReadOperation<>(getDatabaseName(), new BsonDocument('profile', new BsonInt32(0)), @@ -418,7 +410,7 @@ class FindOperationSpecification extends OperationFunctionalSpecification { def 'should apply $showDiskLoc'() { given: - String fieldName = serverVersionAtLeast(3, 2) ? '$recordId' : '$diskLoc' + String fieldName = '$recordId' collectionHelper.insertDocuments(new BsonDocument()) def operation = new FindOperation(getNamespace(), new DocumentCodec()) @@ -693,7 +685,6 @@ class FindOperationSpecification extends OperationFunctionalSpecification { async << [true, false] } - @IgnoreIf({ serverVersionLessThan(3, 4) }) def 'should support collation'() { given: def document = BsonDocument.parse('{_id: 1, str: "foo"}') diff --git a/driver-core/src/test/functional/com/mongodb/internal/operation/ListCollectionsOperationSpecification.groovy b/driver-core/src/test/functional/com/mongodb/internal/operation/ListCollectionsOperationSpecification.groovy index 07a3fadc5fd..0d2688e0da6 100644 --- a/driver-core/src/test/functional/com/mongodb/internal/operation/ListCollectionsOperationSpecification.groovy +++ b/driver-core/src/test/functional/com/mongodb/internal/operation/ListCollectionsOperationSpecification.groovy @@ -16,7 +16,6 @@ package com.mongodb.internal.operation - import com.mongodb.MongoNamespace import com.mongodb.OperationFunctionalSpecification import com.mongodb.ReadPreference @@ -38,18 +37,14 @@ import org.bson.BsonBoolean import org.bson.BsonDocument import org.bson.BsonDouble import org.bson.BsonInt64 -import org.bson.BsonRegularExpression import org.bson.BsonString import org.bson.Document import org.bson.codecs.Decoder import org.bson.codecs.DocumentCodec -import spock.lang.IgnoreIf import static com.mongodb.ClusterFixture.OPERATION_CONTEXT import static com.mongodb.ClusterFixture.executeAsync import static com.mongodb.ClusterFixture.getBinding -import static com.mongodb.ClusterFixture.serverVersionAtLeast -import static com.mongodb.ClusterFixture.serverVersionLessThan class ListCollectionsOperationSpecification extends OperationFunctionalSpecification { @@ -106,19 +101,6 @@ class ListCollectionsOperationSpecification extends OperationFunctionalSpecifica names.findAll { it.contains('$') }.isEmpty() } - @IgnoreIf({ serverVersionAtLeast(3, 0) }) - def 'should throw if filtering on name with something other than a string'() { - given: - def operation = new ListCollectionsOperation(databaseName, new DocumentCodec()) - .filter(new BsonDocument('name', new BsonRegularExpression('^[^$]*$'))) - - when: - operation.execute(getBinding()) - - then: - thrown(IllegalArgumentException) - } - def 'should filter collection names if a name filter is specified'() { given: def operation = new ListCollectionsOperation(databaseName, new DocumentCodec()) @@ -158,21 +140,6 @@ class ListCollectionsOperationSpecification extends OperationFunctionalSpecifica !names.contains(collectionName) } - @IgnoreIf({ serverVersionLessThan(3, 4) || serverVersionAtLeast(4, 0) }) - def 'should get all fields when nameOnly is not requested'() { - given: - def operation = new ListCollectionsOperation(databaseName, new DocumentCodec()) - getCollectionHelper().create('collection4', new CreateCollectionOptions()) - - when: - def cursor = operation.execute(getBinding()) - def collection = cursor.next()[0] - - then: - collection.size() > 2 - } - - @IgnoreIf({ serverVersionLessThan(4, 0) }) def 'should only get collection names when nameOnly is requested'() { given: def operation = new ListCollectionsOperation(databaseName, new DocumentCodec()) @@ -187,7 +154,6 @@ class ListCollectionsOperationSpecification extends OperationFunctionalSpecifica collection.size() == 2 } - @IgnoreIf({ serverVersionLessThan(4, 0) }) def 'should only get collection names when nameOnly and authorizedCollections are requested'() { given: def operation = new ListCollectionsOperation(databaseName, new DocumentCodec()) @@ -203,22 +169,6 @@ class ListCollectionsOperationSpecification extends OperationFunctionalSpecifica collection.size() == 2 } - @IgnoreIf({ serverVersionLessThan(3, 4) || serverVersionAtLeast(4, 0) }) - def 'should only get all field names when nameOnly is requested on server versions that do not support nameOnly'() { - given: - def operation = new ListCollectionsOperation(databaseName, new DocumentCodec()) - .nameOnly(true) - getCollectionHelper().create('collection7', new CreateCollectionOptions()) - - when: - def cursor = operation.execute(getBinding()) - def collection = cursor.next()[0] - - then: - collection.size() > 2 - } - - @IgnoreIf({ serverVersionLessThan(4, 0) }) def 'should get all fields when authorizedCollections is requested and nameOnly is not requested'() { given: def operation = new ListCollectionsOperation(databaseName, new DocumentCodec()) diff --git a/driver-core/src/test/functional/com/mongodb/internal/operation/MapReduceToCollectionOperationSpecification.groovy b/driver-core/src/test/functional/com/mongodb/internal/operation/MapReduceToCollectionOperationSpecification.groovy index f7eb191773f..0f48042da47 100644 --- a/driver-core/src/test/functional/com/mongodb/internal/operation/MapReduceToCollectionOperationSpecification.groovy +++ b/driver-core/src/test/functional/com/mongodb/internal/operation/MapReduceToCollectionOperationSpecification.groovy @@ -167,7 +167,6 @@ class MapReduceToCollectionOperationSpecification extends OperationFunctionalSpe } - @IgnoreIf({ serverVersionLessThan(3, 2) }) def 'should support bypassDocumentValidation'() { given: def collectionOutHelper = getCollectionHelper(new MongoNamespace(getDatabaseName(), 'collectionOut')) @@ -206,7 +205,7 @@ class MapReduceToCollectionOperationSpecification extends OperationFunctionalSpe async << [true, false] } - @IgnoreIf({ serverVersionLessThan(3, 4) || !isDiscoverableReplicaSet() }) + @IgnoreIf({ !isDiscoverableReplicaSet() }) def 'should throw on write concern error'() { given: getCollectionHelper().insertDocuments(new BsonDocument()) @@ -296,7 +295,6 @@ class MapReduceToCollectionOperationSpecification extends OperationFunctionalSpe [3, 4, 0] | true | true | true | false } - @IgnoreIf({ serverVersionLessThan(3, 4) }) def 'should support collation'() { given: def outCollectionHelper = getCollectionHelper(new MongoNamespace(mapReduceInputNamespace.getDatabaseName(), 'collectionOut')) diff --git a/driver-core/src/test/functional/com/mongodb/internal/operation/MapReduceWithInlineResultsOperationSpecification.groovy b/driver-core/src/test/functional/com/mongodb/internal/operation/MapReduceWithInlineResultsOperationSpecification.groovy index ece8045c578..17b3c28f637 100644 --- a/driver-core/src/test/functional/com/mongodb/internal/operation/MapReduceWithInlineResultsOperationSpecification.groovy +++ b/driver-core/src/test/functional/com/mongodb/internal/operation/MapReduceWithInlineResultsOperationSpecification.groovy @@ -43,11 +43,9 @@ import org.bson.BsonTimestamp import org.bson.Document import org.bson.codecs.BsonDocumentCodec import org.bson.codecs.DocumentCodec -import spock.lang.IgnoreIf import static com.mongodb.ClusterFixture.OPERATION_CONTEXT import static com.mongodb.ClusterFixture.executeAsync -import static com.mongodb.ClusterFixture.serverVersionLessThan import static com.mongodb.connection.ServerType.STANDALONE import static com.mongodb.internal.operation.OperationReadConcernHelper.appendReadConcernToCommand import static com.mongodb.internal.operation.ServerVersionHelper.UNKNOWN_WIRE_VERSION @@ -194,7 +192,6 @@ class MapReduceWithInlineResultsOperationSpecification extends OperationFunction [3, 0, 0] | false | false } - @IgnoreIf({ serverVersionLessThan(3, 4) }) def 'should support collation'() { given: def document = Document.parse('{_id: 1, str: "foo"}') diff --git a/driver-core/src/test/functional/com/mongodb/internal/operation/MixedBulkWriteOperationSpecification.groovy b/driver-core/src/test/functional/com/mongodb/internal/operation/MixedBulkWriteOperationSpecification.groovy index 6bdedf2ff60..619eb6747f7 100644 --- a/driver-core/src/test/functional/com/mongodb/internal/operation/MixedBulkWriteOperationSpecification.groovy +++ b/driver-core/src/test/functional/com/mongodb/internal/operation/MixedBulkWriteOperationSpecification.groovy @@ -33,6 +33,7 @@ import com.mongodb.internal.bulk.DeleteRequest import com.mongodb.internal.bulk.InsertRequest import com.mongodb.internal.bulk.UpdateRequest import com.mongodb.internal.bulk.WriteRequest +import com.mongodb.spock.Slow import org.bson.BsonBinary import org.bson.BsonBoolean import org.bson.BsonDocument @@ -46,7 +47,6 @@ import org.bson.codecs.BsonDocumentCodec import org.bson.codecs.DocumentCodec import org.bson.types.ObjectId import spock.lang.IgnoreIf -import com.mongodb.spock.Slow import static com.mongodb.ClusterFixture.configureFailPoint import static com.mongodb.ClusterFixture.disableFailPoint @@ -55,7 +55,6 @@ import static com.mongodb.ClusterFixture.enableOnPrimaryTransactionalWriteFailPo import static com.mongodb.ClusterFixture.getAsyncSingleConnectionBinding import static com.mongodb.ClusterFixture.getSingleConnectionBinding import static com.mongodb.ClusterFixture.isDiscoverableReplicaSet -import static com.mongodb.ClusterFixture.serverVersionAtLeast import static com.mongodb.ClusterFixture.serverVersionLessThan import static com.mongodb.WriteConcern.ACKNOWLEDGED import static com.mongodb.WriteConcern.UNACKNOWLEDGED @@ -843,7 +842,7 @@ class MixedBulkWriteOperationSpecification extends OperationFunctionalSpecificat async << [true, false] } - @IgnoreIf({ serverVersionLessThan(3, 8) || !isDiscoverableReplicaSet() }) + @IgnoreIf({ !isDiscoverableReplicaSet() }) def 'should throw on write concern error on multiple failpoint'() { given: getCollectionHelper().insertDocuments(getTestInserts()) @@ -888,7 +887,6 @@ class MixedBulkWriteOperationSpecification extends OperationFunctionalSpecificat ordered << [true, false] } - @IgnoreIf({ serverVersionLessThan(3, 2) }) def 'should throw if bypassDocumentValidation is set and writeConcern is UNACKNOWLEDGED'() { given: def operation = new MixedBulkWriteOperation(getNamespace(), @@ -905,7 +903,6 @@ class MixedBulkWriteOperationSpecification extends OperationFunctionalSpecificat [async, bypassDocumentValidation] << [[false, false], [true, false]].combinations() } - @IgnoreIf({ serverVersionLessThan(3, 4) }) def 'should throw if collation is set and write is UNACKNOWLEDGED'() { given: def operation = new MixedBulkWriteOperation(getNamespace(), @@ -921,7 +918,6 @@ class MixedBulkWriteOperationSpecification extends OperationFunctionalSpecificat [async, bypassDocumentValidation] << [[true, false], [true, false]].combinations() } - @IgnoreIf({ serverVersionLessThan(3, 2) }) def 'should honour the bypass validation flag for inserts'() { given: def namespace = new MongoNamespace(getDatabaseName(), 'collection') @@ -955,7 +951,6 @@ class MixedBulkWriteOperationSpecification extends OperationFunctionalSpecificat [async, ordered] << [[true, false], [true, false]].combinations() } - @IgnoreIf({ serverVersionLessThan(3, 2) }) def 'should honour the bypass validation flag for updates'() { given: def namespace = new MongoNamespace(getDatabaseName(), 'collection') @@ -987,36 +982,6 @@ class MixedBulkWriteOperationSpecification extends OperationFunctionalSpecificat [async, ordered] << [[true, false], [true, false]].combinations() } - @IgnoreIf({ serverVersionAtLeast(3, 4) }) - def 'should throw an exception when using an unsupported Collation'() { - given: - getCollectionHelper().insertDocuments(new DocumentCodec(), new Document('x', 1), new Document('y', 1), - new Document('z', 1)) - def operation = new MixedBulkWriteOperation(namespace, requests, false, ACKNOWLEDGED, false) - - when: - execute(operation, async) - - then: - def exception = thrown(Exception) - exception instanceof IllegalArgumentException - exception.getMessage().startsWith('Collation not supported by wire version:') - getCollectionHelper().count() == 3 - - where: - [async, requests] << [ - [true, false], - [[new DeleteRequest(BsonDocument.parse('{x: 1}}')).collation(defaultCollation)], - [new UpdateRequest(BsonDocument.parse('{x: 1}}'), BsonDocument.parse('{x: 10}}'), REPLACE), - new UpdateRequest(BsonDocument.parse('{y: 1}}'), BsonDocument.parse('{x: 10}}'), REPLACE).collation(defaultCollation)], - [new DeleteRequest(BsonDocument.parse('{x: 1}}')), - new DeleteRequest(BsonDocument.parse('{y: 1}}')).collation(defaultCollation)], - [new DeleteRequest(BsonDocument.parse('{x: 1}}')), - new UpdateRequest(BsonDocument.parse('{y: 1}}'), BsonDocument.parse('{x: 10}}'), REPLACE).collation(defaultCollation)]] - ].combinations() - } - - @IgnoreIf({ serverVersionLessThan(3, 4) }) def 'should support collation'() { given: getCollectionHelper().insertDocuments(Document.parse('{str: "foo"}'), Document.parse('{str: "bar"}')) @@ -1044,7 +1009,7 @@ class MixedBulkWriteOperationSpecification extends OperationFunctionalSpecificat def operation = new MixedBulkWriteOperation(getNamespace(), testWrites, true, ACKNOWLEDGED, true) when: - if (serverVersionAtLeast(3, 6) && isDiscoverableReplicaSet()) { + if (isDiscoverableReplicaSet()) { enableOnPrimaryTransactionalWriteFailPoint(BsonDocument.parse(failPoint)) } BulkWriteResult result = executeWithSession(operation, async) @@ -1079,7 +1044,7 @@ class MixedBulkWriteOperationSpecification extends OperationFunctionalSpecificat ].combinations() } - @IgnoreIf({ serverVersionLessThan(3, 6) || !isDiscoverableReplicaSet() }) + @IgnoreIf({ !isDiscoverableReplicaSet() }) def 'should fail as expected with retryWrites and failPoints'() { given: def testWrites = getTestWrites() @@ -1104,7 +1069,7 @@ class MixedBulkWriteOperationSpecification extends OperationFunctionalSpecificat ].combinations() } - @IgnoreIf({ serverVersionLessThan(3, 6) || !isDiscoverableReplicaSet() }) + @IgnoreIf({ !isDiscoverableReplicaSet() }) def 'should not fail with unacknowledged writes, retryWrites and failPoints'() { given: def testWrites = getTestWrites() @@ -1129,7 +1094,6 @@ class MixedBulkWriteOperationSpecification extends OperationFunctionalSpecificat ].combinations() } - @IgnoreIf({ serverVersionLessThan(3, 6) }) def 'should retry if the connection initially fails'() { when: def cannedResult = BsonDocument.parse('{ok: 1.0, n: 1}') @@ -1172,7 +1136,6 @@ class MixedBulkWriteOperationSpecification extends OperationFunctionalSpecificat async << [true, false] } - @IgnoreIf({ serverVersionLessThan(3, 6) }) def 'should not request retryable write for multi updates or deletes'() { given: def operation = new MixedBulkWriteOperation(getNamespace(), writes, true, ACKNOWLEDGED, true) @@ -1210,7 +1173,6 @@ class MixedBulkWriteOperationSpecification extends OperationFunctionalSpecificat ].combinations() } - @IgnoreIf({ serverVersionLessThan(3, 6) }) def 'should support array filters'() { given: def documentOne = BsonDocument.parse('{_id: 1, y: [ {b: 3}, {b: 1}]}') @@ -1238,26 +1200,6 @@ class MixedBulkWriteOperationSpecification extends OperationFunctionalSpecificat async << [true, false] } - @IgnoreIf({ serverVersionAtLeast(3, 6) }) - def 'should throw IllegalArgumentException if array filters is set and server version is less than 3.6'() { - given: - def requests = [ - new UpdateRequest(new BsonDocument(), BsonDocument.parse('{ $set: {"y.$[i].b": 2}}'), UPDATE) - .arrayFilters([BsonDocument.parse('{"i.b": 3}')]) - ] - def operation = new MixedBulkWriteOperation(namespace, requests, true, ACKNOWLEDGED, false) - - when: - execute(operation, async) - - then: - thrown(IllegalArgumentException) - - where: - async << [true, false] - } - - @IgnoreIf({ serverVersionLessThan(3, 6) }) def 'should throw if array filters is set and write concern is UNACKNOWLEDGED'() { given: def requests = [ @@ -1276,44 +1218,6 @@ class MixedBulkWriteOperationSpecification extends OperationFunctionalSpecificat async << [true, false] } - @IgnoreIf({ serverVersionAtLeast(3, 4) }) - def 'should throw IllegalArgumentException if hint is set and server version is less than 3.4'() { - given: - def requests = [ - new UpdateRequest(new BsonDocument(), BsonDocument.parse('{ $set: {"y.$[i].b": 2}}'), UPDATE) - .hint(BsonDocument.parse('{ _id: 1 }')) - ] - def operation = new MixedBulkWriteOperation(namespace, requests, true, ACKNOWLEDGED, false) - - when: - execute(operation, async) - - then: - thrown(IllegalArgumentException) - - where: - async << [true, false] - } - - @IgnoreIf({ serverVersionLessThan(3, 4) || serverVersionAtLeast(4, 2) }) - def 'should throw if hint is set and write concern is UNACKNOWLEDGED'() { - given: - def requests = [ - new UpdateRequest(new BsonDocument(), BsonDocument.parse('{ $set: {"y.$[i].b": 2}}'), UPDATE) - .hintString('_id') - ] - def operation = new MixedBulkWriteOperation(namespace, requests, true, UNACKNOWLEDGED, false) - - when: - execute(operation, async) - - then: - thrown(IllegalArgumentException) - - where: - async << [true, false] - } - private static List getTestWrites() { [new UpdateRequest(new BsonDocument('_id', new BsonInt32(1)), new BsonDocument('$set', new BsonDocument('x', new BsonInt32(2))), diff --git a/driver-core/src/test/functional/com/mongodb/internal/operation/RenameCollectionOperationSpecification.groovy b/driver-core/src/test/functional/com/mongodb/internal/operation/RenameCollectionOperationSpecification.groovy index 043c6de48a3..f2e75a235df 100644 --- a/driver-core/src/test/functional/com/mongodb/internal/operation/RenameCollectionOperationSpecification.groovy +++ b/driver-core/src/test/functional/com/mongodb/internal/operation/RenameCollectionOperationSpecification.groovy @@ -29,7 +29,6 @@ import static com.mongodb.ClusterFixture.executeAsync import static com.mongodb.ClusterFixture.getBinding import static com.mongodb.ClusterFixture.isDiscoverableReplicaSet import static com.mongodb.ClusterFixture.isSharded -import static com.mongodb.ClusterFixture.serverVersionLessThan @IgnoreIf( { isSharded() } ) // these tests don't reliably pass against mongos class RenameCollectionOperationSpecification extends OperationFunctionalSpecification { @@ -74,7 +73,7 @@ class RenameCollectionOperationSpecification extends OperationFunctionalSpecific async << [true, false] } - @IgnoreIf({ serverVersionLessThan(3, 4) || !isDiscoverableReplicaSet() }) + @IgnoreIf({ !isDiscoverableReplicaSet() }) def 'should throw on write concern error'() { given: getCollectionHelper().insertDocuments(new DocumentCodec(), new Document('documentThat', 'forces creation of the Collection')) diff --git a/driver-legacy/src/test/functional/com/mongodb/DBCollectionFunctionalSpecification.groovy b/driver-legacy/src/test/functional/com/mongodb/DBCollectionFunctionalSpecification.groovy index 50dedf9cc72..b285b697018 100644 --- a/driver-legacy/src/test/functional/com/mongodb/DBCollectionFunctionalSpecification.groovy +++ b/driver-legacy/src/test/functional/com/mongodb/DBCollectionFunctionalSpecification.groovy @@ -31,8 +31,6 @@ import spock.lang.IgnoreIf import spock.lang.Unroll import static com.mongodb.ClusterFixture.isDiscoverableReplicaSet -import static com.mongodb.ClusterFixture.serverVersionAtLeast -import static com.mongodb.ClusterFixture.serverVersionLessThan import static org.hamcrest.Matchers.contains import static org.hamcrest.Matchers.containsInAnyOrder import static spock.util.matcher.HamcrestSupport.that @@ -157,30 +155,6 @@ class DBCollectionFunctionalSpecification extends FunctionalSpecification { document.get('background') == true } - @IgnoreIf({ serverVersionAtLeast(3, 0) }) - def 'should support legacy dropDups when creating a unique index'() { - when: - collection.drop() - collection.insert(~['y': 1]) - collection.insert(~['y': 1]) - - then: - collection.count() == 2 - - when: - collection.createIndex(~['y': 1], ~['unique': true]) - - then: - thrown(DuplicateKeyException) - - when: - collection.createIndex(~['y': 1], ~['unique': true, 'dropDups': true]) - - then: - notThrown(DuplicateKeyException) - collection.count() == 1 - } - def 'drop index should not fail if collection does not exist'() { given: collection.drop() @@ -418,7 +392,7 @@ class DBCollectionFunctionalSpecification extends FunctionalSpecification { QueryBuilder.start('x').lessThan(2).get() | [y: -1] as BasicDBObject | 5 } - @IgnoreIf({ serverVersionLessThan(3, 4) || !isDiscoverableReplicaSet() }) + @IgnoreIf({ !isDiscoverableReplicaSet() }) def 'should throw WriteConcernException on write concern error for rename'() { given: assert database.getCollectionNames().contains(collectionName) @@ -435,7 +409,7 @@ class DBCollectionFunctionalSpecification extends FunctionalSpecification { collection.setWriteConcern(null) } - @IgnoreIf({ serverVersionLessThan(3, 4) || !isDiscoverableReplicaSet() }) + @IgnoreIf({ !isDiscoverableReplicaSet() }) def 'should throw WriteConcernException on write concern error for drop'() { given: assert database.getCollectionNames().contains(collectionName) @@ -452,7 +426,7 @@ class DBCollectionFunctionalSpecification extends FunctionalSpecification { collection.setWriteConcern(null) } - @IgnoreIf({ serverVersionLessThan(3, 4) || !isDiscoverableReplicaSet() }) + @IgnoreIf({ !isDiscoverableReplicaSet() }) def 'should throw WriteConcernException on write concern error for createIndex'() { given: assert database.getCollectionNames().contains(collectionName) @@ -469,7 +443,7 @@ class DBCollectionFunctionalSpecification extends FunctionalSpecification { collection.setWriteConcern(null) } - @IgnoreIf({ serverVersionLessThan(3, 4) || !isDiscoverableReplicaSet() }) + @IgnoreIf({ !isDiscoverableReplicaSet() }) def 'should throw WriteConcernException on write concern error for dropIndex'() { given: assert database.getCollectionNames().contains(collectionName) @@ -487,7 +461,6 @@ class DBCollectionFunctionalSpecification extends FunctionalSpecification { collection.setWriteConcern(null) } - @IgnoreIf({ serverVersionLessThan(3, 4) }) def 'should support creating an index with collation options'() { given: def collation = Collation.builder() @@ -521,7 +494,6 @@ class DBCollectionFunctionalSpecification extends FunctionalSpecification { indexCollation == collation.asDocument() } - @IgnoreIf({ serverVersionLessThan(3, 4) }) def 'should find with collation'() { given: def document = BasicDBObject.parse('{_id: 1, str: "foo"}') @@ -541,7 +513,6 @@ class DBCollectionFunctionalSpecification extends FunctionalSpecification { ++result == document } - @IgnoreIf({ serverVersionLessThan(3, 4) }) def 'should aggregate with collation'() { given: def document = BasicDBObject.parse('{_id: 1, str: "foo"}') @@ -562,7 +533,6 @@ class DBCollectionFunctionalSpecification extends FunctionalSpecification { ++result == document } - @IgnoreIf({ serverVersionLessThan(3, 4) }) def 'should count with collation'() { given: collection.insert(BasicDBObject.parse('{_id: 1, str: "foo"}')) @@ -580,7 +550,6 @@ class DBCollectionFunctionalSpecification extends FunctionalSpecification { result == 1L } - @IgnoreIf({ serverVersionLessThan(3, 4) }) def 'should update with collation'() { given: collection.insert(BasicDBObject.parse('{_id: 1, str: "foo"}')) @@ -599,7 +568,6 @@ class DBCollectionFunctionalSpecification extends FunctionalSpecification { result.getN() == 1 } - @IgnoreIf({ serverVersionLessThan(3, 4) }) def 'should remove with collation'() { given: collection.insert(BasicDBObject.parse('{_id: 1, str: "foo"}')) @@ -617,7 +585,6 @@ class DBCollectionFunctionalSpecification extends FunctionalSpecification { result.getN() == 1 } - @IgnoreIf({ serverVersionLessThan(3, 4) }) def 'should find and modify with collation'() { given: def document = BasicDBObject.parse('{_id: 1, str: "foo"}') diff --git a/driver-legacy/src/test/functional/com/mongodb/DBCollectionTest.java b/driver-legacy/src/test/functional/com/mongodb/DBCollectionTest.java index 9631b4deb40..c4a238ed73b 100644 --- a/driver-legacy/src/test/functional/com/mongodb/DBCollectionTest.java +++ b/driver-legacy/src/test/functional/com/mongodb/DBCollectionTest.java @@ -49,7 +49,6 @@ import static com.mongodb.ClusterFixture.enableMaxTimeFailPoint; import static com.mongodb.ClusterFixture.isDiscoverableReplicaSet; import static com.mongodb.ClusterFixture.isSharded; -import static com.mongodb.ClusterFixture.serverVersionAtLeast; import static com.mongodb.DBObjectMatchers.hasSubdocument; import static java.util.Arrays.asList; import static java.util.concurrent.TimeUnit.MILLISECONDS; @@ -779,7 +778,6 @@ public void testWriteConcernExceptionOnUpdate() throws UnknownHostException { @Test public void testWriteConcernExceptionOnFindAndModify() throws UnknownHostException { - assumeThat(serverVersionAtLeast(3, 2), is(true)); assumeThat(isDiscoverableReplicaSet(), is(true)); ObjectId id = new ObjectId(); @@ -884,9 +882,7 @@ public void testBypassDocumentValidationForInserts() { try { c.insert(Collections.singletonList(new BasicDBObject("level", 9))); - if (serverVersionAtLeast(3, 2)) { - fail(); - } + fail(); } catch (MongoException e) { // success } @@ -894,9 +890,7 @@ public void testBypassDocumentValidationForInserts() { try { c.insert(Collections.singletonList(new BasicDBObject("level", 9)), new InsertOptions().bypassDocumentValidation(false)); - if (serverVersionAtLeast(3, 2)) { - fail(); - } + fail(); } catch (MongoException e) { // success } @@ -914,9 +908,7 @@ public void testBypassDocumentValidationForInserts() { new InsertOptions() .bypassDocumentValidation(true) .writeConcern(WriteConcern.UNACKNOWLEDGED)); - if (serverVersionAtLeast(3, 2)) { - fail(); - } + fail(); } catch (MongoException e) { // success } @@ -932,9 +924,7 @@ public void testBypassDocumentValidationForUpdates() { try { c.update(new BasicDBObject("_id", 1), new BasicDBObject("_id", 1).append("level", 9), true, false, WriteConcern.ACKNOWLEDGED, null); - if (serverVersionAtLeast(3, 2)) { - fail(); - } + fail(); } catch (MongoException e) { // success } @@ -942,9 +932,7 @@ public void testBypassDocumentValidationForUpdates() { try { c.update(new BasicDBObject("_id", 1), new BasicDBObject("_id", 1).append("level", 9), true, false, WriteConcern.ACKNOWLEDGED, false, null); - if (serverVersionAtLeast(3, 2)) { - fail(); - } + fail(); } catch (MongoException e) { // success } @@ -968,9 +956,7 @@ public void testBypassDocumentValidationForUpdates() { c.update(new BasicDBObject("_id", 1), new BasicDBObject("_id", 1).append("level", 9), true, false, WriteConcern.UNACKNOWLEDGED, true, null); - if (serverVersionAtLeast(3, 2)) { - fail(); - } + fail(); } catch (MongoException e) { // success } @@ -986,9 +972,7 @@ public void testBypassDocumentValidationForFindAndModify() { try { c.findAndModify(new BasicDBObject("_id", 1), new BasicDBObject("_id", 1).append("level", 9)); - if (serverVersionAtLeast(3, 2)) { - fail(); - } + fail(); } catch (MongoException e) { // success } @@ -996,9 +980,7 @@ public void testBypassDocumentValidationForFindAndModify() { try { c.findAndModify(new BasicDBObject("_id", 1), null, null, false, new BasicDBObject("_id", 1).append("level", 9), false, false, false, 0, TimeUnit.SECONDS); - if (serverVersionAtLeast(3, 2)) { - fail(); - } + fail(); } catch (MongoException e) { // success } @@ -1028,9 +1010,7 @@ public void testBypassDocumentValidationForBulkInsert() { BulkWriteOperation bulk = c.initializeOrderedBulkOperation(); bulk.insert(new BasicDBObject("level", 9)); bulk.execute(); - if (serverVersionAtLeast(3, 2)) { - fail(); - } + fail(); } catch (MongoException e) { // success } @@ -1040,9 +1020,7 @@ public void testBypassDocumentValidationForBulkInsert() { bulk.setBypassDocumentValidation(false); bulk.insert(new BasicDBObject("level", 9)); bulk.execute(); - if (serverVersionAtLeast(3, 2)) { - fail(); - } + fail(); } catch (MongoException e) { // success } @@ -1080,9 +1058,7 @@ public void testBypassDocumentValidationForBulkInsert() { bulk.setBypassDocumentValidation(true); bulk.insert(new BasicDBObject("level", 9)); bulk.execute(WriteConcern.UNACKNOWLEDGED); - if (serverVersionAtLeast(3, 2)) { - fail(); - } + fail(); } catch (MongoException e) { // success } @@ -1098,9 +1074,7 @@ public void testBypassDocumentValidationForBulkUpdate() { BulkWriteOperation bulk = c.initializeOrderedBulkOperation(); bulk.find(new BasicDBObject("_id", 1)).upsert().update(new BasicDBObject("$set", new BasicDBObject("level", 9))); bulk.execute(); - if (serverVersionAtLeast(3, 2)) { - fail(); - } + fail(); } catch (MongoException e) { // success } @@ -1110,9 +1084,7 @@ public void testBypassDocumentValidationForBulkUpdate() { bulk.setBypassDocumentValidation(false); bulk.find(new BasicDBObject("_id", 1)).upsert().update(new BasicDBObject("$set", new BasicDBObject("level", 9))); bulk.execute(); - if (serverVersionAtLeast(3, 2)) { - fail(); - } + fail(); } catch (MongoException e) { // success } @@ -1150,9 +1122,7 @@ public void testBypassDocumentValidationForBulkUpdate() { bulk.setBypassDocumentValidation(true); bulk.find(new BasicDBObject("_id", 1)).upsert().update(new BasicDBObject("$set", new BasicDBObject("level", 9))); bulk.execute(WriteConcern.UNACKNOWLEDGED); - if (serverVersionAtLeast(3, 2)) { - fail(); - } + fail(); } catch (MongoException e) { // success } @@ -1168,9 +1138,7 @@ public void testBypassDocumentValidationForBulkReplace() { BulkWriteOperation bulk = c.initializeOrderedBulkOperation(); bulk.find(new BasicDBObject("_id", 1)).upsert().replaceOne(new BasicDBObject("level", 9)); bulk.execute(); - if (serverVersionAtLeast(3, 2)) { - fail(); - } + fail(); } catch (MongoException e) { // success } @@ -1180,9 +1148,7 @@ public void testBypassDocumentValidationForBulkReplace() { bulk.setBypassDocumentValidation(false); bulk.find(new BasicDBObject("_id", 1)).upsert().replaceOne(new BasicDBObject("level", 9)); bulk.execute(); - if (serverVersionAtLeast(3, 2)) { - fail(); - } + fail(); } catch (MongoException e) { // success } @@ -1220,9 +1186,7 @@ public void testBypassDocumentValidationForBulkReplace() { bulk.setBypassDocumentValidation(true); bulk.find(new BasicDBObject("_id", 1)).upsert().replaceOne(new BasicDBObject("level", 9)); bulk.execute(WriteConcern.UNACKNOWLEDGED); - if (serverVersionAtLeast(3, 2)) { - fail(); - } + fail(); } catch (MongoException e) { // success } @@ -1240,9 +1204,7 @@ public void testBypassDocumentValidationForAggregateDollarOut() { try { c.aggregate(Collections.singletonList(new BasicDBObject("$out", cOut.getName())), AggregationOptions.builder().build()); - if (serverVersionAtLeast(3, 2)) { - fail(); - } + fail(); } catch (MongoException e) { // success } @@ -1252,9 +1214,7 @@ public void testBypassDocumentValidationForAggregateDollarOut() { AggregationOptions.builder() .bypassDocumentValidation(false) .build()); - if (serverVersionAtLeast(3, 2)) { - fail(); - } + fail(); } catch (MongoException e) { // success } @@ -1294,9 +1254,7 @@ public void testBypassDocumentValidationForNonInlineMapReduce() { MapReduceCommand mapReduceCommand = new MapReduceCommand(c, map, reduce, cOut.getName(), MapReduceCommand.OutputType.REPLACE, new BasicDBObject()); c.mapReduce(mapReduceCommand); - if (serverVersionAtLeast(3, 2)) { - fail(); - } + fail(); } catch (MongoException e) { // success } @@ -1306,9 +1264,7 @@ public void testBypassDocumentValidationForNonInlineMapReduce() { new BasicDBObject()); mapReduceCommand.setBypassDocumentValidation(false); c.mapReduce(mapReduceCommand); - if (serverVersionAtLeast(3, 2)) { - fail(); - } + fail(); } catch (MongoException e) { // success } diff --git a/driver-legacy/src/test/functional/com/mongodb/DBCursorFunctionalSpecification.groovy b/driver-legacy/src/test/functional/com/mongodb/DBCursorFunctionalSpecification.groovy index cb464f92bc3..a527fa8cdba 100644 --- a/driver-legacy/src/test/functional/com/mongodb/DBCursorFunctionalSpecification.groovy +++ b/driver-legacy/src/test/functional/com/mongodb/DBCursorFunctionalSpecification.groovy @@ -20,12 +20,8 @@ import com.mongodb.client.internal.TestOperationExecutor import com.mongodb.client.model.Collation import com.mongodb.client.model.CollationStrength import com.mongodb.internal.operation.BatchCursor -import spock.lang.IgnoreIf import spock.lang.Subject -import static com.mongodb.ClusterFixture.serverVersionAtLeast -import static com.mongodb.ClusterFixture.serverVersionLessThan - class DBCursorFunctionalSpecification extends FunctionalSpecification { def cursorMap = [a: 1] @@ -52,7 +48,6 @@ class DBCursorFunctionalSpecification extends FunctionalSpecification { 1 * decoder.decode(_ as byte[], collection) } - @IgnoreIf({ serverVersionLessThan(3, 0) }) def 'should use provided hints for queries mongod > 3.0'() { given: collection.createIndex(new BasicDBObject('a', 1)) @@ -274,34 +269,6 @@ class DBCursorFunctionalSpecification extends FunctionalSpecification { executor.getReadPreference() == ReadPreference.secondaryPreferred() } - @IgnoreIf({ serverVersionAtLeast(3, 4) }) - def 'should throw an exception when using an unsupported Collation'() { - given: - dbCursor = collection.find().setCollation(caseInsensitiveCollation) - - when: - dbCursor.count() - - then: - def exception = thrown(IllegalArgumentException) - exception.getMessage().startsWith('Collation not supported by wire version:') - - when: - dbCursor.one() - - then: - exception = thrown(IllegalArgumentException) - exception.getMessage().startsWith('Collation not supported by wire version:') - - when: - ++dbCursor.iterator() - - then: - exception = thrown(IllegalArgumentException) - exception.getMessage().startsWith('Collation not supported by wire version:') - } - - @IgnoreIf({ serverVersionLessThan(3, 4) }) def 'should support collation'() { when: def document = BasicDBObject.parse('{_id: 1, str: "foo"}') diff --git a/driver-legacy/src/test/functional/com/mongodb/DBFunctionalSpecification.groovy b/driver-legacy/src/test/functional/com/mongodb/DBFunctionalSpecification.groovy index 55e1985f86b..cbacecabb45 100644 --- a/driver-legacy/src/test/functional/com/mongodb/DBFunctionalSpecification.groovy +++ b/driver-legacy/src/test/functional/com/mongodb/DBFunctionalSpecification.groovy @@ -21,25 +21,21 @@ import spock.lang.IgnoreIf import static com.mongodb.ClusterFixture.configureFailPoint import static com.mongodb.ClusterFixture.isDiscoverableReplicaSet -import static com.mongodb.ClusterFixture.serverVersionAtLeast -import static com.mongodb.ClusterFixture.serverVersionLessThan class DBFunctionalSpecification extends FunctionalSpecification { - @IgnoreIf({ serverVersionLessThan(3, 4) || !isDiscoverableReplicaSet() }) + @IgnoreIf({ !isDiscoverableReplicaSet() }) def 'should throw WriteConcernException on write concern error for drop'() { given: database.createCollection('ctest', new BasicDBObject()) // On servers older than 4.0 that don't support this failpoint, use a crazy w value instead - def w = serverVersionAtLeast(4, 0) ? 2 : 5 + def w = 2 database.setWriteConcern(new WriteConcern(w)) - if (serverVersionAtLeast(4, 0)) { - configureFailPoint(BsonDocument.parse('{ configureFailPoint: "failCommand", ' + - 'mode : {times : 1}, ' + - 'data : {failCommands : ["dropDatabase"], ' + - 'writeConcernError : {code : 100, errmsg : "failed"}}}')) - } + configureFailPoint(BsonDocument.parse('{ configureFailPoint: "failCommand", ' + + 'mode : {times : 1}, ' + + 'data : {failCommands : ["dropDatabase"], ' + + 'writeConcernError : {code : 100, errmsg : "failed"}}}')) when: database.dropDatabase() @@ -52,7 +48,7 @@ class DBFunctionalSpecification extends FunctionalSpecification { database.setWriteConcern(null) } - @IgnoreIf({ serverVersionLessThan(3, 4) || !isDiscoverableReplicaSet() }) + @IgnoreIf({ !isDiscoverableReplicaSet() }) def 'should throw WriteConcernException on write concern error for create collection'() { given: database.setWriteConcern(new WriteConcern(5)) @@ -68,7 +64,7 @@ class DBFunctionalSpecification extends FunctionalSpecification { database.setWriteConcern(null) } - @IgnoreIf({ serverVersionLessThan(3, 4) || !isDiscoverableReplicaSet() }) + @IgnoreIf({ !isDiscoverableReplicaSet() }) def 'should throw WriteConcernException on write concern error for create view'() { given: database.setWriteConcern(new WriteConcern(5)) diff --git a/driver-legacy/src/test/functional/com/mongodb/LegacyMixedBulkWriteOperationSpecification.groovy b/driver-legacy/src/test/functional/com/mongodb/LegacyMixedBulkWriteOperationSpecification.groovy index 85fb3ad867e..42854387e4a 100644 --- a/driver-legacy/src/test/functional/com/mongodb/LegacyMixedBulkWriteOperationSpecification.groovy +++ b/driver-legacy/src/test/functional/com/mongodb/LegacyMixedBulkWriteOperationSpecification.groovy @@ -31,7 +31,6 @@ import spock.lang.IgnoreIf import static com.mongodb.ClusterFixture.getBinding import static com.mongodb.ClusterFixture.getSingleConnectionBinding import static com.mongodb.ClusterFixture.isDiscoverableReplicaSet -import static com.mongodb.ClusterFixture.serverVersionLessThan import static com.mongodb.LegacyMixedBulkWriteOperation.createBulkWriteOperationForDelete import static com.mongodb.LegacyMixedBulkWriteOperation.createBulkWriteOperationForInsert import static com.mongodb.LegacyMixedBulkWriteOperation.createBulkWriteOperationForReplace @@ -134,7 +133,7 @@ class LegacyMixedBulkWriteOperationSpecification extends OperationFunctionalSpec getCollectionHelper().count() == 1 } - @IgnoreIf({ serverVersionLessThan(3, 6) || !isDiscoverableReplicaSet() }) + @IgnoreIf({ !isDiscoverableReplicaSet() }) def 'should support retryable writes'() { given: def insert = new InsertRequest(new BsonDocument('_id', new BsonInt32(1))) diff --git a/driver-legacy/src/test/functional/com/mongodb/MongoClientSessionSpecification.groovy b/driver-legacy/src/test/functional/com/mongodb/MongoClientSessionSpecification.groovy index b76872c3d81..333a9b95bd8 100644 --- a/driver-legacy/src/test/functional/com/mongodb/MongoClientSessionSpecification.groovy +++ b/driver-legacy/src/test/functional/com/mongodb/MongoClientSessionSpecification.groovy @@ -20,6 +20,7 @@ import com.mongodb.client.MongoCollection import com.mongodb.client.model.Filters import com.mongodb.event.CommandStartedEvent import com.mongodb.internal.connection.TestCommandListener +import com.mongodb.spock.Slow import org.bson.BsonBinarySubType import org.bson.BsonDocument import org.bson.BsonInt32 @@ -28,14 +29,12 @@ import org.bson.Document import org.bson.types.ObjectId import org.junit.Assert import spock.lang.IgnoreIf -import com.mongodb.spock.Slow import java.util.concurrent.TimeUnit import static Fixture.getDefaultDatabaseName import static Fixture.getMongoClientURI import static com.mongodb.ClusterFixture.isDiscoverableReplicaSet -import static com.mongodb.ClusterFixture.serverVersionLessThan import static com.mongodb.Fixture.getMongoClient import static com.mongodb.Fixture.getOptions @@ -49,7 +48,6 @@ class MongoClientSessionSpecification extends FunctionalSpecification { thrown(IllegalArgumentException) } - @IgnoreIf({ serverVersionLessThan(3, 6) }) def 'should create session with correct defaults'() { given: def clientSession = getMongoClient().startSession() @@ -72,7 +70,6 @@ class MongoClientSessionSpecification extends FunctionalSpecification { clientSession?.close() } - @IgnoreIf({ serverVersionLessThan(3, 6) }) def 'cluster time should advance'() { given: def firstOperationTime = new BsonTimestamp(42, 1) @@ -116,7 +113,6 @@ class MongoClientSessionSpecification extends FunctionalSpecification { clientSession?.close() } - @IgnoreIf({ serverVersionLessThan(3, 6) }) def 'operation time should advance'() { given: def firstOperationTime = new BsonTimestamp(42, 1) @@ -157,7 +153,6 @@ class MongoClientSessionSpecification extends FunctionalSpecification { clientSession?.close() } - @IgnoreIf({ serverVersionLessThan(3, 6) }) def 'methods that use the session should throw if the session is closed'() { given: def options = ClientSessionOptions.builder().build() @@ -186,7 +181,6 @@ class MongoClientSessionSpecification extends FunctionalSpecification { clientSession?.close() } - @IgnoreIf({ serverVersionLessThan(3, 6) }) def 'informational methods should not throw if the session is closed'() { given: def options = ClientSessionOptions.builder().build() @@ -206,7 +200,6 @@ class MongoClientSessionSpecification extends FunctionalSpecification { clientSession?.close() } - @IgnoreIf({ serverVersionLessThan(3, 6) }) def 'should apply causally consistent session option to client session'() { when: def clientSession = getMongoClient().startSession(ClientSessionOptions.builder() @@ -224,7 +217,6 @@ class MongoClientSessionSpecification extends FunctionalSpecification { causallyConsistent << [true, false] } - @IgnoreIf({ serverVersionLessThan(3, 6) }) def 'client session should have server session with valid identifier'() { given: def clientSession = getMongoClient().startSession(ClientSessionOptions.builder().build()) @@ -243,7 +235,6 @@ class MongoClientSessionSpecification extends FunctionalSpecification { clientSession?.close() } - @IgnoreIf({ serverVersionLessThan(3, 6) }) def 'should use a default session'() { given: def commandListener = new TestCommandListener() @@ -270,7 +261,6 @@ class MongoClientSessionSpecification extends FunctionalSpecification { // This test is inherently racy as it's possible that the server _does_ replicate fast enough and therefore the test passes anyway // even if causal consistency was not actually in effect. For that reason the test iterates a number of times in order to increase // confidence that it's really causal consistency that is causing the test to succeed - @IgnoreIf({ serverVersionLessThan(3, 6) }) @Slow def 'should find inserted document on a secondary when causal consistency is enabled'() { given: @@ -303,7 +293,6 @@ class MongoClientSessionSpecification extends FunctionalSpecification { } - @IgnoreIf({ serverVersionLessThan(3, 6) }) def 'should not use an implicit session for an unacknowledged write'() { given: def commandListener = new TestCommandListener() @@ -326,7 +315,6 @@ class MongoClientSessionSpecification extends FunctionalSpecification { client?.close() } - @IgnoreIf({ serverVersionLessThan(3, 6) }) def 'should throw exception if unacknowledged write used with explicit session'() { given: def session = getMongoClient().startSession() @@ -343,7 +331,7 @@ class MongoClientSessionSpecification extends FunctionalSpecification { session?.close() } - @IgnoreIf({ serverVersionLessThan(4, 0) || !isDiscoverableReplicaSet() }) + @IgnoreIf({ !isDiscoverableReplicaSet() }) def 'should ignore unacknowledged write concern when in a transaction'() { given: def collection = getMongoClient().getDatabase(getDatabaseName()).getCollection(getCollectionName()) diff --git a/driver-reactive-streams/src/test/functional/com/mongodb/reactivestreams/client/ClientSideEncryptionBsonSizeLimitsSpecification.groovy b/driver-reactive-streams/src/test/functional/com/mongodb/reactivestreams/client/ClientSideEncryptionBsonSizeLimitsSpecification.groovy index 17805e5f2a0..874f2204c6d 100644 --- a/driver-reactive-streams/src/test/functional/com/mongodb/reactivestreams/client/ClientSideEncryptionBsonSizeLimitsSpecification.groovy +++ b/driver-reactive-streams/src/test/functional/com/mongodb/reactivestreams/client/ClientSideEncryptionBsonSizeLimitsSpecification.groovy @@ -31,7 +31,6 @@ import org.bson.codecs.BsonDocumentCodec import reactor.core.publisher.Mono import static com.mongodb.ClusterFixture.TIMEOUT_DURATION -import static com.mongodb.ClusterFixture.serverVersionAtLeast import static com.mongodb.reactivestreams.client.Fixture.drop import static com.mongodb.reactivestreams.client.Fixture.getDefaultDatabaseName import static com.mongodb.reactivestreams.client.Fixture.getMongoClientBuilderFromConnectionString @@ -51,7 +50,6 @@ class ClientSideEncryptionBsonSizeLimitsSpecification extends FunctionalSpecific private MongoCollection autoEncryptingDataCollection def setup() { - assumeTrue(serverVersionAtLeast(4, 2)) assumeTrue('Key vault tests disabled', !System.getProperty('AWS_ACCESS_KEY_ID', '').isEmpty()) drop(keyVaultNamespace) diff --git a/driver-reactive-streams/src/test/functional/com/mongodb/reactivestreams/client/ExplainTest.java b/driver-reactive-streams/src/test/functional/com/mongodb/reactivestreams/client/ExplainTest.java index d573fef87ed..b4c2458eef7 100644 --- a/driver-reactive-streams/src/test/functional/com/mongodb/reactivestreams/client/ExplainTest.java +++ b/driver-reactive-streams/src/test/functional/com/mongodb/reactivestreams/client/ExplainTest.java @@ -46,11 +46,4 @@ public void testExplainOfAggregateWithNewResponseStructure() { super.testExplainOfAggregateWithNewResponseStructure(); assertContextPassedThrough(); } - - @Test - @Override - public void testExplainOfAggregateWithOldResponseStructure() { - super.testExplainOfAggregateWithOldResponseStructure(); - assertContextPassedThrough(); - } } diff --git a/driver-reactive-streams/src/test/functional/com/mongodb/reactivestreams/client/MongoClientSessionSpecification.groovy b/driver-reactive-streams/src/test/functional/com/mongodb/reactivestreams/client/MongoClientSessionSpecification.groovy index 5fda2f76319..ae35b20cb3b 100644 --- a/driver-reactive-streams/src/test/functional/com/mongodb/reactivestreams/client/MongoClientSessionSpecification.groovy +++ b/driver-reactive-streams/src/test/functional/com/mongodb/reactivestreams/client/MongoClientSessionSpecification.groovy @@ -24,6 +24,7 @@ import com.mongodb.TransactionOptions import com.mongodb.WriteConcern import com.mongodb.event.CommandStartedEvent import com.mongodb.internal.connection.TestCommandListener +import com.mongodb.spock.Slow import org.bson.BsonBinarySubType import org.bson.BsonDocument import org.bson.BsonInt32 @@ -32,14 +33,12 @@ import org.bson.Document import org.junit.Assert import reactor.core.publisher.Mono import spock.lang.IgnoreIf -import com.mongodb.spock.Slow import java.util.concurrent.TimeUnit import static Fixture.getMongoClient import static com.mongodb.ClusterFixture.TIMEOUT_DURATION import static com.mongodb.ClusterFixture.isDiscoverableReplicaSet -import static com.mongodb.ClusterFixture.serverVersionLessThan import static com.mongodb.reactivestreams.client.Fixture.getDefaultDatabase import static com.mongodb.reactivestreams.client.Fixture.getMongoClientBuilderFromConnectionString @@ -53,7 +52,6 @@ class MongoClientSessionSpecification extends FunctionalSpecification { thrown(IllegalArgumentException) } - @IgnoreIf({ serverVersionLessThan(3, 6) }) def 'should create session with correct defaults'() { when: def options = ClientSessionOptions.builder().build() @@ -78,7 +76,6 @@ class MongoClientSessionSpecification extends FunctionalSpecification { clientSession.close() } - @IgnoreIf({ serverVersionLessThan(3, 6) }) def 'cluster time should advance'() { given: def firstOperationTime = new BsonTimestamp(42, 1) @@ -122,7 +119,6 @@ class MongoClientSessionSpecification extends FunctionalSpecification { clientSession.close() } - @IgnoreIf({ serverVersionLessThan(3, 6) }) def 'operation time should advance'() { given: def firstOperationTime = new BsonTimestamp(42, 1) @@ -163,7 +159,6 @@ class MongoClientSessionSpecification extends FunctionalSpecification { clientSession.close() } - @IgnoreIf({ serverVersionLessThan(3, 6) }) def 'methods that use the session should throw if the session is closed'() { given: def options = ClientSessionOptions.builder().build() @@ -192,7 +187,6 @@ class MongoClientSessionSpecification extends FunctionalSpecification { clientSession.close() } - @IgnoreIf({ serverVersionLessThan(3, 6) }) def 'informational methods should not throw if the session is closed'() { given: def options = ClientSessionOptions.builder().build() @@ -209,7 +203,6 @@ class MongoClientSessionSpecification extends FunctionalSpecification { true } - @IgnoreIf({ serverVersionLessThan(3, 6) }) def 'should apply causally consistent session option to client session'() { when: def clientSession = startSession(ClientSessionOptions.builder().causallyConsistent(causallyConsistent).build()) @@ -225,7 +218,6 @@ class MongoClientSessionSpecification extends FunctionalSpecification { causallyConsistent << [true, false] } - @IgnoreIf({ serverVersionLessThan(3, 6) }) def 'client session should have server session with valid identifier'() { given: def clientSession = startSession(ClientSessionOptions.builder().build()) @@ -244,7 +236,6 @@ class MongoClientSessionSpecification extends FunctionalSpecification { clientSession.close() } - @IgnoreIf({ serverVersionLessThan(3, 6) }) def 'should use a default session'() { given: def commandListener = new TestCommandListener() @@ -263,7 +254,6 @@ class MongoClientSessionSpecification extends FunctionalSpecification { client?.close() } - @IgnoreIf({ serverVersionLessThan(3, 6) }) def 'should throw exception if unacknowledged write used with explicit session'() { given: def session = Mono.from(getMongoClient().startSession()).block(TIMEOUT_DURATION) @@ -282,7 +272,7 @@ class MongoClientSessionSpecification extends FunctionalSpecification { } - @IgnoreIf({ serverVersionLessThan(4, 0) || !isDiscoverableReplicaSet() }) + @IgnoreIf({ !isDiscoverableReplicaSet() }) def 'should ignore unacknowledged write concern when in a transaction'() { given: def collection = getMongoClient().getDatabase(getDatabaseName()).getCollection(getCollectionName()) @@ -308,7 +298,6 @@ class MongoClientSessionSpecification extends FunctionalSpecification { // This test is inherently racy as it's possible that the server _does_ replicate fast enough and therefore the test passes anyway // even if causal consistency was not actually in effect. For that reason the test iterates a number of times in order to increase // confidence that it's really causal consistency that is causing the test to succeed - @IgnoreIf({ serverVersionLessThan(3, 6) }) @Slow def 'should find inserted document on a secondary when causal consistency is enabled'() { given: diff --git a/driver-reactive-streams/src/test/functional/com/mongodb/reactivestreams/client/RetryableWritesProseTest.java b/driver-reactive-streams/src/test/functional/com/mongodb/reactivestreams/client/RetryableWritesProseTest.java index 39178750bd4..7194c7811f1 100644 --- a/driver-reactive-streams/src/test/functional/com/mongodb/reactivestreams/client/RetryableWritesProseTest.java +++ b/driver-reactive-streams/src/test/functional/com/mongodb/reactivestreams/client/RetryableWritesProseTest.java @@ -16,28 +16,16 @@ package com.mongodb.reactivestreams.client; -import com.mongodb.MongoClientException; -import com.mongodb.MongoException; import com.mongodb.client.test.CollectionHelper; import com.mongodb.reactivestreams.client.syncadapter.SyncMongoClient; import org.bson.Document; import org.bson.codecs.DocumentCodec; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import reactor.core.publisher.Mono; import java.util.concurrent.ExecutionException; import java.util.concurrent.TimeoutException; -import static com.mongodb.ClusterFixture.TIMEOUT_DURATION; -import static com.mongodb.ClusterFixture.getServerStatus; -import static com.mongodb.ClusterFixture.isDiscoverableReplicaSet; -import static com.mongodb.ClusterFixture.isSharded; -import static com.mongodb.ClusterFixture.serverVersionLessThan; -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertTrue; -import static org.junit.jupiter.api.Assumptions.assumeTrue; - /** * See * Retryable Write Prose Tests. @@ -54,40 +42,6 @@ public void setUp() { collectionHelper.create(); } - @Test - public void testRetryWritesWithInsertOneAgainstMMAPv1RaisesError() { - assumeTrue(canRunMmapv1Tests()); - boolean exceptionFound = false; - - try { - Mono.from(collection.insertOne(Document.parse("{ x : 1 }"))).block(TIMEOUT_DURATION); - } catch (MongoClientException e) { - assertEquals("This MongoDB deployment does not support retryable writes. " - + "Please add retryWrites=false to your connection string.", e.getMessage()); - assertEquals(20, ((MongoException) e.getCause()).getCode()); - assertTrue(e.getCause().getMessage().contains("Transaction numbers")); - exceptionFound = true; - } - assertTrue(exceptionFound); - } - - @Test - public void testRetryWritesWithFindOneAndDeleteAgainstMMAPv1RaisesError() { - assumeTrue(canRunMmapv1Tests()); - boolean exceptionFound = false; - - try { - Mono.from(collection.findOneAndDelete(Document.parse("{ x : 1 }"))).block(TIMEOUT_DURATION); - } catch (MongoClientException e) { - assertEquals("This MongoDB deployment does not support retryable writes. " - + "Please add retryWrites=false to your connection string.", e.getMessage()); - assertEquals(20, ((MongoException) e.getCause()).getCode()); - assertTrue(e.getCause().getMessage().contains("Transaction numbers")); - exceptionFound = true; - } - assertTrue(exceptionFound); - } - /** * Prose test #2. */ @@ -126,12 +80,4 @@ public void retriesOnSameMongosWhenAnotherNotAvailable() { mongoClientSettings -> new SyncMongoClient(MongoClients.create(mongoClientSettings)), mongoCollection -> mongoCollection.insertOne(new Document()), "insert", true); } - - private boolean canRunMmapv1Tests() { - Document storageEngine = (Document) getServerStatus().get("storageEngine"); - - return ((isSharded() || isDiscoverableReplicaSet()) - && storageEngine != null && storageEngine.get("name").equals("mmapv1") - && serverVersionLessThan(4, 2)); - } } diff --git a/driver-reactive-streams/src/test/functional/com/mongodb/reactivestreams/client/SmokeTestSpecification.groovy b/driver-reactive-streams/src/test/functional/com/mongodb/reactivestreams/client/SmokeTestSpecification.groovy index d43bf99f6da..de7c4e4d0ef 100644 --- a/driver-reactive-streams/src/test/functional/com/mongodb/reactivestreams/client/SmokeTestSpecification.groovy +++ b/driver-reactive-streams/src/test/functional/com/mongodb/reactivestreams/client/SmokeTestSpecification.groovy @@ -31,7 +31,6 @@ import static Fixture.getMongoClient import static com.mongodb.ClusterFixture.TIMEOUT_DURATION import static com.mongodb.ClusterFixture.getConnectionString import static com.mongodb.reactivestreams.client.Fixture.isReplicaSet -import static com.mongodb.reactivestreams.client.Fixture.serverVersionAtLeast class SmokeTestSpecification extends FunctionalSpecification { @@ -152,7 +151,7 @@ class SmokeTestSpecification extends FunctionalSpecification { !run('the collection name is no longer in the collectionNames list', database.&listCollectionNames).contains(collectionName) } - @IgnoreIf({ !(serverVersionAtLeast(4, 0) && isReplicaSet()) }) + @IgnoreIf({ !isReplicaSet() }) def 'should commit a transaction'() { given: run('create collection', database.&createCollection, collection.namespace.collectionName) @@ -170,7 +169,7 @@ class SmokeTestSpecification extends FunctionalSpecification { session?.close() } - @IgnoreIf({ !(serverVersionAtLeast(4, 0) && isReplicaSet()) }) + @IgnoreIf({ !isReplicaSet() }) def 'should abort a transaction'() { given: run('create collection', database.&createCollection, collection.namespace.collectionName) diff --git a/driver-reactive-streams/src/test/functional/com/mongodb/reactivestreams/client/TransactionFailureTest.java b/driver-reactive-streams/src/test/functional/com/mongodb/reactivestreams/client/TransactionFailureTest.java deleted file mode 100644 index 760acea2a66..00000000000 --- a/driver-reactive-streams/src/test/functional/com/mongodb/reactivestreams/client/TransactionFailureTest.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright 2008-present MongoDB, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.mongodb.reactivestreams.client; - -import com.mongodb.ClientSessionOptions; -import com.mongodb.MongoClientException; -import org.bson.Document; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; -import reactor.core.publisher.Mono; - -import static com.mongodb.ClusterFixture.TIMEOUT_DURATION; -import static com.mongodb.ClusterFixture.isSharded; -import static com.mongodb.ClusterFixture.serverVersionLessThan; -import static org.junit.jupiter.api.Assertions.assertThrows; -import static org.junit.jupiter.api.Assumptions.assumeTrue; - -public class TransactionFailureTest extends DatabaseTestCase { - public TransactionFailureTest() { - } - - @BeforeEach - public void setUp() { - assumeTrue(canRunTests()); - super.setUp(); - } - - @Test - public void testTransactionFails() { - try (ClientSession clientSession = createSession()) { - clientSession.startTransaction(); - assertThrows(MongoClientException.class, () -> - Mono.from(collection.insertOne(clientSession, Document.parse("{_id: 1, a: 1}"))).block(TIMEOUT_DURATION)); - } - } - - private ClientSession createSession() { - ClientSessionOptions options = ClientSessionOptions.builder().build(); - return Mono.from(client.startSession(options)).block(TIMEOUT_DURATION); - } - - private boolean canRunTests() { - return serverVersionLessThan(4, 0) || (serverVersionLessThan(4, 2) && isSharded()); - } -} diff --git a/driver-reactive-streams/src/test/functional/com/mongodb/reactivestreams/client/WriteConcernProseTest.java b/driver-reactive-streams/src/test/functional/com/mongodb/reactivestreams/client/WriteConcernProseTest.java index d06dece28a7..417a10f4037 100644 --- a/driver-reactive-streams/src/test/functional/com/mongodb/reactivestreams/client/WriteConcernProseTest.java +++ b/driver-reactive-streams/src/test/functional/com/mongodb/reactivestreams/client/WriteConcernProseTest.java @@ -31,7 +31,6 @@ import static com.mongodb.ClusterFixture.TIMEOUT_DURATION; import static com.mongodb.ClusterFixture.isDiscoverableReplicaSet; -import static com.mongodb.ClusterFixture.serverVersionAtLeast; import static com.mongodb.reactivestreams.client.Fixture.getDefaultDatabaseName; import static java.lang.String.format; import static java.util.Arrays.asList; @@ -94,6 +93,6 @@ private void disableFailPoint() { } private boolean canRunTests() { - return isDiscoverableReplicaSet() && serverVersionAtLeast(4, 0); + return isDiscoverableReplicaSet(); } } diff --git a/driver-reactive-streams/src/test/functional/com/mongodb/reactivestreams/client/internal/BatchCursorFluxTest.java b/driver-reactive-streams/src/test/functional/com/mongodb/reactivestreams/client/internal/BatchCursorFluxTest.java index ebbd2069f70..49d416da22e 100644 --- a/driver-reactive-streams/src/test/functional/com/mongodb/reactivestreams/client/internal/BatchCursorFluxTest.java +++ b/driver-reactive-streams/src/test/functional/com/mongodb/reactivestreams/client/internal/BatchCursorFluxTest.java @@ -57,7 +57,6 @@ import static com.mongodb.reactivestreams.client.Fixture.drop; import static com.mongodb.reactivestreams.client.Fixture.getMongoClientBuilderFromConnectionString; import static com.mongodb.reactivestreams.client.Fixture.isReplicaSet; -import static com.mongodb.reactivestreams.client.Fixture.serverVersionAtLeast; import static java.util.Arrays.asList; import static java.util.Collections.emptyList; import static java.util.Collections.singletonList; @@ -292,7 +291,7 @@ public void testCalculateBatchSize() { @Test @DisplayName("ChangeStreamPublisher for a collection must complete after dropping the collection") void changeStreamPublisherCompletesAfterDroppingCollection() { - assumeTrue(isReplicaSet() && serverVersionAtLeast(4, 0)); + assumeTrue(isReplicaSet()); TestSubscriber> subscriber = new TestSubscriber<>(); subscriber.doOnSubscribe(subscription -> { subscription.request(Long.MAX_VALUE); diff --git a/driver-reactive-streams/src/test/functional/com/mongodb/reactivestreams/client/internal/ConnectionsSurvivePrimaryStepDownProseTest.java b/driver-reactive-streams/src/test/functional/com/mongodb/reactivestreams/client/internal/ConnectionsSurvivePrimaryStepDownProseTest.java index 7e55971ea1d..634618f2dce 100644 --- a/driver-reactive-streams/src/test/functional/com/mongodb/reactivestreams/client/internal/ConnectionsSurvivePrimaryStepDownProseTest.java +++ b/driver-reactive-streams/src/test/functional/com/mongodb/reactivestreams/client/internal/ConnectionsSurvivePrimaryStepDownProseTest.java @@ -63,7 +63,7 @@ public class ConnectionsSurvivePrimaryStepDownProseTest { @Before public void setUp() { - assumeTrue(isDiscoverableReplicaSet() && serverVersionAtLeast(4, 0)); + assumeTrue(isDiscoverableReplicaSet()); connectionPoolListener = new TestConnectionPoolListener(); MongoClientSettings settings = MongoClientSettings.builder(getMongoClientSettings()).retryWrites(false) .applyToConnectionPoolSettings(builder -> builder.addConnectionPoolListener(connectionPoolListener)).build(); diff --git a/driver-sync/src/examples/documentation/TransactionExample.java b/driver-sync/src/examples/documentation/TransactionExample.java index b11694d2e3b..aea26849e7e 100644 --- a/driver-sync/src/examples/documentation/TransactionExample.java +++ b/driver-sync/src/examples/documentation/TransactionExample.java @@ -170,10 +170,8 @@ private boolean canRunTest() { return false; } else if (isSharded()) { return serverVersionAtLeast(4, 2); - } else if (isDiscoverableReplicaSet()) { - return serverVersionAtLeast(4, 0); } else { - return false; + return isDiscoverableReplicaSet(); } } } diff --git a/driver-sync/src/test/functional/com/mongodb/client/AbstractExplainTest.java b/driver-sync/src/test/functional/com/mongodb/client/AbstractExplainTest.java index d9df697b3ed..c94067f52e0 100644 --- a/driver-sync/src/test/functional/com/mongodb/client/AbstractExplainTest.java +++ b/driver-sync/src/test/functional/com/mongodb/client/AbstractExplainTest.java @@ -33,7 +33,6 @@ import java.util.concurrent.TimeUnit; import static com.mongodb.ClusterFixture.serverVersionAtLeast; -import static com.mongodb.ClusterFixture.serverVersionLessThan; import static com.mongodb.client.Fixture.getDefaultDatabaseName; import static java.util.Collections.singletonList; import static org.junit.Assert.assertEquals; @@ -204,33 +203,6 @@ private static BsonDocument getAggregateExplainDocument(final BsonDocument rootA return aggregateExplainDocument; } - @Test - public void testExplainOfAggregateWithOldResponseStructure() { - // Aggregate explain is supported on earlier versions, but the structure of the response on which we're asserting in this test - // changed radically in 4.2. So here we just assert that we got a non-error respinse - assumeTrue(serverVersionLessThan(4, 2)); - - MongoCollection collection = client.getDatabase(getDefaultDatabaseName()) - .getCollection("explainTest", BsonDocument.class); - collection.drop(); - collection.insertOne(new BsonDocument("_id", new BsonInt32(1))); - - AggregateIterable iterable = collection - .aggregate(singletonList(Aggregates.match(Filters.eq("_id", 1)))); - - Document explainDocument = iterable.explain(); - assertNotNull(explainDocument); - - explainDocument = iterable.explain(ExplainVerbosity.QUERY_PLANNER); - assertNotNull(explainDocument); - - BsonDocument explainBsonDocument = iterable.explain(BsonDocument.class); - assertNotNull(explainBsonDocument); - - explainBsonDocument = iterable.explain(BsonDocument.class, ExplainVerbosity.QUERY_PLANNER); - assertNotNull(explainBsonDocument); - } - private void assertExplainableCommandContainMaxTimeMS() { assertEquals(1, commandListener.getCommandStartedEvents().size()); CommandStartedEvent explain = commandListener.getCommandStartedEvent("explain"); diff --git a/driver-sync/src/test/functional/com/mongodb/client/ChangeStreamProseTest.java b/driver-sync/src/test/functional/com/mongodb/client/ChangeStreamProseTest.java index 4474e4b0fd2..eb9bdad3c25 100644 --- a/driver-sync/src/test/functional/com/mongodb/client/ChangeStreamProseTest.java +++ b/driver-sync/src/test/functional/com/mongodb/client/ChangeStreamProseTest.java @@ -41,7 +41,6 @@ import static com.mongodb.ClusterFixture.isDiscoverableReplicaSet; import static com.mongodb.ClusterFixture.serverVersionAtLeast; -import static com.mongodb.ClusterFixture.serverVersionLessThan; import static com.mongodb.client.CrudTestHelper.repeat; import static com.mongodb.client.model.Updates.set; import static java.util.Arrays.asList; @@ -147,7 +146,6 @@ public void test02MissingResumeTokenThrowsException() { // @Test public void test03ResumeOneTimeOnError() { - assumeTrue(serverVersionAtLeast(4, 0)); try (MongoChangeStreamCursor> cursor = collection.watch().cursor()) { collection.insertOne(Document.parse("{ x: 1 }")); setFailPoint("getMore", 10107); @@ -198,8 +196,6 @@ public void test07CursorNotClosed() { // @Test public void test11GetResumeTokenReturnsPostBatchResumeToken() throws NoSuchFieldException, IllegalAccessException { - assumeTrue(serverVersionAtLeast(4, 0)); - MongoChangeStreamCursor> cursor = collection.watch().cursor(); assertNull(cursor.getResumeToken()); collection.insertOne(Document.parse("{ _id: 42, x: 1 }")); @@ -214,46 +210,6 @@ public void test11GetResumeTokenReturnsPostBatchResumeToken() throws NoSuchField } } - // - // 12. For a ChangeStream under these conditions: - // Running against a server <4.0.7. - // The batch is empty or has been iterated to the last document. - // Expected result: - // getResumeToken must return the _id of the last document returned if one exists. - // getResumeToken must return resumeAfter from the initial aggregate if the option was specified. - // If the resumeAfter option was not specified, the getResumeToken result must be empty. - // - @Test - public void test12GetResumeTokenShouldWorkAsExpectedForEmptyAndIteratedBatch() { - assumeTrue(serverVersionLessThan(4, 0)); - - BsonDocument resumeAfterToken; - MongoChangeStreamCursor> cursor = collection.watch().cursor(); - try { - cursor.tryNext(); - assertNull(cursor.getResumeToken()); - collection.insertOne(Document.parse("{ _id: 42, x: 1 }")); - collection.insertOne(Document.parse("{ _id: 43, x: 1 }")); - resumeAfterToken = cursor.next().getResumeToken(); - - cursor.next(); // iterate to the end of the batch - BsonDocument lastResumeToken = cursor.getResumeToken(); - assertNotNull(lastResumeToken); - - cursor.tryNext(); // returns an empty batch - assertEquals(lastResumeToken, cursor.getResumeToken()); - } finally { - cursor.close(); - } - - cursor = collection.watch().resumeAfter(resumeAfterToken).cursor(); - try { - assertEquals(resumeAfterToken, cursor.getResumeToken()); - } finally { - cursor.close(); - } - } - // // 13. For a ChangeStream under these conditions: // The batch is not empty. @@ -358,8 +314,6 @@ public void test14GetResumeTokenReturnsResumeAfter() { @Test public void test15GetResumeTokenReturnsPostBatchResumeTokenAfterGetMore() throws NoSuchFieldException, IllegalAccessException { - assumeTrue(serverVersionAtLeast(4, 0)); - try (MongoChangeStreamCursor> cursor = collection.watch().cursor()) { collection.insertOne(Document.parse("{ _id: 42, x: 1 }")); // use reflection to access the postBatchResumeToken @@ -375,38 +329,6 @@ public void test15GetResumeTokenReturnsPostBatchResumeTokenAfterGetMore() } } - // - // 16. For a ChangeStream under these conditions: - // Running against a server <4.0.7. - // The batch is not empty. - // The batch hasn’t been iterated at all. - // The stream has iterated beyond a previous batch and a getMore command has just been executed. - // Expected result: - // getResumeToken must return the _id of the previous document returned if one exists. - // getResumeToken must return resumeAfter from the initial aggregate if the option was specified. - // If the resumeAfter option was not specified, the getResumeToken result must be empty. - // - @Test - public void test16GetResumeTokenReturnsIdOfPreviousDocument() { - assumeTrue(serverVersionLessThan(4, 0)); - - BsonDocument resumeToken; - try (MongoChangeStreamCursor> cursor = collection.watch().cursor()) { - collection.insertOne(Document.parse("{ _id: 42, x: 1 }")); - cursor.next(); - resumeToken = cursor.getResumeToken(); - assertNotNull(resumeToken); - - collection.insertOne(Document.parse("{ _id: 43, x: 1 }")); - cursor.next(); - assertNotNull(cursor.getResumeToken()); - } - - try (MongoChangeStreamCursor> cursor2 = collection.watch().resumeAfter(resumeToken).cursor()) { - assertEquals(resumeToken, cursor2.getResumeToken()); - } - } - @Test public void test19SplitChangeStreamEvents() { assumeTrue(serverVersionAtLeast(6, 0)); diff --git a/driver-sync/src/test/functional/com/mongodb/client/ClientSideEncryptionBsonSizeLimitsSpecification.groovy b/driver-sync/src/test/functional/com/mongodb/client/ClientSideEncryptionBsonSizeLimitsSpecification.groovy index d15e6d92a38..68a5c1e9a1c 100644 --- a/driver-sync/src/test/functional/com/mongodb/client/ClientSideEncryptionBsonSizeLimitsSpecification.groovy +++ b/driver-sync/src/test/functional/com/mongodb/client/ClientSideEncryptionBsonSizeLimitsSpecification.groovy @@ -28,7 +28,6 @@ import org.bson.BsonDocument import org.bson.BsonString import static com.mongodb.ClusterFixture.isClientSideEncryptionTest -import static com.mongodb.ClusterFixture.serverVersionAtLeast import static com.mongodb.client.Fixture.getDefaultDatabaseName import static com.mongodb.client.Fixture.getMongoClient import static com.mongodb.client.Fixture.getMongoClientSettings @@ -56,7 +55,6 @@ class ClientSideEncryptionBsonSizeLimitsSpecification extends FunctionalSpecific private MongoCollection autoEncryptingDataCollection def setup() { - assumeTrue(serverVersionAtLeast(4, 2)) assumeTrue(isClientSideEncryptionTest()) dataKeyCollection.drop() dataCollection.drop() diff --git a/driver-sync/src/test/functional/com/mongodb/client/ClientSideEncryptionExternalKeyVaultSpecification.groovy b/driver-sync/src/test/functional/com/mongodb/client/ClientSideEncryptionExternalKeyVaultSpecification.groovy index 3f59638e562..8c888420b27 100644 --- a/driver-sync/src/test/functional/com/mongodb/client/ClientSideEncryptionExternalKeyVaultSpecification.groovy +++ b/driver-sync/src/test/functional/com/mongodb/client/ClientSideEncryptionExternalKeyVaultSpecification.groovy @@ -31,7 +31,6 @@ import org.bson.BsonBinarySubType import org.bson.BsonDocument import org.bson.BsonString -import static com.mongodb.ClusterFixture.serverVersionAtLeast import static com.mongodb.client.Fixture.getDefaultDatabaseName import static com.mongodb.client.Fixture.getMongoClient import static com.mongodb.client.Fixture.getMongoClientSettingsBuilder @@ -57,7 +56,6 @@ class ClientSideEncryptionExternalKeyVaultSpecification extends FunctionalSpecif private TestCommandListener commandListener def setup() { - assumeTrue(serverVersionAtLeast(4, 2)) assumeTrue('Key vault tests disabled', System.getProperty('AWS_ACCESS_KEY_ID') != null && !System.getProperty('AWS_ACCESS_KEY_ID').isEmpty()) diff --git a/driver-sync/src/test/functional/com/mongodb/client/ConnectionsSurvivePrimaryStepDownProseTest.java b/driver-sync/src/test/functional/com/mongodb/client/ConnectionsSurvivePrimaryStepDownProseTest.java index 06aef2168b0..004690d9a54 100644 --- a/driver-sync/src/test/functional/com/mongodb/client/ConnectionsSurvivePrimaryStepDownProseTest.java +++ b/driver-sync/src/test/functional/com/mongodb/client/ConnectionsSurvivePrimaryStepDownProseTest.java @@ -54,7 +54,7 @@ public class ConnectionsSurvivePrimaryStepDownProseTest { @Before public void setUp() { - assumeTrue(isDiscoverableReplicaSet() && serverVersionAtLeast(4, 0)); + assumeTrue(isDiscoverableReplicaSet()); connectionPoolListener = new TestConnectionPoolListener(); MongoClientSettings settings = MongoClientSettings.builder(getMongoClientSettings()).retryWrites(false) .applyToConnectionPoolSettings(builder -> builder.addConnectionPoolListener(connectionPoolListener)).build(); diff --git a/driver-sync/src/test/functional/com/mongodb/client/CrudProseTest.java b/driver-sync/src/test/functional/com/mongodb/client/CrudProseTest.java index 016887c33b7..75419ea1608 100644 --- a/driver-sync/src/test/functional/com/mongodb/client/CrudProseTest.java +++ b/driver-sync/src/test/functional/com/mongodb/client/CrudProseTest.java @@ -104,7 +104,7 @@ public class CrudProseTest { @Test @SuppressWarnings("try") void testWriteConcernErrInfoIsPropagated() throws InterruptedException { - assumeTrue(isDiscoverableReplicaSet() && serverVersionAtLeast(4, 0)); + assumeTrue(isDiscoverableReplicaSet()); BsonDocument failPointDocument = new BsonDocument("configureFailPoint", new BsonString("failCommand")) .append("mode", new BsonDocument("times", new BsonInt32(1))) .append("data", new BsonDocument("failCommands", new BsonArray(singletonList(new BsonString("insert")))) diff --git a/driver-sync/src/test/functional/com/mongodb/client/MongoClientSessionSpecification.groovy b/driver-sync/src/test/functional/com/mongodb/client/MongoClientSessionSpecification.groovy index a8596536e8e..2004f3df9ff 100644 --- a/driver-sync/src/test/functional/com/mongodb/client/MongoClientSessionSpecification.groovy +++ b/driver-sync/src/test/functional/com/mongodb/client/MongoClientSessionSpecification.groovy @@ -27,6 +27,7 @@ import com.mongodb.client.model.Filters import com.mongodb.event.CommandStartedEvent import com.mongodb.internal.connection.TestCommandListener import com.mongodb.internal.time.Timeout +import com.mongodb.spock.Slow import org.bson.BsonBinarySubType import org.bson.BsonDocument import org.bson.BsonInt32 @@ -35,12 +36,10 @@ import org.bson.Document import org.bson.types.ObjectId import org.junit.Assert import spock.lang.IgnoreIf -import com.mongodb.spock.Slow import java.util.concurrent.TimeUnit import static com.mongodb.ClusterFixture.isDiscoverableReplicaSet -import static com.mongodb.ClusterFixture.serverVersionLessThan import static com.mongodb.client.Fixture.getDefaultDatabaseName import static com.mongodb.client.Fixture.getMongoClient import static com.mongodb.client.Fixture.getMongoClientSettings @@ -55,7 +54,6 @@ class MongoClientSessionSpecification extends FunctionalSpecification { thrown(IllegalArgumentException) } - @IgnoreIf({ serverVersionLessThan(3, 6) }) def 'should create session with correct defaults'() { expect: clientSession.getOriginator() == getMongoClient() @@ -79,7 +77,6 @@ class MongoClientSessionSpecification extends FunctionalSpecification { getMongoClient().startSession(ClientSessionOptions.builder().build())] } - @IgnoreIf({ serverVersionLessThan(3, 6) }) def 'cluster time should advance'() { given: def firstOperationTime = new BsonTimestamp(42, 1) @@ -120,7 +117,6 @@ class MongoClientSessionSpecification extends FunctionalSpecification { clientSession.getClusterTime() == secondClusterTime } - @IgnoreIf({ serverVersionLessThan(3, 6) }) def 'operation time should advance'() { given: def firstOperationTime = new BsonTimestamp(42, 1) @@ -158,7 +154,6 @@ class MongoClientSessionSpecification extends FunctionalSpecification { clientSession.getOperationTime() == secondOperationTime } - @IgnoreIf({ serverVersionLessThan(3, 6) }) def 'methods that use the session should throw if the session is closed'() { given: def options = ClientSessionOptions.builder().build() @@ -184,7 +179,6 @@ class MongoClientSessionSpecification extends FunctionalSpecification { thrown(IllegalStateException) } - @IgnoreIf({ serverVersionLessThan(3, 6) }) def 'informational methods should not throw if the session is closed'() { given: def options = ClientSessionOptions.builder().build() @@ -201,7 +195,6 @@ class MongoClientSessionSpecification extends FunctionalSpecification { noExceptionThrown() } - @IgnoreIf({ serverVersionLessThan(3, 6) }) def 'should apply causally consistent session option to client session'() { when: def clientSession = getMongoClient().startSession(ClientSessionOptions.builder() @@ -216,7 +209,6 @@ class MongoClientSessionSpecification extends FunctionalSpecification { causallyConsistent << [true, false] } - @IgnoreIf({ serverVersionLessThan(3, 6) }) def 'client session should have server session with valid identifier'() { given: def clientSession = getMongoClient().startSession(ClientSessionOptions.builder().build()) @@ -232,7 +224,6 @@ class MongoClientSessionSpecification extends FunctionalSpecification { identifier.getBinary('id').data.length == 16 } - @IgnoreIf({ serverVersionLessThan(3, 6) }) def 'should use a default session'() { given: def commandListener = new TestCommandListener() @@ -258,7 +249,6 @@ class MongoClientSessionSpecification extends FunctionalSpecification { // This test is inherently racy as it's possible that the server _does_ replicate fast enough and therefore the test passes anyway // even if causal consistency was not actually in effect. For that reason the test iterates a number of times in order to increase // confidence that it's really causal consistency that is causing the test to succeed - @IgnoreIf({ serverVersionLessThan(3, 6) }) @Slow def 'should find inserted document on a secondary when causal consistency is enabled'() { given: @@ -290,7 +280,6 @@ class MongoClientSessionSpecification extends FunctionalSpecification { readConcern << [ReadConcern.DEFAULT, ReadConcern.LOCAL, ReadConcern.MAJORITY] } - @IgnoreIf({ serverVersionLessThan(3, 6) }) def 'should not use an implicit session for an unacknowledged write'() { given: def commandListener = new TestCommandListener() @@ -311,7 +300,6 @@ class MongoClientSessionSpecification extends FunctionalSpecification { client?.close() } - @IgnoreIf({ serverVersionLessThan(3, 6) }) def 'should throw exception if unacknowledged write used with explicit session'() { given: def session = getMongoClient().startSession() @@ -329,7 +317,7 @@ class MongoClientSessionSpecification extends FunctionalSpecification { } - @IgnoreIf({ serverVersionLessThan(4, 0) || !isDiscoverableReplicaSet() }) + @IgnoreIf({ !isDiscoverableReplicaSet() }) def 'should ignore unacknowledged write concern when in a transaction'() { given: def collection = getMongoClient().getDatabase(getDatabaseName()).getCollection(getCollectionName()) diff --git a/driver-sync/src/test/functional/com/mongodb/client/RetryableWritesProseTest.java b/driver-sync/src/test/functional/com/mongodb/client/RetryableWritesProseTest.java index c18b6995156..36310dd19ca 100644 --- a/driver-sync/src/test/functional/com/mongodb/client/RetryableWritesProseTest.java +++ b/driver-sync/src/test/functional/com/mongodb/client/RetryableWritesProseTest.java @@ -18,9 +18,7 @@ import com.mongodb.ConnectionString; import com.mongodb.Function; -import com.mongodb.MongoClientException; import com.mongodb.MongoClientSettings; -import com.mongodb.MongoException; import com.mongodb.MongoServerException; import com.mongodb.MongoWriteConcernException; import com.mongodb.ServerAddress; @@ -62,13 +60,11 @@ import static com.mongodb.ClusterFixture.getConnectionString; import static com.mongodb.ClusterFixture.getMultiMongosConnectionString; -import static com.mongodb.ClusterFixture.getServerStatus; import static com.mongodb.ClusterFixture.isDiscoverableReplicaSet; import static com.mongodb.ClusterFixture.isServerlessTest; import static com.mongodb.ClusterFixture.isSharded; import static com.mongodb.ClusterFixture.isStandalone; import static com.mongodb.ClusterFixture.serverVersionAtLeast; -import static com.mongodb.ClusterFixture.serverVersionLessThan; import static com.mongodb.client.Fixture.getDefaultDatabaseName; import static com.mongodb.client.Fixture.getMongoClientSettingsBuilder; import static com.mongodb.client.Fixture.getMultiMongosMongoClientSettingsBuilder; @@ -95,40 +91,6 @@ public void setUp() { super.setUp(); } - @Test - public void testRetryWritesWithInsertOneAgainstMMAPv1RaisesError() { - assumeTrue(canRunMmapv1Tests()); - boolean exceptionFound = false; - - try { - collection.insertOne(Document.parse("{x: 1}")); - } catch (MongoClientException e) { - assertEquals("This MongoDB deployment does not support retryable writes. " - + "Please add retryWrites=false to your connection string.", e.getMessage()); - assertEquals(20, ((MongoException) e.getCause()).getCode()); - assertTrue(e.getCause().getMessage().contains("Transaction numbers")); - exceptionFound = true; - } - assertTrue(exceptionFound); - } - - @Test - public void testRetryWritesWithFindOneAndDeleteAgainstMMAPv1RaisesError() { - assumeTrue(canRunMmapv1Tests()); - boolean exceptionFound = false; - - try { - collection.findOneAndDelete(Document.parse("{x: 1}")); - } catch (MongoClientException e) { - assertEquals("This MongoDB deployment does not support retryable writes. " - + "Please add retryWrites=false to your connection string.", e.getMessage()); - assertEquals(20, ((MongoException) e.getCause()).getCode()); - assertTrue(e.getCause().getMessage().contains("Transaction numbers")); - exceptionFound = true; - } - assertTrue(exceptionFound); - } - /** * Prose test #2. */ @@ -397,12 +359,4 @@ public static void retriesOnSameMongosWhenAnotherNotAvailable( assertEquals(s0Address, commandEvents.get(1).getConnectionDescription().getServerAddress(), commandEvents::toString); } } - - private boolean canRunMmapv1Tests() { - Document storageEngine = (Document) getServerStatus().get("storageEngine"); - - return ((isSharded() || isDiscoverableReplicaSet()) - && storageEngine != null && storageEngine.get("name").equals("mmapv1") - && serverVersionLessThan(4, 2)); - } } diff --git a/driver-sync/src/test/functional/com/mongodb/client/TransactionFailureTest.java b/driver-sync/src/test/functional/com/mongodb/client/TransactionFailureTest.java deleted file mode 100644 index ac6732cd334..00000000000 --- a/driver-sync/src/test/functional/com/mongodb/client/TransactionFailureTest.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright 2008-present MongoDB, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.mongodb.client; - -import com.mongodb.MongoClientException; -import org.bson.Document; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; - -import static com.mongodb.ClusterFixture.isSharded; -import static com.mongodb.ClusterFixture.serverVersionLessThan; -import static org.junit.jupiter.api.Assertions.assertThrows; -import static org.junit.jupiter.api.Assumptions.assumeTrue; - -public class TransactionFailureTest extends DatabaseTestCase { - public TransactionFailureTest() { - } - - @BeforeEach - public void setUp() { - assumeTrue(canRunTests()); - super.setUp(); - } - - @Test - public void testTransactionFails() { - try (ClientSession clientSession = client.startSession()) { - clientSession.startTransaction(); - assertThrows(MongoClientException.class, () -> collection.insertOne(clientSession, Document.parse("{_id: 1, a: 1}"))); - } - } - - private boolean canRunTests() { - return serverVersionLessThan(4, 0) - || (serverVersionLessThan(4, 2) && isSharded()); - } -} diff --git a/driver-sync/src/test/functional/com/mongodb/client/WithTransactionProseTest.java b/driver-sync/src/test/functional/com/mongodb/client/WithTransactionProseTest.java index 3a8148f8a92..47e88a78800 100644 --- a/driver-sync/src/test/functional/com/mongodb/client/WithTransactionProseTest.java +++ b/driver-sync/src/test/functional/com/mongodb/client/WithTransactionProseTest.java @@ -210,10 +210,8 @@ public void testTimeoutMSAndLegacySettings() { private boolean canRunTests() { if (isSharded()) { return serverVersionAtLeast(4, 2); - } else if (isDiscoverableReplicaSet()) { - return serverVersionAtLeast(4, 0); } else { - return false; + return isDiscoverableReplicaSet(); } } } diff --git a/driver-sync/src/test/functional/com/mongodb/client/gridfs/GridFSBucketSmokeTestSpecification.groovy b/driver-sync/src/test/functional/com/mongodb/client/gridfs/GridFSBucketSmokeTestSpecification.groovy index 8010d73a3b0..e629dc40859 100644 --- a/driver-sync/src/test/functional/com/mongodb/client/gridfs/GridFSBucketSmokeTestSpecification.groovy +++ b/driver-sync/src/test/functional/com/mongodb/client/gridfs/GridFSBucketSmokeTestSpecification.groovy @@ -32,10 +32,8 @@ import org.bson.Document import org.bson.UuidRepresentation import org.bson.codecs.UuidCodec import org.bson.types.ObjectId -import spock.lang.IgnoreIf import spock.lang.Unroll -import static com.mongodb.ClusterFixture.serverVersionLessThan import static com.mongodb.client.Fixture.getDefaultDatabase import static com.mongodb.client.Fixture.getDefaultDatabaseName import static com.mongodb.client.Fixture.getMongoClientSettingsBuilder @@ -461,7 +459,6 @@ class GridFSBucketSmokeTestSpecification extends FunctionalSpecification { direct << [true, false] } - @IgnoreIf({ serverVersionLessThan(3, 4) }) def 'should not create if index is numerically the same'() { when: filesCollection.createIndex(new Document('filename', indexValue1).append('uploadDate', indexValue2)) From dbf4c9de7abd5f0c62e4288cb5cc0b09e9eafd4a Mon Sep 17 00:00:00 2001 From: Jeff Yemin Date: Tue, 13 May 2025 10:23:40 -0400 Subject: [PATCH 2/4] Add import --- .../internal/operation/AggregateOperationSpecification.groovy | 1 + 1 file changed, 1 insertion(+) diff --git a/driver-core/src/test/functional/com/mongodb/internal/operation/AggregateOperationSpecification.groovy b/driver-core/src/test/functional/com/mongodb/internal/operation/AggregateOperationSpecification.groovy index b0b6c360083..6cb9e972335 100644 --- a/driver-core/src/test/functional/com/mongodb/internal/operation/AggregateOperationSpecification.groovy +++ b/driver-core/src/test/functional/com/mongodb/internal/operation/AggregateOperationSpecification.groovy @@ -24,6 +24,7 @@ import com.mongodb.ServerAddress import com.mongodb.WriteConcern import com.mongodb.client.model.Collation import com.mongodb.client.model.CreateCollectionOptions +import com.mongodb.client.model.Filters import com.mongodb.connection.ClusterId import com.mongodb.connection.ConnectionDescription import com.mongodb.connection.ConnectionId From 8ad0179d80b3dba293b24d28db677dfe4ff99e53 Mon Sep 17 00:00:00 2001 From: Jeff Yemin Date: Tue, 13 May 2025 10:38:59 -0400 Subject: [PATCH 3/4] Fix agg tests --- .../operation/AggregateOperationSpecification.groovy | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/driver-core/src/test/functional/com/mongodb/internal/operation/AggregateOperationSpecification.groovy b/driver-core/src/test/functional/com/mongodb/internal/operation/AggregateOperationSpecification.groovy index 6cb9e972335..89df2c03eca 100644 --- a/driver-core/src/test/functional/com/mongodb/internal/operation/AggregateOperationSpecification.groovy +++ b/driver-core/src/test/functional/com/mongodb/internal/operation/AggregateOperationSpecification.groovy @@ -183,9 +183,9 @@ class AggregateOperationSpecification extends OperationFunctionalSpecification { def operation = new AggregateOperation(namespace, pipeline, new BsonDocumentCodec()) when: - helper.create(helper.getNamespace().getCollectionName(), new CreateCollectionOptions()) + collectionHelper.create(collectionHelper.getNamespace().getCollectionName(), new CreateCollectionOptions()) def cursor = execute(operation, async) - helper.insertDocuments(['{_id: 0, a: 0}', '{_id: 1, a: 1}'].collect { BsonDocument.parse(it) }) + collectionHelper.insertDocuments(['{_id: 0, a: 0}', '{_id: 1, a: 1}'].collect { BsonDocument.parse(it) }) then: def nextDoc = next(cursor, async).collect { doc -> @@ -317,7 +317,7 @@ class AggregateOperationSpecification extends OperationFunctionalSpecification { [async, options] << [[true, false], [defaultCollation, null, Collation.builder().build()]].combinations() } - // Explain output keeps changing so only testing this in the range where the assertion still works + @IgnoreIf({ isSharded() }) def 'should apply $hint'() { given: def index = new BsonDocument('a', new BsonInt32(1)) From 70b16e862e4392ce3e4018b4ef5467bd601cbc95 Mon Sep 17 00:00:00 2001 From: Jeff Yemin Date: Thu, 15 May 2025 10:35:07 -0400 Subject: [PATCH 4/4] Revert unnecessary refactoring --- .../operation/AggregateOperationSpecification.groovy | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/driver-core/src/test/functional/com/mongodb/internal/operation/AggregateOperationSpecification.groovy b/driver-core/src/test/functional/com/mongodb/internal/operation/AggregateOperationSpecification.groovy index 89df2c03eca..b2814756eeb 100644 --- a/driver-core/src/test/functional/com/mongodb/internal/operation/AggregateOperationSpecification.groovy +++ b/driver-core/src/test/functional/com/mongodb/internal/operation/AggregateOperationSpecification.groovy @@ -16,6 +16,7 @@ package com.mongodb.internal.operation + import com.mongodb.MongoNamespace import com.mongodb.OperationFunctionalSpecification import com.mongodb.ReadConcern @@ -181,11 +182,12 @@ class AggregateOperationSpecification extends OperationFunctionalSpecification { def expected = [createExpectedChangeNotification(namespace, 0), createExpectedChangeNotification(namespace, 1)] def pipeline = ['{$changeStream: {}}', '{$project: {"_id.clusterTime": 0, "_id.uuid": 0}}'].collect { BsonDocument.parse(it) } def operation = new AggregateOperation(namespace, pipeline, new BsonDocumentCodec()) + def helper = getCollectionHelper() when: - collectionHelper.create(collectionHelper.getNamespace().getCollectionName(), new CreateCollectionOptions()) + helper.create(helper.getNamespace().getCollectionName(), new CreateCollectionOptions()) def cursor = execute(operation, async) - collectionHelper.insertDocuments(['{_id: 0, a: 0}', '{_id: 1, a: 1}'].collect { BsonDocument.parse(it) }) + helper.insertDocuments(['{_id: 0, a: 0}', '{_id: 1, a: 1}'].collect { BsonDocument.parse(it) }) then: def nextDoc = next(cursor, async).collect { doc ->