mcp: re-enable race test after fixing data races (#851)
1. (non-test) Don't queue notifications if there are no connected sessions. 2. Change `reconnectInitialDelay` to be atomic, as it is modified in tests. 3. Protect map access with mutex in `TestServerTransportCleanup`.
This commit is contained in:
parent
ea161959d7
commit
755b9ed4df
1 changed files with 34 additions and 16 deletions
|
|
@ -446,10 +446,10 @@ func TestStreamableClientResumption_Cancelled(t *testing.T) {
|
|||
//
|
||||
// TODO(#680): experiment with instead using synctest.
|
||||
const tick = 10 * time.Millisecond
|
||||
defer func(delay time.Duration) {
|
||||
reconnectInitialDelay = delay
|
||||
}(reconnectInitialDelay)
|
||||
reconnectInitialDelay = 2 * tick
|
||||
defer func(delay int64) {
|
||||
reconnectInitialDelay.Store(delay)
|
||||
}(reconnectInitialDelay.Load())
|
||||
reconnectInitialDelay.Store(int64(2 * tick))
|
||||
|
||||
// The setup: terminate a request stream and make the resumed request hang
|
||||
// indefinitely. CallTool should still exit when its context is canceled.
|
||||
|
|
@ -702,10 +702,10 @@ func TestStreamableClientTransientErrors(t *testing.T) {
|
|||
func TestStreamableClientRetryWithoutProgress(t *testing.T) {
|
||||
// Speed up reconnection delays for testing.
|
||||
const tick = 10 * time.Millisecond
|
||||
defer func(delay time.Duration) {
|
||||
reconnectInitialDelay = delay
|
||||
}(reconnectInitialDelay)
|
||||
reconnectInitialDelay = tick
|
||||
defer func(delay int64) {
|
||||
reconnectInitialDelay.Store(delay)
|
||||
}(reconnectInitialDelay.Load())
|
||||
reconnectInitialDelay.Store(int64(tick))
|
||||
|
||||
// Use the fakeStreamableServer pattern like other tests to avoid race conditions.
|
||||
ctx := context.Background()
|
||||
|
|
|
|||
Loading…
Reference in a new issue