summaryrefslogtreecommitdiff
path: root/simulator/opendc-workflows/src/test/kotlin
diff options
context:
space:
mode:
authorFabian Mastenbroek <mail.fabianm@gmail.com>2021-03-09 20:47:06 +0100
committerGitHub <noreply@github.com>2021-03-09 20:47:06 +0100
commit3b6fbe0b535bf3398f120373f59f87adbba34005 (patch)
treebc880252a935cc0b1558c50fe83f71d21b735d29 /simulator/opendc-workflows/src/test/kotlin
parent66c2501d95b167f9e7474a45e542f82d2d8e83ff (diff)
parent40e5871e01858a55372bfcb51cf90069c080e751 (diff)
compute: Improvements to cloud compute model (v2)
This is the second in the series of pull requests to improve the existing cloud compute model (see #86). This pull request removes the dependency on the bare-metal provisioning code which simplifies experiment setup tremendously: - Remove bare-metal provisioning code (opendc-metal) - Remove opendc-core which was a relic of the previous codebase and was only used sparingly. - Move ownership of Server, Image and Flavor to the compute service. Users are expected to create instances via the compute service.
Diffstat (limited to 'simulator/opendc-workflows/src/test/kotlin')
-rw-r--r--simulator/opendc-workflows/src/test/kotlin/org/opendc/workflows/service/StageWorkflowSchedulerIntegrationTest.kt142
1 files changed, 0 insertions, 142 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
deleted file mode 100644
index 4207cdfd..00000000
--- a/simulator/opendc-workflows/src/test/kotlin/org/opendc/workflows/service/StageWorkflowSchedulerIntegrationTest.kt
+++ /dev/null
@@ -1,142 +0,0 @@
-/*
- * MIT License
- *
- * 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.workflows.service
-
-import kotlinx.coroutines.ExperimentalCoroutinesApi
-import kotlinx.coroutines.async
-import kotlinx.coroutines.delay
-import kotlinx.coroutines.flow.collect
-import kotlinx.coroutines.flow.onEach
-import kotlinx.coroutines.launch
-import kotlinx.coroutines.test.TestCoroutineScope
-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.service.ComputeService
-import org.opendc.compute.service.scheduler.NumberOfActiveServersAllocationPolicy
-import org.opendc.compute.simulator.SimHostProvisioner
-import org.opendc.format.environment.sc18.Sc18EnvironmentReader
-import org.opendc.format.trace.gwf.GwfTraceReader
-import org.opendc.metal.service.ProvisioningService
-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.task.NullTaskEligibilityPolicy
-import org.opendc.workflows.service.stage.task.SubmissionTimeTaskOrderPolicy
-import kotlin.math.max
-
-/**
- * Integration test suite for the [StageWorkflowService].
- */
-@DisplayName("StageWorkflowService")
-@OptIn(ExperimentalCoroutinesApi::class)
-internal class StageWorkflowSchedulerIntegrationTest {
- /**
- * A large integration test where we check whether all tasks in some trace are executed correctly.
- */
- @Test
- fun testTrace() {
- var jobsSubmitted = 0L
- var jobsStarted = 0L
- var jobsFinished = 0L
- var tasksStarted = 0L
- var tasksFinished = 0L
-
- 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 = SimHostProvisioner(testScope.coroutineContext, bareMetal, SimSpaceSharedHypervisorProvider())
- val hosts = provisioner.provisionAll()
- val compute = ComputeService(testScope.coroutineContext, clock, tracer, NumberOfActiveServersAllocationPolicy(), schedulingQuantum = 1000)
-
- hosts.forEach { compute.addHost(it) }
-
- // Wait for the hypervisors to be spawned
- delay(10)
-
- StageWorkflowService(
- testScope,
- clock,
- tracer,
- compute.newClient(),
- mode = WorkflowSchedulerMode.Batch(100),
- jobAdmissionPolicy = NullJobAdmissionPolicy,
- jobOrderPolicy = SubmissionTimeJobOrderPolicy(),
- taskEligibilityPolicy = NullTaskEligibilityPolicy,
- taskOrderPolicy = SubmissionTimeTaskOrderPolicy(),
- )
- }
-
- testScope.launch {
- val scheduler = schedulerAsync.await()
- scheduler.events
- .onEach { event ->
- when (event) {
- is WorkflowEvent.JobStarted -> jobsStarted++
- is WorkflowEvent.JobFinished -> jobsFinished++
- is WorkflowEvent.TaskStarted -> tasksStarted++
- is WorkflowEvent.TaskFinished -> tasksFinished++
- }
- }
- .collect()
- }
-
- testScope.launch {
- val reader = GwfTraceReader(object {}.javaClass.getResourceAsStream("/trace.gwf"))
- val scheduler = schedulerAsync.await()
-
- while (reader.hasNext()) {
- val (time, job) = reader.next()
- jobsSubmitted++
- delay(max(0, time - clock.millis()))
- scheduler.submit(job)
- }
- }
-
- testScope.advanceUntilIdle()
-
- 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") }
- )
- }
-}