mirror of
https://github.com/google/nomulus.git
synced 2025-07-21 18:26:12 +02:00
Fix a test flake in SetDatabaseMigrationScheduleCommandTest (#1198)
* Fix a test flake in SetDatabaseMigrationScheduleCommandTest The cache is static so some odd state may stick around between tests -- we should clear it
This commit is contained in:
parent
6604b5599f
commit
66a07ab225
2 changed files with 15 additions and 1 deletions
|
@ -111,7 +111,8 @@ public class DatabaseMigrationStateSchedule extends CrossTldSingleton
|
||||||
* Cache of the current migration schedule. The key is meaningless; this is essentially a memoized
|
* 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.
|
* Supplier that can be reset for testing purposes and after writes.
|
||||||
*/
|
*/
|
||||||
private static final LoadingCache<
|
@VisibleForTesting
|
||||||
|
public static final LoadingCache<
|
||||||
Class<DatabaseMigrationStateSchedule>,
|
Class<DatabaseMigrationStateSchedule>,
|
||||||
TimedTransitionProperty<MigrationState, MigrationStateTransition>>
|
TimedTransitionProperty<MigrationState, MigrationStateTransition>>
|
||||||
// Each instance should cache the migration schedule for five minutes before reloading
|
// Each instance should cache the migration schedule for five minutes before reloading
|
||||||
|
|
|
@ -28,12 +28,25 @@ import google.registry.model.common.DatabaseMigrationStateSchedule.MigrationStat
|
||||||
import google.registry.testing.DualDatabaseTest;
|
import google.registry.testing.DualDatabaseTest;
|
||||||
import google.registry.testing.TestOfyAndSql;
|
import google.registry.testing.TestOfyAndSql;
|
||||||
import org.joda.time.DateTime;
|
import org.joda.time.DateTime;
|
||||||
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
|
|
||||||
/** Tests for {@link SetDatabaseMigrationStateCommand}. */
|
/** Tests for {@link SetDatabaseMigrationStateCommand}. */
|
||||||
@DualDatabaseTest
|
@DualDatabaseTest
|
||||||
public class SetDatabaseMigrationStateCommandTest
|
public class SetDatabaseMigrationStateCommandTest
|
||||||
extends CommandTestCase<SetDatabaseMigrationStateCommand> {
|
extends CommandTestCase<SetDatabaseMigrationStateCommand> {
|
||||||
|
|
||||||
|
@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
|
@TestOfyAndSql
|
||||||
void testSuccess_setsBasicSchedule() throws Exception {
|
void testSuccess_setsBasicSchedule() throws Exception {
|
||||||
assertThat(DatabaseMigrationStateSchedule.get()).isEqualTo(DEFAULT_TRANSITION_MAP);
|
assertThat(DatabaseMigrationStateSchedule.get()).isEqualTo(DEFAULT_TRANSITION_MAP);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue