Skip to content

Commit 93b1142

Browse files
committed
Increased the timeouts for the slow GridFS tests
Added runSlow method to Async GridFS test helper JAVA-1282
1 parent 4ba19ea commit 93b1142

File tree

2 files changed

+14
-5
lines changed

2 files changed

+14
-5
lines changed

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

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ import java.security.SecureRandom
3939
import static GridFSTestHelper.run
4040
import static com.mongodb.async.client.Fixture.getDefaultDatabaseName
4141
import static com.mongodb.async.client.Fixture.getMongoClient
42+
import static com.mongodb.async.client.gridfs.GridFSTestHelper.runSlow
4243
import static com.mongodb.async.client.gridfs.helpers.AsyncStreamHelper.toAsyncInputStream
4344
import static com.mongodb.async.client.gridfs.helpers.AsyncStreamHelper.toAsyncOutputStream
4445
import static com.mongodb.client.model.Filters.eq
@@ -134,7 +135,7 @@ class GridFSBucketSmokeTestSpecification extends FunctionalSpecification {
134135
ObjectId fileId
135136

136137
when:
137-
fileId = run(gridFSBucket.&uploadFromStream, 'myFile', toAsyncInputStream(contentBytes), options);
138+
fileId = runSlow(gridFSBucket.&uploadFromStream, 'myFile', toAsyncInputStream(contentBytes), options);
138139

139140
then:
140141
run(filesCollection.&count) == 1
@@ -143,7 +144,7 @@ class GridFSBucketSmokeTestSpecification extends FunctionalSpecification {
143144
when:
144145
def outStream = new ByteArrayOutputStream();
145146
def asyncOutputStream = toAsyncOutputStream(outStream);
146-
run(gridFSBucket.&downloadToStream, fileId, asyncOutputStream)
147+
runSlow(gridFSBucket.&downloadToStream, fileId, asyncOutputStream)
147148

148149
then:
149150
outStream.toByteArray() == contentBytes
@@ -160,7 +161,7 @@ class GridFSBucketSmokeTestSpecification extends FunctionalSpecification {
160161
ObjectId fileId
161162

162163
when:
163-
fileId = run(gridFSBucket.&uploadFromStream, 'myFile', toAsyncInputStream(contentBytes), options);
164+
fileId = runSlow(gridFSBucket.&uploadFromStream, 'myFile', toAsyncInputStream(contentBytes), options);
164165

165166
then:
166167
run(filesCollection.&count) == 1
@@ -169,7 +170,7 @@ class GridFSBucketSmokeTestSpecification extends FunctionalSpecification {
169170
when:
170171
def outStream = new ByteArrayOutputStream();
171172
def asyncOutputStream = toAsyncOutputStream(outStream);
172-
run(gridFSBucket.&downloadToStream, fileId, asyncOutputStream)
173+
runSlow(gridFSBucket.&downloadToStream, fileId, asyncOutputStream)
173174

174175
then:
175176
outStream.toByteArray() == contentBytes

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

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,18 @@ import static java.util.concurrent.TimeUnit.SECONDS
2828
class GridFSTestHelper {
2929

3030
static run(operation, ... args) {
31+
runOp(operation, 60, *args)
32+
}
33+
34+
static runSlow(operation, ... args) {
35+
runOp(operation, 180, *args)
36+
}
37+
38+
static runOp(operation, timeout, ... args) {
3139
FutureResultCallback futureResultCallback = new FutureResultCallback()
3240
List opArgs = (args != null) ? args : []
3341
operation.call(*opArgs + futureResultCallback)
34-
futureResultCallback.get(60, SECONDS)
42+
futureResultCallback.get(timeout, SECONDS)
3543
}
3644

3745
static class TestAsynchronousByteChannel implements AsynchronousByteChannel, Closeable {

0 commit comments

Comments
 (0)