(t *testing.T)
| 2183 | } |
| 2184 | |
| 2185 | func TestPutRevHighRevCacheChurn(t *testing.T) { |
| 2186 | |
| 2187 | dbcOptions := DatabaseContextOptions{ |
| 2188 | RevisionCacheOptions: &RevisionCacheOptions{ |
| 2189 | MaxItemCount: 2, |
| 2190 | ShardCount: 1, |
| 2191 | }, |
| 2192 | } |
| 2193 | var wg sync.WaitGroup |
| 2194 | db, ctx := SetupTestDBWithOptions(t, dbcOptions) |
| 2195 | defer db.Close(ctx) |
| 2196 | collection, ctx := GetSingleDatabaseCollectionWithUser(ctx, t, db) |
| 2197 | docID := "doc1" |
| 2198 | wg.Add(1) |
| 2199 | |
| 2200 | testCtx, testCtxCancel := context.WithCancel(base.TestCtx(t)) |
| 2201 | defer testCtxCancel() |
| 2202 | |
| 2203 | for i := 0; i < 2; i++ { |
| 2204 | docID := fmt.Sprintf("extraDoc%d", i) |
| 2205 | revID, _, err := collection.Put(ctx, docID, Body{"fake": "body"}) |
| 2206 | require.NoError(t, err) |
| 2207 | go func() { |
| 2208 | for { |
| 2209 | select { |
| 2210 | case <-testCtx.Done(): |
| 2211 | return |
| 2212 | default: |
| 2213 | _, err = db.revisionCache.GetWithRev(ctx, docID, revID, collection.GetCollectionID(), RevCacheOmitDelta) //nolint:errcheck |
| 2214 | } |
| 2215 | } |
| 2216 | }() |
| 2217 | } |
| 2218 | |
| 2219 | go func() { |
| 2220 | for i := 0; i < 100; i++ { |
| 2221 | docRev := DocumentRevision{DocID: docID, RevID: fmt.Sprintf("1-%d", i), CV: &Version{SourceID: "someSrc", Value: uint64(i)}, BodyBytes: []byte(fmt.Sprintf(`{"ver": "%d"}`, i)), History: Revisions{"start": 1}} |
| 2222 | db.revisionCache.Put(ctx, docRev, collection.GetCollectionID()) |
| 2223 | } |
| 2224 | wg.Done() |
| 2225 | }() |
| 2226 | wg.Wait() |
| 2227 | } |
| 2228 | |
| 2229 | func TestRevCacheOnDemandImportNoCache(t *testing.T) { |
| 2230 | base.SkipImportTestsIfNotEnabled(t) |
nothing calls this directly
no test coverage detected