From 84889adbfb343aff6da390605d759537955630a8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ji=C5=99=C3=AD=20=C4=8Ctvrtka?= Date: Mon, 15 Sep 2025 12:03:52 +0200 Subject: [PATCH] PMM-11406 Test to check current results. --- src/go/pt-mongodb-summary/main_test.go | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/go/pt-mongodb-summary/main_test.go b/src/go/pt-mongodb-summary/main_test.go index 29ca665c..b4873f0a 100644 --- a/src/go/pt-mongodb-summary/main_test.go +++ b/src/go/pt-mongodb-summary/main_test.go @@ -8,6 +8,7 @@ import ( "time" "github.com/pborman/getopt" + "github.com/stretchr/testify/require" tu "github.com/percona/percona-toolkit/src/go/internal/testutils" ) @@ -48,6 +49,26 @@ func TestGetHostInfo(t *testing.T) { } } +func TestGetHostInfoResult(t *testing.T) { + assert := require.New(t) + + ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second) + defer cancel() + + client, err := tu.TestClient(ctx, tu.MongoDBShard1PrimaryPort) + assert.NoError(err, "cannot get a new MongoDB client") + + host, err := getHostInfo(ctx, client) + assert.NoError(err, "getHostInfo error") + + // With the current setup, we should get this information. + assert.NotEmpty(host.ProcessName, "ProcessName should not be empty if serverStatus succeeds") + assert.NotEmpty(host.Version, "Version should not be empty if serverStatus succeeds") + assert.NotEmpty(host.ProcPath, "ProcPath should not be empty if getProcInfo succeeds") + assert.NotEmpty(host.ProcUserName, "ProcUserName should not be empty if getProcInfo succeeds") + assert.False(host.ProcCreateTime.IsZero(), "ProcCreateTime should not be zero if getProcInfo succeeds") +} + func TestClusterWideInfo(t *testing.T) { testCases := []struct { name string