Skip to content

Commit f33a9ce

Browse files
committed
PMM-13477 Fix tests.
1 parent a727a92 commit f33a9ce

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

exporter/diagnostic_data_collector_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -421,7 +421,7 @@ func cleanTestData(ctx context.Context, client *mongo.Client, count int) error {
421421
}
422422

423423
func TestDisconnectedDiagnosticDataCollector(t *testing.T) {
424-
ctx, cancel := context.WithTimeout(context.Background(), 3*time.Second)
424+
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
425425
defer cancel()
426426

427427
client := tu.DefaultTestClient(ctx, t)
@@ -434,7 +434,7 @@ func TestDisconnectedDiagnosticDataCollector(t *testing.T) {
434434
ti := labelsGetterMock{}
435435

436436
dbBuildInfo, err := retrieveMongoDBBuildInfo(ctx, client, logger.WithField("component", "test"))
437-
require.NoError(t, err)
437+
require.Error(t, err)
438438

439439
c := newDiagnosticDataCollector(ctx, client, logger, true, ti, dbBuildInfo)
440440

exporter/v1_compatibility.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -852,6 +852,9 @@ func specialMetrics(ctx context.Context, client *mongo.Client, m bson.M, nodeTyp
852852
}
853853

854854
func retrieveMongoDBBuildInfo(ctx context.Context, client *mongo.Client, l *logrus.Entry) (buildInfo, error) {
855+
if client == nil {
856+
return buildInfo{}, errors.New("cannot get mongo build info: client is nil")
857+
}
855858
buildInfoCmd := bson.D{bson.E{Key: "buildInfo", Value: 1}}
856859
res := client.Database("admin").RunCommand(ctx, buildInfoCmd)
857860

0 commit comments

Comments
 (0)