summaryrefslogtreecommitdiff
path: root/opendc-simulator/opendc-simulator-flow/src/test
diff options
context:
space:
mode:
authorFabian Mastenbroek <mail.fabianm@gmail.com>2022-12-07 23:14:16 +0000
committerFabian Mastenbroek <mail.fabianm@gmail.com>2022-12-07 23:33:22 +0000
commitde739998fde6b856e40f8a98f78efddc0c57f167 (patch)
tree0a9829fcc837dd7ac041ab75e1a0ed18644c53df /opendc-simulator/opendc-simulator-flow/src/test
parentb88f07ebb056293b1a29f24e4f42203c09bcbcf8 (diff)
bug(sim/flow): Record capacity changes on idle outlets
This change fixes an issue with the `ForwardingFlowMultiplexer` where the capacity of new outlets were not recorded correctly due to no handler being attached to idle outlets, causing the `pull` events to be disregarded. This bug manifested in an issue where the CPU counters where reporting negative values. This was caused by the CPU usage/demand being subtracted from a zero capacity.
Diffstat (limited to 'opendc-simulator/opendc-simulator-flow/src/test')
-rw-r--r--opendc-simulator/opendc-simulator-flow/src/test/kotlin/org/opendc/simulator/flow2/mux/ForwardingFlowMultiplexerTest.kt5
1 files changed, 5 insertions, 0 deletions
diff --git a/opendc-simulator/opendc-simulator-flow/src/test/kotlin/org/opendc/simulator/flow2/mux/ForwardingFlowMultiplexerTest.kt b/opendc-simulator/opendc-simulator-flow/src/test/kotlin/org/opendc/simulator/flow2/mux/ForwardingFlowMultiplexerTest.kt
index fef49786..d1795841 100644
--- a/opendc-simulator/opendc-simulator-flow/src/test/kotlin/org/opendc/simulator/flow2/mux/ForwardingFlowMultiplexerTest.kt
+++ b/opendc-simulator/opendc-simulator-flow/src/test/kotlin/org/opendc/simulator/flow2/mux/ForwardingFlowMultiplexerTest.kt
@@ -22,6 +22,7 @@
package org.opendc.simulator.flow2.mux
+import kotlinx.coroutines.yield
import org.junit.jupiter.api.Assertions.assertEquals
import org.junit.jupiter.api.Test
import org.junit.jupiter.api.assertAll
@@ -46,6 +47,10 @@ class ForwardingFlowMultiplexerTest {
val sink = SimpleFlowSink(graph, 3200.0f)
graph.connect(switch.newOutput(), sink.input)
+ yield()
+
+ assertEquals(sink.capacity, switch.capacity) { "Capacity is not detected" }
+
val workload =
TraceFlowSource(
graph,