Skip to content

Commit

Permalink
remove /throttler/check usage in endtoend test, use gRPC
Browse files Browse the repository at this point in the history
Signed-off-by: Shlomi Noach <2607934+shlomi-noach@users.noreply.github.com>
  • Loading branch information
shlomi-noach committed Mar 3, 2025
1 parent d32fb67 commit 57d9fe3
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 44 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
38 changes: 0 additions & 38 deletions go/test/endtoend/throttler/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -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:
}
}
}

0 comments on commit 57d9fe3

Please sign in to comment.