(t *testing.T)
| 218 | } |
| 219 | |
| 220 | func TestTeeDropOnMemoryGuard(t *testing.T) { |
| 221 | t.Parallel() |
| 222 | var pressure atomic.Bool |
| 223 | pressure.Store(true) |
| 224 | drops := newDropSink() |
| 225 | |
| 226 | h := newHarness(t, Config{ |
| 227 | MemoryGuardCheck: pressure.Load, |
| 228 | OnMarkMockIncomplete: drops.record, |
| 229 | }) |
| 230 | |
| 231 | // Forward traffic under memory pressure. Real traffic still flows. |
| 232 | go h.writeClient([]byte("visible")) |
| 233 | got := h.readDest(len("visible")) |
| 234 | if string(got) != "visible" { |
| 235 | t.Fatalf("dest got %q, want %q", got, "visible") |
| 236 | } |
| 237 | |
| 238 | // But the FakeConn does not receive the chunk. |
| 239 | _ = h.r.ClientStream().SetReadDeadline(time.Now().Add(100 * time.Millisecond)) |
| 240 | _, err := h.r.ClientStream().ReadChunk() |
| 241 | if err == nil { |
| 242 | t.Fatalf("ClientStream should have timed out, got chunk") |
| 243 | } |
| 244 | if !errors.Is(err, fakeconn.ErrDeadlineExceeded) && err.(net.Error).Timeout() != true { |
| 245 | t.Fatalf("expected deadline error, got %v", err) |
| 246 | } |
| 247 | |
| 248 | if drops.count(DropMemoryPressure) == 0 { |
| 249 | t.Fatalf("expected memory_pressure drop reason, got %v", drops.snapshot()) |
| 250 | } |
| 251 | } |
| 252 | |
| 253 | func TestTeeDropOnPerConnCap(t *testing.T) { |
| 254 | t.Parallel() |
nothing calls this directly
no test coverage detected