Skip to content

Commit b42456e

Browse files
committed
Add handshake prose Test 9: backpressure: true in handshake documents
1 parent d083e1b commit b42456e

1 file changed

Lines changed: 21 additions & 0 deletions

File tree

driver-sync/src/test/functional/com/mongodb/client/AbstractClientMetadataProseTest.java

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
import com.mongodb.internal.connection.TestCommandListener;
2525
import com.mongodb.internal.connection.TestConnectionPoolListener;
2626
import com.mongodb.lang.Nullable;
27+
import org.bson.BsonBoolean;
2728
import org.bson.BsonDocument;
2829
import org.junit.jupiter.api.AfterEach;
2930
import org.junit.jupiter.api.Assertions;
@@ -45,6 +46,7 @@
4546
import static com.mongodb.assertions.Assertions.assertTrue;
4647
import static java.util.Optional.ofNullable;
4748
import static org.junit.jupiter.api.Assertions.assertEquals;
49+
import static org.junit.jupiter.api.Assertions.assertFalse;
4850
import static org.junit.jupiter.api.Assumptions.assumeFalse;
4951

5052
/**
@@ -333,6 +335,25 @@ void testEmptyStringsAreConsideredUnsetWhenAppendingMetadataIdenticalToInitialMe
333335
}
334336
}
335337

338+
@DisplayName("Test 9: Handshake documents include backpressure: true")
339+
@Test
340+
void testHandshakeDocumentsIncludeBackpressureTrue() {
341+
try (MongoClient mongoClient = createMongoClient(null, getMongoClientSettings())) {
342+
commandListener.reset();
343+
mongoClient.getDatabase("admin").runCommand(BsonDocument.parse("{ping: 1}"));
344+
345+
List<CommandStartedEvent> handshakeEvents = commandListener.getCommandStartedEvents("isMaster");
346+
assertFalse(handshakeEvents.isEmpty(), "Expected at least one handshake document to be captured");
347+
for (CommandStartedEvent event : handshakeEvents) {
348+
BsonDocument helloCommand = event.getCommand();
349+
assertTrue(helloCommand.containsKey("backpressure"),
350+
"Handshake document is missing 'backpressure' field");
351+
assertEquals(BsonBoolean.TRUE, helloCommand.getBoolean("backpressure"),
352+
"Handshake document 'backpressure' field is not true");
353+
}
354+
}
355+
}
356+
336357
public static Stream<Arguments> provideDriverInformation() {
337358
return Stream.of(
338359
Arguments.of(new DriverInformation("framework", "2.0", "Framework Platform")),

0 commit comments

Comments
 (0)