Modify the CreateSynthetic pipeline to run over all non-deleted domains (#1803)

This commit is contained in:
gbrodman 2022-10-03 15:15:41 -04:00 committed by GitHub
parent 63b218a0b8
commit 916f746af9
2 changed files with 8 additions and 13 deletions

View file

@ -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(

View file

@ -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);
}
}