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

Function TestChangeCache_InsertPendingEntries

db/change_cache_test.go:1669–1694  ·  view source on GitHub ↗

Validates InsertPendingEntries timing

(t *testing.T)

Source from the content-addressed store, hash-verified

1667
1668// Validates InsertPendingEntries timing
1669func TestChangeCache_InsertPendingEntries(t *testing.T) {
1670 base.SetUpTestLogging(t, base.LevelDebug, base.KeyCache, base.KeyChanges)
1671
1672 cacheOptions := DefaultCacheOptions()
1673 cacheOptions.CachePendingSeqMaxWait = 100 * time.Millisecond
1674
1675 db, ctx := setupTestDBWithCacheOptions(t, cacheOptions)
1676 defer db.Close(ctx)
1677
1678 // Create a user with access to some channels
1679 authenticator := db.Authenticator(ctx)
1680 user, err := authenticator.NewUser("naomi", "letmein", channels.BaseSetOf(t, "ABC", "PBS", "NBC", "TBS"))
1681 require.NoError(t, err)
1682 require.NoError(t, authenticator.Save(user))
1683
1684 collection := GetSingleDatabaseCollection(t, db.DatabaseContext)
1685 // Simulate seq 3 + 4 being delayed - write 1,2,5,6
1686 WriteDirect(t, collection, []string{"ABC", "NBC"}, 1)
1687 WriteDirect(t, collection, []string{"ABC"}, 2)
1688 WriteDirect(t, collection, []string{"ABC", "PBS"}, 5)
1689 WriteDirect(t, collection, []string{"ABC", "PBS"}, 6)
1690
1691 // wait for InsertPendingEntries to fire, move 3 and 4 to skipped and get seqs 5 + 6
1692 require.NoError(t, db.changeCache.waitForSequence(ctx, 6, base.DefaultWaitForSequence))
1693
1694}
1695
1696// Generator for processEntry
1697type testProcessEntryFeed struct {

Callers

nothing calls this directly

Calls 11

SetUpTestLoggingFunction · 0.92
BaseSetOfFunction · 0.92
DefaultCacheOptionsFunction · 0.85
WriteDirectFunction · 0.85
NewUserMethod · 0.80
SaveMethod · 0.80
waitForSequenceMethod · 0.80
CloseMethod · 0.65
AuthenticatorMethod · 0.45

Tested by

no test coverage detected