Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CBG-3464 Update TestMigratev30PersistentConfigCollision based on changes to delete handling #6513

Merged
merged 2 commits into from
Oct 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading