Skip to content

Commit fbffe45

Browse files
committed
fix test
1 parent e0453b8 commit fbffe45

File tree

2 files changed

+2
-94
lines changed

2 files changed

+2
-94
lines changed

test/integration/grpc_management_plane_api_test.go

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -505,9 +505,6 @@ func getManagementPlaneResponses(t *testing.T, numberOfExpectedResponses int) []
505505
unmarshalErr := json.Unmarshal(responseData, &response)
506506
require.NoError(t, unmarshalErr)
507507

508-
assert.Eventually(t, func() bool { return len(response) == numberOfExpectedResponses },
509-
2*time.Second, 10*time.Millisecond)
510-
511508
slices.SortFunc(response, func(a, b *mpi.DataPlaneResponse) int {
512509
return a.GetMessageMeta().GetTimestamp().AsTime().Compare(b.GetMessageMeta().GetTimestamp().AsTime())
513510
})
@@ -527,7 +524,6 @@ func clearManagementPlaneResponses(t *testing.T) {
527524
assert.Equal(t, http.StatusOK, resp.StatusCode())
528525
}
529526

530-
// nolint
531527
func verifyConnection(t *testing.T, instancesLength int) string {
532528
t.Helper()
533529

@@ -541,11 +537,7 @@ func verifyConnection(t *testing.T, instancesLength int) string {
541537
pb := protojson.UnmarshalOptions{DiscardUnknown: true}
542538
unmarshalErr := pb.Unmarshal(responseData, &connectionRequest)
543539

544-
t.Logf("Connection response: %v", &connectionRequest)
545-
t.Logf("Error response: %v", unmarshalErr)
546-
t.Logf("status %v", r.StatusCode())
547-
548-
return r.StatusCode() == http.StatusNotFound || unmarshalErr == nil
540+
return r.StatusCode() == http.StatusNotFound || unmarshalErr != nil
549541
},
550542
)
551543
url := fmt.Sprintf("http://%s/api/v1/connection", mockManagementPlaneAPIAddress)

test/integration/nginx_less_mpi_connection_test.go

Lines changed: 1 addition & 85 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,8 @@
66
package integration
77

88
import (
9-
"encoding/json"
10-
"fmt"
11-
"net/http"
129
"testing"
1310

14-
"github.com/go-resty/resty/v2"
15-
mpi "github.com/nginx/agent/v3/api/grpc/mpi/v1"
16-
"github.com/stretchr/testify/require"
17-
"google.golang.org/protobuf/encoding/protojson"
18-
1911
"github.com/stretchr/testify/assert"
2012
)
2113

@@ -24,82 +16,6 @@ func TestNginxLessGrpc_Connection(t *testing.T) {
2416
teardownTest := setupConnectionTest(t, true, true)
2517
defer teardownTest(t)
2618

27-
verifyNginxLessConnection(t, 1)
19+
verifyConnection(t, 1)
2820
assert.False(t, t.Failed())
2921
}
30-
31-
// nolint
32-
func verifyNginxLessConnection(t *testing.T, instancesLength int) string {
33-
t.Helper()
34-
35-
client := resty.New()
36-
client.SetRetryCount(retryCount).SetRetryWaitTime(retryWaitTime).SetRetryMaxWaitTime(retryMaxWaitTime)
37-
connectionRequest := mpi.CreateConnectionRequest{}
38-
39-
url := fmt.Sprintf("http://%s/api/v1/connection", mockManagementPlaneAPIAddress)
40-
t.Logf("Connecting to %s", url)
41-
resp, err := client.R().EnableTrace().Get(url)
42-
43-
require.NoError(t, err)
44-
assert.Equal(t, http.StatusOK, resp.StatusCode())
45-
46-
responseData := resp.Body()
47-
t.Logf("Response: %s", string(responseData))
48-
assert.True(t, json.Valid(responseData))
49-
50-
pb := protojson.UnmarshalOptions{DiscardUnknown: true}
51-
unmarshalErr := pb.Unmarshal(responseData, &connectionRequest)
52-
require.NoError(t, unmarshalErr)
53-
54-
t.Logf("ConnectionRequest: %v", &connectionRequest)
55-
56-
resource := connectionRequest.GetResource()
57-
58-
assert.NotNil(t, resource.GetResourceId())
59-
assert.NotNil(t, resource.GetContainerInfo().GetContainerId())
60-
61-
assert.Len(t, resource.GetInstances(), instancesLength)
62-
63-
var nginxInstanceID string
64-
65-
for _, instance := range resource.GetInstances() {
66-
switch instance.GetInstanceMeta().GetInstanceType() {
67-
case mpi.InstanceMeta_INSTANCE_TYPE_AGENT:
68-
agentInstanceMeta := instance.GetInstanceMeta()
69-
70-
assert.NotEmpty(t, agentInstanceMeta.GetInstanceId())
71-
assert.NotEmpty(t, agentInstanceMeta.GetVersion())
72-
73-
assert.NotEmpty(t, instance.GetInstanceRuntime().GetBinaryPath())
74-
75-
assert.Equal(t, "/etc/nginx-agent/nginx-agent.conf", instance.GetInstanceRuntime().GetConfigPath())
76-
case mpi.InstanceMeta_INSTANCE_TYPE_NGINX:
77-
nginxInstanceMeta := instance.GetInstanceMeta()
78-
79-
nginxInstanceID = nginxInstanceMeta.GetInstanceId()
80-
assert.NotEmpty(t, nginxInstanceID)
81-
assert.NotEmpty(t, nginxInstanceMeta.GetVersion())
82-
83-
assert.NotEmpty(t, instance.GetInstanceRuntime().GetBinaryPath())
84-
85-
assert.Equal(t, "/etc/nginx/nginx.conf", instance.GetInstanceRuntime().GetConfigPath())
86-
case mpi.InstanceMeta_INSTANCE_TYPE_NGINX_PLUS:
87-
nginxInstanceMeta := instance.GetInstanceMeta()
88-
89-
nginxInstanceID = nginxInstanceMeta.GetInstanceId()
90-
assert.NotEmpty(t, nginxInstanceID)
91-
assert.NotEmpty(t, nginxInstanceMeta.GetVersion())
92-
93-
assert.NotEmpty(t, instance.GetInstanceRuntime().GetBinaryPath())
94-
95-
assert.Equal(t, "/etc/nginx/nginx.conf", instance.GetInstanceRuntime().GetConfigPath())
96-
case mpi.InstanceMeta_INSTANCE_TYPE_UNIT,
97-
mpi.InstanceMeta_INSTANCE_TYPE_UNSPECIFIED:
98-
fallthrough
99-
default:
100-
t.Fail()
101-
}
102-
}
103-
104-
return nginxInstanceID
105-
}

0 commit comments

Comments
 (0)