diff --git a/core/src/main/java/google/registry/model/common/DatabaseMigrationStateSchedule.java b/core/src/main/java/google/registry/model/common/DatabaseMigrationStateSchedule.java index 61e199f61..083f18557 100644 --- a/core/src/main/java/google/registry/model/common/DatabaseMigrationStateSchedule.java +++ b/core/src/main/java/google/registry/model/common/DatabaseMigrationStateSchedule.java @@ -111,7 +111,8 @@ public class DatabaseMigrationStateSchedule extends CrossTldSingleton * Cache of the current migration schedule. The key is meaningless; this is essentially a memoized * Supplier that can be reset for testing purposes and after writes. */ - private static final LoadingCache< + @VisibleForTesting + public static final LoadingCache< Class, TimedTransitionProperty> // Each instance should cache the migration schedule for five minutes before reloading diff --git a/core/src/test/java/google/registry/tools/SetDatabaseMigrationStateCommandTest.java b/core/src/test/java/google/registry/tools/SetDatabaseMigrationStateCommandTest.java index 5c841b568..2be0c8890 100644 --- a/core/src/test/java/google/registry/tools/SetDatabaseMigrationStateCommandTest.java +++ b/core/src/test/java/google/registry/tools/SetDatabaseMigrationStateCommandTest.java @@ -28,12 +28,25 @@ import google.registry.model.common.DatabaseMigrationStateSchedule.MigrationStat import google.registry.testing.DualDatabaseTest; import google.registry.testing.TestOfyAndSql; import org.joda.time.DateTime; +import org.junit.jupiter.api.BeforeEach; /** Tests for {@link SetDatabaseMigrationStateCommand}. */ @DualDatabaseTest public class SetDatabaseMigrationStateCommandTest extends CommandTestCase { + @BeforeEach + void beforeEach() { + // clear out any static state that may have been persisted + ofyTm() + .transact( + () -> + ofyTm() + .loadSingleton(DatabaseMigrationStateSchedule.class) + .ifPresent(ofyTm()::delete)); + DatabaseMigrationStateSchedule.CACHE.invalidateAll(); + } + @TestOfyAndSql void testSuccess_setsBasicSchedule() throws Exception { assertThat(DatabaseMigrationStateSchedule.get()).isEqualTo(DEFAULT_TRANSITION_MAP);