(t *testing.T)
| 156 | traceHeadersReachedOrigin.Store(r.Header.Get("traceparent") != "" || r.Header.Get("tracestate") != "") |
| 157 | w.Header().Set("Content-Type", "application/octet-stream") |
| 158 | w.WriteHeader(http.StatusOK) |
| 159 | _, _ = w.Write([]byte("hello-parquet-bytes")) |
| 160 | }) |
| 161 | |
| 162 | // First request: cache miss → origin fetch → cached. |
| 163 | headers := http.Header{ |
| 164 | "Range": []string{"bytes=0-18"}, |
| 165 | "traceparent": []string{"00-00000000000000000000000000000001-0000000000000002-01"}, |
| 166 | "tracestate": []string{"vendor=value"}, |
| 167 | } |
| 168 | rec := doForwardProxyRequest(proxy, "GET", originURL+"/bucket/file.parquet", headers) |
| 169 | if rec.Code != http.StatusPartialContent { |
| 170 | t.Fatalf("miss: status = %d, want 206", rec.Code) |
| 171 | } |
| 172 | if body := rec.Body.String(); body != "hello-parquet-bytes" { |
| 173 | t.Errorf("miss body = %q, want hello-parquet-bytes", body) |
| 174 | } |
| 175 | if atomic.LoadInt32(&originCalls) != 1 { |
| 176 | t.Errorf("origin calls = %d, want 1 on miss", originCalls) |
| 177 | } |
| 178 | if traceHeadersReachedOrigin.Load() { |
| 179 | t.Fatal("trace propagation headers reached cached origin fetch") |
| 180 | } |
| 181 | |
| 182 | // Second request for the same URL + Range: cache hit, no extra origin call. |
| 183 | rec = doForwardProxyRequest(proxy, "GET", originURL+"/bucket/file.parquet", headers) |
| 184 | if rec.Code != http.StatusPartialContent { |
| 185 | t.Fatalf("hit: status = %d, want 206", rec.Code) |
| 186 | } |
| 187 | if atomic.LoadInt32(&originCalls) != 1 { |
nothing calls this directly
no test coverage detected