summaryrefslogtreecommitdiff
path: root/opendc-trace/opendc-trace-api/src/test/kotlin/formats/wfformat
diff options
context:
space:
mode:
authorDante Niewenhuis <d.niewenhuis@hotmail.com>2025-07-22 15:47:44 +0200
committerGitHub <noreply@github.com>2025-07-22 15:47:44 +0200
commite22c97dcca7478d6941b78bdf7cd873bc0d23cdc (patch)
treef1859c16f4c7973d8b16ed693caad4c749d42331 /opendc-trace/opendc-trace-api/src/test/kotlin/formats/wfformat
parent0c0cf25616771cd40a9e401edcba4a5e5016f76e (diff)
Updated workload schema (#360)
Diffstat (limited to 'opendc-trace/opendc-trace-api/src/test/kotlin/formats/wfformat')
-rw-r--r--opendc-trace/opendc-trace-api/src/test/kotlin/formats/wfformat/WfFormatTaskTableReaderTest.kt361
-rw-r--r--opendc-trace/opendc-trace-api/src/test/kotlin/formats/wfformat/WfFormatTraceFormatTest.kt129
2 files changed, 0 insertions, 490 deletions
diff --git a/opendc-trace/opendc-trace-api/src/test/kotlin/formats/wfformat/WfFormatTaskTableReaderTest.kt b/opendc-trace/opendc-trace-api/src/test/kotlin/formats/wfformat/WfFormatTaskTableReaderTest.kt
deleted file mode 100644
index 1701e566..00000000
--- a/opendc-trace/opendc-trace-api/src/test/kotlin/formats/wfformat/WfFormatTaskTableReaderTest.kt
+++ /dev/null
@@ -1,361 +0,0 @@
-/*
- * Copyright (c) 2021 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 formats.wfformat
-
-import com.fasterxml.jackson.core.JsonFactory
-import com.fasterxml.jackson.core.JsonParseException
-import org.junit.jupiter.api.Assertions.assertEquals
-import org.junit.jupiter.api.Assertions.assertFalse
-import org.junit.jupiter.api.Assertions.assertTrue
-import org.junit.jupiter.api.Test
-import org.junit.jupiter.api.assertDoesNotThrow
-import org.junit.jupiter.api.assertThrows
-import org.opendc.trace.conv.TASK_ID
-import org.opendc.trace.conv.TASK_PARENTS
-import org.opendc.trace.wfformat.WfFormatTaskTableReader
-
-/**
- * Test suite for the [WfFormatTaskTableReader] class.
- */
-internal class WfFormatTaskTableReaderTest {
- /**
- * The [JsonFactory] used to construct the parser.
- */
- private val factory = JsonFactory()
-
- @Test
- fun testEmptyInput() {
- val content = ""
- val parser = factory.createParser(content)
- val reader = WfFormatTaskTableReader(parser)
-
- assertFalse(reader.nextRow())
- reader.close()
- }
-
- @Test
- fun testTopLevelArrayInput() {
- val content = "[]"
- val parser = factory.createParser(content)
- val reader = WfFormatTaskTableReader(parser)
-
- assertThrows<JsonParseException> {
- while (reader.nextRow()) {
- continue
- }
- }
-
- reader.close()
- }
-
- @Test
- fun testNoWorkflow() {
- val content =
- """
- {
- "name": "eager-nextflow-chameleon"
- }
- """.trimIndent()
- val parser = factory.createParser(content)
- val reader = WfFormatTaskTableReader(parser)
-
- assertDoesNotThrow {
- while (reader.nextRow()) {
- continue
- }
- }
-
- reader.close()
- }
-
- @Test
- fun testWorkflowArrayType() {
- val content =
- """
- {
- "name": "eager-nextflow-chameleon",
- "workflow": []
- }
- """.trimIndent()
- val parser = factory.createParser(content)
- val reader = WfFormatTaskTableReader(parser)
-
- assertThrows<JsonParseException> {
- while (reader.nextRow()) {
- continue
- }
- }
-
- reader.close()
- }
-
- @Test
- fun testWorkflowNullType() {
- val content =
- """
- {
- "name": "eager-nextflow-chameleon",
- "workflow": null
- }
- """.trimIndent()
- val parser = factory.createParser(content)
- val reader = WfFormatTaskTableReader(parser)
-
- assertThrows<JsonParseException> {
- while (reader.nextRow()) {
- continue
- }
- }
-
- reader.close()
- }
-
- @Test
- fun testNoJobs() {
- val content =
- """
- {
- "name": "eager-nextflow-chameleon",
- "workflow": {
-
- }
- }
- """.trimIndent()
- val parser = factory.createParser(content)
- val reader = WfFormatTaskTableReader(parser)
-
- assertDoesNotThrow { reader.nextRow() }
-
- reader.close()
- }
-
- @Test
- fun testJobsObjectType() {
- val content =
- """
- {
- "name": "eager-nextflow-chameleon",
- "workflow": { "jobs": {} }
- }
- """.trimIndent()
- val parser = factory.createParser(content)
- val reader = WfFormatTaskTableReader(parser)
-
- assertThrows<JsonParseException> { reader.nextRow() }
-
- reader.close()
- }
-
- @Test
- fun testJobsNullType() {
- val content =
- """
- {
- "name": "eager-nextflow-chameleon",
- "workflow": { "jobs": null }
- }
- """.trimIndent()
- val parser = factory.createParser(content)
- val reader = WfFormatTaskTableReader(parser)
-
- assertThrows<JsonParseException> { reader.nextRow() }
-
- reader.close()
- }
-
- @Test
- fun testJobsInvalidChildType() {
- val content =
- """
- {
- "name": "eager-nextflow-chameleon",
- "workflow": {
- "jobs": [1]
- }
- }
- """.trimIndent()
- val parser = factory.createParser(content)
- val reader = WfFormatTaskTableReader(parser)
-
- assertThrows<JsonParseException> { reader.nextRow() }
-
- reader.close()
- }
-
- @Test
- fun testJobsValidChildType() {
- val content =
- """
- {
- "name": "eager-nextflow-chameleon",
- "workflow": {
- "jobs": [
- {
- "name": "test"
- }
- ]
- }
- }
- """.trimIndent()
- val parser = factory.createParser(content)
- val reader = WfFormatTaskTableReader(parser)
-
- assertTrue(reader.nextRow())
- assertEquals("test", reader.getString(TASK_ID))
- assertFalse(reader.nextRow())
-
- reader.close()
- }
-
- @Test
- fun testJobsInvalidParents() {
- val content =
- """
- {
- "name": "eager-nextflow-chameleon",
- "workflow": {
- "jobs": [
- {
- "name": "test",
- "parents": 1,
- }
- ]
- }
- }
- """.trimIndent()
- val parser = factory.createParser(content)
- val reader = WfFormatTaskTableReader(parser)
-
- assertThrows<JsonParseException> { reader.nextRow() }
-
- reader.close()
- }
-
- @Test
- fun testJobsInvalidParentsItem() {
- val content =
- """
- {
- "name": "eager-nextflow-chameleon",
- "workflow": {
- "jobs": [
- {
- "name": "test",
- "parents": [1],
- }
- ]
- }
- }
- """.trimIndent()
- val parser = factory.createParser(content)
- val reader = WfFormatTaskTableReader(parser)
-
- assertThrows<JsonParseException> { reader.nextRow() }
-
- reader.close()
- }
-
- @Test
- fun testJobsValidParents() {
- val content =
- """
- {
- "name": "eager-nextflow-chameleon",
- "workflow": {
- "jobs": [
- {
- "name": "test",
- "parents": ["1"]
- }
- ]
- }
- }
- """.trimIndent()
- val parser = factory.createParser(content)
- val reader = WfFormatTaskTableReader(parser)
-
- assertTrue(reader.nextRow())
- assertEquals(setOf("1"), reader.getSet(TASK_PARENTS, String::class.java))
- assertFalse(reader.nextRow())
-
- reader.close()
- }
-
- @Test
- fun testJobsInvalidSecondEntry() {
- val content =
- """
- {
- "workflow": {
- "jobs": [
- {
- "name": "test",
- "parents": ["1"]
- },
- "test"
- ]
- }
- }
- """.trimIndent()
- val parser = factory.createParser(content)
- val reader = WfFormatTaskTableReader(parser)
-
- assertDoesNotThrow { reader.nextRow() }
- assertThrows<JsonParseException> { reader.nextRow() }
-
- reader.close()
- }
-
- @Test
- fun testDuplicateJobsArray() {
- val content =
- """
- {
- "name": "eager-nextflow-chameleon",
- "workflow": {
- "jobs": [
- {
- "name": "test",
- "parents": ["1"]
- }
- ],
- "jobs": [
- {
- "name": "test2",
- "parents": ["test"]
- }
- ]
- }
- }
- """.trimIndent()
- val parser = factory.createParser(content)
- val reader = WfFormatTaskTableReader(parser)
-
- assertTrue(reader.nextRow())
- assertTrue(reader.nextRow())
- assertEquals("test2", reader.getString(TASK_ID))
- assertFalse(reader.nextRow())
-
- reader.close()
- }
-}
diff --git a/opendc-trace/opendc-trace-api/src/test/kotlin/formats/wfformat/WfFormatTraceFormatTest.kt b/opendc-trace/opendc-trace-api/src/test/kotlin/formats/wfformat/WfFormatTraceFormatTest.kt
deleted file mode 100644
index 94ed30d7..00000000
--- a/opendc-trace/opendc-trace-api/src/test/kotlin/formats/wfformat/WfFormatTraceFormatTest.kt
+++ /dev/null
@@ -1,129 +0,0 @@
-/*
- * Copyright (c) 2021 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 formats.wfformat
-
-import org.junit.jupiter.api.Assertions.assertAll
-import org.junit.jupiter.api.Assertions.assertEquals
-import org.junit.jupiter.api.Assertions.assertTrue
-import org.junit.jupiter.api.BeforeEach
-import org.junit.jupiter.api.DisplayName
-import org.junit.jupiter.api.Nested
-import org.junit.jupiter.api.Test
-import org.junit.jupiter.api.assertDoesNotThrow
-import org.junit.jupiter.api.assertThrows
-import org.opendc.trace.TableColumn
-import org.opendc.trace.TableReader
-import org.opendc.trace.conv.TABLE_TASKS
-import org.opendc.trace.conv.TASK_ID
-import org.opendc.trace.conv.TASK_PARENTS
-import org.opendc.trace.conv.TASK_RUNTIME
-import org.opendc.trace.conv.TASK_WORKFLOW_ID
-import org.opendc.trace.testkit.TableReaderTestKit
-import org.opendc.trace.wfformat.WfFormatTraceFormat
-import java.nio.file.Paths
-
-/**
- * Test suite for the [WfFormatTraceFormat] class.
- */
-@DisplayName("WfFormat TraceFormat")
-class WfFormatTraceFormatTest {
- private val format = WfFormatTraceFormat()
-
- @Test
- fun testTables() {
- val path = Paths.get("src/test/resources/wfformat/trace.json")
-
- assertEquals(listOf(TABLE_TASKS), format.getTables(path))
- }
-
- @Test
- fun testTableExists() {
- val path = Paths.get("src/test/resources/wfformat/trace.json")
- assertDoesNotThrow { format.getDetails(path, TABLE_TASKS) }
- }
-
- @Test
- fun testTableDoesNotExist() {
- val path = Paths.get("src/test/resources/wfformat/trace.json")
-
- assertThrows<IllegalArgumentException> { format.getDetails(path, "test") }
- }
-
- /**
- * Smoke test for parsing WfCommons traces.
- */
- @Test
- fun testTableReader() {
- val path = Paths.get("src/test/resources/wfformat/trace.json")
- val reader = format.newReader(path, TABLE_TASKS, null)
-
- assertAll(
- { assertTrue(reader.nextRow()) },
- { assertEquals("makebwaindex_mammoth_mt_krause.fasta", reader.getString(TASK_ID)) },
- { assertEquals("eager-nextflow-chameleon", reader.getString(TASK_WORKFLOW_ID)) },
- { assertEquals(172000, reader.getDuration(TASK_RUNTIME)?.toMillis()) },
- { assertEquals(emptySet<String>(), reader.getSet(TASK_PARENTS, String::class.java)) },
- )
-
- assertAll(
- { assertTrue(reader.nextRow()) },
- { assertEquals("makeseqdict_mammoth_mt_krause.fasta", reader.getString(TASK_ID)) },
- { assertEquals("eager-nextflow-chameleon", reader.getString(TASK_WORKFLOW_ID)) },
- { assertEquals(175000, reader.getDuration(TASK_RUNTIME)?.toMillis()) },
- { assertEquals(setOf("makebwaindex_mammoth_mt_krause.fasta"), reader.getSet(TASK_PARENTS, String::class.java)) },
- )
-
- reader.close()
- }
-
- /**
- * Test full iteration of the table.
- */
- @Test
- fun testTableReaderFull() {
- val path = Paths.get("src/test/resources/wfformat/trace.json")
- val reader = format.newReader(path, TABLE_TASKS, null)
-
- assertDoesNotThrow {
- while (reader.nextRow()) {
- // reader.get(TASK_ID)
- }
- 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/wfformat/trace.json")
-
- columns = format.getDetails(path, TABLE_TASKS).columns
- reader = format.newReader(path, TABLE_TASKS, null)
- }
- }
-}