Skip to content

Commit 5b6f0a0

Browse files
authored
fix test case std to report correct metrics (#999)
1 parent ef6f0cf commit 5b6f0a0

2 files changed

Lines changed: 22 additions & 4 deletions

File tree

Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -285,6 +285,7 @@ test-benchmark: manifests generate fmt vet ## Run benchmark tests (scale-up-late
285285
USE_SIMULATOR=$(USE_SIMULATOR) \
286286
SCALER_BACKEND=$(SCALER_BACKEND) \
287287
MODEL_ID=$(MODEL_ID) \
288+
PROMETHEUS_TOKEN=$$(oc whoami -t 2>/dev/null || echo "") \
288289
go test ./test/benchmark/ -timeout 75m -v -ginkgo.v \
289290
-ginkgo.label-filter="phase3a"; \
290291
TEST_EXIT_CODE=$$?; \

test/utils/e2eutils.go

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -981,20 +981,37 @@ func (p *PrometheusClient) API() promv1.API {
981981
return p.client
982982
}
983983

984+
type authRoundTripper struct {
985+
token string
986+
rt http.RoundTripper
987+
}
988+
989+
func (a *authRoundTripper) RoundTrip(req *http.Request) (*http.Response, error) {
990+
req.Header.Set("Authorization", "Bearer "+a.token)
991+
return a.rt.RoundTrip(req)
992+
}
993+
984994
// creates a new Prometheus client for e2e tests
985995
func NewPrometheusClient(baseURL string, insecureSkipVerify bool) (*PrometheusClient, error) {
986996
config := promAPI.Config{
987997
Address: baseURL,
988998
}
989999

990-
if insecureSkipVerify {
991-
roundTripper := promAPI.DefaultRoundTripper
992-
if rt, ok := roundTripper.(*http.Transport); ok {
1000+
roundTripper := promAPI.DefaultRoundTripper
1001+
if rt, ok := roundTripper.(*http.Transport); ok {
1002+
if insecureSkipVerify {
9931003
rt.TLSClientConfig = &tls.Config{InsecureSkipVerify: true}
9941004
}
995-
config.RoundTripper = roundTripper
9961005
}
9971006

1007+
if token := os.Getenv("PROMETHEUS_TOKEN"); token != "" {
1008+
roundTripper = &authRoundTripper{
1009+
token: token,
1010+
rt: roundTripper,
1011+
}
1012+
}
1013+
config.RoundTripper = roundTripper
1014+
9981015
client, err := promAPI.NewClient(config)
9991016
if err != nil {
10001017
return nil, fmt.Errorf("failed to create prometheus client: %w", err)

0 commit comments

Comments
 (0)