Skip to content

Commit

Permalink
CBG-3464 Update TestMigratev30PersistentConfigCollision based on chan…
Browse files Browse the repository at this point in the history
…ges to delete handling (#6513)

* CBG-3646 Update TestMigratev30PersistentConfigCollision based on changes to delete handling

migrateV30Configs no longer terminates and returns error on migrate failure for a single bucket - it instead logs the error and continues through the rest of the bucket.

* Avoid race in TestCorruptDbConfigHandling
  • Loading branch information
adamcfraser authored and torcolvin committed Oct 31, 2023
1 parent 99c767a commit 5f4c1cf
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
5 changes: 4 additions & 1 deletion rest/adminapitest/admin_api_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1579,6 +1579,8 @@ func TestCorruptDbConfigHandling(t *testing.T) {
responseConfig := rt.ServerContext().GetDbConfig("db1")
assert.Nil(t, responseConfig)

require.Equal(t, 1, len(rt.ServerContext().AllInvalidDatabases()))

// assert that fetching config fails with the correct error message to the user
resp = rt.SendAdminRequest(http.MethodGet, "/db1/_config", "")
rest.RequireStatus(t, resp, http.StatusNotFound)
Expand All @@ -1601,7 +1603,8 @@ func TestCorruptDbConfigHandling(t *testing.T) {
// wait some time for interval to pick up change
err = rt.WaitForConditionWithOptions(func() bool {
list := rt.ServerContext().AllDatabaseNames()
return len(list) == 1
numInvalid := len(rt.ServerContext().AllInvalidDatabases())
return len(list) == 1 && numInvalid == 0
}, 200, 1000)
require.NoError(t, err)

Expand Down
10 changes: 6 additions & 4 deletions rest/persistent_config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1285,11 +1285,9 @@ func TestMigratev30PersistentConfigCollision(t *testing.T) {
_, insertError := sc.BootstrapContext.Connection.InsertMetadataDocument(ctx, bucketName, PersistentConfigKey30(ctx, groupID), defaultDatabaseConfig)
require.NoError(t, insertError)

// migration should not return error, but legacy config will not be migrated due to collection conflict
migrateErr := sc.migrateV30Configs(ctx)
require.Error(t, migrateErr)
var httpErr *base.HTTPError
require.ErrorAs(t, migrateErr, &httpErr)
require.Equal(t, 409, httpErr.Status)
require.NoError(t, migrateErr)

// Fetch the registry, verify newDefaultDb still exists and defaultDb30 has not been migrated due to collection conflict
registry, registryErr := sc.BootstrapContext.getGatewayRegistry(ctx, bucketName)
Expand All @@ -1298,6 +1296,10 @@ func TestMigratev30PersistentConfigCollision(t *testing.T) {
migratedDb, found := registry.getRegistryDatabase(groupID, newDefaultDbName)
require.True(t, found)
require.Equal(t, "1-a", migratedDb.Version)

// Verify non-migrated legacy config has not been deleted (since it wasn't successfully migrated)
_, getErr := sc.BootstrapContext.Connection.GetMetadataDocument(ctx, bucketName, PersistentConfigKey30(ctx, groupID), defaultDatabaseConfig)
require.NoError(t, getErr)
}

// TestLegacyDuplicate tests the behaviour of GetDatabaseConfigs when the same database exists in legacy and non-legacy format
Expand Down

0 comments on commit 5f4c1cf

Please sign in to comment.