diff options
author | JW Wang <wangchun@google.com> | 2020-03-04 17:28:05 +0800 |
---|---|---|
committer | JW Wang <wangchun@google.com> | 2020-03-09 10:01:23 +0800 |
commit | 45bf445ed4ebb8d2491cdef0046ea7d548cc7799 (patch) | |
tree | 196d24c977d9254a3e8d30531a23c283c11165fe /tests/RollbackTest | |
parent | 71b352b211ca3cefba511094ae0480a92b8216be (diff) |
Rewrite testBadApkOnly (1/n)
When tradefed fails to run a test, it will try to recover the device
which might lead to another reboot. This interferes with our test
flow which also involves reboot. See b/150749023#comment2 for more
details.
Let's rewrite the test to prevent auto-recovery of tradefed from kicking
in. Generally, it is a bad practice to depend our test flow on a failed
test due to reboot. We should call #waitForDeviceNotAvailable to wait
for reboot to happen and then call #waitForDeviceAvailable before
continuing next tests.
Bug: 150749023
Test: atest StagedRollbackTest#testBadApkOnly
Change-Id: Ia39630585c3b7344174a8c66d0a33f05a2d80cc7
Diffstat (limited to 'tests/RollbackTest')
2 files changed, 5 insertions, 9 deletions
diff --git a/tests/RollbackTest/RollbackTest/src/com/android/tests/rollback/StagedRollbackTest.java b/tests/RollbackTest/RollbackTest/src/com/android/tests/rollback/StagedRollbackTest.java index 70be83f216da..a616c61b34f8 100644 --- a/tests/RollbackTest/RollbackTest/src/com/android/tests/rollback/StagedRollbackTest.java +++ b/tests/RollbackTest/RollbackTest/src/com/android/tests/rollback/StagedRollbackTest.java @@ -127,18 +127,12 @@ public class StagedRollbackTest { /** * Test rollbacks of staged installs involving only apks with bad update. - * Trigger rollback phase. This is expected to fail due to watchdog - * rebooting the test out from under it. + * Trigger rollback phase. */ @Test public void testBadApkOnly_Phase3() throws Exception { // One more crash to trigger rollback RollbackUtils.sendCrashBroadcast(TestApp.A, 1); - - // We expect the device to be rebooted automatically. Wait for that to happen. - // This device method will fail and the host will catch the assertion. - // If reboot doesn't happen, the host will fail the assertion. - Thread.sleep(TimeUnit.SECONDS.toMillis(120)); } /** diff --git a/tests/RollbackTest/StagedRollbackTest/src/com/android/tests/rollback/host/StagedRollbackTest.java b/tests/RollbackTest/StagedRollbackTest/src/com/android/tests/rollback/host/StagedRollbackTest.java index 4afebb58c105..282f012dbf6f 100644 --- a/tests/RollbackTest/StagedRollbackTest/src/com/android/tests/rollback/host/StagedRollbackTest.java +++ b/tests/RollbackTest/StagedRollbackTest/src/com/android/tests/rollback/host/StagedRollbackTest.java @@ -22,7 +22,6 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNull; import static org.junit.Assert.assertTrue; import static org.junit.Assume.assumeTrue; -import static org.testng.Assert.assertThrows; import com.android.compatibility.common.tradefed.build.CompatibilityBuildHelper; import com.android.tradefed.testtype.DeviceJUnit4ClassRunner; @@ -136,7 +135,10 @@ public class StagedRollbackTest extends BaseHostJUnit4Test { getDevice().reboot(); runPhase("testBadApkOnly_Phase2"); - assertThrows(AssertionError.class, () -> runPhase("testBadApkOnly_Phase3")); + // Trigger rollback and wait for reboot to happen + runPhase("testBadApkOnly_Phase3"); + assertTrue(getDevice().waitForDeviceNotAvailable(TimeUnit.MINUTES.toMillis(2))); + getDevice().waitForDeviceAvailable(); runPhase("testBadApkOnly_Phase4"); |