diff --git a/build.gradle b/build.gradle index f897702d1b7..abe0bf8a2a7 100644 --- a/build.gradle +++ b/build.gradle @@ -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) { + useJUnitPlatform { + includeEngines( 'spock') + } systemProperty('spock.configuration', "${configDir}/spock/OnlySlow.groovy") } diff --git a/driver-core/src/test/functional/com/mongodb/internal/connection/AsyncStreamTimeoutsSpecification.groovy b/driver-core/src/test/functional/com/mongodb/internal/connection/AsyncStreamTimeoutsSpecification.groovy index 3e6443aa2e9..c13fcded975 100644 --- a/driver-core/src/test/functional/com/mongodb/internal/connection/AsyncStreamTimeoutsSpecification.groovy +++ b/driver-core/src/test/functional/com/mongodb/internal/connection/AsyncStreamTimeoutsSpecification.groovy @@ -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' }) @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, 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,9 +64,9 @@ 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))); @@ -74,7 +74,7 @@ class AsyncStreamTimeoutsSpecification extends OperationFunctionalSpecification 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,9 +100,9 @@ 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))); @@ -109,7 +110,7 @@ class AsyncStreamTimeoutsSpecification extends OperationFunctionalSpecification 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) diff --git a/driver-core/src/test/unit/com/mongodb/internal/connection/DefaultConnectionPoolSpecification.groovy b/driver-core/src/test/unit/com/mongodb/internal/connection/DefaultConnectionPoolSpecification.groovy index 6bb9febe0e4..257b2dca055 100644 --- a/driver-core/src/test/unit/com/mongodb/internal/connection/DefaultConnectionPoolSpecification.groovy +++ b/driver-core/src/test/unit/com/mongodb/internal/connection/DefaultConnectionPoolSpecification.groovy @@ -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 connectionFactory.createdConnections.get(0).opened() // if the first one is opened, they all should be } 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 62e0b9741d2..0e2e4ed02d7 100644 --- a/driver-sync/src/test/functional/com/mongodb/client/ClientSideEncryptionBsonSizeLimitsSpecification.groovy +++ b/driver-sync/src/test/functional/com/mongodb/client/ClientSideEncryptionBsonSizeLimitsSpecification.groovy @@ -39,10 +39,10 @@ import static util.JsonPoweredTestHelper.getTestDocument class ClientSideEncryptionBsonSizeLimitsSpecification extends FunctionalSpecification { - private final String collectionName = 'ClientSideEncryptionBsonSizeLimitsSpecification' + private final String collName = 'ClientSideEncryptionBsonSizeLimitsSpecification' 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)