From 6c1813b75ecf8d7d6e65cd556550c9bdc709ffe5 Mon Sep 17 00:00:00 2001 From: Justin Jung Date: Tue, 28 Nov 2023 10:13:51 -0800 Subject: [PATCH] Attempt to fix tests Signed-off-by: Justin Jung --- pkg/frontend/transport/handler.go | 1 - pkg/querier/tripperware/priority.go | 4 ++-- pkg/util/httpgrpcutil/header.go | 7 ++++++- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/pkg/frontend/transport/handler.go b/pkg/frontend/transport/handler.go index 042dbd32b7..700145312f 100644 --- a/pkg/frontend/transport/handler.go +++ b/pkg/frontend/transport/handler.go @@ -200,7 +200,6 @@ func (f *Handler) ServeHTTP(w http.ResponseWriter, r *http.Request) { r.Body = io.NopCloser(&buf) } - r.Header.Get("test") startTime := time.Now() resp, err := f.roundTripper.RoundTrip(r) queryResponseTime := time.Since(startTime) diff --git a/pkg/querier/tripperware/priority.go b/pkg/querier/tripperware/priority.go index 5ce4e0d3fa..b96a3b0e9a 100644 --- a/pkg/querier/tripperware/priority.go +++ b/pkg/querier/tripperware/priority.go @@ -88,7 +88,7 @@ func isWithinTimeAttributes(attribute validation.QueryAttribute, now time.Time, } func FindMinMaxTime(s *parser.EvalStmt) (int64, int64) { - // Placeholder until Prometheus is updated to >=0.48.0 - // which includes https://github.com/prometheus/prometheus/commit/9e3df532d8294d4fe3284bde7bc96db336a33552 + // Placeholder until Prometheus is updated to include + // https://github.com/prometheus/prometheus/commit/9e3df532d8294d4fe3284bde7bc96db336a33552 return s.Start.Unix(), s.End.Unix() } diff --git a/pkg/util/httpgrpcutil/header.go b/pkg/util/httpgrpcutil/header.go index b844e0c65f..ed453f01fa 100644 --- a/pkg/util/httpgrpcutil/header.go +++ b/pkg/util/httpgrpcutil/header.go @@ -7,7 +7,12 @@ import ( // GetHeader is similar to http.Header.Get, which gets the first value associated with the given key. // If there are no values associated with the key, it returns "". func GetHeader(r httpgrpc.HTTPRequest, key string) string { - return GetHeaderValues(r, key)[0] + values := GetHeaderValues(r, key) + if len(values) == 0 { + return "" + } + + return values[0] } // GetHeaderValues is similar to http.Header.Values, which returns all values associated with the given key.