summaryrefslogtreecommitdiff
path: root/opendc/opendc-compute/src/test
diff options
context:
space:
mode:
authorGeorgios Andreadis <g.andreadis@student.tudelft.nl>2020-05-20 15:59:54 +0200
committerGeorgios Andreadis <g.andreadis@student.tudelft.nl>2020-05-20 15:59:54 +0200
commit70ad01d793f88b1bef7d7988d24bff384ddbb3b9 (patch)
tree10b4d6053d1cd58e921f71ff7b0d6f0cf7bab75a /opendc/opendc-compute/src/test
parentee494d6ce6f817cf4e9ab0dba0d9f9f1987c0029 (diff)
parent21eafd32c45495ab9e8ebbeffbdbe1d43ffe566b (diff)
Merge branch 'perf/batch-slices' into '2.x'
Batch VM slices See merge request opendc/opendc-simulator!70
Diffstat (limited to 'opendc/opendc-compute/src/test')
-rw-r--r--opendc/opendc-compute/src/test/kotlin/com/atlarge/opendc/compute/metal/driver/SimpleBareMetalDriverTest.kt11
-rw-r--r--opendc/opendc-compute/src/test/kotlin/com/atlarge/opendc/compute/virt/HypervisorTest.kt77
2 files changed, 87 insertions, 1 deletions
diff --git a/opendc/opendc-compute/src/test/kotlin/com/atlarge/opendc/compute/metal/driver/SimpleBareMetalDriverTest.kt b/opendc/opendc-compute/src/test/kotlin/com/atlarge/opendc/compute/metal/driver/SimpleBareMetalDriverTest.kt
index 0fc64373..071c0626 100644
--- a/opendc/opendc-compute/src/test/kotlin/com/atlarge/opendc/compute/metal/driver/SimpleBareMetalDriverTest.kt
+++ b/opendc/opendc-compute/src/test/kotlin/com/atlarge/opendc/compute/metal/driver/SimpleBareMetalDriverTest.kt
@@ -25,12 +25,15 @@
package com.atlarge.opendc.compute.metal.driver
import com.atlarge.odcsim.SimulationEngineProvider
+import com.atlarge.odcsim.simulationContext
import com.atlarge.opendc.compute.core.ProcessingNode
import com.atlarge.opendc.compute.core.ProcessingUnit
import com.atlarge.opendc.compute.core.ServerEvent
import com.atlarge.opendc.compute.core.ServerState
import com.atlarge.opendc.compute.core.image.FlopsApplicationImage
import kotlinx.coroutines.flow.collect
+import kotlinx.coroutines.flow.launchIn
+import kotlinx.coroutines.flow.onEach
import kotlinx.coroutines.launch
import kotlinx.coroutines.runBlocking
import kotlinx.coroutines.withContext
@@ -61,9 +64,15 @@ internal class SimpleBareMetalDriverTest {
driver.init()
driver.setImage(image)
val server = driver.start().server!!
+ driver.usage
+ .onEach { println("${simulationContext.clock.millis()} $it") }
+ .launchIn(this)
server.events.collect { event ->
when (event) {
- is ServerEvent.StateChanged -> { println(event); finalState = event.server.state }
+ is ServerEvent.StateChanged -> {
+ println("${simulationContext.clock.millis()} $event")
+ finalState = event.server.state
+ }
}
}
}
diff --git a/opendc/opendc-compute/src/test/kotlin/com/atlarge/opendc/compute/virt/HypervisorTest.kt b/opendc/opendc-compute/src/test/kotlin/com/atlarge/opendc/compute/virt/HypervisorTest.kt
index 4f3abc02..ca00fc94 100644
--- a/opendc/opendc-compute/src/test/kotlin/com/atlarge/opendc/compute/virt/HypervisorTest.kt
+++ b/opendc/opendc-compute/src/test/kotlin/com/atlarge/opendc/compute/virt/HypervisorTest.kt
@@ -29,6 +29,8 @@ import com.atlarge.opendc.compute.core.ProcessingUnit
import com.atlarge.opendc.compute.core.Flavor
import com.atlarge.opendc.compute.core.ProcessingNode
import com.atlarge.opendc.compute.core.image.FlopsApplicationImage
+import com.atlarge.opendc.compute.core.image.FlopsHistoryFragment
+import com.atlarge.opendc.compute.core.image.VmImage
import com.atlarge.opendc.compute.metal.driver.SimpleBareMetalDriver
import com.atlarge.opendc.compute.virt.driver.VirtDriver
import kotlinx.coroutines.ExperimentalCoroutinesApi
@@ -37,7 +39,10 @@ import kotlinx.coroutines.flow.launchIn
import kotlinx.coroutines.flow.onEach
import kotlinx.coroutines.launch
import kotlinx.coroutines.runBlocking
+import org.junit.jupiter.api.Assertions.assertEquals
+import org.junit.jupiter.api.Disabled
import org.junit.jupiter.api.Test
+import org.junit.jupiter.api.assertAll
import java.util.ServiceLoader
import java.util.UUID
@@ -50,6 +55,7 @@ internal class HypervisorTest {
*/
@OptIn(ExperimentalCoroutinesApi::class)
@Test
+ @Disabled
fun smoke() {
val provider = ServiceLoader.load(SimulationEngineProvider::class.java).first()
val system = provider("test")
@@ -87,4 +93,75 @@ internal class HypervisorTest {
system.terminate()
}
}
+
+ /**
+ * Test overcommissioning of a hypervisor.
+ */
+ @Test
+ fun overcommission() {
+ val provider = ServiceLoader.load(SimulationEngineProvider::class.java).first()
+ val system = provider("test")
+ val root = system.newDomain("root")
+
+ var requestedBurst = 0L
+ var grantedBurst = 0L
+ var overcommissionedBurst = 0L
+
+ root.launch {
+ val vmm = HypervisorImage
+ val duration = 5 * 60L
+ val vmImageA = VmImage(UUID.randomUUID(), "<unnamed>", emptyMap(), sequenceOf(
+ FlopsHistoryFragment(0, 28L * duration, duration * 1000, 28.0, 2),
+ FlopsHistoryFragment(0, 3500L * duration, duration * 1000, 3500.0, 2),
+ FlopsHistoryFragment(0, 0, duration * 1000, 0.0, 2),
+ FlopsHistoryFragment(0, 183L * duration, duration * 1000, 183.0, 2)
+ ), 2, 0)
+ val vmImageB = VmImage(UUID.randomUUID(), "<unnamed>", emptyMap(), sequenceOf(
+ FlopsHistoryFragment(0, 28L * duration, duration * 1000, 28.0, 2),
+ FlopsHistoryFragment(0, 3100L * duration, duration * 1000, 3100.0, 2),
+ FlopsHistoryFragment(0, 0, duration * 1000, 0.0, 2),
+ FlopsHistoryFragment(0, 73L * duration, duration * 1000, 73.0, 2)
+ ), 2, 0)
+
+ val driverDom = root.newDomain("driver")
+
+ val cpuNode = ProcessingNode("Intel", "Xeon", "amd64", 2)
+ val cpus = List(2) { ProcessingUnit(cpuNode, it, 3200.0) }
+ val metalDriver = SimpleBareMetalDriver(driverDom, UUID.randomUUID(), "test", emptyMap(), cpus, emptyList())
+
+ metalDriver.init()
+ metalDriver.setImage(vmm)
+ metalDriver.start()
+
+ delay(5)
+
+ val flavor = Flavor(2, 0)
+ val vmDriver = metalDriver.refresh().server!!.services[VirtDriver]
+ vmDriver.events
+ .onEach { event ->
+ when (event) {
+ is HypervisorEvent.SliceFinished -> {
+ requestedBurst += event.requestedBurst
+ grantedBurst += event.grantedBurst
+ overcommissionedBurst += event.overcommissionedBurst
+ }
+ }
+ }
+ .launchIn(this)
+
+ vmDriver.spawn("a", vmImageA, flavor)
+ vmDriver.spawn("b", vmImageB, flavor)
+ }
+
+ runBlocking {
+ system.run()
+ system.terminate()
+ }
+
+ assertAll(
+ { assertEquals(2073600, requestedBurst, "Requested Burst does not match") },
+ { assertEquals(2013600, grantedBurst, "Granted Burst does not match") },
+ { assertEquals(60000, overcommissionedBurst, "Overcommissioned Burst does not match") }
+ )
+ }
}