Skip to content

Commit 7d19b99

Browse files
committed
Add a new test category for slow tests that either don't need a running MongoDB server or don't need to be run against multiple versions or configurations of MongoDB.
Add a way to exclude those tests when run from Gradle by specifying -Pquicktest=true, and to run only those tests via the new testSlowUnit task.
1 parent 97cda7b commit 7d19b99

File tree

4 files changed

+35
-6
lines changed

4 files changed

+35
-6
lines changed

build.gradle

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ configure(subprojects.findAll { it.name != 'util' && it.name != 'mongo-java-driv
181181
excludeCategories 'category.ReplicaSet'
182182
}
183183
if (project.buildingWith('quicktest')) {
184-
excludeCategories 'category.Slow'
184+
excludeCategories 'category.SlowUnit'
185185
}
186186
}
187187

@@ -201,6 +201,12 @@ configure(subprojects.findAll { it.name != 'util' && it.name != 'mongo-java-driv
201201
testLogging { exceptionFormat = 'full' }
202202
}
203203

204+
task testSlowUnit(type: Test) {
205+
useJUnit {
206+
includeCategories 'category.SlowUnit'
207+
}
208+
}
209+
204210
gradle.taskGraph.whenReady { taskGraph ->
205211
if (taskGraph.hasTask(testCoverage)) {
206212
tasks.withType(Test) { jacoco { enabled = true } }

driver-core/src/test/functional/com/mongodb/connection/AsyncStreamTimeoutsSpecification.groovy

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
package com.mongodb.connection
1818

19-
import category.Slow
19+
import category.SlowUnit
2020
import com.mongodb.MongoSocketOpenException
2121
import com.mongodb.MongoSocketReadTimeoutException
2222
import com.mongodb.OperationFunctionalSpecification
@@ -35,7 +35,7 @@ import static com.mongodb.ClusterFixture.getPrimary
3535
import static com.mongodb.ClusterFixture.getSslSettings
3636
import static com.mongodb.connection.CommandHelper.executeCommand
3737

38-
@Category(Slow)
38+
@Category(SlowUnit)
3939
class AsyncStreamTimeoutsSpecification extends OperationFunctionalSpecification {
4040

4141
static SocketSettings openSocketSettings = SocketSettings.builder().connectTimeout(1, TimeUnit.MILLISECONDS).build();

driver-core/src/test/unit/com/mongodb/connection/InternalStreamConnectionSpecification.groovy

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
package com.mongodb.connection
1818

1919
import category.Async
20-
import category.Slow
20+
import category.SlowUnit
2121
import com.mongodb.MongoInternalException
2222
import com.mongodb.MongoNamespace
2323
import com.mongodb.MongoSocketClosedException
@@ -577,7 +577,7 @@ class InternalStreamConnectionSpecification extends Specification {
577577
}
578578
}
579579

580-
@Category(Slow)
580+
@Category(SlowUnit)
581581
def 'should have threadsafe connection pipelining'() {
582582
given:
583583
int threads = 10
@@ -612,7 +612,7 @@ class InternalStreamConnectionSpecification extends Specification {
612612
pool.shutdown()
613613
}
614614

615-
@Category([Async, Slow])
615+
@Category([Async, SlowUnit])
616616
@IgnoreIf({ javaVersion < 1.7 })
617617
def 'should have threadsafe connection pipelining asynchronously'() {
618618
given:

util/src/main/category/SlowUnit.java

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/*
2+
* Copyright 2015 MongoDB, Inc.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package category;
18+
19+
/**
20+
* Marker for slow tests that do not need to be run against multiple versions or configurations of MongoDB.
21+
*/
22+
public interface SlowUnit {
23+
}

0 commit comments

Comments
 (0)