MCPcopy
hub / github.com/keploy/keploy / BeginTestErrorCapture

Method BeginTestErrorCapture

pkg/agent/proxy/proxy.go:2886–2899  ·  view source on GitHub ↗

BeginTestErrorCapture starts collecting mock-not-found errors for the current test case into a fresh per-test accumulator, so the replayer's GetMockErrors returns only THIS test's misses instead of draining a shared global queue. Stale stragglers retained before any window (startup / between-test ba

()

Source from the content-addressed store, hash-verified

2884// background traffic) are discarded so they don't attach to this test.
2885// GetMockErrors retrieves and the next BeginTestErrorCapture resets the window.
2886func (p *Proxy) BeginTestErrorCapture() {
2887 p.captureMu.Lock()
2888 p.pendingMockErrors.drain()
2889 // Discard anything left in a prior window that was never closed — e.g. a
2890 // GetMockErrors whose HTTP round-trip failed, so the replayer couldn't
2891 // finalize it. Carrying those misses into THIS window would misattribute the
2892 // previous test's failures to the current test; they belong to a test we can
2893 // no longer report for, so drop them (same reasoning as the pre-window
2894 // stragglers drained above).
2895 if old := p.activeTestErrors.Swap(&testErrorAccumulator{}); old != nil {
2896 old.drain()
2897 }
2898 p.captureMu.Unlock()
2899}
2900
2901// EndTestErrorCapture stops collecting errors and returns all accumulated errors.
2902func (p *Proxy) EndTestErrorCapture() []error {

Implementers 1

Proxypkg/agent/proxy/proxy.go

Calls 2

SwapMethod · 0.80
drainMethod · 0.45