summaryrefslogtreecommitdiff
path: root/opendc-trace/opendc-trace-wtf/src/test
diff options
context:
space:
mode:
authorFabian Mastenbroek <mail.fabianm@gmail.com>2022-06-09 10:31:41 +0200
committerGitHub <noreply@github.com>2022-06-09 10:31:41 +0200
commitd146814bbbb86bfcb19ccb94250424703e9179e5 (patch)
treebf20f51b434d56e60ad013568ac1a32b912a3b5e /opendc-trace/opendc-trace-wtf/src/test
parent61b6550d7a476ab1aae45a5b9385dfd6ca4f6b6f (diff)
parent9d759c9bc987965fae8b0c16c000772c546bf3a2 (diff)
merge: Introduce schema for trace API (#88)
This pull request updates the OpenDC trace API to support proper specification of a schema of the tables exposed by the traces. This functionality makes it easier for the API consumer to understand the types exposed by the API. ## Implementation Notes :hammer_and_pick: * Introduce type system for trace API * Add benchmarks for odcvm trace format * Add benchmarks for Azure trace format * Add conformance suite for OpenDC trace API ## External Dependencies :four_leaf_clover: * N/A ## Breaking API Changes :warning: * Removal of typed `TableColumn`. Instead, `TableColumn` instances are now used to describe the columns belonging to some table. * `TableReader` and `TableWriter` do not support accessing arbitrary objects anymore. Instead, only the types supported by the type system are exposed.
Diffstat (limited to 'opendc-trace/opendc-trace-wtf/src/test')
-rw-r--r--opendc-trace/opendc-trace-wtf/src/test/kotlin/org/opendc/trace/wtf/WtfTraceFormatTest.kt47
1 files changed, 31 insertions, 16 deletions
diff --git a/opendc-trace/opendc-trace-wtf/src/test/kotlin/org/opendc/trace/wtf/WtfTraceFormatTest.kt b/opendc-trace/opendc-trace-wtf/src/test/kotlin/org/opendc/trace/wtf/WtfTraceFormatTest.kt
index c0eb3f08..f6b821c2 100644
--- a/opendc-trace/opendc-trace-wtf/src/test/kotlin/org/opendc/trace/wtf/WtfTraceFormatTest.kt
+++ b/opendc-trace/opendc-trace-wtf/src/test/kotlin/org/opendc/trace/wtf/WtfTraceFormatTest.kt
@@ -22,10 +22,13 @@
package org.opendc.trace.wtf
+import org.junit.jupiter.api.*
import org.junit.jupiter.api.Assertions.*
-import org.junit.jupiter.api.Test
-import org.junit.jupiter.api.assertThrows
+import org.junit.jupiter.api.Assertions.assertAll
+import org.opendc.trace.TableColumn
+import org.opendc.trace.TableReader
import org.opendc.trace.conv.*
+import org.opendc.trace.testkit.TableReaderTestKit
import java.nio.file.Paths
import java.time.Duration
import java.time.Instant
@@ -33,6 +36,7 @@ import java.time.Instant
/**
* Test suite for the [WtfTraceFormat] class.
*/
+@DisplayName("WTF TraceFormat")
class WtfTraceFormatTest {
private val format = WtfTraceFormat()
@@ -65,36 +69,47 @@ class WtfTraceFormatTest {
assertAll(
{ assertTrue(reader.nextRow()) },
- { assertEquals("362334516345962206", reader.get(TASK_ID)) },
- { assertEquals("1078341553348591493", reader.get(TASK_WORKFLOW_ID)) },
- { assertEquals(Instant.ofEpochMilli(245604), reader.get(TASK_SUBMIT_TIME)) },
- { assertEquals(Duration.ofMillis(8163), reader.get(TASK_RUNTIME)) },
+ { assertEquals("362334516345962206", reader.getString(TASK_ID)) },
+ { assertEquals("1078341553348591493", reader.getString(TASK_WORKFLOW_ID)) },
+ { assertEquals(Instant.ofEpochMilli(245604), reader.getInstant(TASK_SUBMIT_TIME)) },
+ { assertEquals(Duration.ofMillis(8163), reader.getDuration(TASK_RUNTIME)) },
{
assertEquals(
setOf("584055316413447529", "133113685133695608", "1008582348422865408"),
- reader.get(
- TASK_PARENTS
- )
+ reader.getSet(TASK_PARENTS, String::class.java)
)
},
)
assertAll(
{ assertTrue(reader.nextRow()) },
- { assertEquals("502010169100446658", reader.get(TASK_ID)) },
- { assertEquals("1078341553348591493", reader.get(TASK_WORKFLOW_ID)) },
- { assertEquals(Instant.ofEpochMilli(251325), reader.get(TASK_SUBMIT_TIME)) },
- { assertEquals(Duration.ofMillis(8216), reader.get(TASK_RUNTIME)) },
+ { assertEquals("502010169100446658", reader.getString(TASK_ID)) },
+ { assertEquals("1078341553348591493", reader.getString(TASK_WORKFLOW_ID)) },
+ { assertEquals(Instant.ofEpochMilli(251325), reader.getInstant(TASK_SUBMIT_TIME)) },
+ { assertEquals(Duration.ofMillis(8216), reader.getDuration(TASK_RUNTIME)) },
{
assertEquals(
setOf("584055316413447529", "133113685133695608", "1008582348422865408"),
- reader.get(
- TASK_PARENTS
- )
+ reader.getSet(TASK_PARENTS, String::class.java)
)
},
)
reader.close()
}
+
+ @DisplayName("TableReader for Tasks")
+ @Nested
+ inner class TasksTableReaderTest : TableReaderTestKit() {
+ override lateinit var reader: TableReader
+ override lateinit var columns: List<TableColumn>
+
+ @BeforeEach
+ fun setUp() {
+ val path = Paths.get("src/test/resources/wtf-trace")
+
+ columns = format.getDetails(path, TABLE_TASKS).columns
+ reader = format.newReader(path, TABLE_TASKS, null)
+ }
+ }
}