-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Build: Fix slow tests #773
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -230,7 +230,7 @@ configure(javaCodeCheckedProjects) { | |
testImplementation('org.junit.jupiter:junit-jupiter') | ||
testImplementation('org.junit.vintage:junit-vintage-engine') | ||
|
||
testImplementation platform('org.spockframework:spock-bom:2.0-M3-groovy-2.5') | ||
testImplementation platform('org.spockframework:spock-bom:2.0-groovy-2.5') | ||
testImplementation 'org.spockframework:spock-core' | ||
testImplementation 'org.spockframework:spock-junit4' | ||
testImplementation("org.mockito:mockito-core:3.8.0") | ||
|
@@ -274,10 +274,17 @@ configure(javaCodeCheckedProjects) { | |
} | ||
|
||
task testSlowOnly(type: Test) { | ||
dependsOn('testSlowGroovy') | ||
useJUnitPlatform { | ||
includeEngines('junit-jupiter', 'junit-vintage', 'spock') | ||
includeEngines('junit-jupiter', 'junit-vintage') | ||
includeTags('Slow') | ||
} | ||
} | ||
|
||
task testSlowGroovy(type: Test) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Had to create a custom task just for the groovy tests and that fixes the issue ?! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, thats's what seem to be suggested as the solution, which is unfortunate: spockframework/spock#1288 (comment). |
||
useJUnitPlatform { | ||
includeEngines( 'spock') | ||
} | ||
systemProperty('spock.configuration', "${configDir}/spock/OnlySlow.groovy") | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,6 +21,7 @@ import com.mongodb.MongoSocketReadTimeoutException | |
import com.mongodb.OperationFunctionalSpecification | ||
import com.mongodb.ServerAddress | ||
import com.mongodb.connection.AsynchronousSocketChannelStreamFactory | ||
import com.mongodb.connection.ClusterConnectionMode | ||
import com.mongodb.connection.ClusterId | ||
import com.mongodb.connection.ServerId | ||
import com.mongodb.connection.SocketSettings | ||
|
@@ -39,7 +40,6 @@ import static com.mongodb.ClusterFixture.getServerApi | |
import static com.mongodb.ClusterFixture.getSslSettings | ||
import static com.mongodb.internal.connection.CommandHelper.executeCommand | ||
|
||
@IgnoreIf({ System.getProperty('ignoreSlowUnitTests') == 'true' }) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This seems to be a legacy system property |
||
@Slow | ||
class AsyncStreamTimeoutsSpecification extends OperationFunctionalSpecification { | ||
|
||
|
@@ -49,9 +49,9 @@ class AsyncStreamTimeoutsSpecification extends OperationFunctionalSpecification | |
@IgnoreIf({ getSslSettings().isEnabled() }) | ||
def 'should throw a MongoSocketOpenException when the AsynchronousSocket Stream fails to open'() { | ||
given: | ||
def connection = new InternalStreamConnectionFactory( | ||
def connection = new InternalStreamConnectionFactory(ClusterConnectionMode.SINGLE, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These changes are just to bring the code up to date. |
||
new AsynchronousSocketChannelStreamFactory(openSocketSettings, getSslSettings()), getCredentialWithCache(), null, null, | ||
[], getServerApi()) | ||
[], null, getServerApi()) | ||
.create(new ServerId(new ClusterId(), new ServerAddress(new InetSocketAddress('192.168.255.255', 27017)))) | ||
|
||
when: | ||
|
@@ -64,17 +64,17 @@ class AsyncStreamTimeoutsSpecification extends OperationFunctionalSpecification | |
@IgnoreIf({ getSslSettings().isEnabled() }) | ||
def 'should throw a MongoSocketReadTimeoutException with the AsynchronousSocket stream'() { | ||
given: | ||
def connection = new InternalStreamConnectionFactory( | ||
def connection = new InternalStreamConnectionFactory(ClusterConnectionMode.SINGLE, | ||
new AsynchronousSocketChannelStreamFactory(readSocketSettings, getSslSettings()), getCredentialWithCache(), null, null, | ||
[], getServerApi(),).create(new ServerId(new ClusterId(), getPrimary())) | ||
[], null, getServerApi()).create(new ServerId(new ClusterId(), getPrimary())) | ||
connection.open() | ||
|
||
getCollectionHelper().insertDocuments(new BsonDocument('_id', new BsonInt32(1))); | ||
def countCommand = new BsonDocument('count', new BsonString(getCollectionName())) | ||
countCommand.put('query', new BsonDocument('$where', new BsonString('sleep(5050); return true;'))) | ||
|
||
when: | ||
executeCommand(getDatabaseName(), countCommand, connection) | ||
executeCommand(getDatabaseName(), countCommand, getServerApi(), connection) | ||
|
||
then: | ||
thrown(MongoSocketReadTimeoutException) | ||
|
@@ -85,9 +85,10 @@ class AsyncStreamTimeoutsSpecification extends OperationFunctionalSpecification | |
|
||
def 'should throw a MongoSocketOpenException when the Netty Stream fails to open'() { | ||
given: | ||
def connection = new InternalStreamConnectionFactory( | ||
new NettyStreamFactory(openSocketSettings, getSslSettings()), getCredentialWithCache(), null, null, [], getServerApi(), | ||
).create(new ServerId(new ClusterId(), new ServerAddress(new InetSocketAddress('192.168.255.255', 27017)))) | ||
def connection = new InternalStreamConnectionFactory(ClusterConnectionMode.SINGLE, | ||
new NettyStreamFactory(openSocketSettings, getSslSettings()), getCredentialWithCache(), null, null, | ||
[], null, getServerApi()).create(new ServerId(new ClusterId(), | ||
new ServerAddress(new InetSocketAddress('192.168.255.255', 27017)))) | ||
|
||
when: | ||
connection.open() | ||
|
@@ -99,17 +100,17 @@ class AsyncStreamTimeoutsSpecification extends OperationFunctionalSpecification | |
|
||
def 'should throw a MongoSocketReadTimeoutException with the Netty stream'() { | ||
given: | ||
def connection = new InternalStreamConnectionFactory( | ||
new NettyStreamFactory(readSocketSettings, getSslSettings()), getCredentialWithCache(), null, null, [], getServerApi(), | ||
).create(new ServerId(new ClusterId(), getPrimary()), connectionGeneration) | ||
def connection = new InternalStreamConnectionFactory(ClusterConnectionMode.SINGLE, | ||
new NettyStreamFactory(readSocketSettings, getSslSettings()), getCredentialWithCache(), null, null, | ||
[], null, getServerApi()).create(new ServerId(new ClusterId(), getPrimary())) | ||
connection.open() | ||
|
||
getCollectionHelper().insertDocuments(new BsonDocument('_id', new BsonInt32(1))); | ||
def countCommand = new BsonDocument('count', new BsonString(getCollectionName())) | ||
countCommand.put('query', new BsonDocument('$where', new BsonString('sleep(5050); return true;'))) | ||
|
||
when: | ||
executeCommand(getDatabaseName(), countCommand, connection) | ||
executeCommand(getDatabaseName(), countCommand, getServerApi(), connection) | ||
|
||
then: | ||
thrown(MongoSocketReadTimeoutException) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -50,7 +50,7 @@ class DefaultConnectionPoolSpecification extends Specification { | |
given: | ||
pool = new DefaultConnectionPool(SERVER_ID, connectionFactory, | ||
builder().maxSize(1).build()) | ||
pool.start(); | ||
pool.start() | ||
|
||
expect: | ||
pool.get() != null | ||
|
@@ -60,7 +60,7 @@ class DefaultConnectionPoolSpecification extends Specification { | |
given: | ||
pool = new DefaultConnectionPool(SERVER_ID, connectionFactory, | ||
builder().maxSize(1).build()) | ||
pool.start(); | ||
pool.start() | ||
|
||
when: | ||
pool.get().close() | ||
|
@@ -74,7 +74,7 @@ class DefaultConnectionPoolSpecification extends Specification { | |
given: | ||
pool = new DefaultConnectionPool(SERVER_ID, connectionFactory, | ||
builder().maxSize(1).build()) | ||
pool.start(); | ||
pool.start() | ||
|
||
when: | ||
pool.get().close() | ||
|
@@ -87,7 +87,7 @@ class DefaultConnectionPoolSpecification extends Specification { | |
given: | ||
pool = new DefaultConnectionPool(SERVER_ID, connectionFactory, | ||
builder().maxSize(1).maxWaitTime(1, MILLISECONDS).build()) | ||
pool.start(); | ||
pool.start() | ||
|
||
when: | ||
def first = pool.get() | ||
|
@@ -106,7 +106,7 @@ class DefaultConnectionPoolSpecification extends Specification { | |
given: | ||
pool = new DefaultConnectionPool(SERVER_ID, connectionFactory, | ||
builder().maxSize(1).maxWaitTime(50, MILLISECONDS).build()) | ||
pool.start(); | ||
pool.start() | ||
|
||
pool.get() | ||
|
||
|
@@ -124,7 +124,7 @@ class DefaultConnectionPoolSpecification extends Specification { | |
given: | ||
pool = new DefaultConnectionPool(SERVER_ID, connectionFactory, | ||
builder().maxSize(10).maintenanceInitialDelay(5, MINUTES).build()) | ||
pool.start(); | ||
pool.start() | ||
|
||
when: | ||
pool.doMaintenance() | ||
|
@@ -138,7 +138,7 @@ class DefaultConnectionPoolSpecification extends Specification { | |
given: | ||
pool = new DefaultConnectionPool(SERVER_ID, connectionFactory, | ||
builder().maxSize(10).minSize(5).maintenanceInitialDelay(5, MINUTES).build()) | ||
pool.start(); | ||
pool.start() | ||
|
||
when: 'the maintenance tasks runs' | ||
pool.doMaintenance() | ||
|
@@ -156,7 +156,7 @@ class DefaultConnectionPoolSpecification extends Specification { | |
Thread.sleep(500) | ||
|
||
then: 'it prunes the existing connections and again ensures the minimum size of the pool' | ||
connectionFactory.createdConnections.size() == 10 | ||
connectionFactory.createdConnections.size() == 5 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This was a test bug. |
||
connectionFactory.createdConnections.get(0).opened() // if the first one is opened, they all should be | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -39,10 +39,10 @@ import static util.JsonPoweredTestHelper.getTestDocument | |
|
||
class ClientSideEncryptionBsonSizeLimitsSpecification extends FunctionalSpecification { | ||
|
||
private final String collectionName = 'ClientSideEncryptionBsonSizeLimitsSpecification' | ||
private final String collName = 'ClientSideEncryptionBsonSizeLimitsSpecification' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Side effect of Spock dependency update? Theres a |
||
private final MongoNamespace keyVaultNamespace = new MongoNamespace('test.datakeys') | ||
private final MongoNamespace autoEncryptingCollectionNamespace = new MongoNamespace(getDefaultDatabaseName(), | ||
collectionName) | ||
collName) | ||
private final MongoCollection dataKeyCollection = getMongoClient() | ||
.getDatabase(keyVaultNamespace.databaseName).getCollection(keyVaultNamespace.collectionName, BsonDocument) | ||
.withWriteConcern(WriteConcern.MAJORITY) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add the spock test dependency