Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 0 additions & 21 deletions db/background_mgr.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,8 @@ package db

import (
"context"
"fmt"
"net/http"
"sync"
"testing"
"time"

sgbucket "github.com/couchbase/sg-bucket"
Expand Down Expand Up @@ -408,25 +406,6 @@ func (b *BackgroundManager) GetRunState() BackgroundProcessState {
return b.State
}

// For test use only
// Returns empty string if background process is not cluster aware
func (b *BackgroundManager) GetHeartbeatDocID(t testing.TB) string {
if b.isClusterAware() {
return b.clusterAwareOptions.HeartbeatDocID()
}
return ""
}

// For test use only
// Returns error if background process is not cluster aware
func (b *BackgroundManager) GetHeartbeatDoc(t testing.TB) ([]byte, error) {
if b.isClusterAware() {
b, _, err := b.clusterAwareOptions.metadataStore.GetRaw(b.GetHeartbeatDocID(t))
return b, err
}
return nil, fmt.Errorf("background process is not cluster aware")
}

func (b *BackgroundManager) SetError(err error) {
b.lock.Lock()
defer b.lock.Unlock()
Expand Down
10 changes: 5 additions & 5 deletions db/background_mgr_attachment_migration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ func TestAttachmentMigrationTaskMixMigratedAndNonMigratedDocs(t *testing.T) {
require.NoError(t, err)

// wait for task to complete
RequireBackgroundManagerState(t, ctx, attachMigrationMgr, BackgroundProcessStateCompleted)
RequireBackgroundManagerState(t, attachMigrationMgr, BackgroundProcessStateCompleted)

// assert that the subset (5) of the docs were changed, all created docs were processed (10)
stats := getAttachmentMigrationStats(t, attachMigrationMgr.Process)
Expand Down Expand Up @@ -118,7 +118,7 @@ func TestAttachmentMigrationManagerResumeStoppedMigration(t *testing.T) {
}
}()

RequireBackgroundManagerState(t, ctx, attachMigrationMgr, BackgroundProcessStateStopped)
RequireBackgroundManagerState(t, attachMigrationMgr, BackgroundProcessStateStopped)

stats := getAttachmentMigrationStats(t, attachMigrationMgr.Process)
require.Less(t, stats.DocsProcessed, int64(4000))
Expand All @@ -132,7 +132,7 @@ func TestAttachmentMigrationManagerResumeStoppedMigration(t *testing.T) {
err = attachMigrationMgr.Start(ctx, nil)
require.NoError(t, err)

RequireBackgroundManagerState(t, ctx, attachMigrationMgr, BackgroundProcessStateCompleted)
RequireBackgroundManagerState(t, attachMigrationMgr, BackgroundProcessStateCompleted)

stats = getAttachmentMigrationStats(t, attachMigrationMgr.Process)
require.GreaterOrEqual(t, stats.DocsProcessed, int64(4000))
Expand Down Expand Up @@ -169,7 +169,7 @@ func TestAttachmentMigrationManagerNoDocsToMigrate(t *testing.T) {
require.NoError(t, err)

// wait for task to complete
RequireBackgroundManagerState(t, ctx, attachMigrationMgr, BackgroundProcessStateCompleted)
RequireBackgroundManagerState(t, attachMigrationMgr, BackgroundProcessStateCompleted)

// assert that the two added docs above were processed but not changed
stats := getAttachmentMigrationStats(t, attachMigrationMgr.Process)
Expand Down Expand Up @@ -227,7 +227,7 @@ func TestMigrationManagerDocWithSyncAndGlobalAttachmentMetadata(t *testing.T) {
require.NoError(t, err)

// wait for task to complete
RequireBackgroundManagerState(t, ctx, attachMigrationMgr, BackgroundProcessStateCompleted)
RequireBackgroundManagerState(t, attachMigrationMgr, BackgroundProcessStateCompleted)

// assert that the two added docs above were processed but not changed
stats := getAttachmentMigrationStats(t, attachMigrationMgr.Process)
Expand Down
5 changes: 4 additions & 1 deletion db/background_mgr_resync_dcp.go
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,10 @@ func (r *ResyncManagerDCP) Run(ctx context.Context, options map[string]any, pers
for _, databaseCollection := range db.CollectionByID {
collectionNames = append(collectionNames, databaseCollection.ScopeAndCollectionName())
}
db.invalidateAllPrincipals(ctx, collectionNames, endSeq)
err = db.invalidateAllPrincipals(ctx, collectionNames, endSeq)
if err != nil {
return fmt.Errorf("Could not invalidate principal documents: %w", err)
}

}

Expand Down
Loading
Loading