Skip to content

Commit

Permalink
TSPS-387 return UTC-formatted timestamps (#178)
Browse files Browse the repository at this point in the history
  • Loading branch information
mmorgantaylor authored Dec 4, 2024
1 parent 4554646 commit f9ed1ec
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import jakarta.persistence.Table;
import java.time.LocalDateTime;
import java.time.Instant;
import java.util.UUID;
import lombok.Getter;
import lombok.NoArgsConstructor;
Expand Down Expand Up @@ -57,11 +57,11 @@ public class PipelineRun {

@Column(name = "created", insertable = false)
@CreationTimestamp(source = SourceType.DB)
private LocalDateTime created;
private Instant created;

@Column(name = "updated", insertable = false)
@UpdateTimestamp(source = SourceType.DB)
private LocalDateTime updated;
private Instant updated;

@Column(name = "status", nullable = false)
private CommonPipelineRunStatusEnum status;
Expand All @@ -80,8 +80,8 @@ public PipelineRun(
String workspaceName,
String workspaceStorageContainerName,
String workspaceGoogleProject,
LocalDateTime created,
LocalDateTime updated,
Instant created,
Instant updated,
CommonPipelineRunStatusEnum status,
String description) {
this.jobId = jobId;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertInstanceOf;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.ArgumentMatchers.*;
import static org.mockito.Mockito.doNothing;
import static org.mockito.Mockito.doThrow;
Expand Down Expand Up @@ -44,7 +45,7 @@
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import jakarta.servlet.http.HttpServletRequest;
import java.time.LocalDateTime;
import java.time.Instant;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
Expand Down Expand Up @@ -82,8 +83,8 @@ class PipelineRunsApiControllerTest {
private final String testPipelineWdlMethodVersion = TestUtils.TEST_WDL_METHOD_VERSION_1;
private final Map<String, Object> testPipelineInputs = TestUtils.TEST_PIPELINE_INPUTS;
private final UUID newJobId = TestUtils.TEST_NEW_UUID;
private final LocalDateTime createdTime = LocalDateTime.now();
private final LocalDateTime updatedTime = LocalDateTime.now();
private final Instant createdTime = Instant.now();
private final Instant updatedTime = Instant.now();
private final Map<String, String> testOutputs = TestUtils.TEST_PIPELINE_OUTPUTS;

@BeforeEach
Expand Down Expand Up @@ -594,6 +595,8 @@ void getAllPipelineRunsWithNoPageToken() throws Exception {
assertEquals(getTestPipeline().getName().getValue(), responsePipelineRun1.getPipelineName());
assertEquals(
pipelineRunPreparing.getCreated().toString(), responsePipelineRun1.getTimeSubmitted());
// timestamp string should be marked as UTC, i.e. end with Z
assertTrue(responsePipelineRun1.getTimeSubmitted().endsWith("Z"));
assertNull(responsePipelineRun1.getTimeCompleted());

// succeeded run should have a completed time
Expand All @@ -604,8 +607,12 @@ void getAllPipelineRunsWithNoPageToken() throws Exception {
assertEquals(getTestPipeline().getName().getValue(), responsePipelineRun2.getPipelineName());
assertEquals(
pipelineRunSucceeded.getCreated().toString(), responsePipelineRun2.getTimeSubmitted());
// timestamp string should be marked as UTC, i.e. end with Z
assertTrue(responsePipelineRun2.getTimeSubmitted().endsWith("Z"));
assertEquals(
pipelineRunSucceeded.getUpdated().toString(), responsePipelineRun2.getTimeCompleted());
// timestamp string should be marked as UTC, i.e. end with Z
assertTrue(responsePipelineRun2.getTimeCompleted().endsWith("Z"));

// failed run should have a completed time
ApiPipelineRun responsePipelineRun3 = response.getResults().get(2);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
import io.micrometer.core.instrument.simple.SimpleMeterRegistry;
import java.net.MalformedURLException;
import java.net.URL;
import java.time.LocalDateTime;
import java.time.Instant;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
Expand Down Expand Up @@ -558,7 +558,7 @@ void findPageResultsResultsUseNextPage() {
assertEquals(2, pageResults.content().size());
assertNotNull(pageResults.nextPageCursor());
assertNull(pageResults.previousPageCursor());
LocalDateTime firstResultTime = pageResults.content().get(0).getCreated();
Instant firstResultTime = pageResults.content().get(0).getCreated();

// now query for next page
pageResults =
Expand All @@ -568,7 +568,7 @@ void findPageResultsResultsUseNextPage() {
assertNull(pageResults.nextPageCursor());
assertNotNull(pageResults.previousPageCursor());

LocalDateTime thirdResultTime = pageResults.content().get(0).getCreated();
Instant thirdResultTime = pageResults.content().get(0).getCreated();
// test that results are coming with most recent first
assertTrue(firstResultTime.isAfter(thirdResultTime));
}
Expand Down

0 comments on commit f9ed1ec

Please sign in to comment.