Fix flaky testEnableRollbackTimeoutFailsRollback test

We no longer block on the handler thread in getAvailableRollbacks. That
means it is possible we see an available rollback left over from a
previous test run. Update the test to ensure previous rollbacks are
removed and give sufficient time to make a new rollback available before
concluding that no rollback will be made available in this case.

Test: atest RollbackTest:com.android.tests.rollback.RollbackTest#testEnableRollbackTimeoutFailsRollback
Change-Id: I8b22320bb3ee60152ab808706913eff43ab7cc9f
Merged-In: Id94d5452836b07d6f802758bd0dfdd3c276a3c05
This commit is contained in:
Richard Uhler
2019-08-29 12:03:35 +01:00
committed by Bill Lin
parent 77a40731f8
commit 1d66bf8c48

View File

@@ -1021,6 +1021,7 @@ public class RollbackTest {
Uninstall.packages(TestApp.A);
Install.single(TestApp.A1).commit();
waitForUnavailableRollback(TestApp.A);
// Block the RollbackManager to make extra sure it will not be
// able to enable the rollback in time.
@@ -1029,6 +1030,10 @@ public class RollbackTest {
assertThat(InstallUtils.getInstalledVersion(TestApp.A)).isEqualTo(2);
// Give plenty of time for RollbackManager to unblock and attempt
// to make the rollback available before asserting that the
// rollback was not made available.
Thread.sleep(TimeUnit.SECONDS.toMillis(2));
assertThat(
getUniqueRollbackInfoForPackage(rm.getAvailableRollbacks(), TestApp.A)).isNull();
} finally {