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

Function TestFilterPanicPrintStackRate

proxy/proxy_test.go:1117–1149  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

1115}
1116
1117func TestFilterPanicPrintStackRate(t *testing.T) {
1118 testLog := NewTestLog()
1119 defer testLog.Close()
1120
1121 fr := make(filters.Registry)
1122 fr.Register(new(nilFilterSpec))
1123
1124 tp, err := newTestProxyWithFilters(fr, `* -> nilFilter() -> <shunt>`, FlagsNone)
1125 require.NoError(t, err)
1126 defer tp.close()
1127
1128 const (
1129 panicsCaused = 10
1130 stacksPrinted = 3 // see Proxy.onPanicSometimes
1131 )
1132
1133 for i := 0; i < panicsCaused; i++ {
1134 r := httptest.NewRequest("GET", "/", nil)
1135 w := httptest.NewRecorder()
1136
1137 tp.proxy.ServeHTTP(w, r)
1138 }
1139
1140 const errorMsg = "error while proxying"
1141 if err = testLog.WaitForN(errorMsg, 10, 100*time.Millisecond); err != nil {
1142 t.Errorf(`expected "%s" to be logged exactly %d times`, errorMsg, panicsCaused)
1143 }
1144
1145 const stackMsg = "github.com/zalando/skipper/proxy.TestFilterPanicPrintStackRate"
1146 if err = testLog.WaitForN(stackMsg, 3, 100*time.Millisecond); err != nil {
1147 t.Errorf(`expected "%s" to be logged exactly %d times`, stackMsg, stacksPrinted)
1148 }
1149}
1150
1151func TestProcessesRequestWithShuntBackend(t *testing.T) {
1152 u, _ := url.ParseRequestURI("https://www.example.org/hello")

Callers

nothing calls this directly

Calls 8

newTestProxyWithFiltersFunction · 0.85
RegisterMethod · 0.80
NewTestLogFunction · 0.70
CloseMethod · 0.65
ErrorfMethod · 0.65
closeMethod · 0.45
ServeHTTPMethod · 0.45
WaitForNMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…