Watch
1
0
Fork
You've already forked pkg-proxy
1
mirror of https://github.com/git-pkgs/proxy.git synced 2026-09-15 23:32:04 -04:00

Compare commits

...
Author SHA1 Message Date
Andrew Nesbitt
69f36bfa58
Separate OCI request timeout from readiness probes in loopback test
The 250ms client is meant for the readiness poll, where a timeout is
retried. Reusing it for the OCI manifest request makes the test flake
under -race on Windows CI when fetch and cache I/O take longer, as
seen on #328. The request checks upstream routing, not latency.
2026-09-15 21:28:55 +01:00

View file

@ -237,7 +237,7 @@ func testStartUsesConfiguredLoopbackUpstreams(t *testing.T) {
} }
}() }()
client := &http.Client{Timeout: 250 * time.Millisecond} probeClient := &http.Client{Timeout: 250 * time.Millisecond}
deadline := time.Now().Add(5 * time.Second) deadline := time.Now().Add(5 * time.Second)
for { for {
req, err := http.NewRequest(http.MethodGet, cfg.BaseURL+"/pypi/simple/ruff/", nil) req, err := http.NewRequest(http.MethodGet, cfg.BaseURL+"/pypi/simple/ruff/", nil)
@ -245,7 +245,7 @@ func testStartUsesConfiguredLoopbackUpstreams(t *testing.T) {
t.Fatalf("creating request: %v", err) t.Fatalf("creating request: %v", err)
} }
req.Header.Set("Accept", "application/vnd.pypi.simple.v1+json") req.Header.Set("Accept", "application/vnd.pypi.simple.v1+json")
resp, requestErr := client.Do(req) resp, requestErr := probeClient.Do(req)
if requestErr == nil { if requestErr == nil {
body, readErr := io.ReadAll(resp.Body) body, readErr := io.ReadAll(resp.Body)
_ = resp.Body.Close() _ = resp.Body.Close()
@ -266,6 +266,9 @@ func testStartUsesConfiguredLoopbackUpstreams(t *testing.T) {
time.Sleep(10 * time.Millisecond) time.Sleep(10 * time.Millisecond)
} }
// This checks upstream routing, not latency. Allow time for fetching and
// cache I/O under -race on slower CI workers.
client := &http.Client{Timeout: 5 * time.Second}
resp, err := client.Get(cfg.BaseURL + "/v2/library/demo/manifests/latest") resp, err := client.Get(cfg.BaseURL + "/v2/library/demo/manifests/latest")
if err != nil { if err != nil {
t.Fatalf("OCI request failed: %v", err) t.Fatalf("OCI request failed: %v", err)