Skip to content

Commit

Permalink
Merge branch 'main' into pushdown-docs-1956
Browse files Browse the repository at this point in the history
  • Loading branch information
Elena Grahovac authored Apr 12, 2023
2 parents 8c823ef + 6934d0f commit d630394
Show file tree
Hide file tree
Showing 32 changed files with 742 additions and 442 deletions.
2 changes: 1 addition & 1 deletion Taskfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -167,8 +167,8 @@ tasks:
desc: "Run integration tests for `pg` and `tigris` in parallel"
deps:
- test-integration-pg
- test-integration-tigris
- test-integration-mongodb
# disable for now - test-integration-tigris
# no test-integration-hana

test-integration-pg:
Expand Down
2 changes: 1 addition & 1 deletion build/deps/ferretdb-wrangler.Dockerfile
Original file line number Diff line number Diff line change
@@ -1 +1 @@
FROM ghcr.io/ferretdb/ferretdb-wrangler:2.13.0-1
FROM ghcr.io/ferretdb/ferretdb-wrangler:2.14.0-1
2 changes: 1 addition & 1 deletion build/deps/jaeger.Dockerfile
Original file line number Diff line number Diff line change
@@ -1 +1 @@
FROM jaegertracing/all-in-one:1.43.0
FROM jaegertracing/all-in-one:1.44.0
2 changes: 1 addition & 1 deletion build/deps/trivy.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
FROM aquasec/trivy:0.39.0
FROM aquasec/trivy:0.39.1
WORKDIR /workdir
6 changes: 3 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ require (
github.com/prometheus/client_model v0.3.0
github.com/prometheus/common v0.42.0
github.com/stretchr/testify v1.8.2
github.com/tigrisdata/tigris-client-go v1.0.0-beta.27
github.com/tigrisdata/tigris-client-go v1.0.0-beta.28
go.opentelemetry.io/otel v1.14.0
go.uber.org/zap v1.24.0
golang.org/x/crypto v0.7.0 // indirect; always use @latest
golang.org/x/exp v0.0.0-20230321023759-10a507213a29
golang.org/x/net v0.8.0
golang.org/x/net v0.9.0
golang.org/x/sys v0.7.0
)

Expand Down Expand Up @@ -65,7 +65,7 @@ require (
go.uber.org/atomic v1.7.0 // indirect
go.uber.org/multierr v1.6.0 // indirect
golang.org/x/oauth2 v0.5.0 // indirect
golang.org/x/text v0.8.0 // indirect
golang.org/x/text v0.9.0 // indirect
google.golang.org/appengine v1.6.7 // indirect
google.golang.org/genproto v0.0.0-20230222225845-10f96fb3dbec // indirect
google.golang.org/grpc v1.53.0 // indirect
Expand Down
12 changes: 6 additions & 6 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -264,8 +264,8 @@ github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO
github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
github.com/stretchr/testify v1.8.2 h1:+h33VjcLVPDHtOdpUCuF+7gSuG3yGIftsP1YvFihtJ8=
github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
github.com/tigrisdata/tigris-client-go v1.0.0-beta.27 h1:pbSgOBs2tf4nBNKQCXA93AkDVV+2Te+O8OOGdt6UDlY=
github.com/tigrisdata/tigris-client-go v1.0.0-beta.27/go.mod h1:sT5YZVA9AwI31vIKv0WHqOQYE9pi41HDQ2GDHBo4i3s=
github.com/tigrisdata/tigris-client-go v1.0.0-beta.28 h1:bzzPjYuDGmdDI/sxyl/FsbjNotwJ03LE5c1DGM+sIU8=
github.com/tigrisdata/tigris-client-go v1.0.0-beta.28/go.mod h1:sT5YZVA9AwI31vIKv0WHqOQYE9pi41HDQ2GDHBo4i3s=
github.com/ugorji/go v1.2.7 h1:qYhyWUUd6WbiM+C6JZAUkIJt/1WrjzNHY9+KCIjVqTo=
github.com/ugorji/go v1.2.7/go.mod h1:nF9osbDWLy6bDVv/Rtoh6QgnvNDpmCalQV5urGCCS6M=
github.com/ugorji/go/codec v1.2.7 h1:YPXUKf7fYbp/y8xloBqZOw2qaVggbfwMlI8WM3wZUJ0=
Expand Down Expand Up @@ -344,8 +344,8 @@ golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96b
golang.org/x/net v0.0.0-20210805182204-aaa1db679c0d/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs=
golang.org/x/net v0.8.0 h1:Zrh2ngAOFYneWTAIAPethzeaQLuHwhuBkuV6ZiRnUaQ=
golang.org/x/net v0.8.0/go.mod h1:QVkue5JL9kW//ek3r6jTKnTFis1tRmNAW2P1shuFdJc=
golang.org/x/net v0.9.0 h1:aWJ/m6xSmxWBx+V0XRHTlrYrPG56jKsLdTFmsSsCzOM=
golang.org/x/net v0.9.0/go.mod h1:d48xBJpPfHeWQsugry2m+kC02ZBRGRgulfHnEXEuWns=
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
golang.org/x/oauth2 v0.5.0 h1:HuArIo48skDwlrvM3sEdHXElYslAMsf3KwRkkW4MC4s=
Expand Down Expand Up @@ -393,8 +393,8 @@ golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
golang.org/x/text v0.8.0 h1:57P1ETyNKtuIjB4SRd15iJxuhj8Gc416Y78H3qgMh68=
golang.org/x/text v0.8.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8=
golang.org/x/text v0.9.0 h1:2sjJmO8cDvYveuX97RDLsxlyUxLl+GHoLxBiRdHllBE=
golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY=
Expand Down
6 changes: 6 additions & 0 deletions integration/aggregate_documents_compat_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -787,6 +787,8 @@ func TestAggregateCompatGroupCount(t *testing.T) {
}

func TestAggregateCompatLimit(t *testing.T) {
t.Parallel()

testCases := map[string]aggregateStagesCompatTestCase{
"Zero": {
pipeline: bson.A{
Expand Down Expand Up @@ -1211,6 +1213,8 @@ func TestAggregateCompatSort(t *testing.T) {
}

func TestAggregateCompatUnwind(t *testing.T) {
t.Parallel()

testCases := map[string]aggregateStagesCompatTestCase{
"Simple": {
pipeline: bson.A{
Expand Down Expand Up @@ -1315,6 +1319,8 @@ func TestAggregateCompatUnwind(t *testing.T) {
}

func TestAggregateCompatSkip(t *testing.T) {
t.Parallel()

testCases := map[string]aggregateStagesCompatTestCase{
"Document": {
pipeline: bson.A{bson.D{{"$skip", bson.D{}}}},
Expand Down
6 changes: 6 additions & 0 deletions integration/basic_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -399,6 +399,8 @@ func TestCollectionName(t *testing.T) {
for name, tc := range cases {
name, tc := name, tc
t.Run(name, func(t *testing.T) {
t.Parallel()

err := collection.Database().CreateCollection(ctx, tc.collection)
if tc.err != nil {
AssertEqualAltError(t, *tc.err, tc.alt, err)
Expand Down Expand Up @@ -484,6 +486,8 @@ func TestDatabaseName(t *testing.T) {
for name, tc := range cases {
name, tc := name, tc
t.Run(name, func(t *testing.T) {
t.Parallel()

// there is no explicit command to create database, so create collection instead
err := collection.Database().Client().Database(tc.db).CreateCollection(ctx, collection.Name())
AssertEqualAltError(t, *tc.err, tc.alt, err)
Expand All @@ -492,6 +496,8 @@ func TestDatabaseName(t *testing.T) {
})

t.Run("Empty", func(t *testing.T) {
t.Parallel()

ctx, collection := setup.Setup(t)

err := collection.Database().Client().Database("").CreateCollection(ctx, collection.Name())
Expand Down
2 changes: 1 addition & 1 deletion integration/create_compat_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import (

// TestCreateCompat tests collection creation compatibility for the cases that are not covered by tests setup.
func TestCreateCompat(t *testing.T) {
t.Helper()
t.Parallel()

s := setup.SetupCompatWithOpts(t, &setup.SetupCompatOpts{
Providers: []shareddata.Provider{}, // collections are not needed for this test
Expand Down
30 changes: 16 additions & 14 deletions integration/explain_compat_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,28 +67,28 @@ func testExplainCompatError(t *testing.T, testCases map[string]explainCompatTest
t.Run(targetCollection.Name(), func(t *testing.T) {
t.Helper()

explainParams := bson.D{
{tc.command, targetCollection.Name()},
}
explainTarget := bson.D{{tc.command, targetCollection.Name()}}
explainCompat := bson.D{{tc.command, compatCollection.Name()}}

if tc.filter != nil {
explainParams = bson.D{
{tc.command, targetCollection.Name()},
{"filter", tc.filter},
}
explainTarget = append(explainTarget, bson.E{Key: "filter", Value: tc.filter})
explainCompat = append(explainCompat, bson.E{Key: "filter", Value: tc.filter})
}

if tc.pipeline != nil {
explainParams = bson.D{
{tc.command, targetCollection.Name()},
{"pipeline", tc.pipeline},
}
explainTarget = append(explainTarget, bson.E{Key: "pipeline", Value: tc.pipeline})
explainCompat = append(explainCompat, bson.E{Key: "pipeline", Value: tc.pipeline})
}

explainCommand := bson.D{{"explain", explainParams}}
var targetRes, compatRes bson.D
targetErr := targetCollection.Database().RunCommand(ctx, explainCommand).Decode(&targetRes)
compatErr := compatCollection.Database().RunCommand(ctx, explainCommand).Decode(&compatRes)
targetErr := targetCollection.Database().RunCommand(
ctx,
bson.D{{"explain", explainTarget}},
).Decode(&targetRes)
compatErr := compatCollection.Database().RunCommand(
ctx,
bson.D{{"explain", explainCompat}},
).Decode(&compatRes)

if targetErr != nil {
t.Logf("Target error: %v", targetErr)
Expand Down Expand Up @@ -130,6 +130,8 @@ func testExplainCompatError(t *testing.T, testCases map[string]explainCompatTest
}

func TestExplainCompatError(t *testing.T) {
t.Parallel()

testCases := map[string]explainCompatTestCase{
"AggregateMissingPipeline": {
command: "aggregate",
Expand Down
74 changes: 70 additions & 4 deletions integration/findandmodify_compat_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ import (
)

func TestFindAndModifyCompatSimple(t *testing.T) {
t.Parallel()

testCases := map[string]findAndModifyCompatTestCase{
"EmptyQueryRemove": {
command: bson.D{
Expand Down Expand Up @@ -81,6 +83,8 @@ func TestFindAndModifyCompatSimple(t *testing.T) {
}

func TestFindAndModifyCompatErrors(t *testing.T) {
t.Parallel()

testCases := map[string]findAndModifyCompatTestCase{
"NotEnoughParameters": {
command: bson.D{},
Expand Down Expand Up @@ -108,12 +112,29 @@ func TestFindAndModifyCompatErrors(t *testing.T) {
{"maxTimeMS", "string"},
},
},
"DollarPrefixedFieldName": {
command: bson.D{
{"query", bson.D{{"_id", bson.D{{"key", bson.D{{"$invalid", "val"}}}}}}},
{"upsert", true},
{"update", bson.D{{"v", "replaced"}}},
},
},
"DollarPrefixedNestedFieldName": {
command: bson.D{
{"query", bson.D{{"_id", bson.D{{"key", bson.D{{"nestedKey", bson.D{{"$invalid", "val"}}}}}}}}},
{"upsert", true},
{"update", bson.D{{"v", "replaced"}}},
},
skipForTigris: "schema validation would fail",
},
}

testFindAndModifyCompat(t, testCases)
}

func TestFindAndModifyCompatUpdate(t *testing.T) {
t.Parallel()

testCases := map[string]findAndModifyCompatTestCase{
"Replace": {
command: bson.D{
Expand Down Expand Up @@ -178,6 +199,8 @@ func TestFindAndModifyCompatUpdate(t *testing.T) {
//
// TODO Add more tests for sort: https://github.com/FerretDB/FerretDB/issues/2168
func TestFindAndModifyCompatSort(t *testing.T) {
t.Parallel()

testCases := map[string]findAndModifyCompatTestCase{
"DotNotation": {
command: bson.D{
Expand Down Expand Up @@ -218,14 +241,15 @@ func TestFindAndModifyCompatUpsert(t *testing.T) {
"Tigris' schema doesn't fit for most of providers, upsert for Tigris is tested in TestFindAndModifyUpsert.",
)

t.Parallel()

testCases := map[string]findAndModifyCompatTestCase{
"Upsert": {
command: bson.D{
{"query", bson.D{{"_id", "double"}}},
{"update", bson.D{{"$set", bson.D{{"v", 43.13}}}}},
{"upsert", true},
},
skip: "https://github.com/FerretDB/FerretDB/issues/1098",
},
"UpsertNew": {
command: bson.D{
Expand Down Expand Up @@ -257,7 +281,6 @@ func TestFindAndModifyCompatUpsert(t *testing.T) {
{"update", bson.D{{"v", 43.13}}},
{"upsert", true},
},
skip: "https://github.com/FerretDB/FerretDB/issues/1098",
},
"UpsertReplaceReturnNew": {
command: bson.D{
Expand All @@ -267,19 +290,63 @@ func TestFindAndModifyCompatUpsert(t *testing.T) {
{"new", true},
},
},
"ExistsNew": {
command: bson.D{
{"query", bson.D{{"_id", bson.D{{"$exists", false}}}}},
{"upsert", true},
{"update", bson.D{{"_id", "replaced"}, {"v", "replaced"}}},
{"new", true},
},
},
"ExistsFalse": {
command: bson.D{
{"query", bson.D{{"_id", bson.D{{"$exists", false}}}}},
{"upsert", true},
{"update", bson.D{{"_id", "replaced"}, {"v", "replaced"}}},
},
},
"ExistsTrueID": {
command: bson.D{
{"query", bson.D{{"_id", bson.D{{"$exists", true}}}}},
{"upsert", true},
{"update", bson.D{{"_id", "replaced"}, {"v", "replaced"}}},
},
},
"ExistsTrue": {
command: bson.D{
{"query", bson.D{{"_id", bson.D{{"$exists", true}}}}},
{"upsert", true},
{"update", bson.D{{"v", "replaced"}}},
},
},
"UnsetForNonExisting": {
command: bson.D{
{"query", bson.D{{"_id", bson.D{{"$exists", true}}}}},
{"upsert", true},
{"update", bson.D{{"$unset", "invalid"}}},
},
},
"UnsetForExisting": {
command: bson.D{
{"query", bson.D{{"_id", bson.D{{"$exists", false}}}}},
{"upsert", true},
{"update", bson.D{{"$unset", "invalid"}}},
},
},
}

testFindAndModifyCompat(t, testCases)
}

func TestFindAndModifyCompatRemove(t *testing.T) {
t.Parallel()

testCases := map[string]findAndModifyCompatTestCase{
"Remove": {
command: bson.D{
{"query", bson.D{{"_id", "double"}}},
{"remove", true},
},
skip: "https://github.com/FerretDB/FerretDB/issues/1243",
},
"RemoveEmptyQueryResult": {
command: bson.D{
Expand All @@ -295,7 +362,6 @@ func TestFindAndModifyCompatRemove(t *testing.T) {
},
{"remove", true},
},
skip: "https://github.com/FerretDB/FerretDB/issues/1243",
},
}

Expand Down
29 changes: 29 additions & 0 deletions integration/findandmodify_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ func TestFindAndModifyUpsertComplex(t *testing.T) {
for name, tc := range map[string]struct {
command bson.D
lastErrorObject bson.D
skipForTigris string
}{
"UpsertNoSuchDocumentNoIdInQuery": {
command: bson.D{
Expand All @@ -166,9 +167,37 @@ func TestFindAndModifyUpsertComplex(t *testing.T) {
{"updatedExisting", false},
},
},
"UpsertExpressionKey": {
command: bson.D{
{"query", bson.D{{"_id", bson.D{{"$exists", false}}}}},
{"upsert", true},
{"update", bson.D{{"v", "replaced"}}},
},
lastErrorObject: bson.D{
{"n", int32(1)},
{"updatedExisting", false},
},
skipForTigris: "schema validation would fail",
},
"UpsertDocumentKey": {
command: bson.D{
{"query", bson.D{{"_id", bson.D{{"key", "val"}}}}},
{"upsert", true},
{"update", bson.D{{"v", "replaced"}}},
},
lastErrorObject: bson.D{
{"n", int32(1)},
{"updatedExisting", false},
},
skipForTigris: "schema validation would fail",
},
} {
name, tc := name, tc
t.Run(name, func(t *testing.T) {
if tc.skipForTigris != "" {
setup.SkipForTigrisWithReason(t, tc.skipForTigris)
}

t.Parallel()
ctx, collection := setup.Setup(t, shareddata.Doubles)

Expand Down
Loading

0 comments on commit d630394

Please sign in to comment.