MCPcopy Create free account
hub / github.com/couchbase/sync_gateway / TestImportCompactPanic

Function TestImportCompactPanic

db/database_test.go:4200–4224  ·  view source on GitHub ↗

Regression test for CBG-2058.

(t *testing.T)

Source from the content-addressed store, hash-verified

4198
4199// Regression test for CBG-2058.
4200func TestImportCompactPanic(t *testing.T) {
4201 if !base.TestUseXattrs() {
4202 t.Skip("requires xattrs")
4203 }
4204
4205 // Set the compaction and purge interval unrealistically low to reproduce faster
4206 db, ctx := setupTestDBWithOptionsAndImport(t, nil, DatabaseContextOptions{
4207 CompactInterval: 1,
4208 TestPurgeIntervalOverride: base.Ptr(time.Duration(0)),
4209 })
4210 defer db.Close(ctx)
4211 collection, ctx := GetSingleDatabaseCollectionWithUser(ctx, t, db)
4212
4213 // Create a document, then delete it, to create a tombstone
4214 rev, doc, err := collection.Put(ctx, "test", Body{})
4215 require.NoError(t, err)
4216 _, _, err = collection.DeleteDoc(ctx, doc.ID, DocVersion{RevTreeID: rev})
4217 require.NoError(t, err)
4218 require.NoError(t, collection.WaitForPendingChanges(ctx))
4219
4220 // Wait for Compact to run - in the failing case it'll panic before incrementing the stat
4221 base.RequireWaitForStat(t, func() int64 {
4222 return db.DbStats.Database().NumTombstonesCompacted.Value()
4223 }, 1)
4224}
4225
4226func TestGetDatabaseCollectionWithUserScopesNil(t *testing.T) {
4227 testCases := []struct {

Callers

nothing calls this directly

Calls 11

TestUseXattrsFunction · 0.92
PtrFunction · 0.92
RequireWaitForStatFunction · 0.92
CloseMethod · 0.65
PutMethod · 0.65
DeleteDocMethod · 0.45
WaitForPendingChangesMethod · 0.45
ValueMethod · 0.45
DatabaseMethod · 0.45

Tested by

no test coverage detected