Skip to content

Commit

Permalink
Make administration command integration tests pass for SQLite (Ferret…
Browse files Browse the repository at this point in the history
  • Loading branch information
noisersup authored and yonarw committed Aug 31, 2023
1 parent 98cdaca commit b6e8391
Show file tree
Hide file tree
Showing 4 changed files with 73 additions and 41 deletions.
15 changes: 9 additions & 6 deletions integration/commands_administration_compat_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,11 @@ func TestCommandsAdministrationCompatCollStatsWithScale(t *testing.T) {
} {
name, tc := name, tc

t.Run(name, func(t *testing.T) {
t.Helper()
t.Run(name, func(tt *testing.T) {
tt.Helper()

t.Parallel()
tt.Parallel()
t := setup.FailsForSQLite(tt, "https://github.com/FerretDB/FerretDB/issues/2775")

var targetRes bson.D
targetCommand := bson.D{{"collStats", targetCollection.Name()}, {"scale", tc.scale}}
Expand Down Expand Up @@ -118,10 +119,12 @@ func TestCommandsAdministrationCompatDBStatsWithScale(t *testing.T) {
} {
name, tc := name, tc

t.Run(name, func(t *testing.T) {
t.Helper()
t.Run(name, func(tt *testing.T) {
tt.Helper()

t.Parallel()
tt.Parallel()

t := setup.FailsForSQLite(tt, "https://github.com/FerretDB/FerretDB/issues/2775")

var targetRes bson.D
targetCommand := bson.D{{"dbStats", int32(1)}, {"scale", tc.scale}}
Expand Down
77 changes: 50 additions & 27 deletions integration/commands_administration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,10 @@ func TestCommandsAdministrationCreateDropListDatabases(t *testing.T) {
assert.Equal(t, bson.D{{"ok", 1.0}}, res)
}

func TestCommandsAdministrationListDatabases(t *testing.T) {
t.Parallel()
func TestCommandsAdministrationListDatabases(tt *testing.T) {
tt.Parallel()

t := setup.FailsForSQLite(tt, "https://github.com/FerretDB/FerretDB/issues/2775")
ctx, collection := setup.Setup(t, shareddata.DocumentsStrings)

db := collection.Database()
Expand Down Expand Up @@ -673,9 +675,11 @@ func TestCommandsAdministrationBuildInfoFerretdbExtensions(t *testing.T) {
assert.NotEmpty(t, aggregationStagesArray)
}

func TestCommandsAdministrationCollStatsEmpty(t *testing.T) {
t.Parallel()
ctx, collection := setup.Setup(t)
func TestCommandsAdministrationCollStatsEmpty(tt *testing.T) {
tt.Parallel()
ctx, collection := setup.Setup(tt)

t := setup.FailsForSQLite(tt, "https://github.com/FerretDB/FerretDB/issues/2775")

var actual bson.D
command := bson.D{{"collStats", collection.Name()}}
Expand All @@ -695,8 +699,10 @@ func TestCommandsAdministrationCollStatsEmpty(t *testing.T) {
assert.Equal(t, float64(1), must.NotFail(doc.Get("ok")))
}

func TestCommandsAdministrationCollStats(t *testing.T) {
t.Parallel()
func TestCommandsAdministrationCollStats(tt *testing.T) {
tt.Parallel()

t := setup.FailsForSQLite(tt, "https://github.com/FerretDB/FerretDB/issues/2775")
ctx, collection := setup.Setup(t, shareddata.DocumentsStrings)

var actual bson.D
Expand Down Expand Up @@ -724,8 +730,11 @@ func TestCommandsAdministrationCollStats(t *testing.T) {
assert.InDelta(t, 32_000, must.NotFail(doc.Get("totalSize")), 30_000)
}

func TestCommandsAdministrationCollStatsWithScale(t *testing.T) {
t.Parallel()
func TestCommandsAdministrationCollStatsWithScale(tt *testing.T) {
tt.Parallel()

t := setup.FailsForSQLite(tt, "https://github.com/FerretDB/FerretDB/issues/2775")

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

var actual bson.D
Expand All @@ -751,8 +760,10 @@ func TestCommandsAdministrationCollStatsWithScale(t *testing.T) {
func TestCommandsAdministrationDataSize(t *testing.T) {
t.Parallel()

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

t := setup.FailsForSQLite(tt, "https://github.com/FerretDB/FerretDB/issues/2775")
ctx, collection := setup.Setup(t, shareddata.DocumentsStrings)

var actual bson.D
Expand All @@ -767,8 +778,10 @@ func TestCommandsAdministrationDataSize(t *testing.T) {
assert.InDelta(t, 200, must.NotFail(doc.Get("millis")), 200)
})

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

t := setup.FailsForSQLite(tt, "https://github.com/FerretDB/FerretDB/issues/2775")
ctx, collection := setup.Setup(t)

var actual bson.D
Expand All @@ -784,10 +797,10 @@ func TestCommandsAdministrationDataSize(t *testing.T) {
})
}

func TestCommandsAdministrationDataSizeErrors(t *testing.T) {
t.Parallel()
func TestCommandsAdministrationDataSizeErrors(tt *testing.T) {
tt.Parallel()

ctx, collection := setup.Setup(t, shareddata.DocumentsStrings)
ctx, collection := setup.Setup(tt, shareddata.DocumentsStrings)

for name, tc := range map[string]struct { //nolint:vet // for readability
command bson.D // required, command to run
Expand Down Expand Up @@ -815,12 +828,14 @@ func TestCommandsAdministrationDataSizeErrors(t *testing.T) {
} {
name, tc := name, tc

t.Run(name, func(t *testing.T) {
tt.Run(name, func(tt *testing.T) {
if tc.skip != "" {
t.Skip(tc.skip)
tt.Skip(tc.skip)
}

t.Parallel()
tt.Parallel()

t := setup.FailsForSQLite(tt, "https://github.com/FerretDB/FerretDB/issues/2775")

require.NotNil(t, tc.command, "command must not be nil")
require.NotNil(t, tc.err, "err must not be nil")
Expand All @@ -834,8 +849,10 @@ func TestCommandsAdministrationDataSizeErrors(t *testing.T) {
}
}

func TestCommandsAdministrationDBStats(t *testing.T) {
t.Parallel()
func TestCommandsAdministrationDBStats(tt *testing.T) {
tt.Parallel()

t := setup.FailsForSQLite(tt, "https://github.com/FerretDB/FerretDB/issues/2775")
ctx, collection := setup.Setup(t, shareddata.DocumentsStrings)

var actual bson.D
Expand All @@ -862,8 +879,10 @@ func TestCommandsAdministrationDBStats(t *testing.T) {
// https://github.com/FerretDB/FerretDB/issues/727
}

func TestCommandsAdministrationDBStatsEmpty(t *testing.T) {
t.Parallel()
func TestCommandsAdministrationDBStatsEmpty(tt *testing.T) {
tt.Parallel()

t := setup.FailsForSQLite(tt, "https://github.com/FerretDB/FerretDB/issues/2775")
ctx, collection := setup.Setup(t)

var actual bson.D
Expand All @@ -885,8 +904,10 @@ func TestCommandsAdministrationDBStatsEmpty(t *testing.T) {
// https://github.com/FerretDB/FerretDB/issues/727
}

func TestCommandsAdministrationDBStatsWithScale(t *testing.T) {
t.Parallel()
func TestCommandsAdministrationDBStatsWithScale(tt *testing.T) {
tt.Parallel()

t := setup.FailsForSQLite(tt, "https://github.com/FerretDB/FerretDB/issues/2775")
ctx, collection := setup.Setup(t, shareddata.DocumentsStrings)

var actual bson.D
Expand All @@ -908,8 +929,10 @@ func TestCommandsAdministrationDBStatsWithScale(t *testing.T) {
// https://github.com/FerretDB/FerretDB/issues/727
}

func TestCommandsAdministrationDBStatsEmptyWithScale(t *testing.T) {
t.Parallel()
func TestCommandsAdministrationDBStatsEmptyWithScale(tt *testing.T) {
tt.Parallel()

t := setup.FailsForSQLite(tt, "https://github.com/FerretDB/FerretDB/issues/2775")
ctx, collection := setup.Setup(t)

var actual bson.D
Expand Down
8 changes: 5 additions & 3 deletions integration/commands_authentication_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,12 @@ func TestCommandsAuthenticationLogout(t *testing.T) {
assert.Equal(t, bson.D{{"ok", float64(1)}}, res)
}

func TestCommandsAuthenticationLogoutTLS(t *testing.T) {
t.Parallel()
func TestCommandsAuthenticationLogoutTLS(tt *testing.T) {
tt.Parallel()

setup.SkipForMongoDB(tt, "tls is not enabled for mongodb backend")

setup.SkipForMongoDB(t, "tls is not enabled for mongodb backend")
t := setup.FailsForSQLite(tt, "https://github.com/FerretDB/FerretDB/issues/3008")

ctx, collection := setup.Setup(t)
db := collection.Database()
Expand Down
14 changes: 9 additions & 5 deletions integration/commands_diagnostic_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,10 @@ func TestCommandsDiagnosticExplain(t *testing.T) {
},
} {
name, tc := name, tc
t.Run(name, func(t *testing.T) {
t.Parallel()
t.Run(name, func(tt *testing.T) {
tt.Parallel()

t := setup.FailsForSQLite(tt, "https://github.com/FerretDB/FerretDB/issues/3050")

var actual bson.D

Expand Down Expand Up @@ -184,12 +186,14 @@ func TestCommandsDiagnosticGetLog(t *testing.T) {
},
} {
name, tc := name, tc
t.Run(name, func(t *testing.T) {
t.Run(name, func(tt *testing.T) {
if tc.skip != "" {
t.Skip(tc.skip)
tt.Skip(tc.skip)
}

t.Parallel()
tt.Parallel()

t := setup.FailsForSQLite(tt, "https://github.com/FerretDB/FerretDB/issues/2775")

require.NotNil(t, tc.command, "command must not be nil")

Expand Down

0 comments on commit b6e8391

Please sign in to comment.