Skip to content
This repository has been archived by the owner on Jun 21, 2022. It is now read-only.

Commit

Permalink
PMM-4879 Added coverage tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
pkadej committed Apr 27, 2022
1 parent 5cb6346 commit 64538ce
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 9 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ go 1.18

// Use for local development, but do not commit:
// replace github.com/percona/pmm => ../pmm
replace github.com/percona/pmm => github.com/pkadej/pmm v0.0.0-20220425222533-a6e4e7330135
replace github.com/percona/pmm => github.com/pkadej/pmm v0.0.0-20220427173424-9aa771bbf8c1

// replace github.com/percona-platform/saas => ../saas
// replace github.com/percona-platform/dbaas-api => ../dbaas-api
Expand Down
10 changes: 2 additions & 8 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -465,19 +465,13 @@ github.com/percona-platform/dbaas-api v0.0.0-20220110092915-5aacd784d472 h1:Henk
github.com/percona-platform/dbaas-api v0.0.0-20220110092915-5aacd784d472/go.mod h1:WZZ3Hi+lAWCaGWmsrfkkvRQPkIa8n1OZ0s8Su+vbgus=
github.com/percona-platform/saas v0.0.0-20220326163809-90f261fe195c h1:laB9JpVYIRclGKk596X/qJaHbchx6O/em0MugBkqPVU=
github.com/percona-platform/saas v0.0.0-20220326163809-90f261fe195c/go.mod h1:gFUwaFp6Ugu5qsBwiOVJYbDlzgZ77tmXdXGO7tG5xVI=
github.com/percona/pmm v0.0.0-20220425093801-6ff2b4fb108f h1:HV3NCszjpxkVXWUJSfmT86YFWl1TFHKuAf7mM9t5szQ=
github.com/percona/pmm v0.0.0-20220425093801-6ff2b4fb108f/go.mod h1:FFbpyZXm+Ilg8M/GewuhdjJhPaW1/v1zjRRerYhCfEA=
github.com/percona/pmm v0.0.0-20220426095359-6ec19a46c5a2 h1:82QYprx2f64L08A7g0ZzkzkRlVN2NElGJh/mGsciGGQ=
github.com/percona/pmm v0.0.0-20220426095359-6ec19a46c5a2/go.mod h1:FFbpyZXm+Ilg8M/GewuhdjJhPaW1/v1zjRRerYhCfEA=
github.com/percona/pmm v0.0.0-20220427122756-c52cc545e1f3 h1:6IKHKNDNJADEN/YsvXcUiJ8M75/PW+bJZ3kMb+CL7kM=
github.com/percona/pmm v0.0.0-20220427122756-c52cc545e1f3/go.mod h1:FFbpyZXm+Ilg8M/GewuhdjJhPaW1/v1zjRRerYhCfEA=
github.com/percona/promconfig v0.2.4-0.20211110115058-98687f586f54 h1:aI1emmycDTGWKsBdxFPKZqohfBbK4y2ta9G4+RX7gVg=
github.com/percona/promconfig v0.2.4-0.20211110115058-98687f586f54/go.mod h1:Y2uXi5QNk71+ceJHuI9poank+0S1kjxd3K105fXKVkg=
github.com/pierrec/lz4 v2.0.5+incompatible/go.mod h1:pdkljMzZIN41W+lC3N2tnIh5sFi+IEE17M5jbnwPHcY=
github.com/pierrec/lz4/v4 v4.1.14 h1:+fL8AQEZtz/ijeNnpduH0bROTu0O3NZAlPjQxGn8LwE=
github.com/pierrec/lz4/v4 v4.1.14/go.mod h1:gZWDp/Ze/IJXGXf23ltt2EXimqmTUXEy0GFuRQyBid4=
github.com/pkadej/pmm v0.0.0-20220425222533-a6e4e7330135 h1:oY+J8Q4uw7q/G19ybdZlfcGW1gh3OlJHJumxpdNF5Ks=
github.com/pkadej/pmm v0.0.0-20220425222533-a6e4e7330135/go.mod h1:FFbpyZXm+Ilg8M/GewuhdjJhPaW1/v1zjRRerYhCfEA=
github.com/pkadej/pmm v0.0.0-20220427173424-9aa771bbf8c1 h1:O8OIMYgFTptOkFihK2xCUEoXBX5N0As7p47k+X6qk9s=
github.com/pkadej/pmm v0.0.0-20220427173424-9aa771bbf8c1/go.mod h1:FFbpyZXm+Ilg8M/GewuhdjJhPaW1/v1zjRRerYhCfEA=
github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
Expand Down
48 changes: 48 additions & 0 deletions services/agents/channel/channel_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -356,3 +356,51 @@ func TestUnexpectedResponsePayloadFromAgent(t *testing.T) {
close(stopServer)
<-stop
}

func TestChannelForDefaultsFileParser(t *testing.T) {
const count = 50
require.True(t, count > agentRequestsCap)

connect := func(ch *Channel) error {
testValue := "test"
testPort := uint32(123123)
for i := uint32(1); i <= count; i++ {
resp, err := ch.SendAndWaitResponse(&agentpb.ParseDefaultsFileRequest{})
require.NotNil(t, resp)
parserResponse := resp.(*agentpb.ParseDefaultsFileResponse)
assert.Equal(t, parserResponse.Username, testValue)
assert.Equal(t, parserResponse.Password, testValue)
assert.Equal(t, parserResponse.Socket, testValue)
assert.Equal(t, parserResponse.Port, testPort)
require.NoError(t, err)
assert.NoError(t, err)
}

assert.Nil(t, <-ch.Requests())
return nil
}

stream, _, teardown := setup(t, connect, io.EOF) // EOF = server exits from handler
defer teardown(t)

for i := uint32(1); i <= count; i++ {
msg, err := stream.Recv()
require.NoError(t, err)
assert.Equal(t, i, msg.Id)
assert.NotNil(t, msg.GetParseDefaultsFile())

err = stream.Send(&agentpb.AgentMessage{
Id: i,
Payload: (&agentpb.ParseDefaultsFileResponse{
Username: "test",
Password: "test",
Port: 123123,
Socket: "test",
}).AgentMessageResponsePayload(),
})
assert.NoError(t, err)
}

err := stream.CloseSend()
assert.NoError(t, err)
}

0 comments on commit 64538ce

Please sign in to comment.