Skip to content

Commit 290c6e8

Browse files
authored
Fix failing integration tests (#1001)
1 parent cfc9f48 commit 290c6e8

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

test/integration/grpc_management_plane_api_test.go

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ const (
3636
"configuration file /etc/nginx/nginx.conf test failed\n"
3737

3838
retryCount = 5
39-
retryWaitTime = 2 * time.Second
40-
retryMaxWaitTime = 3 * time.Second
39+
retryWaitTime = 4 * time.Second
40+
retryMaxWaitTime = 5 * time.Second
4141
)
4242

4343
var (
@@ -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
}
@@ -533,15 +531,24 @@ func verifyConnection(t *testing.T, instancesLength int) string {
533531

534532
client := resty.New()
535533
client.SetRetryCount(retryCount).SetRetryWaitTime(retryWaitTime).SetRetryMaxWaitTime(retryMaxWaitTime)
534+
connectionRequest := mpi.CreateConnectionRequest{}
535+
client.AddRetryCondition(
536+
func(r *resty.Response, err error) bool {
537+
responseData := r.Body()
536538

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

540549
require.NoError(t, err)
541550
assert.Equal(t, http.StatusOK, resp.StatusCode())
542551

543-
connectionRequest := mpi.CreateConnectionRequest{}
544-
545552
responseData := resp.Body()
546553
t.Logf("Response: %s", string(responseData))
547554
assert.True(t, json.Valid(responseData))

0 commit comments

Comments
 (0)