diff --git a/rest/adminapitest/admin_api_test.go b/rest/adminapitest/admin_api_test.go index e89564f5c3..a79bddd32c 100644 --- a/rest/adminapitest/admin_api_test.go +++ b/rest/adminapitest/admin_api_test.go @@ -1472,6 +1472,7 @@ func TestCorruptDbConfigHandling(t *testing.T) { base.SetUpTestLogging(t, base.LevelInfo, base.KeyConfig) rt := rest.NewRestTester(t, &rest.RestTesterConfig{ + CustomTestBucket: base.GetTestBucket(t), PersistentConfig: true, MutateStartupConfig: func(config *rest.StartupConfig) { // configure the interval time to pick up new configs from the bucket to every 1 seconds @@ -1556,6 +1557,7 @@ func TestBadConfigInsertionToBucket(t *testing.T) { base.TestsRequireBootstrapConnection(t) rt := rest.NewRestTester(t, &rest.RestTesterConfig{ + CustomTestBucket: base.GetTestBucket(t), PersistentConfig: true, MutateStartupConfig: func(config *rest.StartupConfig) { // configure the interval time to pick up new configs from the bucket to every 1 seconds @@ -1605,8 +1607,12 @@ func TestBadConfigInsertionToBucket(t *testing.T) { func TestMismatchedBucketNameOnDbConfigUpdate(t *testing.T) { base.TestsRequireBootstrapConnection(t) base.RequireNumTestBuckets(t, 2) + ctx := base.TestCtx(t) + tb1 := base.GetTestBucket(t) + defer tb1.Close(ctx) rt := rest.NewRestTester(t, &rest.RestTesterConfig{ + CustomTestBucket: base.GetTestBucket(t), PersistentConfig: true, MutateStartupConfig: func(config *rest.StartupConfig) { // configure the interval time to pick up new configs from the bucket to every 1 seconds @@ -1622,9 +1628,6 @@ func TestMismatchedBucketNameOnDbConfigUpdate(t *testing.T) { // wait for db to come online require.NoError(t, rt.WaitForDBOnline()) - ctx := base.TestCtx(t) - tb1 := base.GetTestBucket(t) - defer tb1.Close(ctx) badName := tb1.GetName() dbConfig.Bucket = &badName diff --git a/rest/importtest/import_test.go b/rest/importtest/import_test.go index 2428a521a7..3a7d0f3d55 100644 --- a/rest/importtest/import_test.go +++ b/rest/importtest/import_test.go @@ -2039,7 +2039,7 @@ func assertDocProperty(t *testing.T, getDocResponse *rest.TestResponse, property err := base.JSONUnmarshal(getDocResponse.Body.Bytes(), &responseBody) assert.NoError(t, err, "Error unmarshalling document response") value, ok := responseBody[propertyName] - require.True(t, ok, fmt.Sprintf("Expected property %s not found in response %s", propertyName, getDocResponse.Body.Bytes())) + assert.True(t, ok, fmt.Sprintf("Expected property %s not found in response %s", propertyName, getDocResponse.Body.Bytes())) assert.Equal(t, expectedPropertyValue, value) } @@ -2734,7 +2734,12 @@ func TestImportRollback(t *testing.T) { base.SetUpTestLogging(t, base.LevelDebug, base.KeyImport, base.KeyDCP) + ctx := base.TestCtx(t) + bucket := base.GetTestBucket(t) + defer bucket.Close(ctx) + rt := rest.NewRestTester(t, &rest.RestTesterConfig{ + CustomTestBucket: bucket.NoCloseClone(), PersistentConfig: false, }) @@ -2763,9 +2768,9 @@ func TestImportRollback(t *testing.T) { }() // fetch the checkpoint for the document's vbucket, modify the checkpoint values to a higher sequence - vbNo, err := base.GetVbucketForKey(rt.TestBucket, key) + vbNo, err := base.GetVbucketForKey(bucket, key) require.NoError(t, err) - metaStore := rt.TestBucket.GetMetadataStore() + metaStore := bucket.GetMetadataStore() checkpointKey := fmt.Sprintf("%s%d", checkpointPrefix, vbNo) var checkpointData dcpMetaData checkpointBytes, _, err := metaStore.GetRaw(checkpointKey) @@ -2784,6 +2789,7 @@ func TestImportRollback(t *testing.T) { // Reopen the db, expect DCP rollback rt2 := rest.NewRestTester(t, &rest.RestTesterConfig{ + CustomTestBucket: bucket.NoCloseClone(), PersistentConfig: false, }) defer rt2.Close() diff --git a/rest/upgradetest/remove_collection_test.go b/rest/upgradetest/remove_collection_test.go index 257b90fa10..4072586208 100644 --- a/rest/upgradetest/remove_collection_test.go +++ b/rest/upgradetest/remove_collection_test.go @@ -27,8 +27,11 @@ func TestRemoveCollection(t *testing.T) { base.TestRequiresCollections(t) base.RequireNumTestBuckets(t, 2) numCollections := 2 + bucket := base.GetTestBucket(t) + defer bucket.Close(base.TestCtx(t)) base.RequireNumTestDataStores(t, numCollections) rtConfig := &rest.RestTesterConfig{ + CustomTestBucket: bucket.NoCloseClone(), PersistentConfig: true, GroupID: base.StringPtr(t.Name()), AdminInterfaceAuthentication: true, @@ -49,7 +52,7 @@ func TestRemoveCollection(t *testing.T) { deletedDataStore := dataStores[1] defer func() { - assert.NoError(t, rt.TestBucket.CreateDataStore(base.TestCtx(t), deletedDataStore)) + assert.NoError(t, bucket.CreateDataStore(base.TestCtx(t), deletedDataStore)) }() // drop a data store @@ -58,7 +61,7 @@ func TestRemoveCollection(t *testing.T) { rt.Close() rtConfig = &rest.RestTesterConfig{ - CustomTestBucket: rt.TestBucket, + CustomTestBucket: bucket.NoCloseClone(), PersistentConfig: true, GroupID: base.StringPtr(t.Name()), AdminInterfaceAuthentication: true, diff --git a/rest/upgradetest/upgrade_registry_test.go b/rest/upgradetest/upgrade_registry_test.go index 9379d8280c..f9142fb5ed 100644 --- a/rest/upgradetest/upgrade_registry_test.go +++ b/rest/upgradetest/upgrade_registry_test.go @@ -189,9 +189,11 @@ func getDbConfigFromLegacyConfig(rt *rest.RestTester) string { } func TestLegacyMetadataID(t *testing.T) { + tb1 := base.GetTestBucket(t) // Create a non-persistent rest tester. Standard RestTester // creates a database 'db' targeting the default collection (when !TestUseNamedCollections) legacyRT := rest.NewRestTesterDefaultCollection(t, &rest.RestTesterConfig{ + CustomTestBucket: tb1.NoCloseClone(), PersistentConfig: false, }) @@ -203,13 +205,13 @@ func TestLegacyMetadataID(t *testing.T) { legacyRT.Close() persistentRT := rest.NewRestTesterDefaultCollection(t, &rest.RestTesterConfig{ - CustomTestBucket: legacyRT.TestBucket, + CustomTestBucket: tb1, PersistentConfig: true, }) defer persistentRT.Close() resp = persistentRT.SendAdminRequest("PUT", "/db/", dbConfigString) - rest.RequireStatus(t, resp, http.StatusCreated) + assert.Equal(t, http.StatusCreated, resp.Code) // check if database is online dbRoot := persistentRT.GetDatabaseRoot("db") @@ -252,9 +254,11 @@ func TestMetadataIDRenameDatabase(t *testing.T) { // Verifies that matching metadataIDs are computed if two config groups for the same database are upgraded func TestMetadataIDWithConfigGroups(t *testing.T) { + tb1 := base.GetTestBucket(t) // Create a non-persistent rest tester. Standard RestTester // creates a database 'db' targeting the default collection for legacy config. legacyRT := rest.NewRestTesterDefaultCollection(t, &rest.RestTesterConfig{ + CustomTestBucket: tb1.NoCloseClone(), PersistentConfig: false, }) @@ -266,14 +270,14 @@ func TestMetadataIDWithConfigGroups(t *testing.T) { legacyRT.Close() group1RT := rest.NewRestTester(t, &rest.RestTesterConfig{ - CustomTestBucket: legacyRT.TestBucket, + CustomTestBucket: tb1, PersistentConfig: true, GroupID: base.StringPtr("group1"), }) defer group1RT.Close() group2RT := rest.NewRestTester(t, &rest.RestTesterConfig{ - CustomTestBucket: legacyRT.TestBucket, + CustomTestBucket: tb1, PersistentConfig: true, GroupID: base.StringPtr("group2"), })