Skip to content

Commit a6cec05

Browse files
committed
Update server version check from development release to actual releases
1 parent e25a78f commit a6cec05

File tree

68 files changed

+266
-302
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

68 files changed

+266
-302
lines changed

driver-async/src/examples/primer/UpdatePrimer.java

+2-4
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,6 @@
2222
import org.bson.Document;
2323
import com.mongodb.async.SingleResultCallback;
2424
import com.mongodb.client.result.UpdateResult;
25-
26-
import static java.util.Arrays.asList;
2725
// @import: end
2826
import static com.mongodb.ClusterFixture.serverVersionAtLeast;
2927
import static org.junit.Assume.assumeTrue;
@@ -32,7 +30,7 @@ public class UpdatePrimer extends PrimerTestCase {
3230

3331
@Test
3432
public void updateTopLevelFields() {
35-
assumeTrue(serverVersionAtLeast(asList(2, 6, 0)));
33+
assumeTrue(serverVersionAtLeast(2, 6));
3634

3735
// @begin: update-top-level-fields
3836
db.getCollection("restaurants").updateOne(new Document("name", "Juni"),
@@ -80,7 +78,7 @@ public void onResult(final UpdateResult result, final Throwable t) {
8078

8179
@Test
8280
public void updateMultipleDocuments() {
83-
assumeTrue(serverVersionAtLeast(asList(2, 6, 0)));
81+
assumeTrue(serverVersionAtLeast(2, 6));
8482

8583
// @begin: update-multiple-documents
8684
db.getCollection("restaurants").updateMany(new Document("address.zipcode", "10016").append("cuisine", "Other"),

driver-async/src/test/functional/com/mongodb/async/client/CrudTest.java

+4-5
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@
5555
import static com.mongodb.ClusterFixture.getDefaultDatabaseName;
5656
import static com.mongodb.ClusterFixture.serverVersionAtLeast;
5757
import static com.mongodb.async.client.Fixture.getDefaultDatabase;
58-
import static java.util.Arrays.asList;
5958
import static org.junit.Assert.assertEquals;
6059
import static org.junit.Assume.assumeFalse;
6160
import static org.junit.Assume.assumeTrue;
@@ -139,7 +138,7 @@ private boolean checkResult() {
139138
if (filename.contains("insert")) {
140139
// We don't return any id's for insert commands
141140
return false;
142-
} else if (!serverVersionAtLeast(asList(3, 0, 0))
141+
} else if (!serverVersionAtLeast(3, 0)
143142
&& description.contains("when no documents match with upsert returning the document before modification")) {
144143
// Pre 3.0 versions of MongoDB return an empty document rather than a null
145144
return false;
@@ -228,7 +227,7 @@ public void execute() {
228227
}
229228

230229
private BsonDocument toResult(final MongoOperationUpdateResult operation) {
231-
assumeTrue(serverVersionAtLeast(asList(2, 6, 0))); // ModifiedCount is not accessible pre 2.6
230+
assumeTrue(serverVersionAtLeast(2, 6)); // ModifiedCount is not accessible pre 2.6
232231

233232
UpdateResult updateResult = operation.get();
234233
BsonDocument resultDoc = new BsonDocument("matchedCount", new BsonInt32((int) updateResult.getMatchedCount()))
@@ -249,7 +248,7 @@ private BsonDocument toResult(final BsonValue results) {
249248
}
250249

251250
private AggregateIterable<BsonDocument> getAggregateMongoOperation(final BsonDocument arguments) {
252-
if (!serverVersionAtLeast(asList(2, 6, 0))) {
251+
if (!serverVersionAtLeast(2, 6)) {
253252
assumeFalse(description.contains("$out"));
254253
}
255254

@@ -361,7 +360,7 @@ public void execute() {
361360
}
362361

363362
private MongoOperationBsonDocument getFindOneAndReplaceMongoOperation(final BsonDocument arguments) {
364-
assumeTrue(serverVersionAtLeast(asList(2, 6, 0))); // in 2.4 the server can ignore the supplied _id and creates an ObjectID
363+
assumeTrue(serverVersionAtLeast(2, 6)); // in 2.4 the server can ignore the supplied _id and creates an ObjectID
365364

366365
return new MongoOperationBsonDocument() {
367366
@Override

driver-async/src/test/functional/com/mongodb/async/client/MongoClientsSpecification.groovy

+1-1
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ class MongoClientsSpecification extends FunctionalSpecification {
172172
'mongodb://localhost/?appname=app1' | 'app1'
173173
}
174174

175-
@IgnoreIf({ !serverVersionAtLeast([3, 3, 9]) || !isStandalone() })
175+
@IgnoreIf({ !serverVersionAtLeast(3, 4) || !isStandalone() })
176176
def 'application name should appear in the system.profile collection'() {
177177
given:
178178
def appName = 'appName1'

driver-async/src/test/functional/com/mongodb/async/client/SmokeTestSpecification.groovy

+1-2
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ import static com.mongodb.ClusterFixture.serverVersionAtLeast
2424
import static com.mongodb.async.client.Fixture.getMongoClient
2525
import static com.mongodb.async.client.Fixture.isSharded
2626
import static com.mongodb.async.client.TestHelper.run
27-
import static java.util.Arrays.asList
2827

2928
class SmokeTestSpecification extends FunctionalSpecification {
3029

@@ -75,7 +74,7 @@ class SmokeTestSpecification extends FunctionalSpecification {
7574
run(collection.distinct('id', String).&into, []) == ['a', 'b', 'c']
7675
}
7776

78-
@IgnoreIf({ !serverVersionAtLeast(asList(2, 6, 0)) })
77+
@IgnoreIf({ !serverVersionAtLeast(2, 6) })
7978
def 'should aggregate to collection'() {
8079
given:
8180
def mongoClient = getMongoClient()

driver-core/src/main/com/mongodb/operation/OperationHelper.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -374,15 +374,15 @@ static boolean serverIsAtLeastVersionTwoDotSix(final ConnectionDescription descr
374374
}
375375

376376
static boolean serverIsAtLeastVersionThreeDotZero(final ConnectionDescription description) {
377-
return serverIsAtLeastVersion(description, new ServerVersion(asList(3, 0, 0)));
377+
return serverIsAtLeastVersion(description, new ServerVersion(3, 0));
378378
}
379379

380380
static boolean serverIsAtLeastVersionThreeDotTwo(final ConnectionDescription description) {
381-
return serverIsAtLeastVersion(description, new ServerVersion(asList(3, 1, 9)));
381+
return serverIsAtLeastVersion(description, new ServerVersion(3, 2));
382382
}
383383

384384
static boolean serverIsAtLeastVersionThreeDotFour(final ConnectionDescription description) {
385-
return serverIsAtLeastVersion(description, new ServerVersion(asList(3, 3, 10)));
385+
return serverIsAtLeastVersion(description, new ServerVersion(3, 4));
386386
}
387387

388388
static boolean serverIsAtLeastVersion(final ConnectionDescription description, final ServerVersion serverVersion) {

driver-core/src/test/functional/com/mongodb/ClusterFixture.java

+5-1
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,10 @@ public static boolean serverVersionAtLeast(final List<Integer> versionArray) {
113113
return getConnectedServerVersion().compareTo(new ServerVersion(versionArray)) >= 0;
114114
}
115115

116+
public static boolean serverVersionAtLeast(final int majorVersion, final int minorVersion) {
117+
return serverVersionAtLeast(asList(majorVersion, minorVersion, 0));
118+
}
119+
116120
public static Document getBuildInfo() {
117121
return new CommandWriteOperation<Document>("admin", new BsonDocument("buildInfo", new BsonInt32(1)), new DocumentCodec())
118122
.execute(getBinding());
@@ -321,7 +325,7 @@ public static void enableMaxTimeFailPoint() {
321325

322326
public static void disableMaxTimeFailPoint() {
323327
assumeThat(isSharded(), is(false));
324-
if (serverVersionAtLeast(asList(2, 6, 0)) && !isSharded()) {
328+
if (serverVersionAtLeast(2, 6) && !isSharded()) {
325329
new CommandWriteOperation<BsonDocument>("admin",
326330
new BsonDocumentWrapper<Document>(new Document("configureFailPoint",
327331
"maxTimeAlwaysTimeOut")

driver-core/src/test/functional/com/mongodb/client/model/AggregatesFunctionalSpecification.groovy

+16-16
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ class AggregatesFunctionalSpecification extends OperationFunctionalSpecification
101101
new Document('_id', 3).append('x', 3).append('c', 'c')]
102102
}
103103

104-
@IgnoreIf({ !serverVersionAtLeast([3, 3, 10]) })
104+
@IgnoreIf({ !serverVersionAtLeast(3, 4) })
105105
def '$project an exclusion'() {
106106
expect:
107107
aggregate([project(exclude('a', 'a1', 'z'))]) == [new Document('_id', 1).append('x', 1).append('y', 'a'),
@@ -135,7 +135,7 @@ class AggregatesFunctionalSpecification extends OperationFunctionalSpecification
135135
new Document('a', 6)]
136136
}
137137

138-
@IgnoreIf({ !serverVersionAtLeast(asList(3, 1, 10)) })
138+
@IgnoreIf({ !serverVersionAtLeast(3, 2) })
139139
def '$unwind with UnwindOptions'() {
140140
given:
141141
getCollectionHelper().drop()
@@ -183,7 +183,7 @@ class AggregatesFunctionalSpecification extends OperationFunctionalSpecification
183183
new Document('_id', false).append('acc', [false])])
184184
}
185185

186-
@IgnoreIf({ !serverVersionAtLeast(asList(2, 6, 0)) })
186+
@IgnoreIf({ !serverVersionAtLeast(2, 6) })
187187
def '$out'() {
188188
given:
189189
def outCollectionName = getCollectionName() + '.out'
@@ -195,7 +195,7 @@ class AggregatesFunctionalSpecification extends OperationFunctionalSpecification
195195
getCollectionHelper(new MongoNamespace(getDatabaseName(), outCollectionName)).find() == [a, b, c]
196196
}
197197

198-
@IgnoreIf({ !serverVersionAtLeast(asList(3, 1, 8)) })
198+
@IgnoreIf({ !serverVersionAtLeast(3, 2) })
199199
def '$stdDev'() {
200200
when:
201201
def results = aggregate([group(null, stdDevPop('stdDevPop', '$x'), stdDevSamp('stdDevSamp', '$x'))]).first()
@@ -207,14 +207,14 @@ class AggregatesFunctionalSpecification extends OperationFunctionalSpecification
207207
results.get('stdDevSamp') == 1.0
208208
}
209209

210-
@IgnoreIf({ !serverVersionAtLeast(asList(3, 1, 8)) })
210+
@IgnoreIf({ !serverVersionAtLeast(3, 2) })
211211
def '$sample'() {
212212
expect:
213213
containsAny([a, b, c], aggregate([sample(1)]).first())
214214
}
215215

216216

217-
@IgnoreIf({ !serverVersionAtLeast(asList(3, 1, 8)) })
217+
@IgnoreIf({ !serverVersionAtLeast(3, 2) })
218218
def '$lookup'() {
219219
given:
220220
def fromCollectionName = 'lookupCollection'
@@ -242,7 +242,7 @@ class AggregatesFunctionalSpecification extends OperationFunctionalSpecification
242242
fromHelper?.drop()
243243
}
244244

245-
@IgnoreIf({ !serverVersionAtLeast(asList(3, 3, 9)) })
245+
@IgnoreIf({ !serverVersionAtLeast(3, 4) })
246246
def '$facet'() {
247247
given:
248248
def helper = getCollectionHelper()
@@ -294,7 +294,7 @@ class AggregatesFunctionalSpecification extends OperationFunctionalSpecification
294294
helper?.drop()
295295
}
296296

297-
@IgnoreIf({ !serverVersionAtLeast(asList(3, 3, 9)) })
297+
@IgnoreIf({ !serverVersionAtLeast(3, 4) })
298298
def '$graphLookup'() {
299299
given:
300300
def fromCollectionName = 'contacts'
@@ -333,7 +333,7 @@ class AggregatesFunctionalSpecification extends OperationFunctionalSpecification
333333
fromHelper?.drop()
334334
}
335335

336-
@IgnoreIf({ !serverVersionAtLeast(asList(3, 3, 9)) })
336+
@IgnoreIf({ !serverVersionAtLeast(3, 4) })
337337
def '$graphLookup with options'() {
338338
given:
339339
def fromCollectionName = 'contacts'
@@ -374,7 +374,7 @@ class AggregatesFunctionalSpecification extends OperationFunctionalSpecification
374374
fromHelper?.drop()
375375
}
376376

377-
@IgnoreIf({ !serverVersionAtLeast(asList(3, 3, 9)) })
377+
@IgnoreIf({ !serverVersionAtLeast(3, 4) })
378378
def '$bucket'() {
379379
given:
380380
def helper = getCollectionHelper()
@@ -408,7 +408,7 @@ class AggregatesFunctionalSpecification extends OperationFunctionalSpecification
408408
helper?.drop()
409409
}
410410

411-
@IgnoreIf({ !serverVersionAtLeast(asList(3, 3, 9)) })
411+
@IgnoreIf({ !serverVersionAtLeast(3, 4) })
412412
def '$bucketAuto'() {
413413
given:
414414
def helper = getCollectionHelper()
@@ -442,7 +442,7 @@ class AggregatesFunctionalSpecification extends OperationFunctionalSpecification
442442
helper?.drop()
443443
}
444444

445-
@IgnoreIf({ !serverVersionAtLeast(asList(3, 3, 9)) })
445+
@IgnoreIf({ !serverVersionAtLeast(3, 4) })
446446
def '$bucketAuto with options'() {
447447
given:
448448
def helper = getCollectionHelper()
@@ -468,7 +468,7 @@ class AggregatesFunctionalSpecification extends OperationFunctionalSpecification
468468
helper?.drop()
469469
}
470470

471-
@IgnoreIf({ !serverVersionAtLeast(asList(3, 3, 9)) })
471+
@IgnoreIf({ !serverVersionAtLeast(3, 4) })
472472
def '$count'() {
473473
given:
474474
def helper = getCollectionHelper()
@@ -503,7 +503,7 @@ class AggregatesFunctionalSpecification extends OperationFunctionalSpecification
503503
helper?.drop()
504504
}
505505

506-
@IgnoreIf({ !serverVersionAtLeast(asList(3, 3, 9)) })
506+
@IgnoreIf({ !serverVersionAtLeast(3, 4) })
507507
def '$sortByCount'() {
508508
given:
509509
def helper = getCollectionHelper()
@@ -542,7 +542,7 @@ class AggregatesFunctionalSpecification extends OperationFunctionalSpecification
542542
helper?.drop()
543543
}
544544

545-
@IgnoreIf({ !serverVersionAtLeast(asList(3, 3, 11)) })
545+
@IgnoreIf({ !serverVersionAtLeast(3, 4) })
546546
def '$addFields'() {
547547
given:
548548
def helper = getCollectionHelper()
@@ -616,7 +616,7 @@ class AggregatesFunctionalSpecification extends OperationFunctionalSpecification
616616
helper?.drop()
617617
}
618618

619-
@IgnoreIf({ !serverVersionAtLeast(asList(3, 3, 11)) })
619+
@IgnoreIf({ !serverVersionAtLeast(3, 4) })
620620
def '$replaceRoot'() {
621621
given:
622622
def helper = getCollectionHelper()

driver-core/src/test/functional/com/mongodb/client/model/ArrayUpdatesFunctionalSpecification.groovy

+1-1
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ class ArrayUpdatesFunctionalSpecification extends OperationFunctionalSpecificati
9191

9292
}
9393

94-
@IgnoreIf({ !serverVersionAtLeast([2, 6, 0]) })
94+
@IgnoreIf({ !serverVersionAtLeast(2, 6) })
9595
def 'push with each'() {
9696
when:
9797
updateOne(pushEach('x', [4, 4, 4, 5, 6], new PushOptions()))

driver-core/src/test/functional/com/mongodb/client/model/BitwiseUpdatesFunctionalSpecification.groovy

+3-3
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ class BitwiseUpdatesFunctionalSpecification extends OperationFunctionalSpecifica
6161
find() == [new Document('_id', 1).append('x', NUM | INT_MASK)]
6262
}
6363

64-
@IgnoreIf({ !serverVersionAtLeast([2, 6, 0]) })
64+
@IgnoreIf({ !serverVersionAtLeast(2, 6) })
6565
def 'integer bitwiseXor'() {
6666
when:
6767
updateOne(bitwiseXor('x', INT_MASK))
@@ -78,7 +78,7 @@ class BitwiseUpdatesFunctionalSpecification extends OperationFunctionalSpecifica
7878
find() == [new Document('_id', 1).append('x', NUM & LONG_MASK)]
7979
}
8080

81-
@IgnoreIf({ !serverVersionAtLeast([2, 6, 0]) }) // a bug in the 2.4 server prevents this test from passing
81+
@IgnoreIf({ !serverVersionAtLeast(2, 6) }) // a bug in the 2.4 server prevents this test from passing
8282
def 'long bitwiseOr'() {
8383
when:
8484
updateOne(bitwiseOr('x', LONG_MASK))
@@ -87,7 +87,7 @@ class BitwiseUpdatesFunctionalSpecification extends OperationFunctionalSpecifica
8787
find() == [new Document('_id', 1).append('x', NUM | LONG_MASK)]
8888
}
8989

90-
@IgnoreIf({ !serverVersionAtLeast([2, 6, 0]) })
90+
@IgnoreIf({ !serverVersionAtLeast(2, 6) })
9191
def 'long bitwiseXor'() {
9292
when:
9393
updateOne(bitwiseXor('x', LONG_MASK))

driver-core/src/test/functional/com/mongodb/client/model/FiltersFunctionalSpecification.groovy

+8-8
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ class FiltersFunctionalSpecification extends OperationFunctionalSpecification {
8686
find(ne('x', 1)) == [b, c]
8787
}
8888

89-
@IgnoreIf({ !serverVersionAtLeast([2, 6, 0]) })
89+
@IgnoreIf({ !serverVersionAtLeast(2, 6) })
9090
def '$not'() {
9191
expect:
9292
find(not(eq('x', 1))) == [b, c]
@@ -195,7 +195,7 @@ class FiltersFunctionalSpecification extends OperationFunctionalSpecification {
195195
find(size('a', 4)) == [b]
196196
}
197197

198-
@IgnoreIf({ !serverVersionAtLeast([3, 1, 10]) })
198+
@IgnoreIf({ !serverVersionAtLeast(3, 2) })
199199
def 'should render $bitsAllClear'() {
200200
when:
201201
def bitDoc = Document.parse('{_id: 1, bits: 20}')
@@ -206,7 +206,7 @@ class FiltersFunctionalSpecification extends OperationFunctionalSpecification {
206206
find(bitsAllClear('bits', 35)) == [bitDoc]
207207
}
208208

209-
@IgnoreIf({ !serverVersionAtLeast([3, 1, 10]) })
209+
@IgnoreIf({ !serverVersionAtLeast(3, 2) })
210210
def 'should render $bitsAllSet'() {
211211
when:
212212
def bitDoc = Document.parse('{_id: 1, bits: 54}')
@@ -217,7 +217,7 @@ class FiltersFunctionalSpecification extends OperationFunctionalSpecification {
217217
find(bitsAllSet('bits', 50)) == [bitDoc]
218218
}
219219

220-
@IgnoreIf({ !serverVersionAtLeast([3, 1, 10]) })
220+
@IgnoreIf({ !serverVersionAtLeast(3, 2) })
221221
def 'should render $bitsAnyClear'() {
222222
when:
223223
def bitDoc = Document.parse('{_id: 1, bits: 50}')
@@ -228,7 +228,7 @@ class FiltersFunctionalSpecification extends OperationFunctionalSpecification {
228228
find(bitsAnyClear('bits', 20)) == [bitDoc]
229229
}
230230

231-
@IgnoreIf({ !serverVersionAtLeast([3, 1, 10]) })
231+
@IgnoreIf({ !serverVersionAtLeast(3, 2) })
232232
def 'should render $bitsAnySet'() {
233233
when:
234234
def bitDoc = Document.parse('{_id: 1, bits: 20}')
@@ -245,15 +245,15 @@ class FiltersFunctionalSpecification extends OperationFunctionalSpecification {
245245
find(type('x', BsonType.ARRAY)) == []
246246
}
247247

248-
@IgnoreIf({ !serverVersionAtLeast([3, 1, 7]) })
248+
@IgnoreIf({ !serverVersionAtLeast(3, 2) })
249249
def 'should render $type with a string type representation'() {
250250
expect:
251251
find(type('x', 'number')) == [a, b, c]
252252
find(type('x', 'array')) == []
253253
}
254254

255255
@SuppressWarnings('deprecated')
256-
@IgnoreIf({ !serverVersionAtLeast([2, 6, 0]) })
256+
@IgnoreIf({ !serverVersionAtLeast(2, 6) })
257257
def 'should render $text'() {
258258
when:
259259
def textDocument = new Document('_id', 4).append('y', 'mongoDB for GIANT ideas')
@@ -265,7 +265,7 @@ class FiltersFunctionalSpecification extends OperationFunctionalSpecification {
265265
find(text('GIANT', new TextSearchOptions().language('english'))) == [textDocument]
266266
}
267267

268-
@IgnoreIf({ !serverVersionAtLeast([3, 1, 8]) })
268+
@IgnoreIf({ !serverVersionAtLeast(3, 2) })
269269
def 'should render $text with 3.2 options'() {
270270
given:
271271
collectionHelper.drop()

0 commit comments

Comments
 (0)