mirror of
https://github.com/google/nomulus.git
synced 2025-06-28 23:33:36 +02:00
Relax reserved list existence check to allow Cloud SQL migration (#429)
This commit is contained in:
parent
9f9acb9980
commit
d28debf149
2 changed files with 15 additions and 8 deletions
|
@ -62,10 +62,16 @@ final class UpdateReservedListCommand extends CreateOrUpdateReservedListCommand
|
||||||
jpaTm()
|
jpaTm()
|
||||||
.transact(
|
.transact(
|
||||||
() -> {
|
() -> {
|
||||||
checkArgument(
|
// This check is currently disabled because, during the Cloud SQL migration, we need
|
||||||
ReservedListDao.checkExists(cloudSqlReservedList.getName()),
|
// to be able to update reserved lists in Datastore while simultaneously creating
|
||||||
"A reserved list of this name doesn't exist: %s.",
|
// their first revision in Cloud SQL (i.e. if they haven't been migrated over yet).
|
||||||
cloudSqlReservedList.getName());
|
// TODO(shicong): Re-instate this once all reserved lists are migrated to Cloud SQL,
|
||||||
|
// and add a unit test to verity that an exception will be thrown if
|
||||||
|
// the reserved list doesn't exist.
|
||||||
|
// checkArgument(
|
||||||
|
// ReservedListDao.checkExists(cloudSqlReservedList.getName()),
|
||||||
|
// "A reserved list of this name doesn't exist: %s.",
|
||||||
|
// cloudSqlReservedList.getName());
|
||||||
ReservedListDao.save(cloudSqlReservedList);
|
ReservedListDao.save(cloudSqlReservedList);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -123,13 +123,14 @@ public class UpdateReservedListCommandTest extends
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSaveToCloudSql_noExceptionThrownWhenSaveFail() throws Exception {
|
public void testSaveToCloudSql_succeedsEvenPreviousListNotExist() throws Exception {
|
||||||
// Note that, during the dual-write phase, we want to make sure that no exception will be
|
// Note that, during the dual-write phase, we just always save the revered list to
|
||||||
// thrown if saving reserved list to Cloud SQL fails.
|
// Cloud SQL (if --also_cloud_sql is set) without checking if there is a list with
|
||||||
|
// same name. This is to backfill the existing list in Datastore when we update it.
|
||||||
populateInitialReservedListInDatastore(true);
|
populateInitialReservedListInDatastore(true);
|
||||||
runCommandForced(
|
runCommandForced(
|
||||||
"--name=xn--q9jyb4c_common-reserved", "--input=" + reservedTermsPath, "--also_cloud_sql");
|
"--name=xn--q9jyb4c_common-reserved", "--input=" + reservedTermsPath, "--also_cloud_sql");
|
||||||
verifyXnq9jyb4cInDatastore();
|
verifyXnq9jyb4cInDatastore();
|
||||||
assertThat(ReservedListDao.checkExists("xn--q9jyb4c_common-reserved")).isFalse();
|
assertThat(ReservedListDao.checkExists("xn--q9jyb4c_common-reserved")).isTrue();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue