diff --git a/rest/adminapitest/admin_api_test.go b/rest/adminapitest/admin_api_test.go index bbc5c9bced..4b48b868d7 100644 --- a/rest/adminapitest/admin_api_test.go +++ b/rest/adminapitest/admin_api_test.go @@ -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) @@ -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) diff --git a/rest/persistent_config_test.go b/rest/persistent_config_test.go index 497712c917..f83bc2366a 100644 --- a/rest/persistent_config_test.go +++ b/rest/persistent_config_test.go @@ -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) @@ -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