Skip to content
Snippets Groups Projects
Commit a76be79b authored by Sören Henning's avatar Sören Henning
Browse files

Fix execution duration serialization

parent e9dca29d
No related branches found
No related tags found
No related merge requests found
Pipeline #8923 passed
......@@ -47,7 +47,7 @@ class ExecutionStatus(
private fun JavaDuration.toK8sString(): String {
return when {
this <= JavaDuration.ofSeconds(2) -> "${this.toSeconds()}s"
this <= JavaDuration.ofMinutes(2) -> "${this.toSeconds()}s"
this < JavaDuration.ofMinutes(99) -> "${this.toMinutes()}m"
this < JavaDuration.ofHours(99) -> "${this.toHours()}h"
else -> "${this.toDays()}d + ${this.minusDays(this.toDays()).toHours()}h"
......
......@@ -101,7 +101,7 @@ internal class ExecutionStatusTest {
}
@Test
fun testDurationSerialization() {
fun testMinutesDurationSerialization() {
val objectMapper = ObjectMapper()
val executionStatus = ExecutionStatus()
val startInstant = Instant.parse("2022-01-02T18:59:20.492103Z")
......@@ -114,6 +114,20 @@ internal class ExecutionStatusTest {
assertEquals("15m", jsonField.asText())
}
@Test
fun testSecondsDurationSerialization() {
val objectMapper = ObjectMapper()
val executionStatus = ExecutionStatus()
val startInstant = Instant.parse("2022-01-02T18:59:20.492103Z")
executionStatus.startTime = MicroTime(startInstant.toString())
executionStatus.completionTime = MicroTime(startInstant.plus(Duration.ofSeconds(45)).toString())
val jsonString = objectMapper.writeValueAsString(executionStatus)
val json = objectMapper.readTree(jsonString)
val jsonField = json.get("executionDuration")
assertTrue(jsonField.isTextual)
assertEquals("45s", jsonField.asText())
}
@Test
fun testNotStartedDurationSerialization() {
val objectMapper = ObjectMapper()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment