From 102cd115715d0644e79afe90155bc89ec1da773f Mon Sep 17 00:00:00 2001 From: Alex Demidoff Date: Thu, 27 Jun 2024 17:37:30 +0000 Subject: [PATCH] fix: node.proto and node_test --- api/management/v1/node.proto | 1 - managed/services/management/node_test.go | 46 ++++++++++++------------ 2 files changed, 24 insertions(+), 23 deletions(-) diff --git a/api/management/v1/node.proto b/api/management/v1/node.proto index d52d44d3023..913415a2041 100644 --- a/api/management/v1/node.proto +++ b/api/management/v1/node.proto @@ -2,7 +2,6 @@ syntax = "proto3"; package management.v1; -import "google/api/annotations.proto"; import "inventory/v1/agents.proto"; import "inventory/v1/nodes.proto"; import "management/v1/metrics.proto"; diff --git a/managed/services/management/node_test.go b/managed/services/management/node_test.go index e6dc03bac62..0140558e39e 100644 --- a/managed/services/management/node_test.go +++ b/managed/services/management/node_test.go @@ -27,6 +27,8 @@ import ( "gopkg.in/reform.v1" "gopkg.in/reform.v1/dialects/postgresql" + inventoryv1 "github.com/percona/pmm/api/inventory/v1" + managementv1 "github.com/percona/pmm/api/management/v1" "github.com/percona/pmm/managed/models" "github.com/percona/pmm/managed/utils/testdb" "github.com/percona/pmm/managed/utils/tests" @@ -86,21 +88,21 @@ func TestNodeService(t *testing.T) { t.Run("New", func(t *testing.T) { nodeName := getTestNodeName() - res, err := s.Register(ctx, &managementpb.RegisterNodeRequest{ - NodeType: inventorypb.NodeType_GENERIC_NODE, + res, err := s.RegisterNode(ctx, &managementv1.RegisterNodeRequest{ + NodeType: inventoryv1.NodeType_NODE_TYPE_GENERIC_NODE, NodeName: nodeName, Address: "some.address.org", Region: "region", }) - expected := &managementpb.RegisterNodeResponse{ - GenericNode: &inventorypb.GenericNode{ + expected := &managementv1.RegisterNodeResponse{ + GenericNode: &inventoryv1.GenericNode{ NodeId: "/node_id/00000000-0000-4000-8000-000000000005", NodeName: nodeName, Address: "some.address.org", Region: "region", }, - ContainerNode: (*inventorypb.ContainerNode)(nil), - PmmAgent: &inventorypb.PMMAgent{ + ContainerNode: (*inventoryv1.ContainerNode)(nil), + PmmAgent: &inventoryv1.PMMAgent{ AgentId: "/agent_id/00000000-0000-4000-8000-000000000006", RunsOnNodeId: "/node_id/00000000-0000-4000-8000-000000000005", }, @@ -111,8 +113,8 @@ func TestNodeService(t *testing.T) { }) t.Run("Exist", func(t *testing.T) { - res, err := s.Register(ctx, &managementpb.RegisterNodeRequest{ - NodeType: inventorypb.NodeType_GENERIC_NODE, + res, err := s.RegisterNode(ctx, &managementv1.RegisterNodeRequest{ + NodeType: inventoryv1.NodeType_NODE_TYPE_GENERIC_NODE, NodeName: getTestNodeName(), }) assert.Nil(t, res) @@ -127,10 +129,10 @@ func TestNodeService(t *testing.T) { authProvider := &mockGrafanaClient{} authProvider.Test(t) authProvider.On("CreateServiceAccount", ctx, nodeName, reregister).Return(serviceAccountID, "test-token", nil) - s.ap = authProvider + s.grafanaClient = authProvider - _, err := s.Register(ctx, &managementpb.RegisterNodeRequest{ - NodeType: inventorypb.NodeType_GENERIC_NODE, + _, err := s.RegisterNode(ctx, &managementv1.RegisterNodeRequest{ + NodeType: inventoryv1.NodeType_NODE_TYPE_GENERIC_NODE, NodeName: nodeName, Address: "some.address.org", Region: "region", @@ -148,24 +150,24 @@ func TestNodeService(t *testing.T) { authProvider := &mockGrafanaClient{} authProvider.Test(t) authProvider.On("CreateServiceAccount", ctx, nodeName, reregister).Return(serviceAccountID, "test-token", nil) - s.ap = authProvider + s.grafanaClient = authProvider - res, err := s.Register(ctx, &managementpb.RegisterNodeRequest{ - NodeType: inventorypb.NodeType_GENERIC_NODE, + res, err := s.RegisterNode(ctx, &managementv1.RegisterNodeRequest{ + NodeType: inventoryv1.NodeType_NODE_TYPE_GENERIC_NODE, NodeName: nodeName, Address: "some.address.org", Region: "region", Reregister: true, }) - expected := &managementpb.RegisterNodeResponse{ - GenericNode: &inventorypb.GenericNode{ + expected := &managementv1.RegisterNodeResponse{ + GenericNode: &inventoryv1.GenericNode{ NodeId: "/node_id/00000000-0000-4000-8000-000000000008", NodeName: nodeName, Address: "some.address.org", Region: "region", }, - ContainerNode: (*inventorypb.ContainerNode)(nil), - PmmAgent: &inventorypb.PMMAgent{ + ContainerNode: (*inventoryv1.ContainerNode)(nil), + PmmAgent: &inventoryv1.PMMAgent{ AgentId: "/agent_id/00000000-0000-4000-8000-000000000009", RunsOnNodeId: "/node_id/00000000-0000-4000-8000-000000000008", }, @@ -185,7 +187,7 @@ func TestNodeService(t *testing.T) { authProvider.Test(t) authProvider.On("CreateServiceAccount", ctx, nodeName, reregister).Return(serviceAccountID, "test-token", nil) authProvider.On("DeleteServiceAccount", ctx, nodeName, force).Return("", nil) - s.ap = authProvider + s.grafanaClient = authProvider state := &mockAgentsStateUpdater{} state.Test(t) @@ -200,8 +202,8 @@ func TestNodeService(t *testing.T) { vmdb.On("RequestConfigurationUpdate").Return() s.vmdb = vmdb - resRegister, err := s.Register(ctx, &managementpb.RegisterNodeRequest{ - NodeType: inventorypb.NodeType_GENERIC_NODE, + resRegister, err := s.RegisterNode(ctx, &managementv1.RegisterNodeRequest{ + NodeType: inventoryv1.NodeType_NODE_TYPE_GENERIC_NODE, NodeName: nodeName, Address: "some.address.org", Region: "region", @@ -209,7 +211,7 @@ func TestNodeService(t *testing.T) { }) assert.NoError(t, err) - res, err := s.Unregister(ctx, &managementpb.UnregisterNodeRequest{ + res, err := s.Unregister(ctx, &managementv1.UnregisterNodeRequest{ NodeId: resRegister.GenericNode.NodeId, Force: true, })