Test low sequence handling of late arriving sequences to a continuous changes feed, when the user doesn't have visibility to some of the late arriving sequences
(t *testing.T)
| 743 | // Test low sequence handling of late arriving sequences to a continuous changes feed, when the |
| 744 | // user doesn't have visibility to some of the late arriving sequences |
| 745 | func TestLowSequenceHandlingAcrossChannels(t *testing.T) { |
| 746 | |
| 747 | base.SetUpTestLogging(t, base.LevelDebug, base.KeyCache, base.KeyChanges, base.KeyQuery) |
| 748 | |
| 749 | db, ctx := setupTestDBWithCacheOptions(t, shortWaitCache()) |
| 750 | defer db.Close(ctx) |
| 751 | |
| 752 | // Create a user with access to channel ABC |
| 753 | authenticator := db.Authenticator(ctx) |
| 754 | user, err := authenticator.NewUser("naomi", "letmein", channels.BaseSetOf(t, "ABC")) |
| 755 | assert.NoError(t, err, fmt.Sprintf("db.Authenticator(db.Ctx) returned err: %v", err)) |
| 756 | require.NoError(t, authenticator.Save(user)) |
| 757 | |
| 758 | collection := GetSingleDatabaseCollection(t, db.DatabaseContext) |
| 759 | // Simulate seq 3 and 4 being delayed - write 1,2,5,6 |
| 760 | WriteDirect(t, collection, []string{"ABC"}, 1) |
| 761 | WriteDirect(t, collection, []string{"ABC"}, 2) |
| 762 | WriteDirect(t, collection, []string{"PBS"}, 5) |
| 763 | WriteDirect(t, collection, []string{"ABC", "PBS"}, 6) |
| 764 | |
| 765 | require.NoError(t, db.changeCache.waitForSequence(ctx, 6, base.DefaultWaitForSequence)) |
| 766 | db.user, err = authenticator.GetUser("naomi") |
| 767 | require.NoError(t, err) |
| 768 | |
| 769 | // Start changes feed |
| 770 | |
| 771 | var options ChangesOptions |
| 772 | options.Since = SequenceID{Seq: 0} |
| 773 | ctx, changesCtxCancel := context.WithCancel(ctx) |
| 774 | options.ChangesCtx = ctx |
| 775 | options.Continuous = true |
| 776 | options.Wait = true |
| 777 | dbCollection, ctx := GetSingleDatabaseCollectionWithUser(ctx, t, db) |
| 778 | feed, err := dbCollection.MultiChangesFeed(ctx, base.SetOf("*"), options) |
| 779 | assert.True(t, err == nil) |
| 780 | |
| 781 | _, err = verifySequencesInFeed(feed, []uint64{1, 2, 6}) |
| 782 | assert.True(t, err == nil) |
| 783 | |
| 784 | // Test backfill of sequence the user doesn't have visibility to |
| 785 | WriteDirect(t, collection, []string{"PBS"}, 3) |
| 786 | WriteDirect(t, collection, []string{"ABC"}, 9) |
| 787 | |
| 788 | _, err = verifySequencesInFeed(feed, []uint64{9}) |
| 789 | assert.True(t, err == nil) |
| 790 | |
| 791 | changesCtxCancel() |
| 792 | } |
| 793 | |
| 794 | // Test low sequence handling of late arriving sequences to a continuous changes feed, when the |
| 795 | // user gets added to a new channel with existing entries (and existing backfill) |
nothing calls this directly
no test coverage detected