diff --git a/core/src/main/java/google/registry/model/EntityClasses.java b/core/src/main/java/google/registry/model/EntityClasses.java index d82e08f94..c0870301d 100644 --- a/core/src/main/java/google/registry/model/EntityClasses.java +++ b/core/src/main/java/google/registry/model/EntityClasses.java @@ -43,7 +43,6 @@ import google.registry.model.reporting.HistoryEntry; import google.registry.model.server.Lock; import google.registry.model.server.ServerSecret; import google.registry.model.tld.Registry; -import google.registry.model.tmch.TmchCrl; /** Sets of classes of the Objectify-registered entities in use throughout the model. */ public final class EntityClasses { @@ -85,8 +84,7 @@ public final class EntityClasses { Registrar.class, RegistrarContact.class, Registry.class, - ServerSecret.class, - TmchCrl.class); + ServerSecret.class); private EntityClasses() {} } diff --git a/core/src/main/java/google/registry/model/tmch/TmchCrl.java b/core/src/main/java/google/registry/model/tmch/TmchCrl.java index 8253e7469..bf0353683 100644 --- a/core/src/main/java/google/registry/model/tmch/TmchCrl.java +++ b/core/src/main/java/google/registry/model/tmch/TmchCrl.java @@ -16,25 +16,18 @@ package google.registry.model.tmch; import static com.google.common.base.Preconditions.checkNotNull; import static google.registry.persistence.transaction.TransactionManagerFactory.jpaTm; -import static google.registry.persistence.transaction.TransactionManagerFactory.ofyTm; -import static google.registry.persistence.transaction.TransactionManagerFactory.tm; -import com.googlecode.objectify.annotation.Entity; -import google.registry.model.annotations.NotBackedUp; -import google.registry.model.annotations.NotBackedUp.Reason; import google.registry.model.common.CrossTldSingleton; -import google.registry.model.replay.NonReplicatedEntity; +import google.registry.model.replay.SqlOnlyEntity; import java.util.Optional; import javax.annotation.concurrent.Immutable; import javax.persistence.Column; import org.joda.time.DateTime; -/** Datastore singleton for ICANN's TMCH CA certificate revocation list (CRL). */ -@Entity +/** Singleton for ICANN's TMCH CA certificate revocation list (CRL). */ @javax.persistence.Entity @Immutable -@NotBackedUp(reason = Reason.EXTERNALLY_SOURCED) -public final class TmchCrl extends CrossTldSingleton implements NonReplicatedEntity { +public final class TmchCrl extends CrossTldSingleton implements SqlOnlyEntity { @Column(name = "certificateRevocations", nullable = false) String crl; @@ -47,25 +40,23 @@ public final class TmchCrl extends CrossTldSingleton implements NonReplicatedEnt /** Returns the singleton instance of this entity, without memoization. */ public static Optional get() { - return tm().transact(() -> tm().loadSingleton(TmchCrl.class)); + return jpaTm().transact(() -> jpaTm().loadSingleton(TmchCrl.class)); } /** - * Change the Datastore singleton to a new ASCII-armored X.509 CRL. + * Change the singleton to a new ASCII-armored X.509 CRL. * *

Please do not call this function unless your CRL is properly formatted, signed by the root, * and actually newer than the one currently in Datastore. - * - *

During the dual-write period, we write to both Datastore and SQL */ public static void set(final String crl, final String url) { - tm().transact( + jpaTm() + .transact( () -> { TmchCrl tmchCrl = new TmchCrl(); - tmchCrl.updated = tm().getTransactionTime(); + tmchCrl.updated = jpaTm().getTransactionTime(); tmchCrl.crl = checkNotNull(crl, "crl"); tmchCrl.url = checkNotNull(url, "url"); - ofyTm().transactNew(() -> ofyTm().putWithoutBackup(tmchCrl)); jpaTm().transactNew(() -> jpaTm().putWithoutBackup(tmchCrl)); }); } @@ -80,7 +71,7 @@ public final class TmchCrl extends CrossTldSingleton implements NonReplicatedEnt return crl; } - /** Time we last updated the Datastore with a newer ICANN CRL. */ + /** Time we last updated the Database with a newer ICANN CRL. */ public final DateTime getUpdated() { return updated; } diff --git a/core/src/test/java/google/registry/backup/ReplayCommitLogsToSqlActionTest.java b/core/src/test/java/google/registry/backup/ReplayCommitLogsToSqlActionTest.java index 4f4c419f9..f25b49238 100644 --- a/core/src/test/java/google/registry/backup/ReplayCommitLogsToSqlActionTest.java +++ b/core/src/test/java/google/registry/backup/ReplayCommitLogsToSqlActionTest.java @@ -67,7 +67,6 @@ import google.registry.model.replay.SqlReplayCheckpoint; import google.registry.model.server.Lock; import google.registry.model.tld.label.PremiumList; import google.registry.model.tld.label.PremiumList.PremiumEntry; -import google.registry.model.tmch.TmchCrl; import google.registry.model.translators.VKeyTranslatorFactory; import google.registry.persistence.VKey; import google.registry.persistence.transaction.JpaTransactionManager; @@ -482,7 +481,8 @@ public class ReplayCommitLogsToSqlActionTest { jpaTm().transact(() -> SqlReplayCheckpoint.set(now.minusMinutes(1).minusMillis(1))); // Save a couple deletes that aren't propagated to SQL (the objects deleted are irrelevant) - Key tmchCrlKey = Key.create(TmchCrl.class, 1L); + Key manifestKey = + CommitLogManifest.createKey(getBucketKey(1), now.minusMinutes(1)); saveDiffFile( gcsUtils, createCheckpoint(now.minusMinutes(1)), @@ -490,7 +490,7 @@ public class ReplayCommitLogsToSqlActionTest { getBucketKey(1), now.minusMinutes(1), // one object only exists in Datastore, one is dually-written (so isn't replicated) - ImmutableSet.of(getCrossTldKey(), tmchCrlKey))); + ImmutableSet.of(getCrossTldKey(), manifestKey))); runAndAssertSuccess(now.minusMinutes(1), 1, 1); verify(spy, times(0)).delete(any(VKey.class)); diff --git a/core/src/test/java/google/registry/model/tmch/TmchCrlTest.java b/core/src/test/java/google/registry/model/tmch/TmchCrlTest.java index f1473d60e..a2b0de431 100644 --- a/core/src/test/java/google/registry/model/tmch/TmchCrlTest.java +++ b/core/src/test/java/google/registry/model/tmch/TmchCrlTest.java @@ -15,39 +15,26 @@ package google.registry.model.tmch; import static com.google.common.truth.Truth.assertThat; -import static google.registry.testing.DatabaseHelper.loadByEntity; import google.registry.model.EntityTestCase; -import google.registry.testing.DualDatabaseTest; -import google.registry.testing.TestOfyAndSql; import java.util.Optional; +import org.junit.jupiter.api.Test; /** Unit tests for {@link TmchCrl}. */ -@DualDatabaseTest public class TmchCrlTest extends EntityTestCase { TmchCrlTest() { super(JpaEntityCoverageCheck.ENABLED); } - @TestOfyAndSql + @Test void testSuccess() { assertThat(TmchCrl.get()).isEqualTo(Optional.empty()); TmchCrl.set("lolcat", "https://lol.cat"); assertThat(TmchCrl.get().get().getCrl()).isEqualTo("lolcat"); } - @TestOfyAndSql - void testDualWrite() { - TmchCrl expected = new TmchCrl(); - expected.crl = "lolcat"; - expected.url = "https://lol.cat"; - expected.updated = fakeClock.nowUtc(); - TmchCrl.set("lolcat", "https://lol.cat"); - assertThat(loadByEntity(new TmchCrl())).isEqualTo(expected); - } - - @TestOfyAndSql + @Test void testMultipleWrites() { TmchCrl.set("first", "https://first.cat"); assertThat(TmchCrl.get().get().getCrl()).isEqualTo("first"); diff --git a/core/src/test/resources/google/registry/export/crosstld_kinds.txt b/core/src/test/resources/google/registry/export/crosstld_kinds.txt index e7e0d57c0..bd7a3bd78 100644 --- a/core/src/test/resources/google/registry/export/crosstld_kinds.txt +++ b/core/src/test/resources/google/registry/export/crosstld_kinds.txt @@ -3,4 +3,3 @@ Registrar RegistrarContact Registry ServerSecret -TmchCrl diff --git a/core/src/test/resources/google/registry/model/schema.txt b/core/src/test/resources/google/registry/model/schema.txt index e79600624..69e825846 100644 --- a/core/src/test/resources/google/registry/model/schema.txt +++ b/core/src/test/resources/google/registry/model/schema.txt @@ -789,13 +789,6 @@ enum google.registry.model.tld.Registry$TldType { REAL; TEST; } -class google.registry.model.tmch.TmchCrl { - @Id long id; - @Parent com.googlecode.objectify.Key parent; - java.lang.String crl; - java.lang.String url; - org.joda.time.DateTime updated; -} class google.registry.model.transfer.ContactTransferData { google.registry.model.eppcommon.Trid transferRequestTrid; google.registry.model.transfer.TransferStatus transferStatus;