Skip to content

Commit

Permalink
fix: node.proto and node_test
Browse files Browse the repository at this point in the history
  • Loading branch information
ademidoff committed Jun 27, 2024
1 parent b6700b2 commit 102cd11
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 23 deletions.
1 change: 0 additions & 1 deletion api/management/v1/node.proto
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
46 changes: 24 additions & 22 deletions managed/services/management/node_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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",
},
Expand All @@ -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)
Expand All @@ -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",
Expand All @@ -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",
},
Expand All @@ -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)
Expand All @@ -200,16 +202,16 @@ 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",
Reregister: true,
})
assert.NoError(t, err)

res, err := s.Unregister(ctx, &managementpb.UnregisterNodeRequest{
res, err := s.Unregister(ctx, &managementv1.UnregisterNodeRequest{
NodeId: resRegister.GenericNode.NodeId,
Force: true,
})
Expand Down

0 comments on commit 102cd11

Please sign in to comment.