Skip to content

Commit

Permalink
Rollback changes to use CustomBuckets, will take up in a subsequent c…
Browse files Browse the repository at this point in the history
…ommit
  • Loading branch information
torcolvin committed Nov 8, 2023
1 parent 6022858 commit 5b96089
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 12 deletions.
9 changes: 6 additions & 3 deletions rest/adminapitest/admin_api_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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

Expand Down
12 changes: 9 additions & 3 deletions rest/importtest/import_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Expand Down Expand Up @@ -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,
})

Expand Down Expand Up @@ -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)
Expand All @@ -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()
Expand Down
7 changes: 5 additions & 2 deletions rest/upgradetest/remove_collection_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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
Expand All @@ -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,
Expand Down
12 changes: 8 additions & 4 deletions rest/upgradetest/upgrade_registry_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
})

Expand All @@ -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")
Expand Down Expand Up @@ -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,
})

Expand All @@ -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"),
})
Expand Down

0 comments on commit 5b96089

Please sign in to comment.