summaryrefslogtreecommitdiff
path: root/opendc-simulator/opendc-simulator-compute/src/test
diff options
context:
space:
mode:
authorFabian Mastenbroek <mail.fabianm@gmail.com>2022-09-23 12:49:32 +0200
committerGitHub <noreply@github.com>2022-09-23 12:49:32 +0200
commit2d2a3854d355bd4b074ef651f291d34081e70d96 (patch)
treee99c4bf7e5647341c1e269797f7f46099753436f /opendc-simulator/opendc-simulator-compute/src/test
parent8d1d091f093e6ac32dba1e6a4f74490b280fcc4b (diff)
parent3d5eb562227dcad5a8a60f31b96e6d68f7774fb2 (diff)
merge: Do not require interference model during topology construction (#102)
This pull request refactors the existing workload interference model in order to remove a dependency on it during the topology construction. With this change, interference domains (e.g., a single host) can be constructed independently of the interference profiles of virtual machines. ## Implementation Notes :hammer_and_pick: * Move VM interference model into compute simulator * Remove convergence listener parameter * Remove FlowEngine from SimMachineContext * Remove timestamp parameter from SimTrace * Pass interference key via parameter * Move interference logic into VmInterferenceMember * Prevent boxing in interference algorithm * Extract Random dependency from interference model * Add separate error host state * Simplify constructor of SimHost * Make interference domain independent of profile ## External Dependencies :four_leaf_clover: * N/A ## Breaking API Changes :warning: * The interface of `VmInterferenceModel` is changed. Users do not need to provide a seed for the model anymore. * A `VmInterferenceModel` should be passed via the metadata parameter of `startWorkload` to enable workload interference.
Diffstat (limited to 'opendc-simulator/opendc-simulator-compute/src/test')
-rw-r--r--opendc-simulator/opendc-simulator-compute/src/test/kotlin/org/opendc/simulator/compute/kernel/SimFairShareHypervisorTest.kt39
-rw-r--r--opendc-simulator/opendc-simulator-compute/src/test/kotlin/org/opendc/simulator/compute/kernel/SimSpaceSharedHypervisorTest.kt32
2 files changed, 31 insertions, 40 deletions
diff --git a/opendc-simulator/opendc-simulator-compute/src/test/kotlin/org/opendc/simulator/compute/kernel/SimFairShareHypervisorTest.kt b/opendc-simulator/opendc-simulator-compute/src/test/kotlin/org/opendc/simulator/compute/kernel/SimFairShareHypervisorTest.kt
index 91855e8d..ddf8cf14 100644
--- a/opendc-simulator/opendc-simulator-compute/src/test/kotlin/org/opendc/simulator/compute/kernel/SimFairShareHypervisorTest.kt
+++ b/opendc-simulator/opendc-simulator-compute/src/test/kotlin/org/opendc/simulator/compute/kernel/SimFairShareHypervisorTest.kt
@@ -43,11 +43,12 @@ import org.opendc.simulator.compute.workload.SimTraceFragment
import org.opendc.simulator.compute.workload.SimTraceWorkload
import org.opendc.simulator.core.runBlockingSimulation
import org.opendc.simulator.flow.FlowEngine
+import org.opendc.simulator.flow.mux.FlowMultiplexerFactory
+import java.util.*
/**
* Test suite for the [SimHypervisor] class.
*/
-@OptIn(ExperimentalCoroutinesApi::class)
internal class SimFairShareHypervisorTest {
private lateinit var model: MachineModel
@@ -76,9 +77,9 @@ internal class SimFairShareHypervisorTest {
),
)
- val platform = FlowEngine(coroutineContext, clock)
- val machine = SimBareMetalMachine(platform, model, SimplePowerDriver(ConstantPowerModel(0.0)))
- val hypervisor = SimFairShareHypervisor(platform, null, PerformanceScalingGovernor(), null)
+ val engine = FlowEngine(coroutineContext, clock)
+ val machine = SimBareMetalMachine(engine, model, SimplePowerDriver(ConstantPowerModel(0.0)))
+ val hypervisor = SimHypervisor(engine, FlowMultiplexerFactory.maxMinMultiplexer(), SplittableRandom(1), PerformanceScalingGovernor())
launch {
machine.runWorkload(hypervisor)
@@ -125,11 +126,9 @@ internal class SimFairShareHypervisorTest {
)
)
- val platform = FlowEngine(coroutineContext, clock)
- val machine = SimBareMetalMachine(
- platform, model, SimplePowerDriver(ConstantPowerModel(0.0))
- )
- val hypervisor = SimFairShareHypervisor(platform, null, null, null)
+ val engine = FlowEngine(coroutineContext, clock)
+ val machine = SimBareMetalMachine(engine, model, SimplePowerDriver(ConstantPowerModel(0.0)))
+ val hypervisor = SimHypervisor(engine, FlowMultiplexerFactory.maxMinMultiplexer(), SplittableRandom(1), null)
launch {
machine.runWorkload(hypervisor)
@@ -166,9 +165,9 @@ internal class SimFairShareHypervisorTest {
memory = List(4) { MemoryUnit("Crucial", "MTA18ASF4G72AZ-3G2B1", 3200.0, 32_000) }
)
- val platform = FlowEngine(coroutineContext, clock)
- val machine = SimBareMetalMachine(platform, model, SimplePowerDriver(ConstantPowerModel(0.0)))
- val hypervisor = SimFairShareHypervisor(platform, null, null, null)
+ val engine = FlowEngine(coroutineContext, clock)
+ val machine = SimBareMetalMachine(engine, model, SimplePowerDriver(ConstantPowerModel(0.0)))
+ val hypervisor = SimHypervisor(engine, FlowMultiplexerFactory.maxMinMultiplexer(), SplittableRandom(1), null)
assertDoesNotThrow {
launch {
@@ -193,11 +192,9 @@ internal class SimFairShareHypervisorTest {
.addGroup(targetLoad = 0.1, score = 0.8, members = setOf("a", "n"))
.build()
- val platform = FlowEngine(coroutineContext, clock)
- val machine = SimBareMetalMachine(
- platform, model, SimplePowerDriver(ConstantPowerModel(0.0))
- )
- val hypervisor = SimFairShareHypervisor(platform, null, null, interferenceModel.newDomain())
+ val engine = FlowEngine(coroutineContext, clock)
+ val machine = SimBareMetalMachine(engine, model, SimplePowerDriver(ConstantPowerModel(0.0)))
+ val hypervisor = SimHypervisor(engine, FlowMultiplexerFactory.maxMinMultiplexer(), SplittableRandom(1), null)
val duration = 5 * 60L
val workloadA =
@@ -225,12 +222,12 @@ internal class SimFairShareHypervisorTest {
coroutineScope {
launch {
- val vm = hypervisor.newMachine(model, "a")
- vm.runWorkload(workloadA)
+ val vm = hypervisor.newMachine(model)
+ vm.runWorkload(workloadA, meta = mapOf("interference-model" to interferenceModel.getProfile("a")!!))
hypervisor.removeMachine(vm)
}
- val vm = hypervisor.newMachine(model, "b")
- vm.runWorkload(workloadB)
+ val vm = hypervisor.newMachine(model)
+ vm.runWorkload(workloadB, meta = mapOf("interference-model" to interferenceModel.getProfile("b")!!))
hypervisor.removeMachine(vm)
}
diff --git a/opendc-simulator/opendc-simulator-compute/src/test/kotlin/org/opendc/simulator/compute/kernel/SimSpaceSharedHypervisorTest.kt b/opendc-simulator/opendc-simulator-compute/src/test/kotlin/org/opendc/simulator/compute/kernel/SimSpaceSharedHypervisorTest.kt
index 823a0ae3..df6755f1 100644
--- a/opendc-simulator/opendc-simulator-compute/src/test/kotlin/org/opendc/simulator/compute/kernel/SimSpaceSharedHypervisorTest.kt
+++ b/opendc-simulator/opendc-simulator-compute/src/test/kotlin/org/opendc/simulator/compute/kernel/SimSpaceSharedHypervisorTest.kt
@@ -22,7 +22,6 @@
package org.opendc.simulator.compute.kernel
-import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.launch
import kotlinx.coroutines.yield
import org.junit.jupiter.api.Assertions.*
@@ -40,11 +39,12 @@ import org.opendc.simulator.compute.runWorkload
import org.opendc.simulator.compute.workload.*
import org.opendc.simulator.core.runBlockingSimulation
import org.opendc.simulator.flow.FlowEngine
+import org.opendc.simulator.flow.mux.FlowMultiplexerFactory
+import java.util.*
/**
- * A test suite for the [SimSpaceSharedHypervisor].
+ * A test suite for a space-shared [SimHypervisor].
*/
-@OptIn(ExperimentalCoroutinesApi::class)
internal class SimSpaceSharedHypervisorTest {
private lateinit var machineModel: MachineModel
@@ -75,7 +75,7 @@ internal class SimSpaceSharedHypervisorTest {
val engine = FlowEngine(coroutineContext, clock)
val machine = SimBareMetalMachine(engine, machineModel, SimplePowerDriver(ConstantPowerModel(0.0)))
- val hypervisor = SimSpaceSharedHypervisor(engine, null, null)
+ val hypervisor = SimHypervisor(engine, FlowMultiplexerFactory.forwardingMultiplexer(), SplittableRandom(1), null)
launch { machine.runWorkload(hypervisor) }
val vm = hypervisor.newMachine(machineModel)
@@ -97,7 +97,7 @@ internal class SimSpaceSharedHypervisorTest {
val workload = SimRuntimeWorkload(duration)
val engine = FlowEngine(coroutineContext, clock)
val machine = SimBareMetalMachine(engine, machineModel, SimplePowerDriver(ConstantPowerModel(0.0)))
- val hypervisor = SimSpaceSharedHypervisor(engine, null, null)
+ val hypervisor = SimHypervisor(engine, FlowMultiplexerFactory.forwardingMultiplexer(), SplittableRandom(1), null)
launch { machine.runWorkload(hypervisor) }
yield()
@@ -118,10 +118,8 @@ internal class SimSpaceSharedHypervisorTest {
val duration = 5 * 60L * 1000
val workload = SimFlopsWorkload((duration * 3.2).toLong(), 1.0)
val engine = FlowEngine(coroutineContext, clock)
- val machine = SimBareMetalMachine(
- engine, machineModel, SimplePowerDriver(ConstantPowerModel(0.0))
- )
- val hypervisor = SimSpaceSharedHypervisor(engine, null, null)
+ val machine = SimBareMetalMachine(engine, machineModel, SimplePowerDriver(ConstantPowerModel(0.0)))
+ val hypervisor = SimHypervisor(engine, FlowMultiplexerFactory.forwardingMultiplexer(), SplittableRandom(1), null)
launch { machine.runWorkload(hypervisor) }
yield()
@@ -139,10 +137,8 @@ internal class SimSpaceSharedHypervisorTest {
fun testTwoWorkloads() = runBlockingSimulation {
val duration = 5 * 60L * 1000
val engine = FlowEngine(coroutineContext, clock)
- val machine = SimBareMetalMachine(
- engine, machineModel, SimplePowerDriver(ConstantPowerModel(0.0))
- )
- val hypervisor = SimSpaceSharedHypervisor(engine, null, null)
+ val machine = SimBareMetalMachine(engine, machineModel, SimplePowerDriver(ConstantPowerModel(0.0)))
+ val hypervisor = SimHypervisor(engine, FlowMultiplexerFactory.forwardingMultiplexer(), SplittableRandom(1), null)
launch { machine.runWorkload(hypervisor) }
yield()
@@ -169,7 +165,7 @@ internal class SimSpaceSharedHypervisorTest {
fun testConcurrentWorkloadFails() = runBlockingSimulation {
val engine = FlowEngine(coroutineContext, clock)
val machine = SimBareMetalMachine(engine, machineModel, SimplePowerDriver(ConstantPowerModel(0.0)))
- val hypervisor = SimSpaceSharedHypervisor(engine, null, null)
+ val hypervisor = SimHypervisor(engine, FlowMultiplexerFactory.forwardingMultiplexer(), SplittableRandom(1), null)
launch { machine.runWorkload(hypervisor) }
yield()
@@ -189,11 +185,9 @@ internal class SimSpaceSharedHypervisorTest {
*/
@Test
fun testConcurrentWorkloadSucceeds() = runBlockingSimulation {
- val interpreter = FlowEngine(coroutineContext, clock)
- val machine = SimBareMetalMachine(
- interpreter, machineModel, SimplePowerDriver(ConstantPowerModel(0.0))
- )
- val hypervisor = SimSpaceSharedHypervisor(interpreter, null, null)
+ val engine = FlowEngine(coroutineContext, clock)
+ val machine = SimBareMetalMachine(engine, machineModel, SimplePowerDriver(ConstantPowerModel(0.0)))
+ val hypervisor = SimHypervisor(engine, FlowMultiplexerFactory.forwardingMultiplexer(), SplittableRandom(1), null)
launch { machine.runWorkload(hypervisor) }
yield()