summaryrefslogtreecommitdiff
path: root/simulator/opendc-format
diff options
context:
space:
mode:
authorFabian Mastenbroek <mail.fabianm@gmail.com>2020-10-01 10:42:36 +0200
committerFabian Mastenbroek <mail.fabianm@gmail.com>2020-10-01 10:47:44 +0200
commitebd375d524714708d7b38c0117a77d50d23043a3 (patch)
treebb246d18f86e551dd01f92658c6ef2b14a608fc6 /simulator/opendc-format
parentafee4c550515dc2f6021be33f58823d279980246 (diff)
Add test case for WTA trace parser
Diffstat (limited to 'simulator/opendc-format')
-rw-r--r--simulator/opendc-format/src/main/kotlin/org/opendc/format/trace/wtf/WtfTraceReader.kt2
-rw-r--r--simulator/opendc-format/src/test/kotlin/org/opendc/format/trace/wtf/WtfTraceReaderTest.kt46
-rw-r--r--simulator/opendc-format/src/test/resources/wtf-trace/tasks/schema-1.0/part.0.parquetbin0 -> 87475 bytes
3 files changed, 47 insertions, 1 deletions
diff --git a/simulator/opendc-format/src/main/kotlin/org/opendc/format/trace/wtf/WtfTraceReader.kt b/simulator/opendc-format/src/main/kotlin/org/opendc/format/trace/wtf/WtfTraceReader.kt
index b8f3e771..12a60aec 100644
--- a/simulator/opendc-format/src/main/kotlin/org/opendc/format/trace/wtf/WtfTraceReader.kt
+++ b/simulator/opendc-format/src/main/kotlin/org/opendc/format/trace/wtf/WtfTraceReader.kt
@@ -55,7 +55,7 @@ class WtfTraceReader(path: String) : TraceReader<Job> {
val tasks = mutableMapOf<Long, Task>()
val taskDependencies = mutableMapOf<Task, List<Long>>()
- val reader = AvroParquetReader.builder<GenericRecord>(Path(path)).build()
+ val reader = AvroParquetReader.builder<GenericRecord>(Path(path, "tasks/schema-1.0")).build()
while (true) {
val nextRecord = reader.read() ?: break
diff --git a/simulator/opendc-format/src/test/kotlin/org/opendc/format/trace/wtf/WtfTraceReaderTest.kt b/simulator/opendc-format/src/test/kotlin/org/opendc/format/trace/wtf/WtfTraceReaderTest.kt
new file mode 100644
index 00000000..58d96657
--- /dev/null
+++ b/simulator/opendc-format/src/test/kotlin/org/opendc/format/trace/wtf/WtfTraceReaderTest.kt
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2020 AtLarge Research
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+package org.opendc.format.trace.wtf
+
+import org.junit.jupiter.api.Assertions.*
+import org.junit.jupiter.api.Test
+
+/**
+ * Test suite for the [WtfTraceReader] class.
+ */
+class WtfTraceReaderTest {
+ /**
+ * Smoke test for parsing WTF traces.
+ */
+ @Test
+ fun testParseWtf() {
+ val reader = WtfTraceReader("src/test/resources/wtf-trace")
+ var entry = reader.next()
+ assertEquals(0, entry.submissionTime)
+ assertEquals(23, entry.workload.tasks.size)
+
+ entry = reader.next()
+ assertEquals(333387, entry.submissionTime)
+ assertEquals(23, entry.workload.tasks.size)
+ }
+}
diff --git a/simulator/opendc-format/src/test/resources/wtf-trace/tasks/schema-1.0/part.0.parquet b/simulator/opendc-format/src/test/resources/wtf-trace/tasks/schema-1.0/part.0.parquet
new file mode 100644
index 00000000..d2044038
--- /dev/null
+++ b/simulator/opendc-format/src/test/resources/wtf-trace/tasks/schema-1.0/part.0.parquet
Binary files differ