CTS test race condition on the memory puller atoms
testProcessMemoryState would start a test activity, trigger statsd
to pull the memory metrics and immediately force-stop the test app. This is
race condition which resulted either in pulling the test app memory while in
a zombie state (tests fail because rss = 0) or when killed
altogether (tests fail because the process is not found).
This CL ensures we do not force-stop the process immediately
(the same way as the rest on this class).
Change-Id: Id2f21be22d96c93e6198b4356bcdc26f6c8725f4
Test: UidAtomTests
Bug: b/137818141
diff --git a/hostsidetests/statsd/src/android/cts/statsd/atom/UidAtomTests.java b/hostsidetests/statsd/src/android/cts/statsd/atom/UidAtomTests.java
index 25b27e8..cb66496 100644
--- a/hostsidetests/statsd/src/android/cts/statsd/atom/UidAtomTests.java
+++ b/hostsidetests/statsd/src/android/cts/statsd/atom/UidAtomTests.java
@@ -1104,8 +1104,9 @@
try (AutoCloseable a = withActivity("StatsdCtsForegroundActivity", "action",
"action.show_notification")) {
Thread.sleep(WAIT_TIME_SHORT);
- // Trigger new pull.
+ // Trigger a pull and wait for new pull before killing the process.
setAppBreadcrumbPredicate();
+ Thread.sleep(WAIT_TIME_LONG);
}
// Assert about ProcessMemoryState for the test app.
@@ -1145,6 +1146,7 @@
// Trigger new pull.
setAppBreadcrumbPredicate();
+ Thread.sleep(WAIT_TIME_LONG);
// Assert about NativeProcessMemoryState for statsd.
List<Atom> atoms = getGaugeMetricDataList();
@@ -1181,8 +1183,8 @@
try (AutoCloseable a = withActivity("StatsdCtsForegroundActivity", "action",
"action.show_notification")) {
setAppBreadcrumbPredicate();
+ Thread.sleep(WAIT_TIME_LONG);
}
- Thread.sleep(WAIT_TIME_SHORT);
// Assert about ProcessMemoryHighWaterMark for the test app, statsd and system server.
List<Atom> atoms = getGaugeMetricDataList();