Skip to content

Commit

Permalink
PMM-7 Fix imports protobuf (#2964)
Browse files Browse the repository at this point in the history
  • Loading branch information
BupycHuk authored Apr 20, 2024
1 parent 4daf521 commit 41db807
Show file tree
Hide file tree
Showing 7 changed files with 167 additions and 170 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ require (
github.com/go-openapi/validate v0.24.0
github.com/go-sql-driver/mysql v1.7.1
github.com/golang-migrate/migrate/v4 v4.17.0
github.com/golang/protobuf v1.5.4
github.com/google/uuid v1.6.0
github.com/grafana/grafana-api-golang-client v0.27.0
github.com/grpc-ecosystem/go-grpc-middleware v1.4.0
Expand Down Expand Up @@ -116,6 +115,7 @@ require (
github.com/go-logr/stdr v1.2.2 // indirect
github.com/golang-jwt/jwt/v5 v5.2.0 // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/golang/protobuf v1.5.4 // indirect
github.com/google/gnostic-models v0.6.8 // indirect
github.com/google/gofuzz v1.2.0 // indirect
github.com/google/pprof v0.0.0-20221118152302-e6195bd50e26 // indirect
Expand Down
7 changes: 4 additions & 3 deletions managed/services/agents/channel/channel.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,13 @@ import (
"sync"
"sync/atomic"

"github.com/golang/protobuf/proto" //nolint:staticcheck
"github.com/pkg/errors"
"github.com/sirupsen/logrus"
protostatus "google.golang.org/genproto/googleapis/rpc/status"
"google.golang.org/grpc/codes"
grpcstatus "google.golang.org/grpc/status"
"google.golang.org/protobuf/encoding/prototext"
"google.golang.org/protobuf/proto"

"github.com/percona/pmm/api/agentpb"
"github.com/percona/pmm/utils/logger"
Expand Down Expand Up @@ -194,7 +195,7 @@ func (c *Channel) send(msg *agentpb.ServerMessage) {
if size := proto.Size(msg); size < 100 {
c.l.Debugf("Sending message (%d bytes): %s.", size, msg)
} else {
c.l.Debugf("Sending message (%d bytes):\n%s\n", size, proto.MarshalTextString(msg))
c.l.Debugf("Sending message (%d bytes):\n%s\n", size, prototext.Format(msg))
}
}

Expand Down Expand Up @@ -229,7 +230,7 @@ func (c *Channel) runReceiver() {
if size := proto.Size(msg); size < 100 {
c.l.Debugf("Received message (%d bytes): %s.", size, msg)
} else {
c.l.Debugf("Received message (%d bytes):\n%s\n", size, proto.MarshalTextString(msg))
c.l.Debugf("Received message (%d bytes):\n%s\n", size, prototext.Format(msg))
}
}

Expand Down
4 changes: 2 additions & 2 deletions managed/services/agents/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ import (
"time"

"github.com/AlekSi/pointer"
"github.com/golang/protobuf/proto" //nolint:staticcheck
"github.com/pkg/errors"
"github.com/sirupsen/logrus"
"google.golang.org/protobuf/encoding/prototext"
"gopkg.in/reform.v1"

"github.com/percona/pmm/api/agentpb"
Expand Down Expand Up @@ -274,7 +274,7 @@ func (u *StateUpdater) sendSetStateRequest(ctx context.Context, agent *pmmAgentI
AgentProcesses: agentProcesses,
BuiltinAgents: builtinAgents,
}
l.Debugf("sendSetStateRequest:\n%s", proto.MarshalTextString(state))
l.Debugf("sendSetStateRequest:\n%s", prototext.Format(state))

resp, err := agent.channel.SendAndWaitResponse(state)
if err != nil {
Expand Down
6 changes: 3 additions & 3 deletions managed/services/management/rds_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@ import (
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/credentials"
"github.com/aws/aws-sdk-go/aws/session"
"github.com/golang/protobuf/proto" //nolint:staticcheck
"github.com/google/uuid"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
"google.golang.org/protobuf/encoding/prototext"
"gopkg.in/reform.v1"
"gopkg.in/reform.v1/dialects/postgresql"

Expand Down Expand Up @@ -318,7 +318,7 @@ func TestRDSService(t *testing.T) {
Status: inventorypb.AgentStatus_UNKNOWN,
},
}
assert.Equal(t, proto.MarshalTextString(expected), proto.MarshalTextString(resp)) // for better diffs
assert.Equal(t, prototext.Format(expected), prototext.Format(resp)) // for better diffs
})

t.Run("AddRDSPostgreSQL", func(t *testing.T) {
Expand Down Expand Up @@ -408,6 +408,6 @@ func TestRDSService(t *testing.T) {
Status: inventorypb.AgentStatus_UNKNOWN,
},
}
assert.Equal(t, proto.MarshalTextString(expected), proto.MarshalTextString(resp)) // for better diffs
assert.Equal(t, prototext.Format(expected), prototext.Format(resp)) // for better diffs
})
}
27 changes: 13 additions & 14 deletions qan-api2/services/analytics/filters_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,9 @@ import (
"time"

_ "github.com/ClickHouse/clickhouse-go/151" // register database/sql driver
// TODO replace with 'google.golang.org/protobuf/encoding/protojson' since this one is deprecated.
"github.com/golang/protobuf/ptypes/timestamp"
"github.com/jmoiron/sqlx"
"github.com/stretchr/testify/assert"
"google.golang.org/protobuf/types/known/timestamppb"

qanpb "github.com/percona/pmm/api/qanpb"
"github.com/percona/pmm/qan-api2/models"
Expand Down Expand Up @@ -82,8 +81,8 @@ func TestService_GetFilters(t *testing.T) {
"success",
fields{rm: rm, mm: mm},
&qanpb.FiltersRequest{
PeriodStartFrom: &timestamp.Timestamp{Seconds: t1.Unix()},
PeriodStartTo: &timestamp.Timestamp{Seconds: t2.Unix()},
PeriodStartFrom: &timestamppb.Timestamp{Seconds: t1.Unix()},
PeriodStartTo: &timestamppb.Timestamp{Seconds: t2.Unix()},
},
&want,
false,
Expand All @@ -92,8 +91,8 @@ func TestService_GetFilters(t *testing.T) {
"success_with_dimensions_username",
fields{rm: rm, mm: mm},
&qanpb.FiltersRequest{
PeriodStartFrom: &timestamp.Timestamp{Seconds: t1.Unix()},
PeriodStartTo: &timestamp.Timestamp{Seconds: t2.Unix()},
PeriodStartFrom: &timestamppb.Timestamp{Seconds: t1.Unix()},
PeriodStartTo: &timestamppb.Timestamp{Seconds: t2.Unix()},
Labels: []*qanpb.MapFieldEntry{
{Key: "username", Value: []string{"user1", "user2"}},
},
Expand All @@ -105,8 +104,8 @@ func TestService_GetFilters(t *testing.T) {
"success_with_dimensions_client_host_schema_service_name",
fields{rm: rm, mm: mm},
&qanpb.FiltersRequest{
PeriodStartFrom: &timestamp.Timestamp{Seconds: t1.Unix()},
PeriodStartTo: &timestamp.Timestamp{Seconds: t2.Unix()},
PeriodStartFrom: &timestamppb.Timestamp{Seconds: t1.Unix()},
PeriodStartTo: &timestamppb.Timestamp{Seconds: t2.Unix()},
Labels: []*qanpb.MapFieldEntry{
{Key: "client_host", Value: []string{"10.11.12.1", "10.11.12.2", "10.11.12.3", "10.11.12.4", "10.11.12.5", "10.11.12.6", "10.11.12.7", "10.11.12.8", "10.11.12.9", "10.11.12.10", "10.11.12.11", "10.11.12.12", "10.11.12.13"}},
{Key: "schema", Value: []string{"schema65", "schema6", "schema42", "schema76", "schema90", "schema39", "schema1", "schema17", "schema79", "schema10"}},
Expand All @@ -120,8 +119,8 @@ func TestService_GetFilters(t *testing.T) {
"success_with_dimensions_multiple",
fields{rm: rm, mm: mm},
&qanpb.FiltersRequest{
PeriodStartFrom: &timestamp.Timestamp{Seconds: t1.Unix()},
PeriodStartTo: &timestamp.Timestamp{Seconds: t2.Unix()},
PeriodStartFrom: &timestamppb.Timestamp{Seconds: t1.Unix()},
PeriodStartTo: &timestamppb.Timestamp{Seconds: t2.Unix()},
Labels: []*qanpb.MapFieldEntry{
{Key: "container_id", Value: []string{"container_id"}},
{Key: "container_name", Value: []string{"container_name1"}},
Expand All @@ -148,8 +147,8 @@ func TestService_GetFilters(t *testing.T) {
"success_with_labels",
fields{rm: rm, mm: mm},
&qanpb.FiltersRequest{
PeriodStartFrom: &timestamp.Timestamp{Seconds: t1.Unix()},
PeriodStartTo: &timestamp.Timestamp{Seconds: t2.Unix()},
PeriodStartFrom: &timestamppb.Timestamp{Seconds: t1.Unix()},
PeriodStartTo: &timestamppb.Timestamp{Seconds: t2.Unix()},
Labels: []*qanpb.MapFieldEntry{
{Key: "label0", Value: []string{"value1"}},
},
Expand All @@ -161,8 +160,8 @@ func TestService_GetFilters(t *testing.T) {
"fail",
fields{rm: rm, mm: mm},
&qanpb.FiltersRequest{
PeriodStartFrom: &timestamp.Timestamp{Seconds: t2.Unix()},
PeriodStartTo: &timestamp.Timestamp{Seconds: t1.Unix()},
PeriodStartFrom: &timestamppb.Timestamp{Seconds: t2.Unix()},
PeriodStartTo: &timestamppb.Timestamp{Seconds: t1.Unix()},
},
nil,
true,
Expand Down
Loading

0 comments on commit 41db807

Please sign in to comment.