summaryrefslogtreecommitdiff
path: root/opendc-simulator/opendc-simulator-compute/src/test
diff options
context:
space:
mode:
authorFabian Mastenbroek <mail.fabianm@gmail.com>2021-06-24 12:54:52 +0200
committerFabian Mastenbroek <mail.fabianm@gmail.com>2021-06-24 13:43:34 +0200
commite56967a29ac2b2d26cc085b1f3e27096dad6a170 (patch)
tree67c09fa437bc9b1f37f23b80b970b6aa686ad818 /opendc-simulator/opendc-simulator-compute/src/test
parentbe34a55c2c2fe94a6883c6b97d2abe4c43288e8a (diff)
simulator: Re-implement performance interference model
This change updates reimplements the performance interference model to work on top of the universal resource model in `opendc-simulator-resources`. This enables us to model interference and performance variability of other resources such as disk or network in the future.
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/SimMachineTest.kt12
-rw-r--r--opendc-simulator/opendc-simulator-compute/src/test/kotlin/org/opendc/simulator/compute/kernel/SimHypervisorTest.kt61
2 files changed, 67 insertions, 6 deletions
diff --git a/opendc-simulator/opendc-simulator-compute/src/test/kotlin/org/opendc/simulator/compute/SimMachineTest.kt b/opendc-simulator/opendc-simulator-compute/src/test/kotlin/org/opendc/simulator/compute/SimMachineTest.kt
index 892d5223..a6d955ca 100644
--- a/opendc-simulator/opendc-simulator-compute/src/test/kotlin/org/opendc/simulator/compute/SimMachineTest.kt
+++ b/opendc-simulator/opendc-simulator-compute/src/test/kotlin/org/opendc/simulator/compute/SimMachineTest.kt
@@ -24,12 +24,9 @@ package org.opendc.simulator.compute
import kotlinx.coroutines.*
import kotlinx.coroutines.flow.toList
+import org.junit.jupiter.api.*
import org.junit.jupiter.api.Assertions.assertArrayEquals
import org.junit.jupiter.api.Assertions.assertEquals
-import org.junit.jupiter.api.BeforeEach
-import org.junit.jupiter.api.Test
-import org.junit.jupiter.api.assertDoesNotThrow
-import org.junit.jupiter.api.assertThrows
import org.opendc.simulator.compute.device.SimNetworkAdapter
import org.opendc.simulator.compute.model.*
import org.opendc.simulator.compute.power.ConstantPowerModel
@@ -157,8 +154,10 @@ class SimMachineTest {
try {
coroutineScope {
launch { machine.run(SimFlopsWorkload(2_000, utilization = 1.0)) }
- assertEquals(100.0, machine.psu.powerDraw)
- assertEquals(100.0, source.powerDraw)
+ assertAll(
+ { assertEquals(100.0, machine.psu.powerDraw) },
+ { assertEquals(100.0, source.powerDraw) }
+ )
}
} finally {
machine.close()
@@ -284,6 +283,7 @@ class SimMachineTest {
}
}
+ @Test
fun testDiskWriteUsage() = runBlockingSimulation {
val interpreter = SimResourceInterpreter(coroutineContext, clock)
val machine = SimBareMetalMachine(
diff --git a/opendc-simulator/opendc-simulator-compute/src/test/kotlin/org/opendc/simulator/compute/kernel/SimHypervisorTest.kt b/opendc-simulator/opendc-simulator-compute/src/test/kotlin/org/opendc/simulator/compute/kernel/SimHypervisorTest.kt
index 71d48a31..a61cba8d 100644
--- a/opendc-simulator/opendc-simulator-compute/src/test/kotlin/org/opendc/simulator/compute/kernel/SimHypervisorTest.kt
+++ b/opendc-simulator/opendc-simulator-compute/src/test/kotlin/org/opendc/simulator/compute/kernel/SimHypervisorTest.kt
@@ -34,6 +34,8 @@ import org.junit.jupiter.api.assertAll
import org.junit.jupiter.api.assertDoesNotThrow
import org.opendc.simulator.compute.SimBareMetalMachine
import org.opendc.simulator.compute.kernel.cpufreq.PerformanceScalingGovernor
+import org.opendc.simulator.compute.kernel.interference.VmInterferenceGroup
+import org.opendc.simulator.compute.kernel.interference.VmInterferenceModel
import org.opendc.simulator.compute.model.MachineModel
import org.opendc.simulator.compute.model.MemoryUnit
import org.opendc.simulator.compute.model.ProcessingNode
@@ -223,4 +225,63 @@ internal class SimHypervisorTest {
machine.close()
}
+
+ @Test
+ fun testInterference() = runBlockingSimulation {
+ val cpuNode = ProcessingNode("Intel", "Xeon", "amd64", 2)
+ val model = MachineModel(
+ cpus = List(cpuNode.coreCount) { ProcessingUnit(cpuNode, it, 3200.0) },
+ memory = List(4) { MemoryUnit("Crucial", "MTA18ASF4G72AZ-3G2B1", 3200.0, 32_000) }
+ )
+
+ val groups = listOf(
+ VmInterferenceGroup(targetLoad = 0.0, score = 0.9, members = setOf("a", "b")),
+ VmInterferenceGroup(targetLoad = 0.0, score = 0.6, members = setOf("a", "c")),
+ VmInterferenceGroup(targetLoad = 0.1, score = 0.8, members = setOf("a", "n"))
+ )
+ val interferenceModel = VmInterferenceModel(groups)
+
+ val platform = SimResourceInterpreter(coroutineContext, clock)
+ val machine = SimBareMetalMachine(
+ platform, model, SimplePowerDriver(ConstantPowerModel(0.0))
+ )
+ val hypervisor = SimFairShareHypervisor(platform, interferenceDomain = interferenceModel.newDomain())
+
+ val duration = 5 * 60L
+ val workloadA =
+ SimTraceWorkload(
+ sequenceOf(
+ SimTraceWorkload.Fragment(duration * 1000, 0.0, 1),
+ SimTraceWorkload.Fragment(duration * 1000, 28.0, 1),
+ SimTraceWorkload.Fragment(duration * 1000, 3500.0, 1),
+ SimTraceWorkload.Fragment(duration * 1000, 183.0, 1)
+ ),
+ )
+ val workloadB =
+ SimTraceWorkload(
+ sequenceOf(
+ SimTraceWorkload.Fragment(duration * 1000, 0.0, 1),
+ SimTraceWorkload.Fragment(duration * 1000, 28.0, 1),
+ SimTraceWorkload.Fragment(duration * 1000, 3100.0, 1),
+ SimTraceWorkload.Fragment(duration * 1000, 73.0, 1)
+ )
+ )
+
+ launch {
+ machine.run(hypervisor)
+ }
+
+ coroutineScope {
+ launch {
+ val vm = hypervisor.createMachine(model, "a")
+ vm.run(workloadA)
+ vm.close()
+ }
+ val vm = hypervisor.createMachine(model, "b")
+ vm.run(workloadB)
+ vm.close()
+ }
+
+ machine.close()
+ }
}