Skip to content

Commit a7f99ab

Browse files
committed
Added a test for two updates that together exceed 16MB but still would fit in to a single update command message.
1 parent 508a5ec commit a7f99ab

File tree

1 file changed

+22
-1
lines changed

1 file changed

+22
-1
lines changed

src/test/com/mongodb/BulkWriteOperationSpecification.groovy

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,11 @@ package com.mongodb
1919
import org.bson.types.ObjectId
2020
import spock.lang.Unroll
2121

22-
import static com.mongodb.Fixture.*
22+
import static com.mongodb.Fixture.isReplicaSet
23+
import static com.mongodb.Fixture.isServerStartedWithJournalingDisabled
24+
import static com.mongodb.Fixture.isSharded
25+
import static com.mongodb.Fixture.isStandalone
26+
import static com.mongodb.Fixture.serverIsAtLeastVersion
2327
import static com.mongodb.WriteRequest.Type.INSERT
2428
import static com.mongodb.WriteRequest.Type.REMOVE
2529
import static com.mongodb.WriteRequest.Type.REPLACE
@@ -363,6 +367,23 @@ class BulkWriteOperationSpecification extends FunctionalSpecification {
363367
collection.count() == 1
364368
}
365369

370+
def 'when two update documents together exceed 16MB, the documents are still updated'() {
371+
given:
372+
def operation = collection.initializeOrderedBulkOperation()
373+
operation.find(new BasicDBObject('_id', 1))
374+
.update(new BasicDBObject('$set', new BasicDBObject('x', new byte[1024 * 1024 * 8])));
375+
operation.find(new BasicDBObject('_id', 2))
376+
.update(new BasicDBObject('$set', new BasicDBObject('x', new byte[1024 * 1024 * 8])));
377+
378+
when:
379+
def result = operation.execute()
380+
381+
then:
382+
result == new AcknowledgedBulkWriteResult(UPDATE, 0, expectedModifiedCount(0), [])
383+
collection.count() == 0
384+
}
385+
386+
366387
def 'should handle multi-length runs of ordered insert, update, replace, and remove'() {
367388
given:
368389
collection.insert(getTestInserts())

0 commit comments

Comments
 (0)