Loading tests/RollbackTest/RollbackTest/src/com/android/tests/rollback/StagedRollbackTest.java +23 −5 Original line number Diff line number Diff line Loading @@ -324,6 +324,7 @@ public class StagedRollbackTest { @Test public void testNetworkPassedDoesNotRollback_Phase1() throws Exception { // Remove available rollbacks and uninstall NetworkStack on /data/ RollbackManager rm = RollbackUtils.getRollbackManager(); String networkStack = getNetworkStackPackageName(); Loading @@ -332,6 +333,15 @@ public class StagedRollbackTest { assertThat(getUniqueRollbackInfoForPackage(rm.getAvailableRollbacks(), networkStack)).isNull(); // Reduce health check deadline, here unlike the network failed case, we use // a longer deadline because joining a network can take a much longer time for // reasons external to the device than 'not joining' DeviceConfig.setProperty(DeviceConfig.NAMESPACE_ROLLBACK, PROPERTY_WATCHDOG_REQUEST_TIMEOUT_MILLIS, Integer.toString(300000), false); // Simulate re-installation of new NetworkStack with rollbacks enabled installNetworkStackPackage(); } @Test Loading @@ -343,6 +353,9 @@ public class StagedRollbackTest { @Test public void testNetworkPassedDoesNotRollback_Phase3() throws Exception { // Sleep for > health check deadline. We expect no rollback should happen during sleeping. // If the device reboots for rollback, this device test will fail as well as the host test. Thread.sleep(TimeUnit.SECONDS.toMillis(310)); RollbackManager rm = RollbackUtils.getRollbackManager(); assertThat(getUniqueRollbackInfoForPackage(rm.getRecentlyCommittedRollbacks(), getNetworkStackPackageName())).isNull(); Loading Loading @@ -379,11 +392,6 @@ public class StagedRollbackTest { assertThat(RollbackUtils.getAvailableRollback(getModuleMetadataPackageName())).isNotNull(); } @Test public void testRollbackWhitelistedApp_cleanUp() throws Exception { RollbackUtils.getRollbackManager().expireRollbackForPackage(getModuleMetadataPackageName()); } @Test public void testRollbackDataPolicy_Phase1() throws Exception { Uninstall.packages(TestApp.A, TestApp.B); Loading Loading @@ -422,6 +430,16 @@ public class StagedRollbackTest { assertThat(InstallUtils.getUserDataVersion(TestApp.B)).isEqualTo(1); } @Test public void testCleanUp() throws Exception { // testNativeWatchdogTriggersRollback will fail if multiple staged sessions are // committed on a device which doesn't support checkpoint. Let's clean up all rollbacks // so there is only one rollback to commit when testing native crashes. RollbackManager rm = RollbackUtils.getRollbackManager(); rm.getAvailableRollbacks().stream().flatMap(info -> info.getPackages().stream()) .map(info -> info.getPackageName()).forEach(rm::expireRollbackForPackage); } private static void runShellCommand(String cmd) { ParcelFileDescriptor pfd = InstrumentationRegistry.getInstrumentation().getUiAutomation() .executeShellCommand(cmd); Loading tests/RollbackTest/StagedRollbackTest/src/com/android/tests/rollback/host/StagedRollbackTest.java +9 −26 Original line number Diff line number Diff line Loading @@ -22,8 +22,8 @@ import static org.testng.Assert.assertThrows; import com.android.tradefed.testtype.DeviceJUnit4ClassRunner; import com.android.tradefed.testtype.junit4.BaseHostJUnit4Test; import org.junit.After; import org.junit.Before; import org.junit.Ignore; import org.junit.Test; import org.junit.runner.RunWith; Loading Loading @@ -53,6 +53,11 @@ public class StagedRollbackTest extends BaseHostJUnit4Test { getDevice().reboot(); } @After public void tearDown() throws Exception { runPhase("testCleanUp"); } /** * Tests watchdog triggered staged rollbacks involving only apks. */ Loading Loading @@ -128,21 +133,8 @@ public class StagedRollbackTest extends BaseHostJUnit4Test { * Tests passed network health check does not trigger watchdog staged rollbacks. */ @Test @Ignore("b/143514090") public void testNetworkPassedDoesNotRollback() throws Exception { // Remove available rollbacks and uninstall NetworkStack on /data/ runPhase("testNetworkPassedDoesNotRollback_Phase1"); // Reduce health check deadline, here unlike the network failed case, we use // a longer deadline because joining a network can take a much longer time for // reasons external to the device than 'not joining' getDevice().executeShellCommand("device_config put rollback " + "watchdog_request_timeout_millis 300000"); // Simulate re-installation of new NetworkStack with rollbacks enabled getDevice().executeShellCommand("pm install -r --staged --enable-rollback " + getNetworkStackPath()); // Sleep to allow writes to disk before reboot Thread.sleep(5000); // Reboot device to activate staged package getDevice().reboot(); Loading @@ -157,8 +149,6 @@ public class StagedRollbackTest extends BaseHostJUnit4Test { // on mobile data getDevice().waitForDeviceAvailable(); // Sleep for > health check deadline Thread.sleep(310000); // Verify rollback was not executed after health check deadline runPhase("testNetworkPassedDoesNotRollback_Phase3"); } Loading @@ -180,16 +170,9 @@ public class StagedRollbackTest extends BaseHostJUnit4Test { */ @Test public void testRollbackWhitelistedApp() throws Exception { try { runPhase("testRollbackWhitelistedApp_Phase1"); getDevice().reboot(); runPhase("testRollbackWhitelistedApp_Phase2"); } finally { // testNativeWatchdogTriggersRollback will fail if multiple staged sessions are // committed on a device which doesn't support checkpoint. Let's clean up the rollback // so there is only one rollback to commit when testing native crashes. runPhase("testRollbackWhitelistedApp_cleanUp"); } } @Test Loading Loading
tests/RollbackTest/RollbackTest/src/com/android/tests/rollback/StagedRollbackTest.java +23 −5 Original line number Diff line number Diff line Loading @@ -324,6 +324,7 @@ public class StagedRollbackTest { @Test public void testNetworkPassedDoesNotRollback_Phase1() throws Exception { // Remove available rollbacks and uninstall NetworkStack on /data/ RollbackManager rm = RollbackUtils.getRollbackManager(); String networkStack = getNetworkStackPackageName(); Loading @@ -332,6 +333,15 @@ public class StagedRollbackTest { assertThat(getUniqueRollbackInfoForPackage(rm.getAvailableRollbacks(), networkStack)).isNull(); // Reduce health check deadline, here unlike the network failed case, we use // a longer deadline because joining a network can take a much longer time for // reasons external to the device than 'not joining' DeviceConfig.setProperty(DeviceConfig.NAMESPACE_ROLLBACK, PROPERTY_WATCHDOG_REQUEST_TIMEOUT_MILLIS, Integer.toString(300000), false); // Simulate re-installation of new NetworkStack with rollbacks enabled installNetworkStackPackage(); } @Test Loading @@ -343,6 +353,9 @@ public class StagedRollbackTest { @Test public void testNetworkPassedDoesNotRollback_Phase3() throws Exception { // Sleep for > health check deadline. We expect no rollback should happen during sleeping. // If the device reboots for rollback, this device test will fail as well as the host test. Thread.sleep(TimeUnit.SECONDS.toMillis(310)); RollbackManager rm = RollbackUtils.getRollbackManager(); assertThat(getUniqueRollbackInfoForPackage(rm.getRecentlyCommittedRollbacks(), getNetworkStackPackageName())).isNull(); Loading Loading @@ -379,11 +392,6 @@ public class StagedRollbackTest { assertThat(RollbackUtils.getAvailableRollback(getModuleMetadataPackageName())).isNotNull(); } @Test public void testRollbackWhitelistedApp_cleanUp() throws Exception { RollbackUtils.getRollbackManager().expireRollbackForPackage(getModuleMetadataPackageName()); } @Test public void testRollbackDataPolicy_Phase1() throws Exception { Uninstall.packages(TestApp.A, TestApp.B); Loading Loading @@ -422,6 +430,16 @@ public class StagedRollbackTest { assertThat(InstallUtils.getUserDataVersion(TestApp.B)).isEqualTo(1); } @Test public void testCleanUp() throws Exception { // testNativeWatchdogTriggersRollback will fail if multiple staged sessions are // committed on a device which doesn't support checkpoint. Let's clean up all rollbacks // so there is only one rollback to commit when testing native crashes. RollbackManager rm = RollbackUtils.getRollbackManager(); rm.getAvailableRollbacks().stream().flatMap(info -> info.getPackages().stream()) .map(info -> info.getPackageName()).forEach(rm::expireRollbackForPackage); } private static void runShellCommand(String cmd) { ParcelFileDescriptor pfd = InstrumentationRegistry.getInstrumentation().getUiAutomation() .executeShellCommand(cmd); Loading
tests/RollbackTest/StagedRollbackTest/src/com/android/tests/rollback/host/StagedRollbackTest.java +9 −26 Original line number Diff line number Diff line Loading @@ -22,8 +22,8 @@ import static org.testng.Assert.assertThrows; import com.android.tradefed.testtype.DeviceJUnit4ClassRunner; import com.android.tradefed.testtype.junit4.BaseHostJUnit4Test; import org.junit.After; import org.junit.Before; import org.junit.Ignore; import org.junit.Test; import org.junit.runner.RunWith; Loading Loading @@ -53,6 +53,11 @@ public class StagedRollbackTest extends BaseHostJUnit4Test { getDevice().reboot(); } @After public void tearDown() throws Exception { runPhase("testCleanUp"); } /** * Tests watchdog triggered staged rollbacks involving only apks. */ Loading Loading @@ -128,21 +133,8 @@ public class StagedRollbackTest extends BaseHostJUnit4Test { * Tests passed network health check does not trigger watchdog staged rollbacks. */ @Test @Ignore("b/143514090") public void testNetworkPassedDoesNotRollback() throws Exception { // Remove available rollbacks and uninstall NetworkStack on /data/ runPhase("testNetworkPassedDoesNotRollback_Phase1"); // Reduce health check deadline, here unlike the network failed case, we use // a longer deadline because joining a network can take a much longer time for // reasons external to the device than 'not joining' getDevice().executeShellCommand("device_config put rollback " + "watchdog_request_timeout_millis 300000"); // Simulate re-installation of new NetworkStack with rollbacks enabled getDevice().executeShellCommand("pm install -r --staged --enable-rollback " + getNetworkStackPath()); // Sleep to allow writes to disk before reboot Thread.sleep(5000); // Reboot device to activate staged package getDevice().reboot(); Loading @@ -157,8 +149,6 @@ public class StagedRollbackTest extends BaseHostJUnit4Test { // on mobile data getDevice().waitForDeviceAvailable(); // Sleep for > health check deadline Thread.sleep(310000); // Verify rollback was not executed after health check deadline runPhase("testNetworkPassedDoesNotRollback_Phase3"); } Loading @@ -180,16 +170,9 @@ public class StagedRollbackTest extends BaseHostJUnit4Test { */ @Test public void testRollbackWhitelistedApp() throws Exception { try { runPhase("testRollbackWhitelistedApp_Phase1"); getDevice().reboot(); runPhase("testRollbackWhitelistedApp_Phase2"); } finally { // testNativeWatchdogTriggersRollback will fail if multiple staged sessions are // committed on a device which doesn't support checkpoint. Let's clean up the rollback // so there is only one rollback to commit when testing native crashes. runPhase("testRollbackWhitelistedApp_cleanUp"); } } @Test Loading