|
24 | 24 | import com.mongodb.MongoNamespace;
|
25 | 25 | import com.mongodb.MongoWriteConcernException;
|
26 | 26 | import com.mongodb.MongoWriteException;
|
27 |
| -import com.mongodb.WriteConcern; |
28 | 27 | import com.mongodb.assertions.Assertions;
|
29 | 28 | import com.mongodb.client.model.CreateCollectionOptions;
|
30 | 29 | import com.mongodb.client.model.Filters;
|
@@ -313,6 +312,15 @@ private void assertBulkWriteHandlesCursorRequiringGetMore(final boolean transact
|
313 | 312 | }
|
314 | 313 | }
|
315 | 314 |
|
| 315 | + private static Stream<Arguments> testBulkWriteErrorsForUnacknowledgedTooLargeInsertArgs() { |
| 316 | + return Stream.of( |
| 317 | + arguments("insert", false), |
| 318 | + arguments("insert", true), |
| 319 | + arguments("replace", false), |
| 320 | + arguments("replace", true) |
| 321 | + ); |
| 322 | + } |
| 323 | + |
316 | 324 | @DisplayName("11. MongoClient.bulkWrite batch splits when the addition of a new namespace exceeds the maximum message size")
|
317 | 325 | @Test
|
318 | 326 | protected void testBulkWriteSplitsWhenExceedingMaxMessageSizeBytesDueToNsInfo() {
|
@@ -434,40 +442,6 @@ protected void testBulkWriteErrorsForAutoEncryption() {
|
434 | 442 | }
|
435 | 443 | }
|
436 | 444 |
|
437 |
| - @DisplayName("15. MongoClient.bulkWrite with unacknowledged write concern uses w:0 for all batches") |
438 |
| - @Test |
439 |
| - protected void testWriteConcernOfAllBatchesWhenUnacknowledgedRequested() { |
440 |
| - assumeTrue(serverVersionAtLeast(8, 0)); |
441 |
| - assumeFalse(isServerlessTest()); |
442 |
| - TestCommandListener commandListener = new TestCommandListener(); |
443 |
| - try (MongoClient client = createMongoClient(getMongoClientSettingsBuilder().addCommandListener(commandListener) |
444 |
| - .writeConcern(WriteConcern.UNACKNOWLEDGED))) { |
445 |
| - MongoDatabase database = droppedDatabase(client); |
446 |
| - database.createCollection(NAMESPACE.getCollectionName()); |
447 |
| - Document helloResponse = database.runCommand(new Document("hello", 1)); |
448 |
| - int maxBsonObjectSize = helloResponse.getInteger("maxBsonObjectSize"); |
449 |
| - int maxMessageSizeBytes = helloResponse.getInteger("maxMessageSizeBytes"); |
450 |
| - ClientNamespacedWriteModel model = ClientNamespacedWriteModel.insertOne( |
451 |
| - NAMESPACE, |
452 |
| - new Document("a", join("", nCopies(maxBsonObjectSize - 500, "b")))); |
453 |
| - int numModels = maxMessageSizeBytes / maxBsonObjectSize + 1; |
454 |
| - ClientBulkWriteResult result = client.bulkWrite(nCopies(numModels, model), clientBulkWriteOptions().ordered(false)); |
455 |
| - assertFalse(result.isAcknowledged()); |
456 |
| - List<CommandStartedEvent> startedBulkWriteCommandEvents = commandListener.getCommandStartedEvents("bulkWrite"); |
457 |
| - assertEquals(2, startedBulkWriteCommandEvents.size()); |
458 |
| - CommandStartedEvent firstEvent = startedBulkWriteCommandEvents.get(0); |
459 |
| - BsonDocument firstCommand = firstEvent.getCommand(); |
460 |
| - CommandStartedEvent secondEvent = startedBulkWriteCommandEvents.get(1); |
461 |
| - BsonDocument secondCommand = secondEvent.getCommand(); |
462 |
| - assertEquals(numModels - 1, firstCommand.getArray("ops").size()); |
463 |
| - assertEquals(1, secondCommand.getArray("ops").size()); |
464 |
| - assertEquals(firstEvent.getOperationId(), secondEvent.getOperationId()); |
465 |
| - assertEquals(0, firstCommand.getDocument("writeConcern").getInt32("w").intValue()); |
466 |
| - assertEquals(0, secondCommand.getDocument("writeConcern").getInt32("w").intValue()); |
467 |
| - assertEquals(numModels, database.getCollection(NAMESPACE.getCollectionName()).countDocuments()); |
468 |
| - } |
469 |
| - } |
470 |
| - |
471 | 445 | /**
|
472 | 446 | * This test is not from the specification.
|
473 | 447 | */
|
|
0 commit comments