summaryrefslogtreecommitdiff
path: root/simulator/opendc-workflows/src/test
diff options
context:
space:
mode:
Diffstat (limited to 'simulator/opendc-workflows/src/test')
-rw-r--r--simulator/opendc-workflows/src/test/kotlin/org/opendc/workflows/service/StageWorkflowSchedulerIntegrationTest.kt38
1 files changed, 27 insertions, 11 deletions
diff --git a/simulator/opendc-workflows/src/test/kotlin/org/opendc/workflows/service/StageWorkflowSchedulerIntegrationTest.kt b/simulator/opendc-workflows/src/test/kotlin/org/opendc/workflows/service/StageWorkflowSchedulerIntegrationTest.kt
index 90cf5b99..2bfcba35 100644
--- a/simulator/opendc-workflows/src/test/kotlin/org/opendc/workflows/service/StageWorkflowSchedulerIntegrationTest.kt
+++ b/simulator/opendc-workflows/src/test/kotlin/org/opendc/workflows/service/StageWorkflowSchedulerIntegrationTest.kt
@@ -35,14 +35,17 @@ import org.junit.jupiter.api.Assertions.assertEquals
import org.junit.jupiter.api.Assertions.assertNotEquals
import org.junit.jupiter.api.DisplayName
import org.junit.jupiter.api.Test
+import org.junit.jupiter.api.assertAll
import org.opendc.compute.core.metal.service.ProvisioningService
+import org.opendc.compute.simulator.SimVirtProvisioningService
+import org.opendc.compute.simulator.allocation.NumberOfActiveServersAllocationPolicy
import org.opendc.format.environment.sc18.Sc18EnvironmentReader
import org.opendc.format.trace.gwf.GwfTraceReader
+import org.opendc.simulator.compute.SimSpaceSharedHypervisorProvider
import org.opendc.simulator.utils.DelayControllerClockAdapter
+import org.opendc.trace.core.EventTracer
import org.opendc.workflows.service.stage.job.NullJobAdmissionPolicy
import org.opendc.workflows.service.stage.job.SubmissionTimeJobOrderPolicy
-import org.opendc.workflows.service.stage.resource.FirstFitResourceSelectionPolicy
-import org.opendc.workflows.service.stage.resource.FunctionalResourceFilterPolicy
import org.opendc.workflows.service.stage.task.NullTaskEligibilityPolicy
import org.opendc.workflows.service.stage.task.SubmissionTimeTaskOrderPolicy
import kotlin.math.max
@@ -57,7 +60,7 @@ internal class StageWorkflowSchedulerIntegrationTest {
* A large integration test where we check whether all tasks in some trace are executed correctly.
*/
@Test
- fun `should execute all tasks in trace`() {
+ fun testTrace() {
var jobsSubmitted = 0L
var jobsStarted = 0L
var jobsFinished = 0L
@@ -66,22 +69,32 @@ internal class StageWorkflowSchedulerIntegrationTest {
val testScope = TestCoroutineScope()
val clock = DelayControllerClockAdapter(testScope)
+ val tracer = EventTracer(clock)
val schedulerAsync = testScope.async {
val environment = Sc18EnvironmentReader(object {}.javaClass.getResourceAsStream("/environment.json"))
.use { it.construct(testScope, clock) }
+ val bareMetal = environment.platforms[0].zones[0].services[ProvisioningService]
+
+ // Wait for the bare metal nodes to be spawned
+ delay(10)
+
+ val provisioner = SimVirtProvisioningService(testScope, clock, bareMetal, NumberOfActiveServersAllocationPolicy(), tracer, SimSpaceSharedHypervisorProvider(), schedulingQuantum = 1000)
+
+ // Wait for the hypervisors to be spawned
+ delay(10)
+
StageWorkflowService(
testScope,
clock,
- environment.platforms[0].zones[0].services[ProvisioningService],
+ tracer,
+ provisioner,
mode = WorkflowSchedulerMode.Batch(100),
jobAdmissionPolicy = NullJobAdmissionPolicy,
jobOrderPolicy = SubmissionTimeJobOrderPolicy(),
taskEligibilityPolicy = NullTaskEligibilityPolicy,
taskOrderPolicy = SubmissionTimeTaskOrderPolicy(),
- resourceFilterPolicy = FunctionalResourceFilterPolicy,
- resourceSelectionPolicy = FirstFitResourceSelectionPolicy
)
}
@@ -106,16 +119,19 @@ internal class StageWorkflowSchedulerIntegrationTest {
while (reader.hasNext()) {
val (time, job) = reader.next()
jobsSubmitted++
- delay(max(0, time * 1000 - clock.millis()))
+ delay(max(0, time - clock.millis()))
scheduler.submit(job)
}
}
testScope.advanceUntilIdle()
- assertNotEquals(0, jobsSubmitted, "No jobs submitted")
- assertEquals(jobsSubmitted, jobsStarted, "Not all submitted jobs started")
- assertEquals(jobsSubmitted, jobsFinished, "Not all started jobs finished")
- assertEquals(tasksStarted, tasksFinished, "Not all started tasks finished")
+ assertAll(
+ { assertEquals(emptyList<Throwable>(), testScope.uncaughtExceptions) },
+ { assertNotEquals(0, jobsSubmitted, "No jobs submitted") },
+ { assertEquals(jobsSubmitted, jobsStarted, "Not all submitted jobs started") },
+ { assertEquals(jobsSubmitted, jobsFinished, "Not all started jobs finished") },
+ { assertEquals(tasksStarted, tasksFinished, "Not all started tasks finished") }
+ )
}
}