MongoDB EXPLAIN JSON APIs (#454)

* WIP

* PMM-4192 Updated MongoDB fingerprint

SystemProfile has been changed to use the new bson.D from the official
MongoDB driver instead of the old BsonD. Updated the fingerprinter
module and all tests

* PMM-4192 Updated MongoDB explain tests

Updated test to use bson.D instead of BsonD

* PMM-4192 Code clean-up

* PMM-4192 Changes for CR

* PMM-4192 Changes for CR

* PMM-4192 Removed unused deps

Co-authored-by: Carlos <cfsalguero@gmail.com>
This commit is contained in:
Carlos Salguero
2020-07-08 10:25:12 -03:00
committed by GitHub
parent de27179da8
commit c7eed08e33
205 changed files with 481 additions and 13385 deletions

View File

@@ -13,6 +13,7 @@ import (
"github.com/percona/percona-toolkit/src/go/mongolib/fingerprinter"
"github.com/percona/percona-toolkit/src/go/mongolib/stats"
"github.com/percona/percona-toolkit/src/go/pt-mongodb-query-digest/filter"
"github.com/stretchr/testify/assert"
"go.mongodb.org/mongo-driver/bson/primitive"
"go.mongodb.org/mongo-driver/mongo"
"go.mongodb.org/mongo-driver/mongo/options"
@@ -62,7 +63,8 @@ func TestRegularIterator(t *testing.T) {
if res.Err() != nil {
t.Fatalf("Cannot enable profiler: %s", res.Err())
}
client.Database(database).Drop(ctx)
err = client.Database(database).Drop(ctx)
assert.NoError(t, err)
// re-enable the profiler
res = client.Database("admin").RunCommand(ctx, primitive.D{{"profile", 2}, {"slowms", 2}})
@@ -73,7 +75,8 @@ func TestRegularIterator(t *testing.T) {
// run some queries to have something to profile
count := 1000
for j := 0; j < count; j++ {
client.Database("test").Collection("testc").InsertOne(ctx, primitive.M{"number": j})
_, err := client.Database("test").Collection("testc").InsertOne(ctx, primitive.M{"number": j})
assert.NoError(t, err)
time.Sleep(20 * time.Millisecond)
}
@@ -83,7 +86,7 @@ func TestRegularIterator(t *testing.T) {
}
filters := []filter.Filter{}
fp := fingerprinter.NewFingerprinter(fingerprinter.DEFAULT_KEY_FILTERS)
fp := fingerprinter.NewFingerprinter(fingerprinter.DefaultKeyFilters())
s := stats.New(fp)
prof := NewProfiler(cursor, filters, nil, s)
prof.Start(ctx)