Skip to content

Commit

Permalink
Move ingestAcceptedStatus to IngestJobStatusFromJobTestData
Browse files Browse the repository at this point in the history
  • Loading branch information
patchwork01 committed Dec 18, 2024
1 parent d4ffd1b commit 5c14c25
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,8 @@
import static sleeper.core.properties.testutils.InstancePropertiesTestHelper.createTestInstanceProperties;
import static sleeper.core.properties.testutils.TablePropertiesTestHelper.createTestTableProperties;
import static sleeper.core.record.process.RecordsProcessedSummaryTestHelper.summary;
import static sleeper.ingest.core.job.status.IngestJobStatusFromJobTestData.ingestAcceptedStatus;
import static sleeper.ingest.core.job.status.IngestJobStatusFromJobTestData.ingestJobStatus;
import static sleeper.ingest.core.job.status.IngestJobStatusTestHelper.ingestAcceptedStatus;
import static sleeper.ingest.core.job.status.IngestJobStatusTestHelper.ingestFinishedStatus;
import static sleeper.ingest.core.job.status.IngestJobStatusTestHelper.ingestFinishedStatusUncommitted;
import static sleeper.ingest.core.job.status.IngestJobStatusTestHelper.validatedIngestStartedStatus;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,9 @@
import static sleeper.core.record.process.RecordsProcessedSummaryTestHelper.summary;
import static sleeper.core.schema.SchemaTestHelper.schemaWithKey;
import static sleeper.core.statestore.FileReferenceTestData.defaultFileOnRootPartitionWithRecords;
import static sleeper.ingest.core.job.status.IngestJobStatusFromJobTestData.ingestAcceptedStatus;
import static sleeper.ingest.core.job.status.IngestJobStatusFromJobTestData.ingestJobStatus;
import static sleeper.ingest.core.job.status.IngestJobStatusTestHelper.acceptedRunWhichFailed;
import static sleeper.ingest.core.job.status.IngestJobStatusTestHelper.ingestAcceptedStatus;
import static sleeper.ingest.core.job.status.IngestJobStatusTestHelper.ingestFinishedStatus;
import static sleeper.ingest.core.job.status.IngestJobStatusTestHelper.ingestFinishedStatusUncommitted;
import static sleeper.ingest.core.job.status.IngestJobStatusTestHelper.validatedIngestStartedStatus;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,13 @@

import sleeper.core.record.process.status.ProcessRun;
import sleeper.core.tracker.ingest.job.IngestJobStatus;
import sleeper.core.tracker.ingest.job.query.IngestJobAcceptedStatus;
import sleeper.ingest.core.job.IngestJob;

import java.time.Instant;

import static sleeper.core.record.process.status.ProcessStatusUpdateTestHelper.defaultUpdateTime;

/**
* A helper for creating ingest job statuses for tests.
*/
Expand All @@ -38,4 +43,15 @@ public static IngestJobStatus ingestJobStatus(IngestJob job, ProcessRun... runs)
return IngestJobStatusTestHelper.ingestJobStatus(job.getId(), runs);
}

/**
* Creates an ingest job accepted status.
*
* @param job the ingest job
* @param validationTime the validation time
* @return an ingest job accepted status
*/
public static IngestJobAcceptedStatus ingestAcceptedStatus(IngestJob job, Instant validationTime) {
return IngestJobAcceptedStatus.from(job.getFileCount(), validationTime, defaultUpdateTime(validationTime));
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ private IngestJobStatus statusFromUpdates(ProcessStatusUpdate... updates) {
}

private ProcessStatusUpdate startedRun(Instant startedTime) {
return IngestJobStatusTestHelper.ingestStartedStatus(job, startedTime, defaultUpdateTime(startedTime));
return IngestJobStatusTestHelper.ingestStartedStatus(startedTime, defaultUpdateTime(startedTime));
}

private ProcessStatusUpdate finishedRun(Instant startedTime, Instant finishedTime) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -450,11 +450,11 @@ public void shouldIgnoreJobWithoutStartedUpdateAsItMayHaveExpired() {
}

private IngestJobAcceptedStatus acceptedStatusUpdate(Instant validationTime) {
return IngestJobStatusTestHelper.ingestAcceptedStatus(job, validationTime);
return IngestJobStatusTestHelper.ingestAcceptedStatus(validationTime);
}

private IngestJobStartedStatus startedStatusUpdate(Instant startTime) {
return IngestJobStatusTestHelper.ingestStartedStatus(job, startTime, defaultUpdateTime(startTime));
return IngestJobStatusTestHelper.ingestStartedStatus(startTime, defaultUpdateTime(startTime));
}

private IngestJobStartedStatus startedStatusUpdateAfterValidation(Instant startTime) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -407,12 +407,11 @@ public static IngestJobStatus singleJobStatusFrom(TestProcessStatusUpdateRecords
/**
* Creates an ingest job accepted status.
*
* @param job the ingest job
* @param validationTime the validation time
* @return an ingest job accepted status
*/
public static IngestJobAcceptedStatus ingestAcceptedStatus(IngestJob job, Instant validationTime) {
return IngestJobAcceptedStatus.from(job.getFileCount(), validationTime, defaultUpdateTime(validationTime));
public static IngestJobAcceptedStatus ingestAcceptedStatus(Instant validationTime) {
return IngestJobAcceptedStatus.from(1, validationTime, defaultUpdateTime(validationTime));
}

/**
Expand Down Expand Up @@ -440,6 +439,19 @@ public static IngestJobStartedStatus ingestStartedStatus(IngestJob job, Instant
.build();
}

/**
* Creates an ingest job started status.
*
* @param startTime the start time
* @param updateTime the update time
* @return an ingest job started status
*/
public static IngestJobStartedStatus ingestStartedStatus(Instant startTime, Instant updateTime) {
return IngestJobStartedStatus.withStartOfRun(true).inputFileCount(1)
.startTime(startTime).updateTime(updateTime)
.build();
}

/**
* Creates an ingest job started status.
*
Expand Down

0 comments on commit 5c14c25

Please sign in to comment.