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

Commit 27ef26c8 authored by Dario Freni's avatar Dario Freni
Browse files

Remove tests already covered by CTS.

Bug: 132429173
Bug: 127933960
Test: atest --test-mapping
frameworks/base/services/core/java/com/android/server/rollback/
Change-Id: I88685044d046180866c3cb63538a700cec775fc5
parent 0bb09184
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -14,5 +14,13 @@
        }
      ]
    }
  ],
  "imports": [
    {
      "path": "cts/tests/rollback"
    },
    {
      "path": "cts/hostsidetests/rollback"
    }
  ]
}
+0 −42
Original line number Diff line number Diff line
@@ -78,45 +78,6 @@ android_test_helper_app {
    package_splits: ["anydpi"],
}

apex {
    name: "com.android.tests.rollback.testapex.RollbackTestApexV1",
    manifest: "TestApex/RollbackTestApexV1.json",
    file_contexts: "apex.test",
    prebuilts: ["RollbackTestApex.prebuilt.txt"],
    key: "RollbackTestApex.key",
    installable: false,
}

apex {
    name: "com.android.tests.rollback.testapex.RollbackTestApexV2",
    manifest: "TestApex/RollbackTestApexV2.json",
    file_contexts: "apex.test",
    prebuilts: ["RollbackTestApex.prebuilt.txt"],
    key: "RollbackTestApex.key",
    installable: false,
}

apex {
    name: "com.android.tests.rollback.testapex.RollbackTestApexV3",
    manifest: "TestApex/RollbackTestApexV3.json",
    file_contexts: "apex.test",
    prebuilts: ["RollbackTestApex.prebuilt.txt"],
    key: "RollbackTestApex.key",
    installable: false,
}

apex_key {
    name: "RollbackTestApex.key",
    public_key: "TestApex/com.android.tests.rollback.testapex.avbpubkey",
    private_key: "TestApex/com.android.tests.rollback.testapex.pem",
    installable: false,
}

prebuilt_etc {
    name: "RollbackTestApex.prebuilt.txt",
    src: "TestApex/RollbackTestApex.prebuilt.txt",
}

android_test {
    name: "RollbackTest",
    manifest: "RollbackTest/AndroidManifest.xml",
@@ -132,9 +93,6 @@ android_test {
        ":RollbackTestAppBv2",
        ":RollbackTestAppASplitV1",
        ":RollbackTestAppASplitV2",
        ":com.android.tests.rollback.testapex.RollbackTestApexV1",
        ":com.android.tests.rollback.testapex.RollbackTestApexV2",
        ":com.android.tests.rollback.testapex.RollbackTestApexV3",
    ],
    test_config: "RollbackTest.xml",
    sdk_version: "test_current",
+1 −231
Original line number Diff line number Diff line
@@ -17,7 +17,6 @@
package com.android.tests.rollback;

import static com.android.tests.rollback.RollbackTestUtils.assertRollbackInfoEquals;
import static com.android.tests.rollback.RollbackTestUtils.getRecentlyCommittedRollbackInfoById;
import static com.android.tests.rollback.RollbackTestUtils.getUniqueRollbackInfoForPackage;

import android.Manifest;
@@ -31,7 +30,6 @@ import androidx.test.InstrumentationRegistry;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;

@@ -55,15 +53,7 @@ public class StagedRollbackTest {
    private static final String TAG = "RollbackTest";
    private static final String TEST_APP_A = "com.android.tests.rollback.testapp.A";
    private static final String TEST_APP_A_V1 = "RollbackTestAppAv1.apk";
    private static final String TEST_APP_A_V2 = "RollbackTestAppAv2.apk";
    private static final String TEST_APP_A_CRASHING_V2 = "RollbackTestAppACrashingV2.apk";
    private static final String TEST_APEX_PKG = "com.android.tests.rollback.testapex";
    private static final String TEST_APEX_V1 =
            "com.android.tests.rollback.testapex.RollbackTestApexV1.apex";
    private static final String TEST_APEX_V2 =
            "com.android.tests.rollback.testapex.RollbackTestApexV2.apex";
    private static final String TEST_APEX_V3 =
            "com.android.tests.rollback.testapex.RollbackTestApexV3.apex";

    /**
     * Adopts common shell permissions needed for rollback tests.
@@ -85,59 +75,6 @@ public class StagedRollbackTest {
        RollbackTestUtils.dropShellPermissionIdentity();
    }


    /**
     * Test rollbacks of staged installs involving only apks.
     * Enable rollback phase.
     */
    @Test
    public void testApkOnlyEnableRollback() throws Exception {
        RollbackTestUtils.uninstall(TEST_APP_A);
        assertEquals(-1, RollbackTestUtils.getInstalledVersion(TEST_APP_A));

        RollbackTestUtils.install(TEST_APP_A_V1, false);
        assertEquals(1, RollbackTestUtils.getInstalledVersion(TEST_APP_A));
        RollbackTestUtils.processUserData(TEST_APP_A);

        RollbackTestUtils.installStaged(true, TEST_APP_A_V2);

        // At this point, the host test driver will reboot the device and run
        // testApkOnlyCommitRollback().
    }

    /**
     * Test rollbacks of staged installs involving only apks.
     * Commit rollback phase.
     */
    @Test
    public void testApkOnlyCommitRollback() throws Exception {
        assertEquals(2, RollbackTestUtils.getInstalledVersion(TEST_APP_A));
        RollbackTestUtils.processUserData(TEST_APP_A);

        RollbackManager rm = RollbackTestUtils.getRollbackManager();
        RollbackInfo rollback = getUniqueRollbackInfoForPackage(
                rm.getAvailableRollbacks(), TEST_APP_A);
        assertRollbackInfoEquals(TEST_APP_A, 2, 1, rollback);
        assertTrue(rollback.isStaged());

        RollbackTestUtils.rollback(rollback.getRollbackId(),
                new VersionedPackage(TEST_APP_A, 2));

        rollback = getUniqueRollbackInfoForPackage(
                rm.getRecentlyCommittedRollbacks(), TEST_APP_A);
        assertRollbackInfoEquals(TEST_APP_A, 2, 1, rollback, new VersionedPackage(TEST_APP_A, 2));
        assertTrue(rollback.isStaged());
        assertNotEquals(-1, rollback.getCommittedSessionId());

        RollbackTestUtils.waitForSessionReady(rollback.getCommittedSessionId());

        // The app should not be rolled back until after reboot.
        assertEquals(2, RollbackTestUtils.getInstalledVersion(TEST_APP_A));

        // At this point, the host test driver will reboot the device and run
        // testApkOnlyConfirmRollback().
    }

    /**
     * Test rollbacks of staged installs involving only apks with bad update.
     * Enable rollback phase.
@@ -209,7 +146,7 @@ public class StagedRollbackTest {
     * Confirm rollback phase.
     */
    @Test
    public void testApkOnlyConfirmRollback() throws Exception {
    public void testBadApkOnlyConfirmRollback() throws Exception {
        assertEquals(1, RollbackTestUtils.getInstalledVersion(TEST_APP_A));
        RollbackTestUtils.processUserData(TEST_APP_A);

@@ -220,171 +157,4 @@ public class StagedRollbackTest {
        assertTrue(rollback.isStaged());
        assertNotEquals(-1, rollback.getCommittedSessionId());
    }

    /**
     * Test rollbacks of staged installs an apk and an apex.
     * Enable rollback phase.
     */
    @Test
    public void testApkAndApexEnableRollback() throws Exception {
        RollbackTestUtils.uninstall(TEST_APP_A);
        RollbackTestUtils.install(TEST_APP_A_V1, false);

        assertEquals(1, RollbackTestUtils.getInstalledVersion(TEST_APEX_PKG));
        assertEquals(1, RollbackTestUtils.getInstalledVersion(TEST_APP_A));

        RollbackTestUtils.installStaged(true, TEST_APP_A_V2, TEST_APEX_V2);

        // At this point, the host test driver will reboot the device and run
        // testApkAndApexCommitRollback().
    }

    /**
     * Test rollbacks of staged installs an apk and an apex.
     * Commit rollback phase.
     */
    @Test
    public void testApkAndApexCommitRollback() throws Exception {
        assertEquals(2, RollbackTestUtils.getInstalledVersion(TEST_APEX_PKG));
        assertEquals(2, RollbackTestUtils.getInstalledVersion(TEST_APP_A));

        RollbackTestUtils.processUserData(TEST_APP_A);

        RollbackManager rm = RollbackTestUtils.getRollbackManager();

        RollbackInfo rollback = getUniqueRollbackInfoForPackage(
                rm.getAvailableRollbacks(), TEST_APP_A);
        String[] packagesNames = {TEST_APEX_PKG, TEST_APP_A};
        assertRollbackInfoEquals(packagesNames, 2, 1, rollback);
        assertTrue(rollback.isStaged());

        RollbackTestUtils.rollback(rollback.getRollbackId());

        RollbackInfo committed = getRecentlyCommittedRollbackInfoById(rollback.getRollbackId());

        assertRollbackInfoEquals(packagesNames, 2, 1, committed);
        assertTrue(committed.isStaged());
        assertNotEquals(-1, committed.getCommittedSessionId());

        RollbackTestUtils.waitForSessionReady(committed.getCommittedSessionId());

        // The apex and apk should not be rolled back until after reboot.
        assertEquals(2, RollbackTestUtils.getInstalledVersion(TEST_APEX_PKG));
        assertEquals(2, RollbackTestUtils.getInstalledVersion(TEST_APP_A));

        // At this point, the host test driver will reboot the device and run
        // testApkAndApexConfirmRollback().
    }

    /**
     * Test rollbacks of staged installs an apk and an apex.
     * Confirm rollback phase.
     */
    @Test
    public void testApkAndApexConfirmRollback() throws Exception {
        assertEquals(1, RollbackTestUtils.getInstalledVersion(TEST_APEX_PKG));
        assertEquals(1, RollbackTestUtils.getInstalledVersion(TEST_APP_A));

        RollbackTestUtils.processUserData(TEST_APP_A);
    }

    /**
     * Test rollbacks of staged installs involving only apex.
     * Enable rollback phase.
     */
    @Test
    public void testApexOnlyEnableRollback() throws Exception {
        assertEquals(1, RollbackTestUtils.getInstalledVersion(TEST_APEX_PKG));
        RollbackTestUtils.installStaged(true, TEST_APEX_V2);

        // At this point, the host test driver will reboot the device and run
        // testApexOnlyCommitRollback().
    }

    /**
     * Test rollbacks of staged installs involving only apex.
     * Commit rollback phase.
     */
    @Test
    public void testApexOnlyCommitRollback() throws Exception {
        assertEquals(2, RollbackTestUtils.getInstalledVersion(TEST_APEX_PKG));

        RollbackManager rm = RollbackTestUtils.getRollbackManager();
        RollbackInfo rollback = getUniqueRollbackInfoForPackage(
                rm.getAvailableRollbacks(), TEST_APEX_PKG);
        assertRollbackInfoEquals(TEST_APEX_PKG, 2, 1, rollback);
        assertTrue(rollback.isStaged());

        RollbackTestUtils.rollback(rollback.getRollbackId());

        RollbackInfo committed = getRecentlyCommittedRollbackInfoById(rollback.getRollbackId());

        assertRollbackInfoEquals(TEST_APEX_PKG, 2, 1, committed);
        assertTrue(committed.isStaged());
        assertNotEquals(-1, committed.getCommittedSessionId());

        RollbackTestUtils.waitForSessionReady(committed.getCommittedSessionId());

        // The apex should not be rolled back until after reboot.
        assertEquals(2, RollbackTestUtils.getInstalledVersion(TEST_APEX_PKG));

        // At this point, the host test driver will reboot the device and run
        // testApexOnlyConfirmRollback().
    }

    /**
     * Test rollbacks of staged installs involving only apex.
     * Confirm rollback phase.
     */
    @Test
    public void testApexOnlyConfirmRollback() throws Exception {
        assertEquals(1, RollbackTestUtils.getInstalledVersion(TEST_APEX_PKG));
    }

    /**
     * Tests that apex update expires existing rollbacks for that apex.
     * Enable rollback phase.
     */
    @Test
    public void testApexRollbackExpirationEnableRollback() throws Exception {
        assertEquals(1, RollbackTestUtils.getInstalledVersion(TEST_APEX_PKG));
        RollbackTestUtils.installStaged(true, TEST_APEX_V2);

        // At this point, the host test driver will reboot the device and run
        // testApexRollbackExpirationUpdateApex().
    }

    /**
     * Tests that apex update expires existing rollbacks for that apex.
     * Update apex phase.
     */
    @Test
    public void testApexRollbackExpirationUpdateApex() throws Exception {
        assertEquals(2, RollbackTestUtils.getInstalledVersion(TEST_APEX_PKG));
        RollbackTestUtils.installStaged(false, TEST_APEX_V3);

        // At this point, the host test driver will reboot the device and run
        // testApexRollbackExpirationConfirmExpiration().
    }

    /**
     * Tests that apex update expires existing rollbacks for that apex.
     * Confirm expiration phase.
     */
    @Test
    public void testApexRollbackExpirationConfirmExpiration() throws Exception {
        assertEquals(3, RollbackTestUtils.getInstalledVersion(TEST_APEX_PKG));

        RollbackManager rm = RollbackTestUtils.getRollbackManager();
        assertNull(getUniqueRollbackInfoForPackage(rm.getAvailableRollbacks(), TEST_APEX_PKG));
    }

    /**
     * Helper function called by the host test to install v1 of the test apex,
     * assuming the test apex is not installed.
     */
    @Test
    public void installTestApexV1() throws Exception {
        RollbackTestUtils.installStaged(false, TEST_APEX_V1);
    }
}
+1 −77
Original line number Diff line number Diff line
@@ -19,7 +19,6 @@ package com.android.tests.rollback.host;
import static org.junit.Assert.assertTrue;

import com.android.ddmlib.Log.LogLevel;
import com.android.tradefed.device.ITestDevice;
import com.android.tradefed.log.LogUtil.CLog;
import com.android.tradefed.testtype.DeviceJUnit4ClassRunner;
import com.android.tradefed.testtype.junit4.BaseHostJUnit4Test;
@@ -32,9 +31,6 @@ import org.junit.runner.RunWith;
 */
@RunWith(DeviceJUnit4ClassRunner.class)
public class StagedRollbackTest extends BaseHostJUnit4Test {

    private static final String TEST_APEX_PKG = "com.android.tests.rollback.testapex";

    /**
     * Runs the given phase of a test by calling into the device.
     * Throws an exception if the test phase fails.
@@ -47,18 +43,6 @@ public class StagedRollbackTest extends BaseHostJUnit4Test {
                    phase));
    }

    /**
     * Tests staged rollbacks involving only apks.
     */
    @Test
    public void testApkOnly() throws Exception {
        runPhase("testApkOnlyEnableRollback");
        getDevice().reboot();
        runPhase("testApkOnlyCommitRollback");
        getDevice().reboot();
        runPhase("testApkOnlyConfirmRollback");
    }

    /**
     * Tests watchdog triggered staged rollbacks involving only apks.
     */
@@ -79,66 +63,6 @@ public class StagedRollbackTest extends BaseHostJUnit4Test {
        }

        getDevice().waitForDeviceAvailable();
        runPhase("testApkOnlyConfirmRollback");
    }

    /**
     * Tests staged rollbacks involving only apex.
     */
    @Test
    public void testApexOnly() throws Exception {
        installTestApexV1();
        runPhase("testApexOnlyEnableRollback");
        getDevice().reboot();
        runPhase("testApexOnlyCommitRollback");
        getDevice().reboot();
        runPhase("testApexOnlyConfirmRollback");
    }

    /**
     * Tests staged rollbacks involving apk and apex.
     */
    @Test
    public void testApkAndApex() throws Exception {
        installTestApexV1();
        runPhase("testApkAndApexEnableRollback");
        getDevice().reboot();
        runPhase("testApkAndApexCommitRollback");
        getDevice().reboot();
        runPhase("testApkAndApexConfirmRollback");
    }

    /**
     * Tests that apex update expires existing rollbacks for that apex.
     */
    @Test
    public void testApexRollbackExpiration() throws Exception {
        installTestApexV1();
        runPhase("testApexRollbackExpirationEnableRollback");
        getDevice().reboot();
        runPhase("testApexRollbackExpirationUpdateApex");
        getDevice().reboot();
        runPhase("testApexRollbackExpirationConfirmExpiration");
    }

    /**
     * Do whatever is necessary to get version 1 of the test apex installed on
     * the device. Try to do so without extra reboots where possible to keep
     * the test execution time down.
     */
    private void installTestApexV1() throws Exception {
        for (ITestDevice.ApexInfo apexInfo : getDevice().getActiveApexes()) {
            if (TEST_APEX_PKG.equals(apexInfo.name)) {
                if (apexInfo.versionCode == 1) {
                    return;
                }
                getDevice().uninstallPackage(TEST_APEX_PKG);
                getDevice().reboot();
                break;
            }
        }

        runPhase("installTestApexV1");
        getDevice().reboot();
        runPhase("testBadApkOnlyConfirmRollback");
    }
}
+0 −3
Original line number Diff line number Diff line

This file contains dummy content to include in the RollbackTestApex.
Loading