summaryrefslogtreecommitdiff
path: root/opendc-simulator/opendc-simulator-compute/src/test
diff options
context:
space:
mode:
authorFabian Mastenbroek <mail.fabianm@gmail.com>2022-10-28 11:55:41 +0200
committerFabian Mastenbroek <mail.fabianm@gmail.com>2022-10-28 12:03:39 +0200
commit788c007599ac61a41460589f65454aac1857eb81 (patch)
tree3d2cc6cb9f72be84c89e8dc154f10f3b828d58f4 /opendc-simulator/opendc-simulator-compute/src/test
parent3528091684f610d80fcebb5b730d3a201e79a99a (diff)
refactor(sim/compute): Provide workload constructors in SimWorkloads
This change introduces a new class SimWorkloads which provides construction methods for the standard workloads available in OpenDC.
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.kt14
-rw-r--r--opendc-simulator/opendc-simulator-compute/src/test/kotlin/org/opendc/simulator/compute/kernel/SimSpaceSharedHypervisorTest.kt13
2 files changed, 13 insertions, 14 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 f0aae15b..266839bd 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
@@ -40,9 +40,9 @@ import org.opendc.simulator.compute.model.ProcessingNode
import org.opendc.simulator.compute.model.ProcessingUnit
import org.opendc.simulator.compute.model.StorageDevice
import org.opendc.simulator.compute.power.CpuPowerModels
-import org.opendc.simulator.compute.workload.SimFlopsWorkload
import org.opendc.simulator.compute.workload.SimTrace
import org.opendc.simulator.compute.workload.SimWorkload
+import org.opendc.simulator.compute.workload.SimWorkloads
import org.opendc.simulator.flow2.FlowEngine
import org.opendc.simulator.flow2.source.SimpleFlowSource
import org.opendc.simulator.kotlin.runSimulation
@@ -78,7 +78,7 @@ class SimMachineTest {
machineModel
)
- machine.runWorkload(SimFlopsWorkload(2_000, /*utilization*/ 1.0))
+ machine.runWorkload(SimWorkloads.flops(2_000, /*utilization*/ 1.0))
// Two cores execute 1000 MFlOps per second (1000 ms)
assertEquals(1000, clock.millis())
@@ -123,7 +123,7 @@ class SimMachineTest {
machineModel
)
- machine.runWorkload(SimFlopsWorkload(2_000, /*utilization*/ 1.0))
+ machine.runWorkload(SimWorkloads.flops(2_000, /*utilization*/ 1.0))
// Two sockets with two cores execute 2000 MFlOps per second (500 ms)
assertEquals(500, clock.millis())
@@ -142,7 +142,7 @@ class SimMachineTest {
source.connect(machine.psu)
coroutineScope {
- launch { machine.runWorkload(SimFlopsWorkload(2_000, /*utilization*/ 1.0)) }
+ launch { machine.runWorkload(SimWorkloads.flops(2_000, /*utilization*/ 1.0)) }
yield()
assertAll(
@@ -304,7 +304,7 @@ class SimMachineTest {
try {
coroutineScope {
- launch { machine.runWorkload(SimFlopsWorkload(2_000, /*utilization*/ 1.0)) }
+ launch { machine.runWorkload(SimWorkloads.flops(2_000, /*utilization*/ 1.0)) }
cancel()
}
} catch (_: CancellationException) {
@@ -326,11 +326,11 @@ class SimMachineTest {
coroutineScope {
launch {
- machine.runWorkload(SimFlopsWorkload(2_000, /*utilization*/ 1.0))
+ machine.runWorkload(SimWorkloads.flops(2_000, /*utilization*/ 1.0))
}
assertThrows<IllegalStateException> {
- machine.runWorkload(SimFlopsWorkload(2_000, /*utilization*/ 1.0))
+ machine.runWorkload(SimWorkloads.flops(2_000, /*utilization*/ 1.0))
}
}
}
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 ba5a5c68..d11b91ee 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
@@ -38,10 +38,9 @@ import org.opendc.simulator.compute.model.MemoryUnit
import org.opendc.simulator.compute.model.ProcessingNode
import org.opendc.simulator.compute.model.ProcessingUnit
import org.opendc.simulator.compute.runWorkload
-import org.opendc.simulator.compute.workload.SimFlopsWorkload
-import org.opendc.simulator.compute.workload.SimRuntimeWorkload
import org.opendc.simulator.compute.workload.SimTrace
import org.opendc.simulator.compute.workload.SimTraceFragment
+import org.opendc.simulator.compute.workload.SimWorkloads
import org.opendc.simulator.flow2.FlowEngine
import org.opendc.simulator.flow2.mux.FlowMultiplexerFactory
import org.opendc.simulator.kotlin.runSimulation
@@ -99,7 +98,7 @@ internal class SimSpaceSharedHypervisorTest {
@Test
fun testRuntimeWorkload() = runSimulation {
val duration = 5 * 60L * 1000
- val workload = SimRuntimeWorkload(duration, 1.0)
+ val workload = SimWorkloads.runtime(duration, 1.0)
val engine = FlowEngine.create(coroutineContext, clock)
val graph = engine.newGraph()
@@ -123,7 +122,7 @@ internal class SimSpaceSharedHypervisorTest {
@Test
fun testFlopsWorkload() = runSimulation {
val duration = 5 * 60L * 1000
- val workload = SimFlopsWorkload((duration * 3.2).toLong(), 1.0)
+ val workload = SimWorkloads.flops((duration * 3.2).toLong(), 1.0)
val engine = FlowEngine.create(coroutineContext, clock)
val graph = engine.newGraph()
@@ -155,13 +154,13 @@ internal class SimSpaceSharedHypervisorTest {
yield()
val vm = hypervisor.newMachine(machineModel)
- vm.runWorkload(SimRuntimeWorkload(duration, 1.0))
+ vm.runWorkload(SimWorkloads.runtime(duration, 1.0))
hypervisor.removeMachine(vm)
yield()
val vm2 = hypervisor.newMachine(machineModel)
- vm2.runWorkload(SimRuntimeWorkload(duration, 1.0))
+ vm2.runWorkload(SimWorkloads.runtime(duration, 1.0))
hypervisor.removeMachine(vm2)
machine.cancel()
@@ -184,7 +183,7 @@ internal class SimSpaceSharedHypervisorTest {
yield()
val vm = hypervisor.newMachine(machineModel)
- launch { vm.runWorkload(SimFlopsWorkload(10_000, 1.0)) }
+ launch { vm.runWorkload(SimWorkloads.runtime(10_000, 1.0)) }
yield()
assertAll(