Skip to content

Commit

Permalink
fix TestPreparingProgress
Browse files Browse the repository at this point in the history
Signed-off-by: Ryan Leung <[email protected]>
  • Loading branch information
rleungx committed Nov 13, 2024
1 parent 9415fdc commit 665dee5
Showing 1 changed file with 4 additions and 17 deletions.
21 changes: 4 additions & 17 deletions tests/server/api/api_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1008,28 +1008,15 @@ func TestPreparingProgress(t *testing.T) {
for _, store := range stores[2:] {
tests.MustPutStore(re, cluster, store)
}
// no store preparing
output := sendRequest(re, leader.GetAddr()+"/pd/api/v1/stores/progress?action=preparing", http.MethodGet, http.StatusNotFound)
re.Contains(string(output), "no progress found for the action")
output = sendRequest(re, leader.GetAddr()+"/pd/api/v1/stores/progress?id=4", http.MethodGet, http.StatusNotFound)
re.Contains(string(output), "no progress found for the given store ID")

if !leader.GetRaftCluster().IsPrepared() {
testutil.Eventually(re, func() bool {
if leader.GetRaftCluster().IsPrepared() {
return true
}
url := leader.GetAddr() + "/pd/api/v1/stores/progress?action=preparing"
req, _ := http.NewRequest(http.MethodGet, url, http.NoBody)
resp, err := tests.TestDialClient.Do(req)
re.NoError(err)
defer resp.Body.Close()
if resp.StatusCode != http.StatusNotFound {
return false
}
// is not prepared
output, err := io.ReadAll(resp.Body)
re.NoError(err)

// no store preparing
output := sendRequest(re, leader.GetAddr()+"/pd/api/v1/stores/progress?action=preparing", http.MethodGet, http.StatusNotFound)
re.Contains(string(output), "no progress found for the action")
output = sendRequest(re, leader.GetAddr()+"/pd/api/v1/stores/progress?id=4", http.MethodGet, http.StatusNotFound)
re.Contains(string(output), "no progress found for the given store ID")
Expand Down Expand Up @@ -1092,7 +1079,7 @@ func TestPreparingProgress(t *testing.T) {
return true
})

output = sendRequest(re, leader.GetAddr()+"/pd/api/v1/stores/progress?id=4", http.MethodGet, http.StatusOK)
output := sendRequest(re, leader.GetAddr()+"/pd/api/v1/stores/progress?id=4", http.MethodGet, http.StatusOK)
re.NoError(json.Unmarshal(output, &p))
re.Equal("preparing", p.Action)
re.Equal("0.05", fmt.Sprintf("%.2f", p.Progress))
Expand Down

0 comments on commit 665dee5

Please sign in to comment.