diff options
| author | Fabian Mastenbroek <mail.fabianm@gmail.com> | 2017-09-21 23:25:44 +0200 |
|---|---|---|
| committer | Fabian Mastenbroek <mail.fabianm@gmail.com> | 2017-09-21 23:25:44 +0200 |
| commit | a031db367c71ec1604b34f3765198c2196bfe551 (patch) | |
| tree | 793c4af1a9b0c4f8bbc0d901b2a8ae90ac22d4ee /opendc-omega/src/test | |
| parent | 735d5543ed72f0c6cf632b35b3f23323cebcf81b (diff) | |
Create simple datacenter experiment
Diffstat (limited to 'opendc-omega/src/test')
| -rw-r--r-- | opendc-omega/src/test/kotlin/nl/atlarge/opendc/SmokeTest.kt | 41 |
1 files changed, 34 insertions, 7 deletions
diff --git a/opendc-omega/src/test/kotlin/nl/atlarge/opendc/SmokeTest.kt b/opendc-omega/src/test/kotlin/nl/atlarge/opendc/SmokeTest.kt index 4f48f20d..e2eb8269 100644 --- a/opendc-omega/src/test/kotlin/nl/atlarge/opendc/SmokeTest.kt +++ b/opendc-omega/src/test/kotlin/nl/atlarge/opendc/SmokeTest.kt @@ -25,25 +25,46 @@ package nl.atlarge.opendc import nl.atlarge.opendc.kernel.omega.OmegaKernel +import nl.atlarge.opendc.scheduler.FifoScheduler +import nl.atlarge.opendc.scheduler.SrtfScheduler import nl.atlarge.opendc.topology.AdjacencyList +import nl.atlarge.opendc.topology.container.Datacenter import nl.atlarge.opendc.topology.container.Rack +import nl.atlarge.opendc.topology.container.Room import nl.atlarge.opendc.topology.machine.Cpu import nl.atlarge.opendc.topology.machine.Machine +import nl.atlarge.opendc.workload.Task import org.junit.jupiter.api.Test +import java.util.* internal class SmokeTest { @Test fun smoke() { - val rack = Rack() + val datacenter = Datacenter(SrtfScheduler(), 50) val builder = AdjacencyList.builder() val topology = builder.construct { - add(rack) - val n = 100 + add(datacenter) + + // Add a room to the datacenter + val room = Room().also { + add(it) + connect(datacenter, it, tag = "room") + } + + // Add a rack to the room + val rack = Rack().also { + add(it) + connect(room, it, tag = "rack") + } + + val n = 10 + // Create n machines in the rack repeat(n) { - val machine = Machine() - add(machine) - connect(rack, machine, tag = "machine") + val machine = Machine().also { + add(it) + connect(rack, it, tag = "machine") + } val cpu1 = Cpu(10, 2, 2) val cpu2 = Cpu(5, 3, 2) @@ -56,6 +77,12 @@ internal class SmokeTest { } val simulation = OmegaKernel.create(topology) - simulation.run() + val random = Random(0) + for (i in 0..100) { + val task = Task(i, emptySet(), random.nextInt(10000).toLong()) + simulation.schedule(task, datacenter, delay = random.nextInt(15000).toLong()) + } + simulation.run(50000) + } } |
