From b54ad4c26720955435e4e9f771971bba70741eb9 Mon Sep 17 00:00:00 2001 From: Dmitri Plotnikov Date: Fri, 26 Apr 2024 17:57:39 -0700 Subject: De-flake CpuPowerStatsCollectorTest#isolatedUidReuse The root cause of the flakiness is the implementation of PowerStatsCollector.forceSchedule(), which posts the next collection event at the front of the event queue, which messes with the order of events as expected by the test. Bug: 337087734 Test: atest --rerun-until-failure 500 PowerStatsTests:CpuPowerStatsCollectorTest#isolatedUidReuse Flag: com.android.server.power.optimization.streamlined_battery_stats Change-Id: I02b0a7d9a8d8e4ab09c13fe143a484bf42f1b344 --- .../com/android/server/power/stats/CpuPowerStatsCollectorTest.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/services/tests/powerstatstests/src/com/android/server/power/stats/CpuPowerStatsCollectorTest.java b/services/tests/powerstatstests/src/com/android/server/power/stats/CpuPowerStatsCollectorTest.java index d51828e418c6..4e3e80f8ff10 100644 --- a/services/tests/powerstatstests/src/com/android/server/power/stats/CpuPowerStatsCollectorTest.java +++ b/services/tests/powerstatstests/src/com/android/server/power/stats/CpuPowerStatsCollectorTest.java @@ -341,7 +341,7 @@ public class CpuPowerStatsCollectorTest { }}, 0, 1234); mMockClock.uptime = 1000; - collector.forceSchedule(); + collector.schedule(); waitForIdle(); mUidResolver.noteIsolatedUidRemoved(ISOLATED_UID, UID_2); @@ -354,7 +354,7 @@ public class CpuPowerStatsCollectorTest { }}, 1234, 3421); mMockClock.uptime = 2000; - collector.forceSchedule(); + collector.schedule(); waitForIdle(); assertThat(layout.getUidTimeByPowerBracket(mCollectedStats.uidStats.get(UID_2), 0)) -- cgit v1.2.3-59-g8ed1b