Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
test(mcp-test): await async GET stream in version-negotiation assertions
The GET /mcp stream is opened asynchronously once initialize creates the session, so asserting recorded calls immediately races under load (seen as Jackson 2 Integration Tests failing usesLatestVersion with Expected size: 3 but was: 2). Await the recorded GET before asserting header propagation.
  • Loading branch information
slachiewicz committed Sep 8, 2026
commit c34cc7898cea11ae314d2c4b6953c2888db065ac
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

package io.modelcontextprotocol.common;

import java.time.Duration;
import java.util.List;
import java.util.Map;
import java.util.Objects;
Expand Down Expand Up @@ -32,6 +33,7 @@
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.assertj.core.api.InstanceOfAssertFactories.type;
import static org.awaitility.Awaitility.await;

class HttpClientStreamableHttpVersionNegotiationIntegrationTests {

Expand Down Expand Up @@ -102,6 +104,13 @@ void usesLatestVersion() {
McpSchema.CallToolResult response = client
.callTool(McpSchema.CallToolRequest.builder("test-tool").arguments(Map.of()).build());

// The GET /mcp stream is opened asynchronously once the initialize response
// creates the session, so wait for it to be recorded before asserting.
await().atMost(Duration.ofSeconds(5))
.untilAsserted(
() -> assertThat(requestRecordingFilter.getCalls()).filteredOn(c -> "GET".equals(c.method()))
.hasSize(1));

var calls = requestRecordingFilter.getCalls();

assertThat(calls).filteredOn(c -> !c.body().contains("\"method\":\"initialize\""))
Expand Down