From d1a259f63ac53bf88e711ade41a0f007130588d1 Mon Sep 17 00:00:00 2001 From: gbrodman Date: Mon, 3 Oct 2022 15:15:41 -0400 Subject: [PATCH] Modify the CreateSynthetic pipeline to run over all non-deleted domains (#1803) --- .../CreateSyntheticDomainHistoriesPipeline.java | 11 ++--------- .../CreateSyntheticDomainHistoriesPipelineTest.java | 10 ++++++---- 2 files changed, 8 insertions(+), 13 deletions(-) diff --git a/core/src/main/java/google/registry/tools/javascrap/CreateSyntheticDomainHistoriesPipeline.java b/core/src/main/java/google/registry/tools/javascrap/CreateSyntheticDomainHistoriesPipeline.java index 27b07df20..1b1181c99 100644 --- a/core/src/main/java/google/registry/tools/javascrap/CreateSyntheticDomainHistoriesPipeline.java +++ b/core/src/main/java/google/registry/tools/javascrap/CreateSyntheticDomainHistoriesPipeline.java @@ -61,21 +61,14 @@ public class CreateSyntheticDomainHistoriesPipeline implements Serializable { "Create synthetic domain histories to fix RDE for b/248112997"; private static final DateTime BAD_PIPELINE_START_TIME = DateTime.parse("2022-09-05T09:00:00.000Z"); - private static final DateTime BAD_PIPELINE_END_TIME = DateTime.parse("2022-09-10T12:00:00.000Z"); static void setup(Pipeline pipeline, String registryAdminRegistrarId) { pipeline .apply( "Read all domain repo IDs", RegistryJpaIO.read( - "SELECT d.repoId FROM Domain d WHERE deletionTime > :badPipelineStartTime AND NOT" - + " EXISTS (SELECT 1 FROM DomainHistory dh WHERE dh.domainRepoId = d.repoId" - + " AND dh.modificationTime > :badPipelineEndTime)", - ImmutableMap.of( - "badPipelineStartTime", - BAD_PIPELINE_START_TIME, - "badPipelineEndTime", - BAD_PIPELINE_END_TIME), + "SELECT d.repoId FROM Domain d WHERE deletionTime > :badPipelineStartTime", + ImmutableMap.of("badPipelineStartTime", BAD_PIPELINE_START_TIME), String.class, repoId -> VKey.createSql(Domain.class, repoId))) .apply( diff --git a/core/src/test/java/google/registry/tools/javascrap/CreateSyntheticDomainHistoriesPipelineTest.java b/core/src/test/java/google/registry/tools/javascrap/CreateSyntheticDomainHistoriesPipelineTest.java index c7b2bd478..a2937b078 100644 --- a/core/src/test/java/google/registry/tools/javascrap/CreateSyntheticDomainHistoriesPipelineTest.java +++ b/core/src/test/java/google/registry/tools/javascrap/CreateSyntheticDomainHistoriesPipelineTest.java @@ -98,11 +98,13 @@ public class CreateSyntheticDomainHistoriesPipelineTest { assertAboutImmutableObjects() .that(syntheticHistory.getDomainBase().get()) .isEqualExceptFields(domain, "updateTimestamp"); + // four total histories, two CREATE and two SYNTHETIC + assertThat(loadAllOf(DomainHistory.class)).hasSize(4); - // shouldn't create any entries on re-run + // can create multiple entries if we run it multiple times pipeline.run().waitUntilFinish(); - assertThat(HistoryEntryDao.loadHistoryObjectsForResource(domain.createVKey())).hasSize(2); - // three total histories, two CREATE and one SYNTHETIC - assertThat(loadAllOf(DomainHistory.class)).hasSize(3); + assertThat(HistoryEntryDao.loadHistoryObjectsForResource(domain.createVKey())).hasSize(3); + // six total histories, two CREATE and four SYNTHETIC + assertThat(loadAllOf(DomainHistory.class)).hasSize(6); } }