TestStreamableStatelessKeepaliveRace verifies that there is no data race between ServerSession.startKeepalive and ServerSession.Close in stateless servers.
(t *testing.T)
| 366 | // TestStreamableStatelessKeepaliveRace verifies that there is no data race between |
| 367 | // ServerSession.startKeepalive and ServerSession.Close in stateless servers. |
| 368 | func TestStreamableStatelessKeepaliveRace(t *testing.T) { |
| 369 | ctx := context.Background() |
| 370 | server := NewServer(testImpl, &ServerOptions{KeepAlive: time.Hour}) |
| 371 | AddTool(server, &Tool{Name: "greet"}, sayHi) |
| 372 | handler := NewStreamableHTTPHandler( |
| 373 | func(*http.Request) *Server { return server }, |
| 374 | &StreamableHTTPOptions{Stateless: true}, |
| 375 | ) |
| 376 | httpServer := httptest.NewServer(mustNotPanic(t, handler)) |
| 377 | defer httpServer.Close() |
| 378 | |
| 379 | for range 50 { |
| 380 | cs, err := NewClient(testImpl, nil).Connect(ctx, &StreamableClientTransport{ |
| 381 | Endpoint: httpServer.URL, |
| 382 | }, nil) |
| 383 | if err != nil { |
| 384 | t.Fatalf("NewClient() failed: %v", err) |
| 385 | } |
| 386 | _, _ = cs.CallTool(ctx, &CallToolParams{ |
| 387 | Name: "greet", |
| 388 | Arguments: map[string]any{"Name": "world"}, |
| 389 | }) |
| 390 | _ = cs.Close() |
| 391 | } |
| 392 | } |
| 393 | |
| 394 | // TestClientReplay verifies that the client can recover from a mid-stream |
| 395 | // network failure and receive replayed messages (if replay is configured). It |
nothing calls this directly
no test coverage detected
searching dependent graphs…