From 517eeb0a3815016a3f30efbf352901295495c820 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ji=C5=99=C3=AD=20=C4=8Ctvrtka?= Date: Tue, 3 Dec 2024 21:06:36 +0100 Subject: [PATCH] PMM-5086-12634 Fix agent management tests. --- managed/services/management/agent_test.go | 154 +++++++++++++++++++--- 1 file changed, 134 insertions(+), 20 deletions(-) diff --git a/managed/services/management/agent_test.go b/managed/services/management/agent_test.go index e6d0461f73..40705bc901 100644 --- a/managed/services/management/agent_test.go +++ b/managed/services/management/agent_test.go @@ -148,36 +148,78 @@ func TestAgentService(t *testing.T) { expected := []*agentv1.UniversalAgent{ { - AgentId: pgExporterID, - AgentType: "postgres_exporter", - PmmAgentId: models.PMMServerAgentID, - IsConnected: false, - CreatedAt: timestamppb.New(now), - UpdatedAt: timestamppb.New(now), - Username: "postgres", - PostgresqlOptions: &agentv1.UniversalAgent_PostgreSQLOptions{ - IsSslKeySet: false, - }, + AgentId: pgExporterID, + AgentType: "postgres_exporter", + PmmAgentId: models.PMMServerAgentID, + IsConnected: false, + CreatedAt: timestamppb.New(now), + UpdatedAt: timestamppb.New(now), + Username: "postgres", ServiceId: "00000000-0000-4000-8000-000000000002", Status: "AGENT_STATUS_UNKNOWN", Tls: true, CommentsParsingDisabled: true, - }, - { - AgentId: pgStatStatementID, - AgentType: "qan-postgresql-pgstatements-agent", - PmmAgentId: models.PMMServerAgentID, - IsConnected: false, - CreatedAt: timestamppb.New(now), - UpdatedAt: timestamppb.New(now), - Username: "postgres", + AzureOptions: &agentv1.UniversalAgent_AzureOptions{ + ClientId: "", + IsClientSecretSet: false, + ResourceGroup: "", + SubscriptionId: "", + TenantId: "", + }, + MongoDbOptions: &agentv1.UniversalAgent_MongoDBOptions{ + IsTlsCertificateKeySet: false, + IsTlsCertificateKeyFilePasswordSet: false, + AuthenticationMechanism: "", + AuthenticationDatabase: "", + StatsCollections: nil, + CollectionsLimit: 0, + EnableAllCollectors: false, + }, + MysqlOptions: &agentv1.UniversalAgent_MySQLOptions{ + IsTlsKeySet: false, + }, PostgresqlOptions: &agentv1.UniversalAgent_PostgreSQLOptions{ - IsSslKeySet: false, + IsSslKeySet: false, + AutoDiscoveryLimit: 0, + MaxExporterConnections: 0, }, + }, + { + AgentId: pgStatStatementID, + AgentType: "qan-postgresql-pgstatements-agent", + PmmAgentId: models.PMMServerAgentID, + IsConnected: false, + CreatedAt: timestamppb.New(now), + UpdatedAt: timestamppb.New(now), + Username: "postgres", ServiceId: "00000000-0000-4000-8000-000000000002", Status: "AGENT_STATUS_UNKNOWN", Tls: true, CommentsParsingDisabled: true, + AzureOptions: &agentv1.UniversalAgent_AzureOptions{ + ClientId: "", + IsClientSecretSet: false, + ResourceGroup: "", + SubscriptionId: "", + TenantId: "", + }, + MongoDbOptions: &agentv1.UniversalAgent_MongoDBOptions{ + IsTlsCertificateKeySet: false, + IsTlsCertificateKeyFilePasswordSet: false, + AuthenticationMechanism: "", + AuthenticationDatabase: "", + StatsCollections: nil, + CollectionsLimit: 0, + EnableAllCollectors: false, + }, + MysqlOptions: &agentv1.UniversalAgent_MySQLOptions{ + IsTlsKeySet: false, + }, + PostgresqlOptions: &agentv1.UniversalAgent_PostgreSQLOptions{ + IsSslKeySet: false, + AutoDiscoveryLimit: 0, + MaxExporterConnections: 0, + }, }, { AgentId: models.PMMServerAgentID, @@ -186,6 +228,30 @@ func TestAgentService(t *testing.T) { IsConnected: true, CreatedAt: timestamppb.New(now), UpdatedAt: timestamppb.New(now), + AzureOptions: &agentv1.UniversalAgent_AzureOptions{ + ClientId: "", + IsClientSecretSet: false, + ResourceGroup: "", + SubscriptionId: "", + TenantId: "", + }, + MongoDbOptions: &agentv1.UniversalAgent_MongoDBOptions{ + IsTlsCertificateKeySet: false, + IsTlsCertificateKeyFilePasswordSet: false, + AuthenticationMechanism: "", + AuthenticationDatabase: "", + StatsCollections: nil, + CollectionsLimit: 0, + EnableAllCollectors: false, + }, + MysqlOptions: &agentv1.UniversalAgent_MySQLOptions{ + IsTlsKeySet: false, + }, + PostgresqlOptions: &agentv1.UniversalAgent_PostgreSQLOptions{ + IsSslKeySet: false, + AutoDiscoveryLimit: 0, + MaxExporterConnections: 0, + }, }, } @@ -237,6 +303,30 @@ func TestAgentService(t *testing.T) { UpdatedAt: timestamppb.New(now), ServiceId: "00000000-0000-4000-8000-000000000006", Status: "AGENT_STATUS_UNKNOWN", + AzureOptions: &agentv1.UniversalAgent_AzureOptions{ + ClientId: "", + IsClientSecretSet: false, + ResourceGroup: "", + SubscriptionId: "", + TenantId: "", + }, + MongoDbOptions: &agentv1.UniversalAgent_MongoDBOptions{ + IsTlsCertificateKeySet: false, + IsTlsCertificateKeyFilePasswordSet: false, + AuthenticationMechanism: "", + AuthenticationDatabase: "", + StatsCollections: nil, + CollectionsLimit: 0, + EnableAllCollectors: false, + }, + MysqlOptions: &agentv1.UniversalAgent_MySQLOptions{ + IsTlsKeySet: false, + }, + PostgresqlOptions: &agentv1.UniversalAgent_PostgreSQLOptions{ + IsSslKeySet: false, + AutoDiscoveryLimit: 0, + MaxExporterConnections: 0, + }, }, } assert.Equal(t, expected, response.Agents) @@ -287,6 +377,30 @@ func TestAgentService(t *testing.T) { UpdatedAt: timestamppb.New(now), ServiceId: "00000000-0000-4000-8000-000000000006", Status: "AGENT_STATUS_UNKNOWN", + AzureOptions: &agentv1.UniversalAgent_AzureOptions{ + ClientId: "", + IsClientSecretSet: false, + ResourceGroup: "", + SubscriptionId: "", + TenantId: "", + }, + MongoDbOptions: &agentv1.UniversalAgent_MongoDBOptions{ + IsTlsCertificateKeySet: false, + IsTlsCertificateKeyFilePasswordSet: false, + AuthenticationMechanism: "", + AuthenticationDatabase: "", + StatsCollections: nil, + CollectionsLimit: 0, + EnableAllCollectors: false, + }, + MysqlOptions: &agentv1.UniversalAgent_MySQLOptions{ + IsTlsKeySet: false, + }, + PostgresqlOptions: &agentv1.UniversalAgent_PostgreSQLOptions{ + IsSslKeySet: false, + AutoDiscoveryLimit: 0, + MaxExporterConnections: 0, + }, }, } assert.Equal(t, expected, response.Agents)