From 19e9759a0e9f899b3f65e63932ddb5478bc77531 Mon Sep 17 00:00:00 2001 From: Alex Demidoff Date: Fri, 22 Mar 2024 22:36:48 +0000 Subject: [PATCH] PMM-12913 fix tests --- managed/models/agent_helpers.go | 2 +- managed/services/inventory/agents_test.go | 8 ++++---- managed/services/inventory/services_test.go | 10 +++++----- managed/services/management/service_test.go | 10 +++++----- 4 files changed, 15 insertions(+), 15 deletions(-) diff --git a/managed/models/agent_helpers.go b/managed/models/agent_helpers.go index 40003be9127..470d1f731c9 100644 --- a/managed/models/agent_helpers.go +++ b/managed/models/agent_helpers.go @@ -165,7 +165,7 @@ func AzureOptionsFromRequest(params AzureOptionsParams) *AzureOptions { } // Add a prefix since gRPC does not allow to pass an URL path segment that begins with a slash. -// TODO: Remove these Normalize... functions once we drop prefixes in agent/service/node IDs. +// TODO: remove these Normalize functions once we drop prefixes in agent/service/node IDs. // NormalizeAgentID adds a prefix to the agent ID if it does not already contain it. func NormalizeAgentID(agentID string) string { diff --git a/managed/services/inventory/agents_test.go b/managed/services/inventory/agents_test.go index c88cd3fb9f3..e92858e4545 100644 --- a/managed/services/inventory/agents_test.go +++ b/managed/services/inventory/agents_test.go @@ -321,7 +321,7 @@ func TestAgents(t *testing.T) { err := as.Remove(ctx, "/agent_id/00000000-0000-4000-8000-000000000005", true) require.NoError(t, err) actualAgent, err := as.Get(ctx, "/agent_id/00000000-0000-4000-8000-000000000005") - tests.AssertGRPCError(t, status.New(codes.NotFound, `Agent with ID "/agent_id/00000000-0000-4000-8000-000000000005" not found.`), err) + tests.AssertGRPCError(t, status.New(codes.NotFound, `Agent with ID /agent_id/00000000-0000-4000-8000-000000000005 not found.`), err) assert.Nil(t, actualAgent) actualAgents, err = as.List(ctx, models.AgentFilters{}) @@ -375,7 +375,7 @@ func TestAgents(t *testing.T) { _, err := as.AddNodeExporter(ctx, &inventoryv1.AddNodeExporterParams{ PmmAgentId: "no-such-id", }) - tests.AssertGRPCError(t, status.New(codes.NotFound, `Agent with ID "no-such-id" not found.`), err) + tests.AssertGRPCError(t, status.New(codes.NotFound, `Agent with ID no-such-id not found.`), err) }) t.Run("AddRDSExporter", func(t *testing.T) { @@ -474,7 +474,7 @@ func TestAgents(t *testing.T) { PmmAgentId: pmmAgent.GetPmmAgent().AgentId, ServiceId: "no-such-id", }) - tests.AssertGRPCError(t, status.New(codes.NotFound, `Service with ID "no-such-id" not found.`), err) + tests.AssertGRPCError(t, status.New(codes.NotFound, `Service with ID no-such-id not found.`), err) }) t.Run("RemoveNotFound", func(t *testing.T) { @@ -482,7 +482,7 @@ func TestAgents(t *testing.T) { t.Cleanup(func() { teardown(t) }) err := as.Remove(ctx, "no-such-id", false) - tests.AssertGRPCError(t, status.New(codes.NotFound, `Agent with ID "no-such-id" not found.`), err) + tests.AssertGRPCError(t, status.New(codes.NotFound, `Agent with ID no-such-id not found.`), err) }) t.Run("PushMetricsMongodbExporter", func(t *testing.T) { diff --git a/managed/services/inventory/services_test.go b/managed/services/inventory/services_test.go index 8959a3cb0ff..f7d13acdee9 100644 --- a/managed/services/inventory/services_test.go +++ b/managed/services/inventory/services_test.go @@ -183,13 +183,13 @@ func TestServices(t *testing.T) { tests.AssertGRPCError(t, status.New(codes.NotFound, fmt.Sprintf(`Service with ID "%s" not found.`, mySQLService.ServiceId)), err) _, err = as.Get(ctx, rdsAgent.GetRdsExporter().AgentId) - tests.AssertGRPCError(t, status.New(codes.NotFound, fmt.Sprintf(`Agent with ID "%s" not found.`, rdsAgent.GetRdsExporter().AgentId)), err) + tests.AssertGRPCError(t, status.New(codes.NotFound, fmt.Sprintf(`Agent with ID %s not found.`, rdsAgent.GetRdsExporter().AgentId)), err) _, err = as.Get(ctx, mySQLAgent.GetMysqldExporter().AgentId) - tests.AssertGRPCError(t, status.New(codes.NotFound, fmt.Sprintf(`Agent with ID "%s" not found.`, mySQLAgent.GetMysqldExporter().AgentId)), err) + tests.AssertGRPCError(t, status.New(codes.NotFound, fmt.Sprintf(`Agent with ID %s not found.`, mySQLAgent.GetMysqldExporter().AgentId)), err) _, err = ns.Get(ctx, &inventoryv1.GetNodeRequest{NodeId: node.NodeId}) - tests.AssertGRPCError(t, status.New(codes.NotFound, fmt.Sprintf(`Node with ID "%s" not found.`, node.NodeId)), err) + tests.AssertGRPCError(t, status.New(codes.NotFound, fmt.Sprintf(`Node with ID %s not found.`, node.NodeId)), err) }) t.Run("AzureServiceRemoving", func(t *testing.T) { @@ -244,10 +244,10 @@ func TestServices(t *testing.T) { tests.AssertGRPCError(t, status.New(codes.NotFound, fmt.Sprintf(`Service with ID "%s" not found.`, mySQLService.ServiceId)), err) _, err = as.Get(ctx, azureAgent.GetAzureDatabaseExporter().AgentId) - tests.AssertGRPCError(t, status.New(codes.NotFound, fmt.Sprintf(`Agent with ID "%s" not found.`, azureAgent.GetAzureDatabaseExporter().AgentId)), err) + tests.AssertGRPCError(t, status.New(codes.NotFound, fmt.Sprintf(`Agent with ID %s not found.`, azureAgent.GetAzureDatabaseExporter().AgentId)), err) _, err = as.Get(ctx, mySQLAgent.GetMysqldExporter().AgentId) - tests.AssertGRPCError(t, status.New(codes.NotFound, fmt.Sprintf(`Agent with ID "%s" not found.`, mySQLAgent.GetMysqldExporter().AgentId)), err) + tests.AssertGRPCError(t, status.New(codes.NotFound, fmt.Sprintf(`Agent with ID %s not found.`, mySQLAgent.GetMysqldExporter().AgentId)), err) _, err = ns.Get(ctx, &inventoryv1.GetNodeRequest{NodeId: node.NodeId}) tests.AssertGRPCError(t, status.New(codes.NotFound, fmt.Sprintf(`Node with ID "%s" not found.`, node.NodeId)), err) diff --git a/managed/services/management/service_test.go b/managed/services/management/service_test.go index 8cbec487331..e4d1834e254 100644 --- a/managed/services/management/service_test.go +++ b/managed/services/management/service_test.go @@ -162,7 +162,7 @@ func TestServiceService(t *testing.T) { agent, err := models.FindAgentByID(s.db.Querier, mysqldExporter.AgentID) assert.Nil(t, agent) - tests.AssertGRPCError(t, status.New(codes.NotFound, `Agent with ID "/agent_id/00000000-0000-4000-8000-000000000007" not found.`), err) + tests.AssertGRPCError(t, status.New(codes.NotFound, `Agent with ID /agent_id/00000000-0000-4000-8000-000000000007 not found.`), err) service, err = models.FindServiceByID(s.db.Querier, service.ServiceID) assert.Nil(t, service) @@ -214,10 +214,10 @@ func TestServiceService(t *testing.T) { tests.AssertGRPCError(t, status.New(codes.NotFound, fmt.Sprintf(`Service with ID "%s" not found.`, service.ServiceID)), err) _, err = models.FindAgentByID(s.db.Querier, mysqldExporter.AgentID) - tests.AssertGRPCError(t, status.New(codes.NotFound, fmt.Sprintf(`Agent with ID "%s" not found.`, mysqldExporter.AgentID)), err) + tests.AssertGRPCError(t, status.New(codes.NotFound, fmt.Sprintf(`Agent with ID %s not found.`, mysqldExporter.AgentID)), err) _, err = models.FindAgentByID(s.db.Querier, rdsExporter.AgentID) - tests.AssertGRPCError(t, status.New(codes.NotFound, fmt.Sprintf(`Agent with ID "%s" not found.`, rdsExporter.AgentID)), err) + tests.AssertGRPCError(t, status.New(codes.NotFound, fmt.Sprintf(`Agent with ID %s not found.`, rdsExporter.AgentID)), err) _, err = models.FindNodeByID(s.db.Querier, node.NodeID) tests.AssertGRPCError(t, status.New(codes.NotFound, fmt.Sprintf(`Node with ID "%s" not found.`, node.NodeID)), err) @@ -268,10 +268,10 @@ func TestServiceService(t *testing.T) { tests.AssertGRPCError(t, status.New(codes.NotFound, fmt.Sprintf(`Service with ID "%s" not found.`, service.ServiceID)), err) _, err = models.FindAgentByID(s.db.Querier, mysqldExporter.AgentID) - tests.AssertGRPCError(t, status.New(codes.NotFound, fmt.Sprintf(`Agent with ID "%s" not found.`, mysqldExporter.AgentID)), err) + tests.AssertGRPCError(t, status.New(codes.NotFound, fmt.Sprintf(`Agent with ID %s not found.`, mysqldExporter.AgentID)), err) _, err = models.FindAgentByID(s.db.Querier, azureExporter.AgentID) - tests.AssertGRPCError(t, status.New(codes.NotFound, fmt.Sprintf(`Agent with ID "%s" not found.`, azureExporter.AgentID)), err) + tests.AssertGRPCError(t, status.New(codes.NotFound, fmt.Sprintf(`Agent with ID %s not found.`, azureExporter.AgentID)), err) _, err = models.FindNodeByID(s.db.Querier, node.NodeID) tests.AssertGRPCError(t, status.New(codes.NotFound, fmt.Sprintf(`Node with ID "%s" not found.`, node.NodeID)), err)