Skip to content

Commit e287e05

Browse files
authored
CBG-3271 remove persistent rosmar buckets (#6570)
* CBG-3271 remove persistent rosmar buckets - rosmar now supports persisting in memory buckets, so keep the buckets in memory until the buckets are closed. This eliminates NoCloseClone in many cases. Another PR might be able to remove even more of these. - this is prep for being able to run a bootstrap connection.
1 parent ea7eae7 commit e287e05

18 files changed

+63
-117
lines changed

base/leaky_bucket.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,9 @@ func (b *LeakyBucket) SetIgnoreClose(value bool) {
5858
b.config.IgnoreClose = value
5959
}
6060

61-
func (b *LeakyBucket) CloseAndDelete() error {
61+
func (b *LeakyBucket) CloseAndDelete(ctx context.Context) error {
6262
if bucket, ok := b.bucket.(sgbucket.DeleteableStore); ok {
63-
return bucket.CloseAndDelete()
63+
return bucket.CloseAndDelete(ctx)
6464
}
6565
return nil
6666
}

base/main_test_bucket_pool.go

+6-22
Original file line numberDiff line numberDiff line change
@@ -198,29 +198,17 @@ func (tbp *TestBucketPool) GetWalrusTestBucket(t testing.TB, url string) (b Buck
198198
require.NoError(t, err)
199199

200200
var walrusBucket *rosmar.Bucket
201-
var typeName string
201+
const typeName = "rosmar"
202202
bucketName := tbpBucketNamePrefix + "rosmar_" + id
203203
if url == "walrus:" || url == rosmar.InMemoryURL {
204-
walrusBucket, err = rosmar.OpenBucket(url, rosmar.CreateOrOpen)
205-
if err == nil {
206-
err := walrusBucket.SetName(bucketName)
207-
if err != nil {
208-
tbp.Fatalf(testCtx, "Could not set name %s for rosmar bucket: %s", bucketName, err)
209-
}
210-
}
204+
walrusBucket, err = rosmar.OpenBucket(url, bucketName, rosmar.CreateOrOpen)
211205
} else {
212206
walrusBucket, err = rosmar.OpenBucketIn(url, bucketName, rosmar.CreateOrOpen)
213207
}
214-
typeName = "rosmar"
215208
if err != nil {
216209
tbp.Fatalf(testCtx, "couldn't get %s bucket from <%s>: %v", typeName, url, err)
217210
}
218211

219-
err = walrusBucket.SetName(bucketName)
220-
if err != nil {
221-
tbp.Fatalf(testCtx, "Could not set name %s for rosmar bucket: %s", bucketName, err)
222-
}
223-
224212
// Wrap Walrus buckets with a leaky bucket to support vbucket IDs on feed.
225213
b = &LeakyBucket{bucket: walrusBucket, config: &LeakyBucketConfig{TapFeedVbuckets: true}}
226214

@@ -258,14 +246,10 @@ func (tbp *TestBucketPool) GetWalrusTestBucket(t testing.TB, url string) (b Buck
258246
atomic.AddInt32(&tbp.stats.NumBucketsClosed, 1)
259247
atomic.AddInt64(&tbp.stats.TotalInuseBucketNano, time.Since(openedStart).Nanoseconds())
260248
tbp.markBucketClosed(t, b)
261-
if url == kTestWalrusURL {
262-
b.Close(ctx)
263-
} else {
264-
// Persisted buckets should call close and delete
265-
closeErr := walrusBucket.CloseAndDelete()
266-
if closeErr != nil {
267-
tbp.Logf(ctx, "Unexpected error closing persistent %s bucket: %v", typeName, closeErr)
268-
}
249+
// Persisted buckets should call close and delete
250+
closeErr := walrusBucket.CloseAndDelete(ctx)
251+
if closeErr != nil {
252+
tbp.Logf(ctx, "Unexpected error closing persistent %s bucket: %v", typeName, closeErr)
269253
}
270254

271255
}

base/util_testing.go

-29
Original file line numberDiff line numberDiff line change
@@ -102,12 +102,6 @@ func GetTestBucket(t testing.TB) *TestBucket {
102102
return getTestBucket(t, false)
103103
}
104104

105-
// GetTestBucket returns a test bucket from a pool. If running with walrus buckets, will persist bucket data
106-
// across bucket close.
107-
func GetPersistentTestBucket(t testing.TB) *TestBucket {
108-
return getTestBucket(t, true)
109-
}
110-
111105
// getTestBucket returns a bucket from the bucket pool. Persistent flag determines behaviour for walrus
112106
// buckets only - Couchbase bucket behaviour is defined by the bucket pool readier/init.
113107
func getTestBucket(t testing.TB, persistent bool) *TestBucket {
@@ -204,29 +198,6 @@ func rosmarUriFromPath(path string) string {
204198
return uri + strings.ReplaceAll(path, `\`, `/`)
205199
}
206200

207-
// Gets a Walrus bucket which will be persisted to a temporary directory
208-
// Returns both the test bucket which is persisted and a function which can be used to remove the created temporary
209-
// directory once the test has finished with it.
210-
func GetPersistentWalrusBucket(t testing.TB) (*TestBucket, func()) {
211-
tempDir, err := os.MkdirTemp("", "walrustemp")
212-
require.NoError(t, err)
213-
214-
bucket, spec, closeFn := GTestBucketPool.GetWalrusTestBucket(t, rosmarUriFromPath(tempDir))
215-
216-
// Return this separate to closeFn as we want to avoid this being removed on database close (/_offline handling)
217-
removeFileFunc := func() {
218-
err := os.RemoveAll(tempDir)
219-
require.NoError(t, err)
220-
}
221-
222-
return &TestBucket{
223-
Bucket: bucket,
224-
BucketSpec: spec,
225-
closeFn: closeFn,
226-
t: t,
227-
}, removeFileFunc
228-
}
229-
230201
// Should Sync Gateway use XATTRS functionality when running unit tests?
231202
func TestUseXattrs() bool {
232203
useXattrs, isSet := os.LookupEnv(TestEnvSyncGatewayUseXattrs)

go.mod

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@ require (
1313
github.com/couchbase/gocbcore/v10 v10.2.8
1414
github.com/couchbase/gomemcached v0.2.1
1515
github.com/couchbase/goutils v0.1.2
16-
github.com/couchbase/sg-bucket v0.0.0-20231003103030-627c70e18148
16+
github.com/couchbase/sg-bucket v0.0.0-20231116231254-16c1ad8b2483
1717
github.com/couchbaselabs/go-fleecedelta v0.0.0-20220909152808-6d09efa7a338
1818
github.com/couchbaselabs/gocbconnstr v1.0.5
19-
github.com/couchbaselabs/rosmar v0.0.0-20231003104919-6d4a3e8a6db6
19+
github.com/couchbaselabs/rosmar v0.0.0-20231116232326-adb4806d011e
2020
github.com/elastic/gosigar v0.14.2
2121
github.com/felixge/fgprof v0.9.3
2222
github.com/google/uuid v1.3.1

go.sum

+15-4
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
dario.cat/mergo v1.0.0 h1:AGCNq9Evsj31mOgNPcLyXc+4PNABt905YmuqPYYpBWk=
22
dario.cat/mergo v1.0.0/go.mod h1:uNxQE+84aUszobStD9th8a29P2fMDhsBdgRYvZOxGmk=
33
github.com/Azure/azure-sdk-for-go/sdk/azcore v1.6.1 h1:SEy2xmstIphdPwNBUi7uhvjyjhVKISfwjfOJmuy7kg4=
4+
github.com/Azure/azure-sdk-for-go/sdk/azcore v1.6.1/go.mod h1:bjGvMhVMb+EEm3VRNQawDMUyMMjo+S5ewNjflkep/0Q=
45
github.com/Azure/azure-sdk-for-go/sdk/internal v1.3.0 h1:sXr+ck84g/ZlZUOZiNELInmMgOsuGwdjjVkEIde0OtY=
6+
github.com/Azure/azure-sdk-for-go/sdk/internal v1.3.0/go.mod h1:okt5dMMTOFjX/aovMlrjvvXoPMBVSPzk9185BT0+eZM=
57
github.com/Azure/azure-sdk-for-go/sdk/storage/azblob v1.0.0 h1:u/LLAOFgsMv7HmNL4Qufg58y+qElGOt5qv0z1mURkRY=
8+
github.com/Azure/azure-sdk-for-go/sdk/storage/azblob v1.0.0/go.mod h1:2e8rMJtl2+2j+HXbTBwnyGpm5Nou7KhvSfxOq8JpTag=
69
github.com/BurntSushi/toml v1.3.2 h1:o7IhLm0Msx3BaB+n3Ag7L8EVlByGnpq14C4YWiu/gL8=
710
github.com/BurntSushi/toml v1.3.2/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ=
811
github.com/aws/aws-sdk-go v1.44.299 h1:HVD9lU4CAFHGxleMJp95FV/sRhtg7P4miHD1v88JAQk=
@@ -38,8 +41,10 @@ github.com/couchbase/gomemcached v0.2.1 h1:lDONROGbklo8pOt4Sr4eV436PVEaKDr3o9gUl
3841
github.com/couchbase/gomemcached v0.2.1/go.mod h1:mxliKQxOv84gQ0bJWbI+w9Wxdpt9HjDvgW9MjCym5Vo=
3942
github.com/couchbase/goutils v0.1.2 h1:gWr8B6XNWPIhfalHNog3qQKfGiYyh4K4VhO3P2o9BCs=
4043
github.com/couchbase/goutils v0.1.2/go.mod h1:h89Ek/tiOxxqjz30nPPlwZdQbdB8BwgnuBxeoUe/ViE=
41-
github.com/couchbase/sg-bucket v0.0.0-20231003103030-627c70e18148 h1:9E3u0yA+be219iLLOjuYgagOfM7UqtZ0YIhMXysJVKs=
42-
github.com/couchbase/sg-bucket v0.0.0-20231003103030-627c70e18148/go.mod h1:hy6J0RXx/Ry+5EiI8VVMetsVfBXQq5/djQLbvfRau0k=
44+
github.com/couchbase/sg-bucket v0.0.0-20231108134134-545ec7bf1a9e h1:IFv4HcdpvKFEaaszv6f1WcEbWmU276rFzOaJgarw5gw=
45+
github.com/couchbase/sg-bucket v0.0.0-20231108134134-545ec7bf1a9e/go.mod h1:hy6J0RXx/Ry+5EiI8VVMetsVfBXQq5/djQLbvfRau0k=
46+
github.com/couchbase/sg-bucket v0.0.0-20231116231254-16c1ad8b2483 h1:K6y82On0A3coA+GwW+HGKIwpCpca6ZSvTAJwwTmzCrg=
47+
github.com/couchbase/sg-bucket v0.0.0-20231116231254-16c1ad8b2483/go.mod h1:hy6J0RXx/Ry+5EiI8VVMetsVfBXQq5/djQLbvfRau0k=
4348
github.com/couchbase/tools-common/cloud v1.0.0 h1:SQZIccXoedbrThehc/r9BJbpi/JhwJ8X00PDjZ2gEBE=
4449
github.com/couchbase/tools-common/cloud v1.0.0/go.mod h1:6KVlRpbcnDWrvickUJ+xpqCWx1vgYYlEli/zL4xmZAg=
4550
github.com/couchbase/tools-common/fs v1.0.0 h1:HFA4xCF/r3BtZShFJUxzVvGuXtDkqGnaPzYJP3Kp1mw=
@@ -57,8 +62,10 @@ github.com/couchbaselabs/gocaves/client v0.0.0-20230404095311-05e3ba4f0259 h1:2T
5762
github.com/couchbaselabs/gocaves/client v0.0.0-20230404095311-05e3ba4f0259/go.mod h1:AVekAZwIY2stsJOMWLAS/0uA/+qdp7pjO8EHnl61QkY=
5863
github.com/couchbaselabs/gocbconnstr v1.0.5 h1:e0JokB5qbcz7rfnxEhNRTKz8q1svoRvDoZihsiwNigA=
5964
github.com/couchbaselabs/gocbconnstr v1.0.5/go.mod h1:KV3fnIKMi8/AzX0O9zOrO9rofEqrRF1d2rG7qqjxC7o=
60-
github.com/couchbaselabs/rosmar v0.0.0-20231003104919-6d4a3e8a6db6 h1:TeqaJ0zV0omrnvQfw4DF6o+UQQbFdBNPJVod1Y7ovQo=
61-
github.com/couchbaselabs/rosmar v0.0.0-20231003104919-6d4a3e8a6db6/go.mod h1:+HMmQTjaINo51eSZFeCKreXYSIu6jbIp+EV9keoKl3E=
65+
github.com/couchbaselabs/rosmar v0.0.0-20231108144220-c0c6c76bb267 h1:dIYPzphKBskYB0viAtWHX/nHOimFuxyVwK9cFA103eA=
66+
github.com/couchbaselabs/rosmar v0.0.0-20231108144220-c0c6c76bb267/go.mod h1:AY2mDCIVElNv3rdOAyFeb7g8phFbv821FuMxX4S6MzI=
67+
github.com/couchbaselabs/rosmar v0.0.0-20231116232326-adb4806d011e h1:6DyLYnzHE4dMfuyz0UEWiBOB/PfUXrxRUy1A4478k6A=
68+
github.com/couchbaselabs/rosmar v0.0.0-20231116232326-adb4806d011e/go.mod h1:+AjMZkAOGCeQRLjIBwehXKyWsNCPFrMKYz6lIaZ1idc=
6269
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
6370
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
6471
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
@@ -97,6 +104,7 @@ github.com/golang/snappy v0.0.4/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEW
97104
github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
98105
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
99106
github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38=
107+
github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
100108
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
101109
github.com/google/pprof v0.0.0-20211214055906-6f57359322fd h1:1FjCyPC+syAzJ5/2S8fqdZK1R22vvA0J7JZKcuOIQ7Y=
102110
github.com/google/pprof v0.0.0-20211214055906-6f57359322fd/go.mod h1:KgnwoLYCZ8IQu3XUZ8Nc/bM9CCZFOyjUNOSygVozoDg=
@@ -125,6 +133,7 @@ github.com/klauspost/compress v1.15.11 h1:Lcadnb3RKGin4FYM/orgq0qde+nc15E5Cbqg4B
125133
github.com/klauspost/compress v1.15.11/go.mod h1:QPwzmACJjUTFsnSHH934V6woptycfrDDJnH7hvFVbGM=
126134
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
127135
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
136+
github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk=
128137
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
129138
github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE=
130139
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
@@ -254,6 +263,7 @@ google.golang.org/protobuf v1.31.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqw
254263
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
255264
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
256265
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
266+
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
257267
gopkg.in/natefinch/lumberjack.v2 v2.2.1 h1:bBRl1b0OH9s/DuPhuXpNl+VtCaJXFZ5/uEFST95x9zc=
258268
gopkg.in/natefinch/lumberjack.v2 v2.2.1/go.mod h1:YD8tP3GAjkrDg1eZH7EGmyESg/lsYskCTPBJVb9jqSc=
259269
gopkg.in/readline.v1 v1.0.0-20160726135117-62c6fe619375/go.mod h1:lNEQeAhU009zbRxng+XOj5ITVgY24WcbNnQopyfKoYQ=
@@ -265,6 +275,7 @@ gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
265275
gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
266276
gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
267277
gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
278+
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
268279
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
269280
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
270281
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=

rest/adminapitest/admin_api_test.go

+11-11
Original file line numberDiff line numberDiff line change
@@ -1472,7 +1472,7 @@ func TestCorruptDbConfigHandling(t *testing.T) {
14721472
base.SetUpTestLogging(t, base.LevelInfo, base.KeyConfig)
14731473

14741474
rt := rest.NewRestTester(t, &rest.RestTesterConfig{
1475-
CustomTestBucket: base.GetPersistentTestBucket(t),
1475+
CustomTestBucket: base.GetTestBucket(t),
14761476
PersistentConfig: true,
14771477
MutateStartupConfig: func(config *rest.StartupConfig) {
14781478
// configure the interval time to pick up new configs from the bucket to every 1 seconds
@@ -1557,7 +1557,7 @@ func TestBadConfigInsertionToBucket(t *testing.T) {
15571557
base.TestsRequireBootstrapConnection(t)
15581558

15591559
rt := rest.NewRestTester(t, &rest.RestTesterConfig{
1560-
CustomTestBucket: base.GetPersistentTestBucket(t),
1560+
CustomTestBucket: base.GetTestBucket(t),
15611561
PersistentConfig: true,
15621562
MutateStartupConfig: func(config *rest.StartupConfig) {
15631563
// configure the interval time to pick up new configs from the bucket to every 1 seconds
@@ -1608,11 +1608,11 @@ func TestMismatchedBucketNameOnDbConfigUpdate(t *testing.T) {
16081608
base.TestsRequireBootstrapConnection(t)
16091609
base.RequireNumTestBuckets(t, 2)
16101610
ctx := base.TestCtx(t)
1611-
tb1 := base.GetPersistentTestBucket(t)
1611+
tb1 := base.GetTestBucket(t)
16121612
defer tb1.Close(ctx)
16131613

16141614
rt := rest.NewRestTester(t, &rest.RestTesterConfig{
1615-
CustomTestBucket: base.GetPersistentTestBucket(t),
1615+
CustomTestBucket: base.GetTestBucket(t),
16161616
PersistentConfig: true,
16171617
MutateStartupConfig: func(config *rest.StartupConfig) {
16181618
// configure the interval time to pick up new configs from the bucket to every 1 seconds
@@ -1643,11 +1643,11 @@ func TestMultipleBucketWithBadDbConfigScenario1(t *testing.T) {
16431643
base.TestsRequireBootstrapConnection(t)
16441644
base.RequireNumTestBuckets(t, 3)
16451645
ctx := base.TestCtx(t)
1646-
tb1 := base.GetPersistentTestBucket(t)
1646+
tb1 := base.GetTestBucket(t)
16471647
defer tb1.Close(ctx)
1648-
tb2 := base.GetPersistentTestBucket(t)
1648+
tb2 := base.GetTestBucket(t)
16491649
defer tb2.Close(ctx)
1650-
tb3 := base.GetPersistentTestBucket(t)
1650+
tb3 := base.GetTestBucket(t)
16511651
defer tb3.Close(ctx)
16521652

16531653
const groupID = "60ce5544-c368-4b08-b0ed-4ca3b37973f9"
@@ -1722,9 +1722,9 @@ func TestMultipleBucketWithBadDbConfigScenario2(t *testing.T) {
17221722

17231723
base.RequireNumTestBuckets(t, 3)
17241724
ctx := base.TestCtx(t)
1725-
tb1 := base.GetPersistentTestBucket(t)
1725+
tb1 := base.GetTestBucket(t)
17261726
defer tb1.Close(ctx)
1727-
tb2 := base.GetPersistentTestBucket(t)
1727+
tb2 := base.GetTestBucket(t)
17281728
defer tb2.Close(ctx)
17291729

17301730
rt1 := rest.NewRestTester(t, &rest.RestTesterConfig{
@@ -1792,9 +1792,9 @@ func TestMultipleBucketWithBadDbConfigScenario3(t *testing.T) {
17921792
base.TestsRequireBootstrapConnection(t)
17931793

17941794
ctx := base.TestCtx(t)
1795-
tb1 := base.GetPersistentTestBucket(t)
1795+
tb1 := base.GetTestBucket(t)
17961796
defer tb1.Close(ctx)
1797-
tb2 := base.GetPersistentTestBucket(t)
1797+
tb2 := base.GetTestBucket(t)
17981798
defer tb2.Close(ctx)
17991799

18001800
rt := rest.NewRestTester(t, &rest.RestTesterConfig{

rest/adminapitest/collections_admin_api_test.go

-1
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,6 @@ func TestRequireResync(t *testing.T) {
179179
base.RequireNumTestDataStores(t, 2)
180180
base.SetUpTestLogging(t, base.LevelInfo, base.KeyAll)
181181
rtConfig := &rest.RestTesterConfig{
182-
CustomTestBucket: base.GetPersistentTestBucket(t),
183182
PersistentConfig: true,
184183
}
185184

rest/api.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ func (h *handler) handleFlush() error {
258258
name := h.db.Name
259259
config := h.server.GetDatabaseConfig(name)
260260
h.server.RemoveDatabase(h.ctx(), name)
261-
err := bucket.CloseAndDelete()
261+
err := bucket.CloseAndDelete(h.ctx())
262262
_, err2 := h.server.AddDatabaseFromConfig(h.ctx(), config.DatabaseConfig)
263263
if err == nil {
264264
err = err2

rest/api_collections_test.go

+14-14
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ func TestMultiCollectionChannelAccess(t *testing.T) {
267267
base.SetUpTestLogging(t, base.LevelDebug, base.KeyAll)
268268

269269
ctx := base.TestCtx(t)
270-
tb := base.GetPersistentTestBucket(t)
270+
tb := base.GetTestBucket(t)
271271
defer tb.Close(ctx)
272272

273273
scopesConfig := GetCollectionsConfig(t, tb, 2)
@@ -281,9 +281,8 @@ func TestMultiCollectionChannelAccess(t *testing.T) {
281281
scopesConfig[scope].Collections[collection1] = &CollectionConfig{SyncFn: &c1SyncFunction}
282282
scopesConfig[scope].Collections[collection2] = &CollectionConfig{SyncFn: &c1SyncFunction}
283283

284-
fmt.Println(scopesConfig)
285284
rtConfig := &RestTesterConfig{
286-
CustomTestBucket: tb.NoCloseClone(),
285+
CustomTestBucket: tb,
287286
DatabaseConfig: &DatabaseConfig{DbConfig: DbConfig{
288287
Scopes: scopesConfig,
289288
NumIndexReplicas: base.UintPtr(0),
@@ -337,16 +336,21 @@ func TestMultiCollectionChannelAccess(t *testing.T) {
337336
RequireStatus(t, resp, http.StatusOK)
338337

339338
// Add a new collection and update the db config
340-
scopesConfig = GetCollectionsConfig(t, tb, 3)
341-
dataStoreNames = GetDataStoreNamesFromScopesConfig(scopesConfig)
339+
scopesConfig3Collections := GetCollectionsConfig(t, tb, 3)
340+
dataStoreNames = GetDataStoreNamesFromScopesConfig(scopesConfig3Collections)
342341

343342
collection3 := dataStoreNames[2].CollectionName()
344-
scopesConfig[scope].Collections[collection1] = &CollectionConfig{SyncFn: &c1SyncFunction}
345-
scopesConfig[scope].Collections[collection2] = &CollectionConfig{SyncFn: &c1SyncFunction}
346-
scopesConfig[scope].Collections[collection3] = &CollectionConfig{SyncFn: &c1SyncFunction}
347-
scopesConfigString, err := json.Marshal(scopesConfig)
343+
scopesConfig3Collections[scope].Collections[collection1] = &CollectionConfig{SyncFn: &c1SyncFunction}
344+
scopesConfig3Collections[scope].Collections[collection2] = &CollectionConfig{SyncFn: &c1SyncFunction}
345+
scopesConfig3Collections[scope].Collections[collection3] = &CollectionConfig{SyncFn: &c1SyncFunction}
346+
scopesConfigString, err := json.Marshal(scopesConfig3Collections)
348347
require.NoError(t, err)
349348

349+
scopesConfig2Collections := GetCollectionsConfig(t, tb, 2)
350+
351+
scopesConfig2Collections[scope].Collections[collection1] = &CollectionConfig{SyncFn: &c1SyncFunction}
352+
scopesConfig2Collections[scope].Collections[collection2] = &CollectionConfig{SyncFn: &c1SyncFunction}
353+
350354
resp = rt.SendAdminRequest("PUT", "/db/_config", fmt.Sprintf(
351355
`{"bucket": "%s", "num_index_replicas": 0, "enable_shared_bucket_access": %t, "scopes":%s}`,
352356
tb.GetName(), base.TestUseXattrs(), string(scopesConfigString)))
@@ -378,11 +382,7 @@ func TestMultiCollectionChannelAccess(t *testing.T) {
378382
RequireStatus(t, resp, http.StatusOK)
379383

380384
// Remove collection and update the db config
381-
scopesConfig = GetCollectionsConfig(t, tb, 2)
382-
383-
scopesConfig[scope].Collections[collection1] = &CollectionConfig{SyncFn: &c1SyncFunction}
384-
scopesConfig[scope].Collections[collection2] = &CollectionConfig{SyncFn: &c1SyncFunction}
385-
scopesConfigString, err = json.Marshal(scopesConfig)
385+
scopesConfigString, err = json.Marshal(scopesConfig2Collections)
386386
require.NoError(t, err)
387387

388388
resp = rt.SendAdminRequest("PUT", "/db/_config", fmt.Sprintf(

rest/importtest/collections_import_test.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ func TestMultiCollectionImportFilter(t *testing.T) {
2828
base.RequireNumTestDataStores(t, 3)
2929

3030
ctx := base.TestCtx(t)
31-
testBucket := base.GetPersistentTestBucket(t)
31+
testBucket := base.GetTestBucket(t)
3232
defer testBucket.Close(ctx)
3333

3434
scopesConfig := rest.GetCollectionsConfig(t, testBucket, 2)
@@ -250,7 +250,7 @@ func TestMultiCollectionImportDynamicAddCollection(t *testing.T) {
250250
base.RequireNumTestDataStores(t, 2)
251251

252252
ctx := base.TestCtx(t)
253-
testBucket := base.GetPersistentTestBucket(t)
253+
testBucket := base.GetTestBucket(t)
254254
defer testBucket.Close(ctx)
255255

256256
rtConfig := &rest.RestTesterConfig{
@@ -346,7 +346,7 @@ func TestMultiCollectionImportRemoveCollection(t *testing.T) {
346346
base.RequireNumTestDataStores(t, numCollections)
347347

348348
ctx := base.TestCtx(t)
349-
testBucket := base.GetPersistentTestBucket(t)
349+
testBucket := base.GetTestBucket(t)
350350
defer testBucket.Close(ctx)
351351

352352
rtConfig := &rest.RestTesterConfig{

rest/importtest/import_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -2735,7 +2735,7 @@ func TestImportRollback(t *testing.T) {
27352735
base.SetUpTestLogging(t, base.LevelDebug, base.KeyImport, base.KeyDCP)
27362736

27372737
ctx := base.TestCtx(t)
2738-
bucket := base.GetPersistentTestBucket(t)
2738+
bucket := base.GetTestBucket(t)
27392739
defer bucket.Close(ctx)
27402740

27412741
rt := rest.NewRestTester(t, &rest.RestTesterConfig{

rest/server_context_test.go

-4
Original file line numberDiff line numberDiff line change
@@ -840,11 +840,7 @@ func TestOfflineDatabaseStartup(t *testing.T) {
840840

841841
base.SetUpTestLogging(t, base.LevelDebug, base.KeyAll)
842842

843-
ctx := base.TestCtx(t)
844-
bucket := base.GetPersistentTestBucket(t)
845-
defer bucket.Close(ctx)
846843
rt := NewRestTester(t, &RestTesterConfig{
847-
CustomTestBucket: bucket.NoCloseClone(),
848844
DatabaseConfig: &DatabaseConfig{
849845
DbConfig: DbConfig{
850846
StartOffline: base.BoolPtr(true),

0 commit comments

Comments
 (0)