From de739998fde6b856e40f8a98f78efddc0c57f167 Mon Sep 17 00:00:00 2001 From: Fabian Mastenbroek Date: Wed, 7 Dec 2022 23:14:16 +0000 Subject: 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. --- .../org/opendc/simulator/flow2/mux/ForwardingFlowMultiplexerTest.kt | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'opendc-simulator/opendc-simulator-flow/src/test') 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, -- cgit v1.2.3