MCPcopy Create free account
hub / github.com/zalando/skipper / TestClientTimeoutBeforeStreaming

Function TestClientTimeoutBeforeStreaming

proxy/clienttimeout_test.go:196–229  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

194}
195
196func TestClientTimeoutBeforeStreaming(t *testing.T) {
197 testLog := NewTestLog()
198 defer testLog.Close()
199
200 backend := startTestServer([]byte("backend reply"), 0, func(*http.Request) {})
201 defer backend.Close()
202
203 doc := fmt.Sprintf(`hello: * -> latency("100ms") -> "%s"`, backend.URL)
204 tp, err := newTestProxy(doc, FlagsNone)
205 if err != nil {
206 t.Fatal(err)
207 }
208 defer tp.close()
209
210 ps := httptest.NewServer(tp.proxy)
211 defer ps.Close()
212
213 req, err := http.NewRequest("GET", ps.URL, nil)
214 if err != nil {
215 t.Fatal(err)
216 }
217
218 rsp, err := (&http.Client{
219 Timeout: 50 * time.Millisecond,
220 }).Do(req)
221 if err == nil || rsp != nil {
222 t.Errorf("unexpected err or response: %v %v", err, rsp)
223 }
224
225 const msg = "Client request: context canceled"
226 if err = testLog.WaitFor(msg, 200*time.Millisecond); err != nil {
227 t.Errorf("log should contain '%s'", msg)
228 }
229}

Callers

nothing calls this directly

Calls 8

newTestProxyFunction · 0.85
NewTestLogFunction · 0.70
startTestServerFunction · 0.70
CloseMethod · 0.65
DoMethod · 0.65
ErrorfMethod · 0.65
closeMethod · 0.45
WaitForMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…