summaryrefslogtreecommitdiff
path: root/apct-tests/perftests/multiuser
diff options
context:
space:
mode:
authorTony Mak <tonymak@google.com>2017-05-26 15:38:09 +0100
committerTony Mak <tonymak@google.com>2017-05-31 16:06:02 +0100
commitec7c6963bd7c90e3628a24a6e69443e1aef6e8f4 (patch)
tree8b6f6384f0ff411ea7d8f53bb71a49ff5bc64d87 /apct-tests/perftests/multiuser
parent614636e9263c0d87c8c738dccf298bd16c5fec75 (diff)
Increase the timeout and add stopping managed profile test
The dashbaord suggests that multiple tests are always capped at the same value due to the timeout. To collect the actual metric, set a larger timeout value, 10s for now. Also, added a test to stop managed profile user. However, the test is still finishing surprisingly fast because of the empty broadcast queue. Bug: 62096041 Test: adb shell am instrument -e class android.multiuser.UserLifecycleTest -w com.android.perftests.multiuser/android.support.test.runner.AndroidJUnitRunner Change-Id: Ia52db17525d9eb960c9a8c860cdb52c0f487e5f1
Diffstat (limited to 'apct-tests/perftests/multiuser')
-rw-r--r--apct-tests/perftests/multiuser/src/android/multiuser/UserLifecycleTest.java63
1 files changed, 36 insertions, 27 deletions
diff --git a/apct-tests/perftests/multiuser/src/android/multiuser/UserLifecycleTest.java b/apct-tests/perftests/multiuser/src/android/multiuser/UserLifecycleTest.java
index f56c76332faa..e89157b52108 100644
--- a/apct-tests/perftests/multiuser/src/android/multiuser/UserLifecycleTest.java
+++ b/apct-tests/perftests/multiuser/src/android/multiuser/UserLifecycleTest.java
@@ -56,20 +56,8 @@ import java.util.concurrent.TimeUnit;
@LargeTest
@RunWith(AndroidJUnit4.class)
public class UserLifecycleTest {
- private final int TIMEOUT_REMOVE_USER_MS = 4 * 1000; // 4 sec
- private final int CHECK_USER_REMOVED_INTERVAL_MS = 200; // 0.2 sec
-
- private final int TIMEOUT_USER_START_SEC = 4; // 4 sec
-
- private final int TIMEOUT_USER_SWITCH_SEC = 8; // 8 sec
-
- private final int TIMEOUT_USER_STOP_SEC = 1; // 1 sec
-
- private final int TIMEOUT_MANAGED_PROFILE_UNLOCK_SEC = 2; // 2 sec
-
- private final int TIMEOUT_LOCKED_BOOT_COMPLETE_MS = 5 * 1000; // 5 sec
-
- private final int TIMEOUT_EPHERMAL_USER_STOP_SEC = 6; // 6 sec
+ private final int TIMEOUT_IN_SECOND = 10;
+ private final int CHECK_USER_REMOVED_INTERVAL_MS = 200;
private UserManager mUm;
private ActivityManager mAm;
@@ -109,7 +97,7 @@ public class UserLifecycleTest {
final CountDownLatch latch = new CountDownLatch(1);
registerBroadcastReceiver(Intent.ACTION_USER_STARTED, latch, userInfo.id);
mIam.startUserInBackground(userInfo.id);
- latch.await(TIMEOUT_USER_START_SEC, TimeUnit.SECONDS);
+ latch.await(TIMEOUT_IN_SECOND, TimeUnit.SECONDS);
mState.pauseTiming();
removeUser(userInfo.id);
@@ -142,10 +130,10 @@ public class UserLifecycleTest {
final CountDownLatch latch = new CountDownLatch(1);
registerBroadcastReceiver(Intent.ACTION_USER_STARTED, latch, userInfo.id);
mIam.startUserInBackground(userInfo.id);
- latch.await(TIMEOUT_USER_START_SEC, TimeUnit.SECONDS);
+ latch.await(TIMEOUT_IN_SECOND, TimeUnit.SECONDS);
mState.resumeTiming();
- stopUser(userInfo.id);
+ stopUser(userInfo.id, false);
mState.pauseTiming();
removeUser(userInfo.id);
@@ -164,7 +152,7 @@ public class UserLifecycleTest {
mState.resumeTiming();
mAm.switchUser(userInfo.id);
- latch.await(TIMEOUT_LOCKED_BOOT_COMPLETE_MS, TimeUnit.SECONDS);
+ latch.await(TIMEOUT_IN_SECOND, TimeUnit.SECONDS);
mState.pauseTiming();
switchUser(startUser);
@@ -184,7 +172,7 @@ public class UserLifecycleTest {
mState.resumeTiming();
mIam.startUserInBackground(userInfo.id);
- latch.await(TIMEOUT_MANAGED_PROFILE_UNLOCK_SEC, TimeUnit.SECONDS);
+ latch.await(TIMEOUT_IN_SECOND, TimeUnit.SECONDS);
mState.pauseTiming();
removeUser(userInfo.id);
@@ -215,10 +203,30 @@ public class UserLifecycleTest {
mState.resumeTiming();
mAm.switchUser(startUser);
- latch.await(TIMEOUT_EPHERMAL_USER_STOP_SEC, TimeUnit.SECONDS);
+ latch.await(TIMEOUT_IN_SECOND, TimeUnit.SECONDS);
+
+ mState.pauseTiming();
+ switchLatch.await(TIMEOUT_IN_SECOND, TimeUnit.SECONDS);
+ removeUser(userInfo.id);
+ mState.resumeTiming();
+ }
+ }
+
+ @Test
+ public void managedProfileStoppedPerf() throws Exception {
+ while (mState.keepRunning()) {
+ mState.pauseTiming();
+ final UserInfo userInfo = mUm.createProfileForUser("TestUser",
+ UserInfo.FLAG_MANAGED_PROFILE, mAm.getCurrentUser());
+ final CountDownLatch latch = new CountDownLatch(1);
+ registerBroadcastReceiver(Intent.ACTION_USER_UNLOCKED, latch, userInfo.id);
+ mIam.startUserInBackground(userInfo.id);
+ latch.await(TIMEOUT_IN_SECOND, TimeUnit.SECONDS);
+ mState.resumeTiming();
+
+ stopUser(userInfo.id, true);
mState.pauseTiming();
- switchLatch.await(TIMEOUT_USER_SWITCH_SEC, TimeUnit.SECONDS);
removeUser(userInfo.id);
mState.resumeTiming();
}
@@ -228,12 +236,12 @@ public class UserLifecycleTest {
final CountDownLatch latch = new CountDownLatch(1);
registerUserSwitchObserver(latch, null, userId);
mAm.switchUser(userId);
- latch.await(TIMEOUT_USER_SWITCH_SEC, TimeUnit.SECONDS);
+ latch.await(TIMEOUT_IN_SECOND, TimeUnit.SECONDS);
}
- private void stopUser(int userId) throws Exception {
+ private void stopUser(int userId, boolean force) throws Exception {
final CountDownLatch latch = new CountDownLatch(1);
- mIam.stopUser(userId, false /* force */, new IStopUserCallback.Stub() {
+ mIam.stopUser(userId, force /* force */, new IStopUserCallback.Stub() {
@Override
public void userStopped(int userId) throws RemoteException {
latch.countDown();
@@ -243,7 +251,7 @@ public class UserLifecycleTest {
public void userStopAborted(int userId) throws RemoteException {
}
});
- latch.await(TIMEOUT_USER_STOP_SEC, TimeUnit.SECONDS);
+ latch.await(TIMEOUT_IN_SECOND, TimeUnit.SECONDS);
}
private void registerUserSwitchObserver(final CountDownLatch switchLatch,
@@ -283,9 +291,10 @@ public class UserLifecycleTest {
try {
mUm.removeUser(userId);
final long startTime = System.currentTimeMillis();
+ final long timeoutInMs = TIMEOUT_IN_SECOND * 1000;
while (mUm.getUserInfo(userId) != null &&
- System.currentTimeMillis() - startTime < TIMEOUT_REMOVE_USER_MS) {
- Thread.sleep(CHECK_USER_REMOVED_INTERVAL_MS);
+ System.currentTimeMillis() - startTime < timeoutInMs) {
+ TimeUnit.MILLISECONDS.sleep(CHECK_USER_REMOVED_INTERVAL_MS);
}
} catch (InterruptedException e) {
Thread.currentThread().interrupt();