Skip to content

Commit 83aecaa

Browse files
committed
remove sleep
1 parent 360c8b9 commit 83aecaa

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

test/integration/grpc_management_plane_api_test.go

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -212,8 +212,6 @@ func TestGrpc_Reconnection(t *testing.T) {
212212
require.NoError(t, err)
213213
mockManagementPlaneAPIAddress = net.JoinHostPort(ipAddress, ports["9093/tcp"][0].HostPort)
214214

215-
time.Sleep(5 * time.Second)
216-
217215
currentID := verifyConnection(t, 2)
218216
assert.Equal(t, originalID, currentID)
219217
}
@@ -534,15 +532,25 @@ func verifyConnection(t *testing.T, instancesLength int) string {
534532

535533
client := resty.New()
536534
client.SetRetryCount(retryCount).SetRetryWaitTime(retryWaitTime).SetRetryMaxWaitTime(retryMaxWaitTime)
535+
connectionRequest := mpi.CreateConnectionRequest{}
536+
client.AddRetryCondition(
537+
func(r *resty.Response, err error) bool {
538+
responseData := r.Body()
539+
assert.True(t, json.Valid(responseData))
537540

541+
pb := protojson.UnmarshalOptions{DiscardUnknown: true}
542+
unmarshalErr := pb.Unmarshal(responseData, &connectionRequest)
543+
544+
return r.StatusCode() == http.StatusNotFound || unmarshalErr == nil
545+
},
546+
)
538547
url := fmt.Sprintf("http://%s/api/v1/connection", mockManagementPlaneAPIAddress)
548+
t.Logf("Connecting to %s", url)
539549
resp, err := client.R().EnableTrace().Get(url)
540550

541551
require.NoError(t, err)
542552
assert.Equal(t, http.StatusOK, resp.StatusCode())
543553

544-
connectionRequest := mpi.CreateConnectionRequest{}
545-
546554
responseData := resp.Body()
547555
t.Logf("Response: %s", string(responseData))
548556
assert.True(t, json.Valid(responseData))

0 commit comments

Comments
 (0)