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

Method Close

base/main_test_bucket_pool.go:462–498  ·  view source on GitHub ↗

Close waits for any buckets to be cleaned, and closes the pool.

(ctx context.Context)

Source from the content-addressed store, hash-verified

460
461// Close waits for any buckets to be cleaned, and closes the pool.
462func (tbp *TestBucketPool) Close(ctx context.Context) {
463 if tbp == nil {
464 // noop
465 return
466 }
467 defer tbp.printStats()
468
469 if !tbp.needsBucketTeardown {
470 return
471 }
472 tbp.Logf(ctx, "Closing TestBucketPool and closing all buckets")
473 // Cancel async workers
474 if tbp.ctxCancelFunc != nil {
475 tbp.ctxCancelFunc()
476 tbp.Logf(ctx, "Waiting for bucket readier to finish")
477 tbp.bucketReadierWaitGroup.Wait()
478 tbp.Logf(ctx, "Waiting for bucket creation to finish")
479 <-tbp.bucketCreationDoneChan
480 tbp.Logf(ctx, "Bucket creation finished")
481 }
482
483 if tbp.cluster != nil {
484 bucketLoop:
485 for _ = range tbp.numBuckets {
486 select {
487 case bucket := <-tbp.readyBucketPool:
488 tbp.Logf(ctx, "Closing bucket %s", bucket.GetName())
489 bucket.Close(ctx)
490 default:
491 break bucketLoop
492 }
493 }
494 if err := tbp.cluster.close(); err != nil {
495 tbp.Logf(ctx, "Couldn't close cluster connection: %v", err)
496 }
497 }
498}
499
500// removeOldTestBuckets removes all buckets starting with testBucketNamePrefix
501func (tbp *TestBucketPool) removeOldTestBuckets(ctx context.Context) error {

Callers

nothing calls this directly

Calls 6

printStatsMethod · 0.95
LogfMethod · 0.95
GetNameMethod · 0.65
CloseMethod · 0.65
WaitMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected