Skip to content

Commit

Permalink
more test
Browse files Browse the repository at this point in the history
Signed-off-by: spacewander <spacewanderlzx@gmail.com>
  • Loading branch information
spacewander committed Oct 25, 2024
1 parent f80a75b commit f30af13
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion api/pkg/filtermanager/wrapper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,19 @@ func TestDebugFilter(t *testing.T) {
return api.Continue

})
patches.ApplyMethodFunc(raw1, "EncodeHeaders", func(headers api.ResponseHeaderMap, endStream bool) api.ResultAction {
time.Sleep(50 * time.Millisecond)
return api.Continue
})
patches.ApplyMethodFunc(raw1, "EncodeData", func(data api.BufferInstance, endStream bool) api.ResultAction {
time.Sleep(20 * time.Millisecond)
return api.Continue
})
defer patches.Reset()
f1.DecodeData(nil, false)
f1.DecodeData(nil, true)
f1.EncodeHeaders(nil, false)
f1.EncodeData(nil, true)

records = cb.PluginState().Get("debugMode", "executionRecords").([]*model.ExecutionRecord)
t.Logf("get records %+v\n", records) // for debug when test failed
Expand All @@ -60,5 +70,5 @@ func TestDebugFilter(t *testing.T) {
// Should be the sum of multiple calls
delta := 10 * time.Millisecond
rec := records[1].Record - decodeHeadersCost
assert.True(t, 200*time.Millisecond-delta < rec && rec < 200*time.Millisecond+delta, rec)
assert.True(t, 270*time.Millisecond-delta < rec && rec < 270*time.Millisecond+delta, rec)
}

0 comments on commit f30af13

Please sign in to comment.