MCPcopy Create free account
hub / github.com/PostHog/duckgres / TestHandleProxyForwardsOrigin400Verbatim

Function TestHandleProxyForwardsOrigin400Verbatim

cmd/cache-proxy/proxy_test.go:650–674  ·  view source on GitHub ↗

TestHandleProxyForwardsOrigin400Verbatim is the case the user actually hit: S3 returns 400 with an XML envelope ( ExpiredToken ) and DuckDB needs to see *that* body and *that* status, not a generic 502 with a Go-formatted error string. Without verbatim passthrough the error class (4xx ter

(t *testing.T)

Source from the content-addressed store, hash-verified

648 url := fmt.Sprintf("%s/bucket/concurrent-%d.parquet", originURL, i)
649 headers := http.Header{"Range": []string{fmt.Sprintf("bytes=%d-%d", i, i+1)}}
650 results <- doForwardProxyRequest(proxy, "GET", url, headers)
651 }()
652 }
653
654 deadline := time.Now().Add(2 * time.Second)
655 for atomic.LoadInt32(&originCalls) < requests && time.Now().Before(deadline) {
656 time.Sleep(10 * time.Millisecond)
657 }
658 if got := atomic.LoadInt32(&originCalls); got != requests {
659 release()
660 t.Fatalf("origin calls before release = %d, want %d; metrics-only PR must not limit origin concurrency", got, requests)
661 }
662 if got := atomic.LoadInt32(&maxActiveOriginCalls); got != requests {
663 release()
664 t.Fatalf("simultaneous origin calls before release = %d, want %d; metrics-only PR must not queue origin concurrency", got, requests)
665 }
666 release()
667
668 var failed []string
669 for i := 0; i < requests; i++ {
670 rec := waitForRecorder(t, results, "timed out waiting for concurrent proxy response")
671 if rec.Code != http.StatusPartialContent {
672 failed = append(failed, fmt.Sprintf("response %d status = %d", i+1, rec.Code))
673 }
674 }
675 if len(failed) > 0 {
676 t.Fatalf("metrics-only PR must not add local rejection behavior: %s", strings.Join(failed, ", "))
677 }

Callers

nothing calls this directly

Calls 7

newTestProxyFunction · 0.85
newTestServerFunction · 0.85
doForwardProxyRequestFunction · 0.85
HeaderMethod · 0.45
WriteMethod · 0.45
StringMethod · 0.45
GetMethod · 0.45

Tested by

no test coverage detected