Skip to content

Simplify test assumptions for 4.2 minimum server support #1712

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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'),
Expand Down Expand Up @@ -178,7 +177,6 @@ class AggregatesFunctionalSpecification extends OperationFunctionalSpecification
new Document('a', 6)]
}

@IgnoreIf({ serverVersionLessThan(3, 2) })
def '$unwind with UnwindOptions'() {
given:
getCollectionHelper().drop()
Expand Down Expand Up @@ -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))])
Expand Down Expand Up @@ -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'
Expand Down Expand Up @@ -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()
Expand All @@ -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'
Expand Down Expand Up @@ -455,7 +448,6 @@ class AggregatesFunctionalSpecification extends OperationFunctionalSpecification
fromHelper?.drop()
}

@IgnoreIf({ serverVersionLessThan(3, 6) })
def '$lookup with pipeline'() {
given:
def fromCollectionName = 'warehouses'
Expand Down Expand Up @@ -500,7 +492,6 @@ class AggregatesFunctionalSpecification extends OperationFunctionalSpecification
fromHelper?.drop()
}

@IgnoreIf({ serverVersionLessThan(3, 6) })
def '$lookup with pipeline without variables'() {
given:
def fromCollectionName = 'holidays'
Expand Down Expand Up @@ -555,7 +546,6 @@ class AggregatesFunctionalSpecification extends OperationFunctionalSpecification
fromCollection?.drop()
}

@IgnoreIf({ serverVersionLessThan(3, 4) })
def '$facet'() {
given:
def helper = getCollectionHelper()
Expand Down Expand Up @@ -612,7 +602,6 @@ class AggregatesFunctionalSpecification extends OperationFunctionalSpecification
helper?.drop()
}

@IgnoreIf({ serverVersionLessThan(3, 4) })
def '$graphLookup'() {
given:
def fromCollectionName = 'contacts'
Expand Down Expand Up @@ -651,7 +640,6 @@ class AggregatesFunctionalSpecification extends OperationFunctionalSpecification
fromHelper?.drop()
}

@IgnoreIf({ serverVersionLessThan(3, 4) })
def '$graphLookup with depth options'() {
given:
def fromCollectionName = 'contacts'
Expand Down Expand Up @@ -692,7 +680,6 @@ class AggregatesFunctionalSpecification extends OperationFunctionalSpecification
fromHelper?.drop()
}

@IgnoreIf({ serverVersionLessThan(3, 4) })
def '$graphLookup with query filter option'() {
given:
def fromCollectionName = 'contacts'
Expand Down Expand Up @@ -743,7 +730,6 @@ class AggregatesFunctionalSpecification extends OperationFunctionalSpecification
fromHelper?.drop()
}

@IgnoreIf({ serverVersionLessThan(3, 4) })
def '$bucket'() {
given:
def helper = getCollectionHelper()
Expand Down Expand Up @@ -777,7 +763,6 @@ class AggregatesFunctionalSpecification extends OperationFunctionalSpecification
helper?.drop()
}

@IgnoreIf({ serverVersionLessThan(3, 4) })
def '$bucketAuto'() {
given:
def helper = getCollectionHelper()
Expand Down Expand Up @@ -811,7 +796,6 @@ class AggregatesFunctionalSpecification extends OperationFunctionalSpecification
helper?.drop()
}

@IgnoreIf({ serverVersionLessThan(3, 4) })
def '$bucketAuto with options'() {
given:
def helper = getCollectionHelper()
Expand All @@ -837,7 +821,6 @@ class AggregatesFunctionalSpecification extends OperationFunctionalSpecification
helper?.drop()
}

@IgnoreIf({ serverVersionLessThan(3, 4) })
def '$count'() {
given:
def helper = getCollectionHelper()
Expand Down Expand Up @@ -873,7 +856,6 @@ class AggregatesFunctionalSpecification extends OperationFunctionalSpecification
helper?.drop()
}

@IgnoreIf({ serverVersionLessThan(3, 4) })
def '$sortByCount'() {
given:
def helper = getCollectionHelper()
Expand Down Expand Up @@ -952,7 +934,6 @@ class AggregatesFunctionalSpecification extends OperationFunctionalSpecification
helper?.drop()
}

@IgnoreIf({ serverVersionLessThan(3, 4) })
def '$addFields'() {
given:
def helper = getCollectionHelper()
Expand Down Expand Up @@ -1026,15 +1007,13 @@ 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'),
new Document(b).append('c', 'b'),
new Document(c).append('c', 'c')]
}

@IgnoreIf({ serverVersionLessThan(3, 4) })
def '$replaceRoot'() {
given:
def helper = getCollectionHelper()
Expand Down Expand Up @@ -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()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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}')
Expand All @@ -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}')
Expand All @@ -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}')
Expand All @@ -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}')
Expand All @@ -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]
Expand All @@ -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()
Expand Down Expand Up @@ -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]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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]}");
Expand All @@ -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);
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down
Loading