Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit f86cecf8 authored by JW Wang's avatar JW Wang
Browse files

Rewrite and re-enable the test (1/n)

The test is rewritten as testNetworkFailedRollback was in ag/9648485 to
empoly more device methods for better logging and debugging.

Bug: 147259494
Test: atest StagedRollbackTest
Change-Id: I4104d20296dee4abba2996f8f9e3b47e258bf6a9
parent 72874be4
Loading
Loading
Loading
Loading
+13 −0
Original line number Diff line number Diff line
@@ -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();

@@ -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
@@ -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();
+0 −16
Original line number Diff line number Diff line
@@ -23,7 +23,6 @@ import com.android.tradefed.testtype.DeviceJUnit4ClassRunner;
import com.android.tradefed.testtype.junit4.BaseHostJUnit4Test;

import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;

@@ -128,21 +127,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();

@@ -157,8 +143,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");
    }