summaryrefslogtreecommitdiff
path: root/opendc-simulator
diff options
context:
space:
mode:
authorFabian Mastenbroek <mail.fabianm@gmail.com>2022-10-05 14:10:11 +0200
committerFabian Mastenbroek <mail.fabianm@gmail.com>2022-10-05 14:10:11 +0200
commitbe176910eb870209576326ffaad8bf21241fccbd (patch)
tree3903d8aed5e87850c92e1b2dce8379ea99bdfa6d /opendc-simulator
parentc214a7fe0d46ecc23a71f9237b20281c0ca1c929 (diff)
refactor(sim/core): Rename runBlockingSimulation to runSimulation
This change renames the method `runBlockingSimulation` to `runSimulation` to put more emphasis on the simulation part of the method. The blocking part is not that important, but this behavior is still described in the method documentation.
Diffstat (limited to 'opendc-simulator')
-rw-r--r--opendc-simulator/opendc-simulator-compute/src/jmh/kotlin/org/opendc/simulator/compute/SimMachineBenchmarks.kt16
-rw-r--r--opendc-simulator/opendc-simulator-compute/src/test/kotlin/org/opendc/simulator/compute/SimMachineTest.kt24
-rw-r--r--opendc-simulator/opendc-simulator-compute/src/test/kotlin/org/opendc/simulator/compute/device/SimPsuTest.kt6
-rw-r--r--opendc-simulator/opendc-simulator-compute/src/test/kotlin/org/opendc/simulator/compute/kernel/SimFairShareHypervisorTest.kt10
-rw-r--r--opendc-simulator/opendc-simulator-compute/src/test/kotlin/org/opendc/simulator/compute/kernel/SimSpaceSharedHypervisorTest.kt14
-rw-r--r--opendc-simulator/opendc-simulator-compute/src/test/kotlin/org/opendc/simulator/compute/workload/SimTraceWorkloadTest.kt10
-rw-r--r--opendc-simulator/opendc-simulator-core/src/main/kotlin/org/opendc/simulator/kotlin/SimulationBuilders.kt38
-rw-r--r--opendc-simulator/opendc-simulator-flow/src/jmh/kotlin/org/opendc/simulator/flow/FlowBenchmarks.kt22
-rw-r--r--opendc-simulator/opendc-simulator-flow/src/test/kotlin/org/opendc/simulator/flow/FlowConsumerContextTest.kt8
-rw-r--r--opendc-simulator/opendc-simulator-flow/src/test/kotlin/org/opendc/simulator/flow/FlowForwarderTest.kt28
-rw-r--r--opendc-simulator/opendc-simulator-flow/src/test/kotlin/org/opendc/simulator/flow/FlowSinkTest.kt22
-rw-r--r--opendc-simulator/opendc-simulator-flow/src/test/kotlin/org/opendc/simulator/flow/mux/ForwardingFlowMultiplexerTest.kt10
-rw-r--r--opendc-simulator/opendc-simulator-flow/src/test/kotlin/org/opendc/simulator/flow/mux/MaxMinFlowMultiplexerTest.kt8
-rw-r--r--opendc-simulator/opendc-simulator-flow/src/test/kotlin/org/opendc/simulator/flow/source/FixedFlowSourceTest.kt6
-rw-r--r--opendc-simulator/opendc-simulator-network/src/test/kotlin/org/opendc/simulator/network/SimNetworkSinkTest.kt16
-rw-r--r--opendc-simulator/opendc-simulator-network/src/test/kotlin/org/opendc/simulator/network/SimNetworkSwitchVirtualTest.kt6
-rw-r--r--opendc-simulator/opendc-simulator-power/src/test/kotlin/org/opendc/simulator/power/SimPduTest.kt14
-rw-r--r--opendc-simulator/opendc-simulator-power/src/test/kotlin/org/opendc/simulator/power/SimPowerSourceTest.kt16
-rw-r--r--opendc-simulator/opendc-simulator-power/src/test/kotlin/org/opendc/simulator/power/SimUpsTest.kt10
19 files changed, 153 insertions, 131 deletions
diff --git a/opendc-simulator/opendc-simulator-compute/src/jmh/kotlin/org/opendc/simulator/compute/SimMachineBenchmarks.kt b/opendc-simulator/opendc-simulator-compute/src/jmh/kotlin/org/opendc/simulator/compute/SimMachineBenchmarks.kt
index a2dc9a0f..b319a677 100644
--- a/opendc-simulator/opendc-simulator-compute/src/jmh/kotlin/org/opendc/simulator/compute/SimMachineBenchmarks.kt
+++ b/opendc-simulator/opendc-simulator-compute/src/jmh/kotlin/org/opendc/simulator/compute/SimMachineBenchmarks.kt
@@ -35,7 +35,7 @@ import org.opendc.simulator.compute.workload.SimTrace
import org.opendc.simulator.compute.workload.SimTraceWorkload
import org.opendc.simulator.flow.FlowEngine
import org.opendc.simulator.flow.mux.FlowMultiplexerFactory
-import org.opendc.simulator.kotlin.runBlockingSimulation
+import org.opendc.simulator.kotlin.runSimulation
import org.openjdk.jmh.annotations.*
import java.util.SplittableRandom
import java.util.concurrent.ThreadLocalRandom
@@ -70,18 +70,18 @@ class SimMachineBenchmarks {
@Benchmark
fun benchmarkBareMetal() {
- return runBlockingSimulation {
+ return runSimulation {
val engine = FlowEngine(coroutineContext, clock)
val machine = SimBareMetalMachine(
engine, machineModel, SimplePowerDriver(ConstantPowerModel(0.0))
)
- return@runBlockingSimulation machine.runWorkload(SimTraceWorkload(trace))
+ return@runSimulation machine.runWorkload(SimTraceWorkload(trace))
}
}
@Benchmark
fun benchmarkSpaceSharedHypervisor() {
- return runBlockingSimulation {
+ return runSimulation {
val engine = FlowEngine(coroutineContext, clock)
val machine = SimBareMetalMachine(engine, machineModel, SimplePowerDriver(ConstantPowerModel(0.0)))
val hypervisor = SimHypervisor(engine, FlowMultiplexerFactory.forwardingMultiplexer(), SplittableRandom(1), null)
@@ -91,7 +91,7 @@ class SimMachineBenchmarks {
val vm = hypervisor.newMachine(machineModel)
try {
- return@runBlockingSimulation vm.runWorkload(SimTraceWorkload(trace))
+ return@runSimulation vm.runWorkload(SimTraceWorkload(trace))
} finally {
vm.cancel()
machine.cancel()
@@ -101,7 +101,7 @@ class SimMachineBenchmarks {
@Benchmark
fun benchmarkFairShareHypervisorSingle() {
- return runBlockingSimulation {
+ return runSimulation {
val engine = FlowEngine(coroutineContext, clock)
val machine = SimBareMetalMachine(engine, machineModel, SimplePowerDriver(ConstantPowerModel(0.0)))
val hypervisor = SimHypervisor(engine, FlowMultiplexerFactory.maxMinMultiplexer(), SplittableRandom(1), null)
@@ -111,7 +111,7 @@ class SimMachineBenchmarks {
val vm = hypervisor.newMachine(machineModel)
try {
- return@runBlockingSimulation vm.runWorkload(SimTraceWorkload(trace))
+ return@runSimulation vm.runWorkload(SimTraceWorkload(trace))
} finally {
vm.cancel()
machine.cancel()
@@ -121,7 +121,7 @@ class SimMachineBenchmarks {
@Benchmark
fun benchmarkFairShareHypervisorDouble() {
- return runBlockingSimulation {
+ return runSimulation {
val engine = FlowEngine(coroutineContext, clock)
val machine = SimBareMetalMachine(engine, machineModel, SimplePowerDriver(ConstantPowerModel(0.0)))
val hypervisor = SimHypervisor(engine, FlowMultiplexerFactory.maxMinMultiplexer(), SplittableRandom(1), null)
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 b0175917..b7af6803 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
@@ -35,7 +35,7 @@ import org.opendc.simulator.compute.workload.SimWorkload
import org.opendc.simulator.compute.workload.SimWorkloadLifecycle
import org.opendc.simulator.flow.FlowEngine
import org.opendc.simulator.flow.source.FixedFlowSource
-import org.opendc.simulator.kotlin.runBlockingSimulation
+import org.opendc.simulator.kotlin.runSimulation
import org.opendc.simulator.network.SimNetworkSink
import org.opendc.simulator.power.SimPowerSource
@@ -58,7 +58,7 @@ class SimMachineTest {
}
@Test
- fun testFlopsWorkload() = runBlockingSimulation {
+ fun testFlopsWorkload() = runSimulation {
val machine = SimBareMetalMachine(
FlowEngine(coroutineContext, clock),
machineModel,
@@ -72,7 +72,7 @@ class SimMachineTest {
}
@Test
- fun testDualSocketMachine() = runBlockingSimulation {
+ fun testDualSocketMachine() = runSimulation {
val cpuNode = machineModel.cpus[0].node
val machineModel = MachineModel(
cpus = List(cpuNode.coreCount * 2) { ProcessingUnit(cpuNode, it % 2, 1000.0) },
@@ -91,7 +91,7 @@ class SimMachineTest {
}
@Test
- fun testPower() = runBlockingSimulation {
+ fun testPower() = runSimulation {
val engine = FlowEngine(coroutineContext, clock)
val machine = SimBareMetalMachine(
engine,
@@ -111,7 +111,7 @@ class SimMachineTest {
}
@Test
- fun testCapacityClamp() = runBlockingSimulation {
+ fun testCapacityClamp() = runSimulation {
val machine = SimBareMetalMachine(
FlowEngine(coroutineContext, clock),
machineModel,
@@ -135,7 +135,7 @@ class SimMachineTest {
}
@Test
- fun testMemory() = runBlockingSimulation {
+ fun testMemory() = runSimulation {
val machine = SimBareMetalMachine(
FlowEngine(coroutineContext, clock),
machineModel,
@@ -153,7 +153,7 @@ class SimMachineTest {
}
@Test
- fun testMemoryUsage() = runBlockingSimulation {
+ fun testMemoryUsage() = runSimulation {
val machine = SimBareMetalMachine(
FlowEngine(coroutineContext, clock),
machineModel,
@@ -173,7 +173,7 @@ class SimMachineTest {
}
@Test
- fun testNetUsage() = runBlockingSimulation {
+ fun testNetUsage() = runSimulation {
val engine = FlowEngine(coroutineContext, clock)
val machine = SimBareMetalMachine(
engine,
@@ -198,7 +198,7 @@ class SimMachineTest {
}
@Test
- fun testDiskReadUsage() = runBlockingSimulation {
+ fun testDiskReadUsage() = runSimulation {
val engine = FlowEngine(coroutineContext, clock)
val machine = SimBareMetalMachine(
engine,
@@ -220,7 +220,7 @@ class SimMachineTest {
}
@Test
- fun testDiskWriteUsage() = runBlockingSimulation {
+ fun testDiskWriteUsage() = runSimulation {
val engine = FlowEngine(coroutineContext, clock)
val machine = SimBareMetalMachine(
engine,
@@ -242,7 +242,7 @@ class SimMachineTest {
}
@Test
- fun testCancellation() = runBlockingSimulation {
+ fun testCancellation() = runSimulation {
val machine = SimBareMetalMachine(
FlowEngine(coroutineContext, clock),
machineModel,
@@ -262,7 +262,7 @@ class SimMachineTest {
}
@Test
- fun testConcurrentRuns() = runBlockingSimulation {
+ fun testConcurrentRuns() = runSimulation {
val machine = SimBareMetalMachine(
FlowEngine(coroutineContext, clock),
machineModel,
diff --git a/opendc-simulator/opendc-simulator-compute/src/test/kotlin/org/opendc/simulator/compute/device/SimPsuTest.kt b/opendc-simulator/opendc-simulator-compute/src/test/kotlin/org/opendc/simulator/compute/device/SimPsuTest.kt
index 82ceeecd..5481cad2 100644
--- a/opendc-simulator/opendc-simulator-compute/src/test/kotlin/org/opendc/simulator/compute/device/SimPsuTest.kt
+++ b/opendc-simulator/opendc-simulator-compute/src/test/kotlin/org/opendc/simulator/compute/device/SimPsuTest.kt
@@ -29,7 +29,7 @@ import org.junit.jupiter.api.Test
import org.junit.jupiter.api.assertThrows
import org.opendc.simulator.compute.power.PowerDriver
import org.opendc.simulator.flow.FlowEngine
-import org.opendc.simulator.kotlin.runBlockingSimulation
+import org.opendc.simulator.kotlin.runSimulation
import org.opendc.simulator.power.SimPowerSource
/**
@@ -51,7 +51,7 @@ internal class SimPsuTest {
}
@Test
- fun testPsuIdle() = runBlockingSimulation {
+ fun testPsuIdle() = runSimulation {
val ratedOutputPower = 240.0
val energyEfficiency = mapOf(0.0 to 1.0)
@@ -69,7 +69,7 @@ internal class SimPsuTest {
}
@Test
- fun testPsuPowerLoss() = runBlockingSimulation {
+ fun testPsuPowerLoss() = runSimulation {
val ratedOutputPower = 240.0
// Efficiency of 80 Plus Titanium PSU
val energyEfficiency = sortedMapOf(
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 35e14864..aae8d139 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,7 +43,7 @@ import org.opendc.simulator.compute.workload.SimTraceFragment
import org.opendc.simulator.compute.workload.SimTraceWorkload
import org.opendc.simulator.flow.FlowEngine
import org.opendc.simulator.flow.mux.FlowMultiplexerFactory
-import org.opendc.simulator.kotlin.runBlockingSimulation
+import org.opendc.simulator.kotlin.runSimulation
import java.util.*
/**
@@ -65,7 +65,7 @@ internal class SimFairShareHypervisorTest {
* Test overcommitting of resources via the hypervisor with a single VM.
*/
@Test
- fun testOvercommittedSingle() = runBlockingSimulation {
+ fun testOvercommittedSingle() = runSimulation {
val duration = 5 * 60L
val workloadA =
SimTraceWorkload(
@@ -105,7 +105,7 @@ internal class SimFairShareHypervisorTest {
* Test overcommitting of resources via the hypervisor with two VMs.
*/
@Test
- fun testOvercommittedDual() = runBlockingSimulation {
+ fun testOvercommittedDual() = runSimulation {
val duration = 5 * 60L
val workloadA =
SimTraceWorkload(
@@ -158,7 +158,7 @@ internal class SimFairShareHypervisorTest {
}
@Test
- fun testMultipleCPUs() = runBlockingSimulation {
+ fun testMultipleCPUs() = runSimulation {
val cpuNode = ProcessingNode("Intel", "Xeon", "amd64", 2)
val model = MachineModel(
cpus = List(cpuNode.coreCount) { ProcessingUnit(cpuNode, it, 3200.0) },
@@ -179,7 +179,7 @@ internal class SimFairShareHypervisorTest {
}
@Test
- fun testInterference() = runBlockingSimulation {
+ fun testInterference() = runSimulation {
val cpuNode = ProcessingNode("Intel", "Xeon", "amd64", 2)
val model = MachineModel(
cpus = List(cpuNode.coreCount) { ProcessingUnit(cpuNode, it, 3200.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 96eabf5c..664bb2da 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
@@ -39,7 +39,7 @@ import org.opendc.simulator.compute.runWorkload
import org.opendc.simulator.compute.workload.*
import org.opendc.simulator.flow.FlowEngine
import org.opendc.simulator.flow.mux.FlowMultiplexerFactory
-import org.opendc.simulator.kotlin.runBlockingSimulation
+import org.opendc.simulator.kotlin.runSimulation
import java.util.*
/**
@@ -61,7 +61,7 @@ internal class SimSpaceSharedHypervisorTest {
* Test a trace workload.
*/
@Test
- fun testTrace() = runBlockingSimulation {
+ fun testTrace() = runSimulation {
val duration = 5 * 60L
val workloadA =
SimTraceWorkload(
@@ -92,7 +92,7 @@ internal class SimSpaceSharedHypervisorTest {
* Test runtime workload on hypervisor.
*/
@Test
- fun testRuntimeWorkload() = runBlockingSimulation {
+ fun testRuntimeWorkload() = runSimulation {
val duration = 5 * 60L * 1000
val workload = SimRuntimeWorkload(duration)
val engine = FlowEngine(coroutineContext, clock)
@@ -114,7 +114,7 @@ internal class SimSpaceSharedHypervisorTest {
* Test FLOPs workload on hypervisor.
*/
@Test
- fun testFlopsWorkload() = runBlockingSimulation {
+ fun testFlopsWorkload() = runSimulation {
val duration = 5 * 60L * 1000
val workload = SimFlopsWorkload((duration * 3.2).toLong(), 1.0)
val engine = FlowEngine(coroutineContext, clock)
@@ -134,7 +134,7 @@ internal class SimSpaceSharedHypervisorTest {
* Test two workloads running sequentially.
*/
@Test
- fun testTwoWorkloads() = runBlockingSimulation {
+ fun testTwoWorkloads() = runSimulation {
val duration = 5 * 60L * 1000
val engine = FlowEngine(coroutineContext, clock)
val machine = SimBareMetalMachine(engine, machineModel, SimplePowerDriver(ConstantPowerModel(0.0)))
@@ -162,7 +162,7 @@ internal class SimSpaceSharedHypervisorTest {
* Test concurrent workloads on the machine.
*/
@Test
- fun testConcurrentWorkloadFails() = runBlockingSimulation {
+ fun testConcurrentWorkloadFails() = runSimulation {
val engine = FlowEngine(coroutineContext, clock)
val machine = SimBareMetalMachine(engine, machineModel, SimplePowerDriver(ConstantPowerModel(0.0)))
val hypervisor = SimHypervisor(engine, FlowMultiplexerFactory.forwardingMultiplexer(), SplittableRandom(1), null)
@@ -184,7 +184,7 @@ internal class SimSpaceSharedHypervisorTest {
* Test concurrent workloads on the machine.
*/
@Test
- fun testConcurrentWorkloadSucceeds() = runBlockingSimulation {
+ fun testConcurrentWorkloadSucceeds() = runSimulation {
val engine = FlowEngine(coroutineContext, clock)
val machine = SimBareMetalMachine(engine, machineModel, SimplePowerDriver(ConstantPowerModel(0.0)))
val hypervisor = SimHypervisor(engine, FlowMultiplexerFactory.forwardingMultiplexer(), SplittableRandom(1), null)
diff --git a/opendc-simulator/opendc-simulator-compute/src/test/kotlin/org/opendc/simulator/compute/workload/SimTraceWorkloadTest.kt b/opendc-simulator/opendc-simulator-compute/src/test/kotlin/org/opendc/simulator/compute/workload/SimTraceWorkloadTest.kt
index bf4e7622..70aea3f4 100644
--- a/opendc-simulator/opendc-simulator-compute/src/test/kotlin/org/opendc/simulator/compute/workload/SimTraceWorkloadTest.kt
+++ b/opendc-simulator/opendc-simulator-compute/src/test/kotlin/org/opendc/simulator/compute/workload/SimTraceWorkloadTest.kt
@@ -32,7 +32,7 @@ import org.opendc.simulator.compute.power.ConstantPowerModel
import org.opendc.simulator.compute.power.SimplePowerDriver
import org.opendc.simulator.compute.runWorkload
import org.opendc.simulator.flow.FlowEngine
-import org.opendc.simulator.kotlin.runBlockingSimulation
+import org.opendc.simulator.kotlin.runSimulation
/**
* Test suite for the [SimTraceWorkloadTest] class.
@@ -51,7 +51,7 @@ class SimTraceWorkloadTest {
}
@Test
- fun testSmoke() = runBlockingSimulation {
+ fun testSmoke() = runSimulation {
val machine = SimBareMetalMachine(
FlowEngine(coroutineContext, clock),
machineModel,
@@ -74,7 +74,7 @@ class SimTraceWorkloadTest {
}
@Test
- fun testOffset() = runBlockingSimulation {
+ fun testOffset() = runSimulation {
val machine = SimBareMetalMachine(
FlowEngine(coroutineContext, clock),
machineModel,
@@ -97,7 +97,7 @@ class SimTraceWorkloadTest {
}
@Test
- fun testSkipFragment() = runBlockingSimulation {
+ fun testSkipFragment() = runSimulation {
val machine = SimBareMetalMachine(
FlowEngine(coroutineContext, clock),
machineModel,
@@ -121,7 +121,7 @@ class SimTraceWorkloadTest {
}
@Test
- fun testZeroCores() = runBlockingSimulation {
+ fun testZeroCores() = runSimulation {
val machine = SimBareMetalMachine(
FlowEngine(coroutineContext, clock),
machineModel,
diff --git a/opendc-simulator/opendc-simulator-core/src/main/kotlin/org/opendc/simulator/kotlin/SimulationBuilders.kt b/opendc-simulator/opendc-simulator-core/src/main/kotlin/org/opendc/simulator/kotlin/SimulationBuilders.kt
index a291b4e2..c4cc0171 100644
--- a/opendc-simulator/opendc-simulator-core/src/main/kotlin/org/opendc/simulator/kotlin/SimulationBuilders.kt
+++ b/opendc-simulator/opendc-simulator-core/src/main/kotlin/org/opendc/simulator/kotlin/SimulationBuilders.kt
@@ -29,10 +29,32 @@ import kotlin.coroutines.CoroutineContext
import kotlin.coroutines.EmptyCoroutineContext
/**
- * Executes a [body] inside an immediate execution dispatcher.
+ * Executes [body] as a simulation in a new coroutine.
+ *
+ * This function behaves similarly to [runBlocking], with the difference that the code that it runs will skip delays.
+ * This allows to use [delay] in without causing the simulation to take more time than necessary.
+ *
+ * ```
+ * @Test
+ * fun exampleSimulation() = runSimulation {
+ * val deferred = async {
+ * delay(1_000)
+ * async {
+ * delay(1_000)
+ * }.await()
+ * }
+ *
+ * deferred.await() // result available immediately
+ * }
+ * ```
+ *
+ * The simulation is run in a single thread, unless other [CoroutineDispatcher] are used for child coroutines.
+ * Because of this, child coroutines are not executed in parallel to [body].
+ * In order for the spawned-off asynchronous code to actually be executed, one must either [yield] or suspend the
+ * body some other way, or use commands that control scheduling (see [SimulationScheduler]).
*/
@OptIn(ExperimentalCoroutinesApi::class)
-public fun runBlockingSimulation(
+public fun runSimulation(
context: CoroutineContext = EmptyCoroutineContext,
scheduler: SimulationScheduler = SimulationScheduler(),
body: suspend SimulationCoroutineScope.() -> Unit
@@ -54,16 +76,16 @@ public fun runBlockingSimulation(
}
/**
- * Convenience method for calling [runBlockingSimulation] on an existing [SimulationCoroutineScope].
+ * Convenience method for calling [runSimulation] on an existing [SimulationCoroutineScope].
*/
-public fun SimulationCoroutineScope.runBlockingSimulation(block: suspend SimulationCoroutineScope.() -> Unit): Unit =
- runBlockingSimulation(coroutineContext, scheduler, block)
+public fun SimulationCoroutineScope.runSimulation(block: suspend SimulationCoroutineScope.() -> Unit): Unit =
+ runSimulation(coroutineContext, scheduler, block)
/**
- * Convenience method for calling [runBlockingSimulation] on an existing [SimulationCoroutineDispatcher].
+ * Convenience method for calling [runSimulation] on an existing [SimulationCoroutineDispatcher].
*/
-public fun SimulationCoroutineDispatcher.runBlockingSimulation(block: suspend SimulationCoroutineScope.() -> Unit): Unit =
- runBlockingSimulation(this, scheduler, block)
+public fun SimulationCoroutineDispatcher.runSimulation(block: suspend SimulationCoroutineScope.() -> Unit): Unit =
+ runSimulation(this, scheduler, block)
private fun CoroutineContext.checkArguments(scheduler: SimulationScheduler): Pair<CoroutineContext, SimulationController> {
val dispatcher = get(ContinuationInterceptor).run {
diff --git a/opendc-simulator/opendc-simulator-flow/src/jmh/kotlin/org/opendc/simulator/flow/FlowBenchmarks.kt b/opendc-simulator/opendc-simulator-flow/src/jmh/kotlin/org/opendc/simulator/flow/FlowBenchmarks.kt
index e3cde1d2..86fbe8e4 100644
--- a/opendc-simulator/opendc-simulator-flow/src/jmh/kotlin/org/opendc/simulator/flow/FlowBenchmarks.kt
+++ b/opendc-simulator/opendc-simulator-flow/src/jmh/kotlin/org/opendc/simulator/flow/FlowBenchmarks.kt
@@ -27,7 +27,7 @@ import kotlinx.coroutines.launch
import org.opendc.simulator.flow.mux.ForwardingFlowMultiplexer
import org.opendc.simulator.flow.mux.MaxMinFlowMultiplexer
import org.opendc.simulator.flow.source.TraceFlowSource
-import org.opendc.simulator.kotlin.runBlockingSimulation
+import org.opendc.simulator.kotlin.runSimulation
import org.openjdk.jmh.annotations.*
import java.util.concurrent.ThreadLocalRandom
import java.util.concurrent.TimeUnit
@@ -49,27 +49,27 @@ class FlowBenchmarks {
@Benchmark
fun benchmarkSink() {
- return runBlockingSimulation {
+ return runSimulation {
val engine = FlowEngine(coroutineContext, clock)
val provider = FlowSink(engine, 4200.0)
- return@runBlockingSimulation provider.consume(TraceFlowSource(trace))
+ return@runSimulation provider.consume(TraceFlowSource(trace))
}
}
@Benchmark
fun benchmarkForward() {
- return runBlockingSimulation {
+ return runSimulation {
val engine = FlowEngine(coroutineContext, clock)
val provider = FlowSink(engine, 4200.0)
val forwarder = FlowForwarder(engine)
provider.startConsumer(forwarder)
- return@runBlockingSimulation forwarder.consume(TraceFlowSource(trace))
+ return@runSimulation forwarder.consume(TraceFlowSource(trace))
}
}
@Benchmark
fun benchmarkMuxMaxMinSingleSource() {
- return runBlockingSimulation {
+ return runSimulation {
val engine = FlowEngine(coroutineContext, clock)
val switch = MaxMinFlowMultiplexer(engine)
@@ -77,13 +77,13 @@ class FlowBenchmarks {
FlowSink(engine, 3000.0).startConsumer(switch.newOutput())
val provider = switch.newInput()
- return@runBlockingSimulation provider.consume(TraceFlowSource(trace))
+ return@runSimulation provider.consume(TraceFlowSource(trace))
}
}
@Benchmark
fun benchmarkMuxMaxMinTripleSource() {
- return runBlockingSimulation {
+ return runSimulation {
val engine = FlowEngine(coroutineContext, clock)
val switch = MaxMinFlowMultiplexer(engine)
@@ -101,7 +101,7 @@ class FlowBenchmarks {
@Benchmark
fun benchmarkMuxExclusiveSingleSource() {
- return runBlockingSimulation {
+ return runSimulation {
val engine = FlowEngine(coroutineContext, clock)
val switch = ForwardingFlowMultiplexer(engine)
@@ -109,13 +109,13 @@ class FlowBenchmarks {
FlowSink(engine, 3000.0).startConsumer(switch.newOutput())
val provider = switch.newInput()
- return@runBlockingSimulation provider.consume(TraceFlowSource(trace))
+ return@runSimulation provider.consume(TraceFlowSource(trace))
}
}
@Benchmark
fun benchmarkMuxExclusiveTripleSource() {
- return runBlockingSimulation {
+ return runSimulation {
val engine = FlowEngine(coroutineContext, clock)
val switch = ForwardingFlowMultiplexer(engine)
diff --git a/opendc-simulator/opendc-simulator-flow/src/test/kotlin/org/opendc/simulator/flow/FlowConsumerContextTest.kt b/opendc-simulator/opendc-simulator-flow/src/test/kotlin/org/opendc/simulator/flow/FlowConsumerContextTest.kt
index 220b247f..d782d036 100644
--- a/opendc-simulator/opendc-simulator-flow/src/test/kotlin/org/opendc/simulator/flow/FlowConsumerContextTest.kt
+++ b/opendc-simulator/opendc-simulator-flow/src/test/kotlin/org/opendc/simulator/flow/FlowConsumerContextTest.kt
@@ -26,14 +26,14 @@ import io.mockk.*
import org.junit.jupiter.api.*
import org.opendc.simulator.flow.internal.FlowConsumerContextImpl
import org.opendc.simulator.flow.internal.FlowEngineImpl
-import org.opendc.simulator.kotlin.runBlockingSimulation
+import org.opendc.simulator.kotlin.runSimulation
/**
* A test suite for the [FlowConsumerContextImpl] class.
*/
class FlowConsumerContextTest {
@Test
- fun testFlushWithoutCommand() = runBlockingSimulation {
+ fun testFlushWithoutCommand() = runSimulation {
val engine = FlowEngineImpl(coroutineContext, clock)
val consumer = object : FlowSource {
override fun onPull(conn: FlowConnection, now: Long): Long {
@@ -54,7 +54,7 @@ class FlowConsumerContextTest {
}
@Test
- fun testDoubleStart() = runBlockingSimulation {
+ fun testDoubleStart() = runSimulation {
val engine = FlowEngineImpl(coroutineContext, clock)
val consumer = object : FlowSource {
override fun onPull(conn: FlowConnection, now: Long): Long {
@@ -79,7 +79,7 @@ class FlowConsumerContextTest {
}
@Test
- fun testIdempotentCapacityChange() = runBlockingSimulation {
+ fun testIdempotentCapacityChange() = runSimulation {
val engine = FlowEngineImpl(coroutineContext, clock)
val consumer = spyk(object : FlowSource {
override fun onPull(conn: FlowConnection, now: Long): Long {
diff --git a/opendc-simulator/opendc-simulator-flow/src/test/kotlin/org/opendc/simulator/flow/FlowForwarderTest.kt b/opendc-simulator/opendc-simulator-flow/src/test/kotlin/org/opendc/simulator/flow/FlowForwarderTest.kt
index cd183ae2..2025dd52 100644
--- a/opendc-simulator/opendc-simulator-flow/src/test/kotlin/org/opendc/simulator/flow/FlowForwarderTest.kt
+++ b/opendc-simulator/opendc-simulator-flow/src/test/kotlin/org/opendc/simulator/flow/FlowForwarderTest.kt
@@ -30,14 +30,14 @@ import org.junit.jupiter.api.Test
import org.junit.jupiter.api.assertThrows
import org.opendc.simulator.flow.internal.FlowEngineImpl
import org.opendc.simulator.flow.source.FixedFlowSource
-import org.opendc.simulator.kotlin.runBlockingSimulation
+import org.opendc.simulator.kotlin.runSimulation
/**
* A test suite for the [FlowForwarder] class.
*/
internal class FlowForwarderTest {
@Test
- fun testCancelImmediately() = runBlockingSimulation {
+ fun testCancelImmediately() = runSimulation {
val engine = FlowEngineImpl(coroutineContext, clock)
val forwarder = FlowForwarder(engine)
val source = FlowSink(engine, 2000.0)
@@ -56,7 +56,7 @@ internal class FlowForwarderTest {
}
@Test
- fun testCancel() = runBlockingSimulation {
+ fun testCancel() = runSimulation {
val engine = FlowEngineImpl(coroutineContext, clock)
val forwarder = FlowForwarder(engine)
val source = FlowSink(engine, 2000.0)
@@ -83,7 +83,7 @@ internal class FlowForwarderTest {
}
@Test
- fun testState() = runBlockingSimulation {
+ fun testState() = runSimulation {
val engine = FlowEngineImpl(coroutineContext, clock)
val forwarder = FlowForwarder(engine)
val consumer = object : FlowSource {
@@ -108,7 +108,7 @@ internal class FlowForwarderTest {
}
@Test
- fun testCancelPendingDelegate() = runBlockingSimulation {
+ fun testCancelPendingDelegate() = runSimulation {
val engine = FlowEngineImpl(coroutineContext, clock)
val forwarder = FlowForwarder(engine)
@@ -126,7 +126,7 @@ internal class FlowForwarderTest {
}
@Test
- fun testCancelStartedDelegate() = runBlockingSimulation {
+ fun testCancelStartedDelegate() = runSimulation {
val engine = FlowEngineImpl(coroutineContext, clock)
val forwarder = FlowForwarder(engine)
val source = FlowSink(engine, 2000.0)
@@ -144,7 +144,7 @@ internal class FlowForwarderTest {
}
@Test
- fun testCancelPropagation() = runBlockingSimulation {
+ fun testCancelPropagation() = runSimulation {
val engine = FlowEngineImpl(coroutineContext, clock)
val forwarder = FlowForwarder(engine)
val source = FlowSink(engine, 2000.0)
@@ -162,7 +162,7 @@ internal class FlowForwarderTest {
}
@Test
- fun testExitPropagation() = runBlockingSimulation {
+ fun testExitPropagation() = runSimulation {
val engine = FlowEngineImpl(coroutineContext, clock)
val forwarder = FlowForwarder(engine, isCoupled = true)
val source = FlowSink(engine, 2000.0)
@@ -183,7 +183,7 @@ internal class FlowForwarderTest {
@Test
@Disabled // Due to Kotlin bug: https://github.com/mockk/mockk/issues/368
- fun testAdjustCapacity() = runBlockingSimulation {
+ fun testAdjustCapacity() = runSimulation {
val engine = FlowEngineImpl(coroutineContext, clock)
val forwarder = FlowForwarder(engine)
val sink = FlowSink(engine, 1.0)
@@ -202,7 +202,7 @@ internal class FlowForwarderTest {
}
@Test
- fun testCounters() = runBlockingSimulation {
+ fun testCounters() = runSimulation {
val engine = FlowEngineImpl(coroutineContext, clock)
val forwarder = FlowForwarder(engine)
val source = FlowSink(engine, 1.0)
@@ -224,7 +224,7 @@ internal class FlowForwarderTest {
}
@Test
- fun testCoupledExit() = runBlockingSimulation {
+ fun testCoupledExit() = runSimulation {
val engine = FlowEngineImpl(coroutineContext, clock)
val forwarder = FlowForwarder(engine, isCoupled = true)
val source = FlowSink(engine, 2000.0)
@@ -239,7 +239,7 @@ internal class FlowForwarderTest {
}
@Test
- fun testPullFailureCoupled() = runBlockingSimulation {
+ fun testPullFailureCoupled() = runSimulation {
val engine = FlowEngineImpl(coroutineContext, clock)
val forwarder = FlowForwarder(engine, isCoupled = true)
val source = FlowSink(engine, 2000.0)
@@ -262,7 +262,7 @@ internal class FlowForwarderTest {
}
@Test
- fun testStartFailure() = runBlockingSimulation {
+ fun testStartFailure() = runSimulation {
val engine = FlowEngineImpl(coroutineContext, clock)
val forwarder = FlowForwarder(engine)
val source = FlowSink(engine, 2000.0)
@@ -290,7 +290,7 @@ internal class FlowForwarderTest {
}
@Test
- fun testConvergeFailure() = runBlockingSimulation {
+ fun testConvergeFailure() = runSimulation {
val engine = FlowEngineImpl(coroutineContext, clock)
val forwarder = FlowForwarder(engine)
val source = FlowSink(engine, 2000.0)
diff --git a/opendc-simulator/opendc-simulator-flow/src/test/kotlin/org/opendc/simulator/flow/FlowSinkTest.kt b/opendc-simulator/opendc-simulator-flow/src/test/kotlin/org/opendc/simulator/flow/FlowSinkTest.kt
index 95cb8123..22a84edb 100644
--- a/opendc-simulator/opendc-simulator-flow/src/test/kotlin/org/opendc/simulator/flow/FlowSinkTest.kt
+++ b/opendc-simulator/opendc-simulator-flow/src/test/kotlin/org/opendc/simulator/flow/FlowSinkTest.kt
@@ -30,14 +30,14 @@ import org.junit.jupiter.api.Assertions.assertEquals
import org.opendc.simulator.flow.internal.FlowEngineImpl
import org.opendc.simulator.flow.source.FixedFlowSource
import org.opendc.simulator.flow.source.FlowSourceRateAdapter
-import org.opendc.simulator.kotlin.runBlockingSimulation
+import org.opendc.simulator.kotlin.runSimulation
/**
* A test suite for the [FlowSink] class.
*/
internal class FlowSinkTest {
@Test
- fun testSpeed() = runBlockingSimulation {
+ fun testSpeed() = runSimulation {
val engine = FlowEngineImpl(coroutineContext, clock)
val capacity = 4200.0
val provider = FlowSink(engine, capacity)
@@ -53,7 +53,7 @@ internal class FlowSinkTest {
}
@Test
- fun testAdjustCapacity() = runBlockingSimulation {
+ fun testAdjustCapacity() = runSimulation {
val engine = FlowEngineImpl(coroutineContext, clock)
val provider = FlowSink(engine, 1.0)
@@ -69,7 +69,7 @@ internal class FlowSinkTest {
}
@Test
- fun testSpeedLimit() = runBlockingSimulation {
+ fun testSpeedLimit() = runSimulation {
val engine = FlowEngineImpl(coroutineContext, clock)
val capacity = 4200.0
val provider = FlowSink(engine, capacity)
@@ -89,7 +89,7 @@ internal class FlowSinkTest {
* [FlowSource.onPull].
*/
@Test
- fun testIntermediateInterrupt() = runBlockingSimulation {
+ fun testIntermediateInterrupt() = runSimulation {
val engine = FlowEngineImpl(coroutineContext, clock)
val capacity = 4200.0
val provider = FlowSink(engine, capacity)
@@ -109,7 +109,7 @@ internal class FlowSinkTest {
}
@Test
- fun testInterrupt() = runBlockingSimulation {
+ fun testInterrupt() = runSimulation {
val engine = FlowEngineImpl(coroutineContext, clock)
val capacity = 4200.0
val provider = FlowSink(engine, capacity)
@@ -144,7 +144,7 @@ internal class FlowSinkTest {
}
@Test
- fun testFailure() = runBlockingSimulation {
+ fun testFailure() = runSimulation {
val engine = FlowEngineImpl(coroutineContext, clock)
val capacity = 4200.0
val provider = FlowSink(engine, capacity)
@@ -165,7 +165,7 @@ internal class FlowSinkTest {
}
@Test
- fun testExceptionPropagationOnNext() = runBlockingSimulation {
+ fun testExceptionPropagationOnNext() = runSimulation {
val engine = FlowEngineImpl(coroutineContext, clock)
val capacity = 4200.0
val provider = FlowSink(engine, capacity)
@@ -190,7 +190,7 @@ internal class FlowSinkTest {
}
@Test
- fun testConcurrentConsumption() = runBlockingSimulation {
+ fun testConcurrentConsumption() = runSimulation {
val engine = FlowEngineImpl(coroutineContext, clock)
val capacity = 4200.0
val provider = FlowSink(engine, capacity)
@@ -206,7 +206,7 @@ internal class FlowSinkTest {
}
@Test
- fun testCancelDuringConsumption() = runBlockingSimulation {
+ fun testCancelDuringConsumption() = runSimulation {
val engine = FlowEngineImpl(coroutineContext, clock)
val capacity = 4200.0
val provider = FlowSink(engine, capacity)
@@ -225,7 +225,7 @@ internal class FlowSinkTest {
@Test
fun testInfiniteSleep() {
assertThrows<IllegalStateException> {
- runBlockingSimulation {
+ runSimulation {
val engine = FlowEngineImpl(coroutineContext, clock)
val capacity = 4200.0
val provider = FlowSink(engine, capacity)
diff --git a/opendc-simulator/opendc-simulator-flow/src/test/kotlin/org/opendc/simulator/flow/mux/ForwardingFlowMultiplexerTest.kt b/opendc-simulator/opendc-simulator-flow/src/test/kotlin/org/opendc/simulator/flow/mux/ForwardingFlowMultiplexerTest.kt
index 523dac3a..cfd2bdf0 100644
--- a/opendc-simulator/opendc-simulator-flow/src/test/kotlin/org/opendc/simulator/flow/mux/ForwardingFlowMultiplexerTest.kt
+++ b/opendc-simulator/opendc-simulator-flow/src/test/kotlin/org/opendc/simulator/flow/mux/ForwardingFlowMultiplexerTest.kt
@@ -32,7 +32,7 @@ import org.opendc.simulator.flow.internal.FlowEngineImpl
import org.opendc.simulator.flow.source.FixedFlowSource
import org.opendc.simulator.flow.source.FlowSourceRateAdapter
import org.opendc.simulator.flow.source.TraceFlowSource
-import org.opendc.simulator.kotlin.runBlockingSimulation
+import org.opendc.simulator.kotlin.runSimulation
/**
* Test suite for the [ForwardingFlowMultiplexer] class.
@@ -42,7 +42,7 @@ internal class ForwardingFlowMultiplexerTest {
* Test a trace workload.
*/
@Test
- fun testTrace() = runBlockingSimulation {
+ fun testTrace() = runSimulation {
val engine = FlowEngineImpl(coroutineContext, clock)
val speed = mutableListOf<Double>()
@@ -79,7 +79,7 @@ internal class ForwardingFlowMultiplexerTest {
* Test runtime workload on hypervisor.
*/
@Test
- fun testRuntimeWorkload() = runBlockingSimulation {
+ fun testRuntimeWorkload() = runSimulation {
val engine = FlowEngineImpl(coroutineContext, clock)
val duration = 5 * 60L * 1000
@@ -101,7 +101,7 @@ internal class ForwardingFlowMultiplexerTest {
* Test two workloads running sequentially.
*/
@Test
- fun testTwoWorkloads() = runBlockingSimulation {
+ fun testTwoWorkloads() = runSimulation {
val engine = FlowEngineImpl(coroutineContext, clock)
val duration = 5 * 60L * 1000
@@ -140,7 +140,7 @@ internal class ForwardingFlowMultiplexerTest {
* Test concurrent workloads on the machine.
*/
@Test
- fun testConcurrentWorkloadFails() = runBlockingSimulation {
+ fun testConcurrentWorkloadFails() = runSimulation {
val engine = FlowEngineImpl(coroutineContext, clock)
val switch = ForwardingFlowMultiplexer(engine)
diff --git a/opendc-simulator/opendc-simulator-flow/src/test/kotlin/org/opendc/simulator/flow/mux/MaxMinFlowMultiplexerTest.kt b/opendc-simulator/opendc-simulator-flow/src/test/kotlin/org/opendc/simulator/flow/mux/MaxMinFlowMultiplexerTest.kt
index adfc265a..4e242292 100644
--- a/opendc-simulator/opendc-simulator-flow/src/test/kotlin/org/opendc/simulator/flow/mux/MaxMinFlowMultiplexerTest.kt
+++ b/opendc-simulator/opendc-simulator-flow/src/test/kotlin/org/opendc/simulator/flow/mux/MaxMinFlowMultiplexerTest.kt
@@ -32,14 +32,14 @@ import org.opendc.simulator.flow.consume
import org.opendc.simulator.flow.internal.FlowEngineImpl
import org.opendc.simulator.flow.source.FixedFlowSource
import org.opendc.simulator.flow.source.TraceFlowSource
-import org.opendc.simulator.kotlin.runBlockingSimulation
+import org.opendc.simulator.kotlin.runSimulation
/**
* Test suite for the [FlowMultiplexer] implementations
*/
internal class MaxMinFlowMultiplexerTest {
@Test
- fun testSmoke() = runBlockingSimulation {
+ fun testSmoke() = runSimulation {
val scheduler = FlowEngineImpl(coroutineContext, clock)
val switch = MaxMinFlowMultiplexer(scheduler)
@@ -61,7 +61,7 @@ internal class MaxMinFlowMultiplexerTest {
* Test overcommitting of resources via the hypervisor with a single VM.
*/
@Test
- fun testOvercommittedSingle() = runBlockingSimulation {
+ fun testOvercommittedSingle() = runSimulation {
val scheduler = FlowEngineImpl(coroutineContext, clock)
val duration = 5 * 60L
@@ -99,7 +99,7 @@ internal class MaxMinFlowMultiplexerTest {
* Test overcommitting of resources via the hypervisor with two VMs.
*/
@Test
- fun testOvercommittedDual() = runBlockingSimulation {
+ fun testOvercommittedDual() = runSimulation {
val scheduler = FlowEngineImpl(coroutineContext, clock)
val duration = 5 * 60L
diff --git a/opendc-simulator/opendc-simulator-flow/src/test/kotlin/org/opendc/simulator/flow/source/FixedFlowSourceTest.kt b/opendc-simulator/opendc-simulator-flow/src/test/kotlin/org/opendc/simulator/flow/source/FixedFlowSourceTest.kt
index 99630d32..552579ff 100644
--- a/opendc-simulator/opendc-simulator-flow/src/test/kotlin/org/opendc/simulator/flow/source/FixedFlowSourceTest.kt
+++ b/opendc-simulator/opendc-simulator-flow/src/test/kotlin/org/opendc/simulator/flow/source/FixedFlowSourceTest.kt
@@ -27,14 +27,14 @@ import org.junit.jupiter.api.Test
import org.opendc.simulator.flow.FlowSink
import org.opendc.simulator.flow.consume
import org.opendc.simulator.flow.internal.FlowEngineImpl
-import org.opendc.simulator.kotlin.runBlockingSimulation
+import org.opendc.simulator.kotlin.runSimulation
/**
* A test suite for the [FixedFlowSource] class.
*/
internal class FixedFlowSourceTest {
@Test
- fun testSmoke() = runBlockingSimulation {
+ fun testSmoke() = runSimulation {
val scheduler = FlowEngineImpl(coroutineContext, clock)
val provider = FlowSink(scheduler, 1.0)
@@ -45,7 +45,7 @@ internal class FixedFlowSourceTest {
}
@Test
- fun testUtilization() = runBlockingSimulation {
+ fun testUtilization() = runSimulation {
val scheduler = FlowEngineImpl(coroutineContext, clock)
val provider = FlowSink(scheduler, 1.0)
diff --git a/opendc-simulator/opendc-simulator-network/src/test/kotlin/org/opendc/simulator/network/SimNetworkSinkTest.kt b/opendc-simulator/opendc-simulator-network/src/test/kotlin/org/opendc/simulator/network/SimNetworkSinkTest.kt
index 8e95f2b0..944c4d6a 100644
--- a/opendc-simulator/opendc-simulator-network/src/test/kotlin/org/opendc/simulator/network/SimNetworkSinkTest.kt
+++ b/opendc-simulator/opendc-simulator-network/src/test/kotlin/org/opendc/simulator/network/SimNetworkSinkTest.kt
@@ -32,14 +32,14 @@ import org.junit.jupiter.api.assertDoesNotThrow
import org.junit.jupiter.api.assertThrows
import org.opendc.simulator.flow.*
import org.opendc.simulator.flow.source.FixedFlowSource
-import org.opendc.simulator.kotlin.runBlockingSimulation
+import org.opendc.simulator.kotlin.runSimulation
/**
* Test suite for the [SimNetworkSink] class.
*/
class SimNetworkSinkTest {
@Test
- fun testInitialState() = runBlockingSimulation {
+ fun testInitialState() = runSimulation {
val engine = FlowEngine(coroutineContext, clock)
val sink = SimNetworkSink(engine, capacity = 100.0)
@@ -49,7 +49,7 @@ class SimNetworkSinkTest {
}
@Test
- fun testDisconnectIdempotent() = runBlockingSimulation {
+ fun testDisconnectIdempotent() = runSimulation {
val engine = FlowEngine(coroutineContext, clock)
val sink = SimNetworkSink(engine, capacity = 100.0)
@@ -58,7 +58,7 @@ class SimNetworkSinkTest {
}
@Test
- fun testConnectCircular() = runBlockingSimulation {
+ fun testConnectCircular() = runSimulation {
val engine = FlowEngine(coroutineContext, clock)
val sink = SimNetworkSink(engine, capacity = 100.0)
@@ -68,7 +68,7 @@ class SimNetworkSinkTest {
}
@Test
- fun testConnectAlreadyConnectedTarget() = runBlockingSimulation {
+ fun testConnectAlreadyConnectedTarget() = runSimulation {
val engine = FlowEngine(coroutineContext, clock)
val sink = SimNetworkSink(engine, capacity = 100.0)
val source = mockk<SimNetworkPort>(relaxUnitFun = true)
@@ -80,7 +80,7 @@ class SimNetworkSinkTest {
}
@Test
- fun testConnectAlreadyConnected() = runBlockingSimulation {
+ fun testConnectAlreadyConnected() = runSimulation {
val engine = FlowEngine(coroutineContext, clock)
val sink = SimNetworkSink(engine, capacity = 100.0)
val source1 = Source(engine)
@@ -96,7 +96,7 @@ class SimNetworkSinkTest {
}
@Test
- fun testConnect() = runBlockingSimulation {
+ fun testConnect() = runSimulation {
val engine = FlowEngine(coroutineContext, clock)
val sink = SimNetworkSink(engine, capacity = 100.0)
val source = spyk(Source(engine))
@@ -112,7 +112,7 @@ class SimNetworkSinkTest {
}
@Test
- fun testDisconnect() = runBlockingSimulation {
+ fun testDisconnect() = runSimulation {
val engine = FlowEngine(coroutineContext, clock)
val sink = SimNetworkSink(engine, capacity = 100.0)
val source = spyk(Source(engine))
diff --git a/opendc-simulator/opendc-simulator-network/src/test/kotlin/org/opendc/simulator/network/SimNetworkSwitchVirtualTest.kt b/opendc-simulator/opendc-simulator-network/src/test/kotlin/org/opendc/simulator/network/SimNetworkSwitchVirtualTest.kt
index b45b150d..ff6cb66e 100644
--- a/opendc-simulator/opendc-simulator-network/src/test/kotlin/org/opendc/simulator/network/SimNetworkSwitchVirtualTest.kt
+++ b/opendc-simulator/opendc-simulator-network/src/test/kotlin/org/opendc/simulator/network/SimNetworkSwitchVirtualTest.kt
@@ -29,14 +29,14 @@ import org.junit.jupiter.api.Test
import org.junit.jupiter.api.assertThrows
import org.opendc.simulator.flow.*
import org.opendc.simulator.flow.source.FixedFlowSource
-import org.opendc.simulator.kotlin.runBlockingSimulation
+import org.opendc.simulator.kotlin.runSimulation
/**
* Test suite for the [SimNetworkSwitchVirtual] class.
*/
class SimNetworkSwitchVirtualTest {
@Test
- fun testConnect() = runBlockingSimulation {
+ fun testConnect() = runSimulation {
val engine = FlowEngine(coroutineContext, clock)
val sink = SimNetworkSink(engine, capacity = 100.0)
val source = spyk(Source(engine))
@@ -54,7 +54,7 @@ class SimNetworkSwitchVirtualTest {
}
@Test
- fun testConnectClosedPort() = runBlockingSimulation {
+ fun testConnectClosedPort() = runSimulation {
val engine = FlowEngine(coroutineContext, clock)
val sink = SimNetworkSink(engine, capacity = 100.0)
val switch = SimNetworkSwitchVirtual(engine)
diff --git a/opendc-simulator/opendc-simulator-power/src/test/kotlin/org/opendc/simulator/power/SimPduTest.kt b/opendc-simulator/opendc-simulator-power/src/test/kotlin/org/opendc/simulator/power/SimPduTest.kt
index 2177a374..29c50d3f 100644
--- a/opendc-simulator/opendc-simulator-power/src/test/kotlin/org/opendc/simulator/power/SimPduTest.kt
+++ b/opendc-simulator/opendc-simulator-power/src/test/kotlin/org/opendc/simulator/power/SimPduTest.kt
@@ -30,14 +30,14 @@ import org.junit.jupiter.api.assertThrows
import org.opendc.simulator.flow.FlowEngine
import org.opendc.simulator.flow.FlowSource
import org.opendc.simulator.flow.source.FixedFlowSource
-import org.opendc.simulator.kotlin.runBlockingSimulation
+import org.opendc.simulator.kotlin.runSimulation
/**
* Test suite for the [SimPdu] class.
*/
internal class SimPduTest {
@Test
- fun testZeroOutlets() = runBlockingSimulation {
+ fun testZeroOutlets() = runSimulation {
val engine = FlowEngine(coroutineContext, clock)
val source = SimPowerSource(engine, capacity = 100.0)
val pdu = SimPdu(engine)
@@ -47,7 +47,7 @@ internal class SimPduTest {
}
@Test
- fun testSingleOutlet() = runBlockingSimulation {
+ fun testSingleOutlet() = runSimulation {
val engine = FlowEngine(coroutineContext, clock)
val source = SimPowerSource(engine, capacity = 100.0)
val pdu = SimPdu(engine)
@@ -58,7 +58,7 @@ internal class SimPduTest {
}
@Test
- fun testDoubleOutlet() = runBlockingSimulation {
+ fun testDoubleOutlet() = runSimulation {
val engine = FlowEngine(coroutineContext, clock)
val source = SimPowerSource(engine, capacity = 100.0)
val pdu = SimPdu(engine)
@@ -71,7 +71,7 @@ internal class SimPduTest {
}
@Test
- fun testDisconnect() = runBlockingSimulation {
+ fun testDisconnect() = runSimulation {
val engine = FlowEngine(coroutineContext, clock)
val source = SimPowerSource(engine, capacity = 100.0)
val pdu = SimPdu(engine)
@@ -89,7 +89,7 @@ internal class SimPduTest {
}
@Test
- fun testLoss() = runBlockingSimulation {
+ fun testLoss() = runSimulation {
val engine = FlowEngine(coroutineContext, clock)
val source = SimPowerSource(engine, capacity = 100.0)
// https://download.schneider-electric.com/files?p_Doc_Ref=SPD_NRAN-66CK3D_EN
@@ -100,7 +100,7 @@ internal class SimPduTest {
}
@Test
- fun testOutletClose() = runBlockingSimulation {
+ fun testOutletClose() = runSimulation {
val engine = FlowEngine(coroutineContext, clock)
val source = SimPowerSource(engine, capacity = 100.0)
val pdu = SimPdu(engine)
diff --git a/opendc-simulator/opendc-simulator-power/src/test/kotlin/org/opendc/simulator/power/SimPowerSourceTest.kt b/opendc-simulator/opendc-simulator-power/src/test/kotlin/org/opendc/simulator/power/SimPowerSourceTest.kt
index 832b9d09..b83b6ba7 100644
--- a/opendc-simulator/opendc-simulator-power/src/test/kotlin/org/opendc/simulator/power/SimPowerSourceTest.kt
+++ b/opendc-simulator/opendc-simulator-power/src/test/kotlin/org/opendc/simulator/power/SimPowerSourceTest.kt
@@ -33,14 +33,14 @@ import org.junit.jupiter.api.assertThrows
import org.opendc.simulator.flow.FlowEngine
import org.opendc.simulator.flow.FlowSource
import org.opendc.simulator.flow.source.FixedFlowSource
-import org.opendc.simulator.kotlin.runBlockingSimulation
+import org.opendc.simulator.kotlin.runSimulation
/**
* Test suite for the [SimPowerSource]
*/
internal class SimPowerSourceTest {
@Test
- fun testInitialState() = runBlockingSimulation {
+ fun testInitialState() = runSimulation {
val engine = FlowEngine(coroutineContext, clock)
val source = SimPowerSource(engine, capacity = 100.0)
@@ -50,7 +50,7 @@ internal class SimPowerSourceTest {
}
@Test
- fun testDisconnectIdempotent() = runBlockingSimulation {
+ fun testDisconnectIdempotent() = runSimulation {
val engine = FlowEngine(coroutineContext, clock)
val source = SimPowerSource(engine, capacity = 100.0)
@@ -59,7 +59,7 @@ internal class SimPowerSourceTest {
}
@Test
- fun testConnect() = runBlockingSimulation {
+ fun testConnect() = runSimulation {
val engine = FlowEngine(coroutineContext, clock)
val source = SimPowerSource(engine, capacity = 100.0)
val inlet = SimpleInlet()
@@ -74,7 +74,7 @@ internal class SimPowerSourceTest {
}
@Test
- fun testDisconnect() = runBlockingSimulation {
+ fun testDisconnect() = runSimulation {
val engine = FlowEngine(coroutineContext, clock)
val source = SimPowerSource(engine, capacity = 100.0)
val consumer = spyk(FixedFlowSource(100.0, utilization = 1.0))
@@ -89,7 +89,7 @@ internal class SimPowerSourceTest {
}
@Test
- fun testDisconnectAssertion() = runBlockingSimulation {
+ fun testDisconnectAssertion() = runSimulation {
val engine = FlowEngine(coroutineContext, clock)
val source = SimPowerSource(engine, capacity = 100.0)
val inlet = mockk<SimPowerInlet>(relaxUnitFun = true)
@@ -105,7 +105,7 @@ internal class SimPowerSourceTest {
}
@Test
- fun testOutletAlreadyConnected() = runBlockingSimulation {
+ fun testOutletAlreadyConnected() = runSimulation {
val engine = FlowEngine(coroutineContext, clock)
val source = SimPowerSource(engine, capacity = 100.0)
val inlet = SimpleInlet()
@@ -119,7 +119,7 @@ internal class SimPowerSourceTest {
}
@Test
- fun testInletAlreadyConnected() = runBlockingSimulation {
+ fun testInletAlreadyConnected() = runSimulation {
val engine = FlowEngine(coroutineContext, clock)
val source = SimPowerSource(engine, capacity = 100.0)
val inlet = mockk<SimPowerInlet>(relaxUnitFun = true)
diff --git a/opendc-simulator/opendc-simulator-power/src/test/kotlin/org/opendc/simulator/power/SimUpsTest.kt b/opendc-simulator/opendc-simulator-power/src/test/kotlin/org/opendc/simulator/power/SimUpsTest.kt
index e3e9dbff..2b2921d7 100644
--- a/opendc-simulator/opendc-simulator-power/src/test/kotlin/org/opendc/simulator/power/SimUpsTest.kt
+++ b/opendc-simulator/opendc-simulator-power/src/test/kotlin/org/opendc/simulator/power/SimUpsTest.kt
@@ -30,14 +30,14 @@ import org.junit.jupiter.api.Test
import org.opendc.simulator.flow.FlowEngine
import org.opendc.simulator.flow.FlowSource
import org.opendc.simulator.flow.source.FixedFlowSource
-import org.opendc.simulator.kotlin.runBlockingSimulation
+import org.opendc.simulator.kotlin.runSimulation
/**
* Test suite for the [SimUps] class.
*/
internal class SimUpsTest {
@Test
- fun testSingleInlet() = runBlockingSimulation {
+ fun testSingleInlet() = runSimulation {
val engine = FlowEngine(coroutineContext, clock)
val source = SimPowerSource(engine, capacity = 100.0)
val ups = SimUps(engine)
@@ -48,7 +48,7 @@ internal class SimUpsTest {
}
@Test
- fun testDoubleInlet() = runBlockingSimulation {
+ fun testDoubleInlet() = runSimulation {
val engine = FlowEngine(coroutineContext, clock)
val source1 = SimPowerSource(engine, capacity = 100.0)
val source2 = SimPowerSource(engine, capacity = 100.0)
@@ -65,7 +65,7 @@ internal class SimUpsTest {
}
@Test
- fun testLoss() = runBlockingSimulation {
+ fun testLoss() = runSimulation {
val engine = FlowEngine(coroutineContext, clock)
val source = SimPowerSource(engine, capacity = 100.0)
// https://download.schneider-electric.com/files?p_Doc_Ref=SPD_NRAN-66CK3D_EN
@@ -77,7 +77,7 @@ internal class SimUpsTest {
}
@Test
- fun testDisconnect() = runBlockingSimulation {
+ fun testDisconnect() = runSimulation {
val engine = FlowEngine(coroutineContext, clock)
val source1 = SimPowerSource(engine, capacity = 100.0)
val source2 = SimPowerSource(engine, capacity = 100.0)