Test notification when buffered entries are processed after a user doc arrives.
(t *testing.T)
| 465 | |
| 466 | // Test notification when buffered entries are processed after a user doc arrives. |
| 467 | func TestChannelCacheBufferingWithUserDoc(t *testing.T) { |
| 468 | |
| 469 | base.SetUpTestLogging(t, base.LevelDebug, base.KeyCache, base.KeyChanges, base.KeyDCP) |
| 470 | |
| 471 | db, ctx := setupTestDB(t) |
| 472 | defer db.Close(ctx) |
| 473 | |
| 474 | collection := GetSingleDatabaseCollection(t, db.DatabaseContext) |
| 475 | collectionID := collection.GetCollectionID() |
| 476 | |
| 477 | // Simulate seq 1 (user doc) being delayed - write 2 first |
| 478 | WriteDirect(t, collection, []string{"ABC"}, 2) |
| 479 | |
| 480 | // Start wait for doc in ABC |
| 481 | chans := channels.SetOfNoValidate( |
| 482 | channels.NewID("ABC", collectionID)) |
| 483 | waiter := db.mutationListener.NewWaiterWithChannels(chans, nil, false) |
| 484 | |
| 485 | successChan := make(chan bool) |
| 486 | go func() { |
| 487 | waiter.Wait(ctx) |
| 488 | close(successChan) |
| 489 | }() |
| 490 | |
| 491 | // Simulate a user doc update |
| 492 | writeUserDirect(t, db, "bernard", 1) |
| 493 | |
| 494 | // Wait 3 seconds for notification, else fail the test. |
| 495 | select { |
| 496 | case <-successChan: |
| 497 | log.Println("notification successful") |
| 498 | case <-time.After(time.Second * 3): |
| 499 | t.Fatal("No notification after 3 seconds") |
| 500 | } |
| 501 | |
| 502 | } |
| 503 | |
| 504 | // Test backfill of late arriving sequences to the channel caches |
| 505 | func TestChannelCacheBackfill(t *testing.T) { |
nothing calls this directly
no test coverage detected