From 57d9fe3c35e0b01ad6731c6e3d5e0e44d3ecf853 Mon Sep 17 00:00:00 2001 From: Shlomi Noach <2607934+shlomi-noach@users.noreply.github.com> Date: Mon, 3 Mar 2025 09:05:00 +0200 Subject: [PATCH] remove /throttler/check usage in endtoend test, use gRPC Signed-off-by: Shlomi Noach <2607934+shlomi-noach@users.noreply.github.com> --- .../throttler_topo/throttler_test.go | 7 +--- go/test/endtoend/throttler/util.go | 38 ------------------- 2 files changed, 1 insertion(+), 44 deletions(-) diff --git a/go/test/endtoend/tabletmanager/throttler_topo/throttler_test.go b/go/test/endtoend/tabletmanager/throttler_topo/throttler_test.go index 5ba335597cf..842c3a949a0 100644 --- a/go/test/endtoend/tabletmanager/throttler_topo/throttler_test.go +++ b/go/test/endtoend/tabletmanager/throttler_topo/throttler_test.go @@ -593,12 +593,7 @@ func TestCustomQuery(t *testing.T) { } } } - }) - t.Run("validating OK response from throttler with custom query", func(t *testing.T) { - throttler.WaitForValidData(t, primaryTablet, throttlerEnabledTimeout) - resp, err := throttleCheck(primaryTablet, false) - require.NoError(t, err) - assert.EqualValues(t, tabletmanagerdatapb.CheckThrottlerResponseCode_OK, resp.Check.ResponseCode, "Unexpected response from throttler: %+v", resp) + waitForThrottleCheckStatus(t, primaryTablet, tabletmanagerdatapb.CheckThrottlerResponseCode_OK) }) t.Run("test threads running", func(t *testing.T) { sleepDuration := 20 * time.Second diff --git a/go/test/endtoend/throttler/util.go b/go/test/endtoend/throttler/util.go index 402915a01ef..3cf416d83a1 100644 --- a/go/test/endtoend/throttler/util.go +++ b/go/test/endtoend/throttler/util.go @@ -489,41 +489,3 @@ func getHTTPBody(url string) string { body := string(respByte) return body } - -// WaitForValidData waits for a tablet's checks to return a non 500 http response -// which indicates that it's not able to provide valid results. This is most -// commonly caused by the throttler still gathering the initial results for -// the given configuration. -func WaitForValidData(t *testing.T, tablet *cluster.Vttablet, timeout time.Duration) { - checkURL := fmt.Sprintf("http://localhost:%d/throttler/check", tablet.HTTPPort) - selfCheckURL := fmt.Sprintf("http://localhost:%d/throttler/check-self", tablet.HTTPPort) - ctx, cancel := context.WithTimeout(context.Background(), timeout) - defer cancel() - ticker := time.NewTicker(time.Second) - defer ticker.Stop() - - for { - checkResp, checkErr := http.Get(checkURL) - if checkErr == nil { - defer checkResp.Body.Close() - } - selfCheckResp, selfCheckErr := http.Get(selfCheckURL) - if selfCheckErr == nil { - defer selfCheckResp.Body.Close() - } - if checkErr == nil && selfCheckErr == nil && - checkResp.StatusCode != http.StatusInternalServerError && - selfCheckResp.StatusCode != http.StatusInternalServerError { - return - } - select { - case <-ctx.Done(): - respByte, _ := io.ReadAll(checkResp.Body) - body := string(respByte) - require.Failf(t, "time out", "waiting for %s tablet's throttler to return a valid result after %v; last seen result: %+v", - tablet.Alias, timeout, body) - return - case <-ticker.C: - } - } -}