summaryrefslogtreecommitdiff
path: root/opendc-compute/opendc-compute-simulator/src/test
diff options
context:
space:
mode:
authorFabian Mastenbroek <mail.fabianm@gmail.com>2021-08-17 19:22:34 +0200
committerFabian Mastenbroek <mail.fabianm@gmail.com>2021-09-07 14:24:40 +0200
commit9236b3cfb7be1e9d44fe60cbdd699c19c70f6411 (patch)
tree4648718efcd129d2f4b6faeab4f53d911db47d69 /opendc-compute/opendc-compute-simulator/src/test
parent2dd9cc6ded8c47046f4faa1b2dd6aed1085d6644 (diff)
feat(compute): Track host up/down time
This change adds new metrics for tracking the up and downtime of hosts due to failures. In addition, this change adds a test to verify whether the metrics are collected correctly.
Diffstat (limited to 'opendc-compute/opendc-compute-simulator/src/test')
-rw-r--r--opendc-compute/opendc-compute-simulator/src/test/kotlin/org/opendc/compute/simulator/SimHostTest.kt10
1 files changed, 10 insertions, 0 deletions
diff --git a/opendc-compute/opendc-compute-simulator/src/test/kotlin/org/opendc/compute/simulator/SimHostTest.kt b/opendc-compute/opendc-compute-simulator/src/test/kotlin/org/opendc/compute/simulator/SimHostTest.kt
index 1ba3a9a1..0a2ced7b 100644
--- a/opendc-compute/opendc-compute-simulator/src/test/kotlin/org/opendc/compute/simulator/SimHostTest.kt
+++ b/opendc-compute/opendc-compute-simulator/src/test/kotlin/org/opendc/compute/simulator/SimHostTest.kt
@@ -189,6 +189,8 @@ internal class SimHostTest {
fun testFailure() = runBlockingSimulation {
var requestedWork = 0L
var grantedWork = 0L
+ var totalTime = 0L
+ var downTime = 0L
val meterProvider: MeterProvider = SdkMeterProvider
.builder()
@@ -238,6 +240,12 @@ internal class SimHostTest {
metricsByName["cpu.work.granted"]?.let {
grantedWork = it.doubleSumData.points.sumOf { point -> point.value }.toLong()
}
+ metricsByName["host.time.total"]?.let {
+ totalTime = it.longSumData.points.first().value
+ }
+ metricsByName["host.time.down"]?.let {
+ downTime = it.longSumData.points.first().value
+ }
return CompletableResultCode.ofSuccess()
}
@@ -275,6 +283,8 @@ internal class SimHostTest {
assertAll(
{ assertEquals(2226039, requestedWork, "Total time does not match") },
{ assertEquals(1086039, grantedWork, "Down time does not match") },
+ { assertEquals(1200001, totalTime, "Total time does not match") },
+ { assertEquals(5000, downTime, "Down time does not match") },
)
}