From 27ef26c880e871b0bb9547ebbc4e6b70e8cd9a86 Mon Sep 17 00:00:00 2001 From: Dario Freni Date: Fri, 10 May 2019 17:52:21 +0100 Subject: [PATCH] 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 --- .../com/android/server/rollback/TEST_MAPPING | 8 + tests/RollbackTest/Android.bp | 42 ---- .../tests/rollback/StagedRollbackTest.java | 232 +----------------- .../rollback/host/StagedRollbackTest.java | 78 +----- .../TestApex/RollbackTestApex.prebuilt.txt | 3 - .../TestApex/RollbackTestApexV1.json | 4 - .../TestApex/RollbackTestApexV2.json | 4 - .../TestApex/RollbackTestApexV3.json | 4 - ....android.tests.rollback.testapex.avbpubkey | Bin 1032 -> 0 bytes .../com.android.tests.rollback.testapex.pem | 51 ---- 10 files changed, 10 insertions(+), 416 deletions(-) delete mode 100644 tests/RollbackTest/TestApex/RollbackTestApex.prebuilt.txt delete mode 100644 tests/RollbackTest/TestApex/RollbackTestApexV1.json delete mode 100644 tests/RollbackTest/TestApex/RollbackTestApexV2.json delete mode 100644 tests/RollbackTest/TestApex/RollbackTestApexV3.json delete mode 100644 tests/RollbackTest/TestApex/com.android.tests.rollback.testapex.avbpubkey delete mode 100644 tests/RollbackTest/TestApex/com.android.tests.rollback.testapex.pem diff --git a/services/core/java/com/android/server/rollback/TEST_MAPPING b/services/core/java/com/android/server/rollback/TEST_MAPPING index 921b75478d137..8c7b5acf5c3ab 100644 --- a/services/core/java/com/android/server/rollback/TEST_MAPPING +++ b/services/core/java/com/android/server/rollback/TEST_MAPPING @@ -14,5 +14,13 @@ } ] } + ], + "imports": [ + { + "path": "cts/tests/rollback" + }, + { + "path": "cts/hostsidetests/rollback" + } ] } diff --git a/tests/RollbackTest/Android.bp b/tests/RollbackTest/Android.bp index 1932871d86b9f..1cf3d364a8d55 100644 --- a/tests/RollbackTest/Android.bp +++ b/tests/RollbackTest/Android.bp @@ -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", 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 b3a9f4933de97..1ddfa6ee54ce7 100644 --- a/tests/RollbackTest/RollbackTest/src/com/android/tests/rollback/StagedRollbackTest.java +++ b/tests/RollbackTest/RollbackTest/src/com/android/tests/rollback/StagedRollbackTest.java @@ -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); - } } 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 2433434a29933..75a95adf460a6 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 @@ -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"); } } diff --git a/tests/RollbackTest/TestApex/RollbackTestApex.prebuilt.txt b/tests/RollbackTest/TestApex/RollbackTestApex.prebuilt.txt deleted file mode 100644 index e871146fb8248..0000000000000 --- a/tests/RollbackTest/TestApex/RollbackTestApex.prebuilt.txt +++ /dev/null @@ -1,3 +0,0 @@ - -This file contains dummy content to include in the RollbackTestApex. - diff --git a/tests/RollbackTest/TestApex/RollbackTestApexV1.json b/tests/RollbackTest/TestApex/RollbackTestApexV1.json deleted file mode 100644 index c3239ca0d902f..0000000000000 --- a/tests/RollbackTest/TestApex/RollbackTestApexV1.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "name": "com.android.tests.rollback.testapex", - "version": 1 -} diff --git a/tests/RollbackTest/TestApex/RollbackTestApexV2.json b/tests/RollbackTest/TestApex/RollbackTestApexV2.json deleted file mode 100644 index 9de3f45908774..0000000000000 --- a/tests/RollbackTest/TestApex/RollbackTestApexV2.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "name": "com.android.tests.rollback.testapex", - "version": 2 -} diff --git a/tests/RollbackTest/TestApex/RollbackTestApexV3.json b/tests/RollbackTest/TestApex/RollbackTestApexV3.json deleted file mode 100644 index 87a2c9dbcb6ae..0000000000000 --- a/tests/RollbackTest/TestApex/RollbackTestApexV3.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "name": "com.android.tests.rollback.testapex", - "version": 3 -} diff --git a/tests/RollbackTest/TestApex/com.android.tests.rollback.testapex.avbpubkey b/tests/RollbackTest/TestApex/com.android.tests.rollback.testapex.avbpubkey deleted file mode 100644 index b347331bc539bf2d9ce6fb2d13cc69a803651f69..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1032 zcmV+j1o!&@01yB`1dIc$64(0vkuoB>vV;YJw=_kcu(l@?51RsR?@;6(R!_AjS5>WW z(m$VO;3b;bj;ooN?C)9K<%4nw!@v-whZ;ma4t4kNLyUSbo!e46R2y_OC{sw$koR6 z8TGL#BQw>owdRT5dfkogt_I8K?2lm7#hPzr&0P!$G;jhSD{@n`53eDQ;ZNnrdX^GL zXkNQKJAR;xmBHtMfvUKBR z97Ir&P=Qqjo{YNb5yFNKvg(Z(v+3w=3D{dn;DewARZR#|JH@-G=1by|SY^q)Y@r*! z4C6bJq?h8+YFIzP#aIyM;mIw@OnN4ng@^HiX0H}i-(#p!0)TyKd&meXbAvShx7|Hz=&jJpL310k2=uTsE^5IW z>L9RPaKqOF(2~-PSl&(hAlB4Qp;DJ3Pz*^*q?g-OcpGJtWYkJ>14QsQcC&=blzi)w z82A!jD4#VF0SezCVt>91$FAEy|EOJv&=&=V=8mi5{73hX63mdKUXGU0UT*56J6e6* zM)P^ie84)cDPosEswu;L**1+{GIv@A{kZY?)Pcbd5Y~w{jK&NUwORLbI|0k<=9U@_ zK3%3^pKF&!2&aj+g0kb1=GswgJ&{F`5Fn+23^`Mt