summaryrefslogtreecommitdiff
path: root/opendc-core/src/test
diff options
context:
space:
mode:
authorFabian Mastenbroek <mail.fabianm@gmail.com>2017-09-04 12:56:44 +0200
committerFabian Mastenbroek <mail.fabianm@gmail.com>2017-09-04 12:56:44 +0200
commit96f75806dbdcb8c43a22c7db98e85ac5e854e68b (patch)
tree0cd0202c7cb85482621b5624b710acef1604bea3 /opendc-core/src/test
parent2e8df509bb2fc513b7f793d51c6a85cf6bbe62ca (diff)
Move simulation kernels into topology entities
This change embeds simulation kernels into the entities and relations of the topology.
Diffstat (limited to 'opendc-core/src/test')
-rw-r--r--opendc-core/src/test/kotlin/nl/atlarge/opendc/SmokeTest.kt40
1 files changed, 13 insertions, 27 deletions
diff --git a/opendc-core/src/test/kotlin/nl/atlarge/opendc/SmokeTest.kt b/opendc-core/src/test/kotlin/nl/atlarge/opendc/SmokeTest.kt
index 300ffec8..f18e62bd 100644
--- a/opendc-core/src/test/kotlin/nl/atlarge/opendc/SmokeTest.kt
+++ b/opendc-core/src/test/kotlin/nl/atlarge/opendc/SmokeTest.kt
@@ -24,11 +24,8 @@
package nl.atlarge.opendc
-import nl.atlarge.opendc.kernel.Kernel
import nl.atlarge.opendc.kernel.Simulator
-import nl.atlarge.opendc.kernel.impl.MachineKernel
import nl.atlarge.opendc.topology.AdjacencyListTopologyBuilder
-import nl.atlarge.opendc.topology.Component
import nl.atlarge.opendc.topology.container.Rack
import nl.atlarge.opendc.topology.machine.Cpu
import nl.atlarge.opendc.topology.machine.Machine
@@ -37,37 +34,26 @@ import org.junit.jupiter.api.Test
internal class SmokeTest {
@Test
fun smoke() {
- val mapping: MutableMap<Component<*>, Class<out Kernel<*>>> = HashMap()
val builder = AdjacencyListTopologyBuilder()
val topology = builder.build().apply {
val rack = node(Rack())
- val machineA = node(Machine())
- val machineB = node(Machine())
+ val n = 10
+ // Create n machines in the rack
+ repeat(n) {
+ val machine = node(Machine())
+ connect(rack, machine, tag = "machine")
- connect(rack, machineA, tag = "machine")
- connect(rack, machineB, tag = "machine")
+ val cpu1 = node(Cpu(10, 2, 2))
+ val cpu2 = node(Cpu(5, 3, 2))
- val cpuA1 = node(Cpu(10, 2, 2))
- val cpuA2 = node(Cpu(5, 3, 2))
-
- connect(machineA, cpuA1, tag = "cpu")
- connect(machineA, cpuA2, tag = "cpu")
-
- val cpuB1 = node(Cpu(10, 2, 2))
- val cpuB2 = node(Cpu(5, 3, 2))
-
- connect(machineB, cpuB1, tag = "cpu")
- connect(machineB, cpuB2, tag = "cpu")
-
- mapping.apply {
- put(machineA, MachineKernel::class.java)
- put(machineB, MachineKernel::class.java)
+ connect(machine, cpu1, tag = "cpu")
+ connect(machine, cpu2, tag = "cpu")
}
+ }
- val simulator = Simulator(this, mapping)
- while (simulator.hasNext()) {
- simulator.next()
- }
+ val simulator = Simulator(topology)
+ while (simulator.hasNext()) {
+ simulator.next()
}
}
}