Skip to content

Commit

Permalink
Remove Tigris from tests (#3002)
Browse files Browse the repository at this point in the history
Closes #2253.
  • Loading branch information
AlekSi committed Jul 6, 2023
1 parent 5ee5a5b commit ea31cf5
Show file tree
Hide file tree
Showing 42 changed files with 180 additions and 1,141 deletions.
5 changes: 4 additions & 1 deletion cmd/envtool/tests_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,10 @@ func TestTestsShard(t *testing.T) {
tests, err := getAllTestNames(filepath.Join("..", "..", "integration"))
require.NoError(t, err)
assert.Contains(t, tests, "TestQueryCompatLimit")
assert.Contains(t, tests, "TestInit") // shareddata's

// TODO replace with a real test name is a subdirectory
// https://github.com/FerretDB/engineering/issues/66
assert.Contains(t, tests, "TestSubDir")

t.Run("ShardTestsInvalidIndex", func(t *testing.T) {
t.Parallel()
Expand Down
5 changes: 4 additions & 1 deletion integration/Taskfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,10 @@ tasks:
-tags=ferretdb_testenvdata .
-target-backend=ferretdb-pg
-postgresql-url=postgres://username:password@127.0.0.1:5433/ferretdb?pool_max_conns=50
# no sqlite yet
- >
go test -count=1 {{.RACE_FLAG}} -run=TestEnvData
-tags=ferretdb_testenvdata .
-target-backend=ferretdb-sqlite
# no hana yet
- >
go test -count=1 {{.RACE_FLAG}} -run=TestEnvData
Expand Down
10 changes: 0 additions & 10 deletions integration/aggregate_documents_compat_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ type aggregateStagesCompatTestCase struct {
resultType compatTestCaseResultType // defaults to nonEmptyResult
resultPushdown bool // defaults to false
skip string // skip test for all handlers, must have issue number mentioned
skipForTigris string // skip test for Tigris handler, must have issue number mentioned
}

// testAggregateStagesCompat tests aggregation stages compatibility test cases with all providers.
Expand Down Expand Up @@ -69,10 +68,6 @@ func testAggregateStagesCompatWithProviders(t *testing.T, providers shareddata.P
t.Skip(tc.skip)
}

if tc.skipForTigris != "" {
setup.SkipForTigrisWithReason(t, tc.skipForTigris)
}

t.Parallel()

pipeline := tc.pipeline
Expand Down Expand Up @@ -324,8 +319,6 @@ func TestAggregateCompatOptions(t *testing.T) {
}

func TestAggregateCompatStages(t *testing.T) {
setup.SkipForTigrisWithReason(t, "https://github.com/FerretDB/FerretDB/issues/2523")

t.Parallel()

testCases := map[string]aggregateStagesCompatTestCase{
Expand Down Expand Up @@ -891,7 +884,6 @@ func TestAggregateCompatLimit(t *testing.T) {
bson.D{{"$limit", 100}},
},
resultPushdown: true,
skipForTigris: "TestAggregateCompatLimit",
},
"NoSortBeforeMatch": {
pipeline: bson.A{
Expand Down Expand Up @@ -1129,14 +1121,12 @@ func TestAggregateCompatMatch(t *testing.T) {
bson.D{{"$match", bson.D{{"v", 42}}}},
},
resultPushdown: true,
skipForTigris: "https://github.com/FerretDB/FerretDB/issues/2523",
},
"String": {
pipeline: bson.A{
bson.D{{"$match", bson.D{{"v", "foo"}}}},
},
resultPushdown: true,
skipForTigris: "https://github.com/FerretDB/FerretDB/issues/2523",
},
"Document": {
pipeline: bson.A{bson.D{{"$match", bson.D{{"v", bson.D{{"foo", int32(42)}}}}}}},
Expand Down
26 changes: 0 additions & 26 deletions integration/basic_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@ import (
)

func TestMostCommandsAreCaseSensitive(t *testing.T) {
setup.SkipForTigris(t)

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

Expand Down Expand Up @@ -70,8 +68,6 @@ func TestFindNothing(t *testing.T) {
}

func TestInsertFind(t *testing.T) {
setup.SkipForTigris(t)

t.Parallel()
providers := []shareddata.Provider{shareddata.Scalars, shareddata.Composites}
ctx, collection := setup.Setup(t, providers...)
Expand All @@ -98,8 +94,6 @@ func TestInsertFind(t *testing.T) {

//nolint:paralleltest // we test a global list of databases
func TestFindCommentMethod(t *testing.T) {
setup.SkipForTigris(t)

ctx, collection := setup.Setup(t, shareddata.Scalars)
name := collection.Database().Name()
databaseNames, err := collection.Database().Client().ListDatabaseNames(ctx, bson.D{})
Expand All @@ -115,8 +109,6 @@ func TestFindCommentMethod(t *testing.T) {

//nolint:paralleltest // we test a global list of databases
func TestFindCommentQuery(t *testing.T) {
setup.SkipForTigris(t)

ctx, collection := setup.Setup(t, shareddata.Scalars)
name := collection.Database().Name()
databaseNames, err := collection.Database().Client().ListDatabaseNames(ctx, bson.D{})
Expand All @@ -130,8 +122,6 @@ func TestFindCommentQuery(t *testing.T) {
}

func TestUpdateCommentMethod(t *testing.T) {
setup.SkipForTigris(t)

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

Expand All @@ -157,8 +147,6 @@ func TestUpdateCommentMethod(t *testing.T) {
}

func TestUpdateCommentQuery(t *testing.T) {
setup.SkipForTigris(t)

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

Expand All @@ -181,8 +169,6 @@ func TestUpdateCommentQuery(t *testing.T) {
}

func TestDeleteCommentMethod(t *testing.T) {
setup.SkipForTigris(t)

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

Expand All @@ -206,8 +192,6 @@ func TestDeleteCommentMethod(t *testing.T) {
}

func TestDeleteCommentQuery(t *testing.T) {
setup.SkipForTigris(t)

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

Expand All @@ -229,8 +213,6 @@ func TestDeleteCommentQuery(t *testing.T) {
}

func TestEmptyKey(t *testing.T) {
setup.SkipForTigrisWithReason(t, "Tigris field name cannot be empty")

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

Expand All @@ -251,8 +233,6 @@ func TestEmptyKey(t *testing.T) {
}

func TestFindAndModifyCommentMethod(t *testing.T) {
setup.SkipForTigris(t)

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

Expand All @@ -276,8 +256,6 @@ func TestFindAndModifyCommentMethod(t *testing.T) {
}

func TestFindAndModifyCommentQuery(t *testing.T) {
setup.SkipForTigris(t)

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

Expand Down Expand Up @@ -311,8 +289,6 @@ func TestFindAndModifyCommentQuery(t *testing.T) {
}

func TestCollectionName(t *testing.T) {
setup.SkipForTigris(t)

t.Parallel()

ctx, collection := setup.Setup(t)
Expand Down Expand Up @@ -442,8 +418,6 @@ func TestCollectionName(t *testing.T) {
}

func TestDatabaseName(t *testing.T) {
setup.SkipForTigris(t)

t.Parallel()

t.Run("NoErr", func(t *testing.T) {
Expand Down
65 changes: 1 addition & 64 deletions integration/commands_administration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,6 @@ import (
)

func TestCommandsAdministrationCreateDropList(t *testing.T) {
setup.SkipForTigris(t)

t.Parallel()
ctx, collection := setup.Setup(t) // no providers there

Expand Down Expand Up @@ -97,8 +95,6 @@ func TestCommandsAdministrationCreateDropList(t *testing.T) {
}

func TestCommandsAdministrationCreateDropListDatabases(t *testing.T) {
setup.SkipForTigris(t)

t.Parallel()
ctx, collection := setup.Setup(t) // no providers there

Expand Down Expand Up @@ -164,8 +160,6 @@ func TestCommandsAdministrationListDatabases(t *testing.T) {

assert.Equal(t, expected, actual)

setup.SkipForTigrisWithReason(t, "https://github.com/FerretDB/FerretDB/issues/1051")

assert.NotZero(t, actual.Databases[0].SizeOnDisk, "%s's SizeOnDisk should be non-zero", name)
assert.False(t, actual.Databases[0].Empty, "%s's Empty should be false", name)
assert.NotZero(t, actual.TotalSize, "TotalSize should be non-zero")
Expand Down Expand Up @@ -197,8 +191,6 @@ func TestCommandsAdministrationListCollections(t *testing.T) {
}

func TestCommandsAdministrationGetParameter(t *testing.T) {
setup.SkipForTigris(t)

t.Parallel()
s := setup.SetupWithOpts(t, &setup.SetupOpts{
DatabaseName: "admin",
Expand Down Expand Up @@ -648,18 +640,6 @@ func TestCommandsAdministrationCollStats(t *testing.T) {
assert.Equal(t, int32(1), must.NotFail(doc.Get("scaleFactor")))
assert.Equal(t, float64(1), must.NotFail(doc.Get("ok")))

// For Tigris, we only check that the keys are present (they might be zeros as we don't have the data for them)
if setup.IsTigris(t) {
assert.True(t, doc.Has("size"))
assert.True(t, doc.Has("avgObjSize"))
assert.True(t, doc.Has("storageSize"))
assert.True(t, doc.Has("nindexes"))
assert.True(t, doc.Has("totalIndexSize"))
assert.True(t, doc.Has("totalSize"))

return
}

// Values are returned as "numbers" that could be int32 or int64.
// FerretDB always returns int64 for simplicity.
assert.InDelta(t, 40_000, must.NotFail(doc.Get("size")), 39_900)
Expand All @@ -686,18 +666,6 @@ func TestCommandsAdministrationCollStatsWithScale(t *testing.T) {
assert.Equal(t, int32(1000), must.NotFail(doc.Get("scaleFactor")))
assert.Equal(t, float64(1), must.NotFail(doc.Get("ok")))

// For Tigris, we only check that the keys are present (they might be zeros as we don't have the data for them)
if setup.IsTigris(t) {
assert.True(t, doc.Has("size"))
assert.True(t, doc.Has("avgObjSize"))
assert.True(t, doc.Has("storageSize"))
assert.True(t, doc.Has("nindexes"))
assert.True(t, doc.Has("totalIndexSize"))
assert.True(t, doc.Has("totalSize"))

return
}

assert.InDelta(t, 16, must.NotFail(doc.Get("size")), 16)
assert.InDelta(t, 2_400, must.NotFail(doc.Get("avgObjSize")), 2_370)
assert.InDelta(t, 24, must.NotFail(doc.Get("storageSize")), 24)
Expand Down Expand Up @@ -812,16 +780,6 @@ func TestCommandsAdministrationDBStats(t *testing.T) {
assert.Equal(t, float64(1), doc.Remove("scaleFactor"))
assert.Equal(t, float64(1), doc.Remove("ok"))

// For Tigris, we only check that the keys are present (they might be zeros as we don't have the data for them)
if setup.IsTigris(t) {
assert.True(t, doc.Has("avgObjSize"))
assert.True(t, doc.Has("storageSize"))
assert.True(t, doc.Has("dataSize"))
assert.True(t, doc.Has("totalSize"))

return
}

assert.InDelta(t, 37_500, doc.Remove("avgObjSize"), 37_460)
assert.InDelta(t, 37_500, doc.Remove("dataSize"), 37_450)
assert.InDelta(t, 37_500, doc.Remove("storageSize"), 37_450)
Expand Down Expand Up @@ -902,8 +860,6 @@ func TestCommandsAdministrationDBStatsEmptyWithScale(t *testing.T) {

//nolint:paralleltest // we test a global server status
func TestCommandsAdministrationServerStatus(t *testing.T) {
setup.SkipForTigris(t)

ctx, collection := setup.Setup(t)

var actual bson.D
Expand Down Expand Up @@ -1073,8 +1029,6 @@ func TestCommandsAdministrationServerStatusFreeMonitoring(t *testing.T) {
func TestCommandsAdministrationServerStatusStress(t *testing.T) {
// TODO rewrite using teststress.Stress

setup.SkipForTigrisWithReason(t, "https://github.com/FerretDB/FerretDB/issues/1507")

ctx, collection := setup.Setup(t) // no providers there, we will create collections concurrently
client := collection.Database().Client()

Expand All @@ -1100,24 +1054,7 @@ func TestCommandsAdministrationServerStatusStress(t *testing.T) {

collName := fmt.Sprintf("stress_%d", i)

schema := fmt.Sprintf(`{
"title": "%s",
"description": "Create Collection Stress %d",
"primary_key": ["_id"],
"properties": {
"_id": {"type": "string"},
"v": {"type": "string"}
}
}`, collName, i,
)

// Set $tigrisSchemaString for tigris only.
opts := options.CreateCollection()
if setup.IsTigris(t) {
opts.SetValidator(bson.D{{"$tigrisSchemaString", schema}})
}

err := db.CreateCollection(ctx, collName, opts)
err := db.CreateCollection(ctx, collName)
assert.NoError(t, err)

err = db.Drop(ctx)
Expand Down
1 change: 0 additions & 1 deletion integration/commands_authentication_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ func TestCommandsAuthenticationLogoutTLS(t *testing.T) {
t.Parallel()

setup.SkipForMongoDB(t, "tls is not enabled for mongodb backend")
setup.SkipForTigrisWithReason(t, "tls is not enabled for tigris backend")

ctx, collection := setup.Setup(t)
db := collection.Database()
Expand Down
5 changes: 0 additions & 5 deletions integration/count_command_compat_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import (
)

type countCommandCompatTestCase struct {
skipForTigris string
skip string
collectionName any
command bson.D
Expand All @@ -45,10 +44,6 @@ func testCountCommandCompat(t *testing.T, testCases map[string]countCommandCompa
t.Run(name, func(t *testing.T) {
t.Helper()

if tc.skipForTigris != "" {
setup.SkipForTigrisWithReason(t, tc.skipForTigris)
}

if tc.skip != "" {
t.Skip(tc.skip)
}
Expand Down
21 changes: 1 addition & 20 deletions integration/create_compat_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,10 @@
package integration

import (
"fmt"
"testing"

"github.com/stretchr/testify/require"
"go.mongodb.org/mongo-driver/bson"
"go.mongodb.org/mongo-driver/mongo/options"

"github.com/FerretDB/FerretDB/integration/setup"
"github.com/FerretDB/FerretDB/integration/shareddata"
Expand Down Expand Up @@ -51,24 +49,7 @@ func TestCreateCompat(t *testing.T) {

collName := "in-non-existent-db"

// schema in case of Tigris.
schema := fmt.Sprintf(`{
"title": "%s",
"description": "Create Collection In Non-Existent Database",
"primary_key": ["_id"],
"properties": {
"_id": {"type": "string"}
}
}`, collName,
)

// Set $tigrisSchemaString for tigris only.
opts := options.CreateCollection()
if setup.IsTigris(t) {
opts.SetValidator(bson.D{{"$tigrisSchemaString", schema}})
}

targetErr := targetDB.CreateCollection(s.Ctx, collName, opts)
targetErr := targetDB.CreateCollection(s.Ctx, collName)
compatErr := compatDB.CreateCollection(s.Ctx, collName)
require.Equal(t, targetErr, compatErr)

Expand Down
Loading

0 comments on commit ea31cf5

Please sign in to comment.