summaryrefslogtreecommitdiff
path: root/simulator/opendc-compute/opendc-compute-simulator/src/test/kotlin
diff options
context:
space:
mode:
authorFabian Mastenbroek <mail.fabianm@gmail.com>2021-01-08 18:18:43 +0100
committerFabian Mastenbroek <mail.fabianm@gmail.com>2021-01-11 15:23:56 +0100
commita71d4885efcf01850bc236d3e9f77ab3f44b48aa (patch)
tree797c65e0e5a37b73820ba4ef5d377b4a5524cd5f /simulator/opendc-compute/opendc-compute-simulator/src/test/kotlin
parent42e9a5b5b610f41a03e68f6fc781c54b9402925b (diff)
Convert to pull-based workload model
This change converts the low-level workload model to be pull-based. This reduces the overhead that we experienced with our previous co-routine based approach.
Diffstat (limited to 'simulator/opendc-compute/opendc-compute-simulator/src/test/kotlin')
-rw-r--r--simulator/opendc-compute/opendc-compute-simulator/src/test/kotlin/org/opendc/compute/simulator/SimBareMetalDriverTest.kt4
-rw-r--r--simulator/opendc-compute/opendc-compute-simulator/src/test/kotlin/org/opendc/compute/simulator/SimProvisioningServiceTest.kt2
-rw-r--r--simulator/opendc-compute/opendc-compute-simulator/src/test/kotlin/org/opendc/compute/simulator/SimVirtDriverTest.kt51
3 files changed, 28 insertions, 29 deletions
diff --git a/simulator/opendc-compute/opendc-compute-simulator/src/test/kotlin/org/opendc/compute/simulator/SimBareMetalDriverTest.kt b/simulator/opendc-compute/opendc-compute-simulator/src/test/kotlin/org/opendc/compute/simulator/SimBareMetalDriverTest.kt
index 0f1bd444..fb8a5f47 100644
--- a/simulator/opendc-compute/opendc-compute-simulator/src/test/kotlin/org/opendc/compute/simulator/SimBareMetalDriverTest.kt
+++ b/simulator/opendc-compute/opendc-compute-simulator/src/test/kotlin/org/opendc/compute/simulator/SimBareMetalDriverTest.kt
@@ -64,7 +64,7 @@ internal class SimBareMetalDriverTest {
testScope.launch {
val driver = SimBareMetalDriver(this, clock, UUID.randomUUID(), "test", emptyMap(), machineModel)
- val image = SimWorkloadImage(UUID.randomUUID(), "<unnamed>", emptyMap(), SimFlopsWorkload(4_000, 2, utilization = 1.0))
+ val image = SimWorkloadImage(UUID.randomUUID(), "<unnamed>", emptyMap(), SimFlopsWorkload(4_000, utilization = 1.0))
// Batch driver commands
withContext(coroutineContext) {
@@ -84,6 +84,6 @@ internal class SimBareMetalDriverTest {
testScope.advanceUntilIdle()
assertEquals(ServerState.SHUTOFF, finalState)
- assertEquals(1001, finalTime)
+ assertEquals(501, finalTime)
}
}
diff --git a/simulator/opendc-compute/opendc-compute-simulator/src/test/kotlin/org/opendc/compute/simulator/SimProvisioningServiceTest.kt b/simulator/opendc-compute/opendc-compute-simulator/src/test/kotlin/org/opendc/compute/simulator/SimProvisioningServiceTest.kt
index def78ce7..a33a4e5f 100644
--- a/simulator/opendc-compute/opendc-compute-simulator/src/test/kotlin/org/opendc/compute/simulator/SimProvisioningServiceTest.kt
+++ b/simulator/opendc-compute/opendc-compute-simulator/src/test/kotlin/org/opendc/compute/simulator/SimProvisioningServiceTest.kt
@@ -64,7 +64,7 @@ internal class SimProvisioningServiceTest {
val clock = DelayControllerClockAdapter(testScope)
testScope.launch {
- val image = SimWorkloadImage(UUID.randomUUID(), "<unnamed>", emptyMap(), SimFlopsWorkload(1000, 2))
+ val image = SimWorkloadImage(UUID.randomUUID(), "<unnamed>", emptyMap(), SimFlopsWorkload(1000))
val driver = SimBareMetalDriver(this, clock, UUID.randomUUID(), "test", emptyMap(), machineModel)
val provisioner = SimpleProvisioningService()
diff --git a/simulator/opendc-compute/opendc-compute-simulator/src/test/kotlin/org/opendc/compute/simulator/SimVirtDriverTest.kt b/simulator/opendc-compute/opendc-compute-simulator/src/test/kotlin/org/opendc/compute/simulator/SimVirtDriverTest.kt
index 394e87c6..163b326a 100644
--- a/simulator/opendc-compute/opendc-compute-simulator/src/test/kotlin/org/opendc/compute/simulator/SimVirtDriverTest.kt
+++ b/simulator/opendc-compute/opendc-compute-simulator/src/test/kotlin/org/opendc/compute/simulator/SimVirtDriverTest.kt
@@ -66,17 +66,17 @@ internal class SimVirtDriverTest {
}
/**
- * Test overcommissioning of a hypervisor.
+ * Test overcommitting of resources by the hypervisor.
*/
@Test
- fun overcommission() {
- var requestedBurst = 0L
- var grantedBurst = 0L
- var overcommissionedBurst = 0L
+ fun testOvercommitted() {
+ var requestedWork = 0L
+ var grantedWork = 0L
+ var overcommittedWork = 0L
scope.launch {
- val virtDriverWorkload = SimVirtDriverWorkload()
- val vmm = SimWorkloadImage(UUID.randomUUID(), "vmm", emptyMap(), virtDriverWorkload)
+ val virtDriver = SimVirtDriver(this)
+ val vmm = SimWorkloadImage(UUID.randomUUID(), "vmm", emptyMap(), virtDriver)
val duration = 5 * 60L
val vmImageA = SimWorkloadImage(
UUID.randomUUID(),
@@ -84,10 +84,10 @@ internal class SimVirtDriverTest {
emptyMap(),
SimTraceWorkload(
sequenceOf(
- SimTraceWorkload.Fragment(0, 28L * duration, duration * 1000, 28.0, 2),
- SimTraceWorkload.Fragment(0, 3500L * duration, duration * 1000, 3500.0, 2),
- SimTraceWorkload.Fragment(0, 0, duration * 1000, 0.0, 2),
- SimTraceWorkload.Fragment(0, 183L * duration, duration * 1000, 183.0, 2)
+ SimTraceWorkload.Fragment(duration * 1000, 28.0, 2),
+ SimTraceWorkload.Fragment(duration * 1000, 3500.0, 2),
+ SimTraceWorkload.Fragment(duration * 1000, 0.0, 2),
+ SimTraceWorkload.Fragment(duration * 1000, 183.0, 2)
),
)
)
@@ -97,10 +97,10 @@ internal class SimVirtDriverTest {
emptyMap(),
SimTraceWorkload(
sequenceOf(
- SimTraceWorkload.Fragment(0, 28L * duration, duration * 1000, 28.0, 2),
- SimTraceWorkload.Fragment(0, 3100L * duration, duration * 1000, 3100.0, 2),
- SimTraceWorkload.Fragment(0, 0, duration * 1000, 0.0, 2),
- SimTraceWorkload.Fragment(0, 73L * duration, duration * 1000, 73.0, 2)
+ SimTraceWorkload.Fragment(duration * 1000, 28.0, 2),
+ SimTraceWorkload.Fragment(duration * 1000, 3100.0, 2),
+ SimTraceWorkload.Fragment(duration * 1000, 0.0, 2),
+ SimTraceWorkload.Fragment(duration * 1000, 73.0, 2)
)
),
)
@@ -115,31 +115,30 @@ internal class SimVirtDriverTest {
delay(5)
val flavor = Flavor(2, 0)
- val vmDriver = virtDriverWorkload.driver
- vmDriver.events
+ virtDriver.events
.onEach { event ->
when (event) {
is HypervisorEvent.SliceFinished -> {
- requestedBurst += event.requestedBurst
- grantedBurst += event.grantedBurst
- overcommissionedBurst += event.overcommissionedBurst
+ requestedWork += event.requestedBurst
+ grantedWork += event.grantedBurst
+ overcommittedWork += event.overcommissionedBurst
}
}
}
.launchIn(this)
- vmDriver.spawn("a", vmImageA, flavor)
- vmDriver.spawn("b", vmImageB, flavor)
+ virtDriver.spawn("a", vmImageA, flavor)
+ virtDriver.spawn("b", vmImageB, flavor)
}
scope.advanceUntilIdle()
assertAll(
{ assertEquals(emptyList<Throwable>(), scope.uncaughtExceptions, "No errors") },
- { assertEquals(2082000, requestedBurst, "Requested Burst does not match") },
- { assertEquals(2013600, grantedBurst, "Granted Burst does not match") },
- { assertEquals(60000, overcommissionedBurst, "Overcommissioned Burst does not match") },
- { assertEquals(1200007, scope.currentTime) }
+ { assertEquals(4197600, requestedWork, "Requested work does not match") },
+ { assertEquals(3057600, grantedWork, "Granted work does not match") },
+ { assertEquals(1140000, overcommittedWork, "Overcommitted work does not match") },
+ { assertEquals(1200006, scope.currentTime) }
)
}
}