Commit Graph

20 Commits

Author SHA1 Message Date
JW Wang
350c26a4bf Fix a flaky test.
See b/152840581#comment2 for the analysis.

call #waitForDeviceNotAvailable to wait for reboot reliably.

Bug: 152840581
Test: atest NetworkStagedRollbackTest
Change-Id: Ibbc9998c74681b1b8fc29b90ea66406f39ae7443
2020-04-01 18:33:20 +08:00
JW Wang
d617d2ffbe Extract common code to a lib (4/n)
Bug: 147785893
Test: atest StagedRollbackTest NetworkStagedRollbackTest
Change-Id: I98da9f6287680691eb17afcd931b51c215da213c
2020-02-12 17:22:00 +08:00
JW Wang
ce92d6309a Move network tests to new classes (1/n)
By classifying the tests into 2 categories, we can:
1) run remaining tests with network disabled to reduce the interference
   of network crashes.
2) make it easier to identify bugs caused by network stack or
   problems in rollback infra.

Note this CL contains stubs only. We will move actual test code later.

Bug: 147785893
Test: m
Change-Id: I5ecc63a057e9a115ea3aa446970a3f20dff750d0
2020-02-07 19:49:12 +08:00
Mohammad Samiul Islam
e7e63a692a Revert "Revert "Make RollbackPackageHealthObserver observe apk-in-apex""
This reverts commit 400124c6ae.

Reason for revert: Fixed the compile error; TestAppACrashingV2 was not
available to com.android.apex.apkrollback.test_v1

Change-Id: Ic443e913b837c9bb2716678521ad1d12d3bc7e4d
2020-01-16 14:00:28 +00:00
Greg Kaiser
400124c6ae Revert "Make RollbackPackageHealthObserver observe apk-in-apex"
This reverts commit d56ce00039.

This revert is to fix the wembley build.

Test: Local wembley build
Change-Id: I651f20ffc6ba11cced5a2a737fd3d77211127221
2020-01-16 05:40:17 -08:00
Mohammad Samiul Islam
d56ce00039 Make RollbackPackageHealthObserver observe apk-in-apex
Due to b/147666157, this CL will only work as long as an apk is not
embedded in two different apex.

Bug: 142712057
Test: StagedRollbackTest#testRollbackApexWithApkCrashing
Change-Id: I60f7f70b627fd380094a11373259debddd5dc532
2020-01-15 15:29:32 +00:00
Mohammad Samiul Islam
3fcecfc1ce Rollback user data of apks-in-apex while rolling back the apex
Currently, the RollbackManager is not aware of the apk-in-apex being
installed since the install is done by PM during scan phase of boot. As
such, RM does not backup the user data of the apk-in-apex.

In the new implementation, we ask the RM to snapshot/restore user data
of apk-in-apex while resuming the apex session in StagingManager.

Bug: 142712057
Test: atest StagedRollbackTest#testRollbackApexWithApk
Test: atest AppDataRollbackHelperTest
Test: atest RollbackStoreTest
Test: atest RollbackUnitTest
Change-Id: Ibbaa5d0c98cb883588c085d77bc89c3e8217d76a
2020-01-10 16:15:47 +00:00
JW Wang
05ebdd40b9 Rewrite testNetworkFailedRollback_Phase3 (1/n)
Move test code to device side so we can assert reboot more reliably.

Bug: 143035398
Test: atest StagedRollbackTest
Change-Id: I84f65ce17ad38b524b26436933f9c090c1b581c5
2019-10-28 09:16:28 +08:00
JW Wang
0551fa0e78 Remov a todo that is no longer needed
There is not much point in building internal tests against the SDK and
limiting its API usage.

See b/136044235 #4 ~ #6 for detailed discussion.

Bug: 136044235
Test: mm
no build breaks should happen

Change-Id: I02437d7e4436cfc9b1fce9b04b0edb50bf70dc28
2019-10-15 09:29:43 +08:00
Gavin Corkery
a859e8affc Add multi-user test for the general non-staged case
This test makes assertions about the case where there are two
users running a test application. It verifies that each user can
have its own unique userdata for the same app, and that upgrades
and downgrades are applicable for all users on the device.

Test: atest MultiUserRollbackTest
Test: atest RollbackTest
Bug: 140401995
Change-Id: I5e5c154758b3f0e4731696c813519ac798fbbae9
2019-09-06 16:16:52 +01:00
shafik
e17ad4aa30 Migrate RollbackTest and StagedRollbackTest to cts utils
Replace the usage of RollbackTestUtils with the API offered by
com.android.cts.install.lib and com.android.cts.rollback.lib.

Test: atest RollbackTest
Test: atest StagedRollbackTest #testBadApkOnly

Bug: 132757394
Bug: 132422403
Change-Id: I25cb9dca103852d7ee3691e4df927e1fc5848074
2019-06-24 12:44:11 +01:00
shafik
2340e8bca1 Add host side test for secondary user rollback
Run RollbackTest#testBasic only under a secondary user.

The host-driven test adds a new user and then installs the TEST (not the
test app) for that new user.
Note: this was the missing step in the previous attempt to test
RollbackTest under a secondary user.

Test: atest SecondaryUserRollbackTest
Test: test failed when multiuser support was removed from rollback
manager
Test: adb shell pm list packages --user 11 | grep rollback while running
the test in order to make sure the test is installing packages for the right user

Bug: 133852817
Bug: 129747710
Change-Id: Id1e54769cc2a9631d1464c07bad2b685f78689bc
2019-06-19 17:42:18 +01:00
Zimuzo
e77a3e1de2 Add network health check watchdog triggered rollback tests
This cl improves code coverage for the PackageWatchdog explicit health
checks.

Updating the NetworkStack triggers an explicit health check with
a time deadline. At the deadline, if network is unavailable on the device,
the update is rolled back, if network is available, nothing happens.

Bug: 132640467
Test: atest StagedRollbackTest

Change-Id: I16a40244de9345930a1c981188aa33546fe872fc
2019-05-30 13:30:26 +01:00
Dario Freni
27ef26c880 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
2019-05-22 15:16:37 +01:00
Richard Uhler
2124d4b313 Ensure race between rollback and roll forward is properly handled
If rollback for a package is committed at the same time the package is
updated, it's possible we will incorrectly roll back the newly updated
version of the application.

Add a hidden API to the package installer that lets you set a required
existing version of a package to be updated. If the expected package
version is not installed at the time of commit, the update install
fails.

The RollbackManager uses this new API to ensure that rollback will fail
if the package in question was just updated.

Test: atest RollbackTest, with new test added and manual confirmation
      that the race condition was exercised by the new test.
Bug: 128831080

Change-Id: Ifa5627e257d2ef13e2b213ef0dbc93932797ce0d
2019-05-01 09:10:36 +00:00
Richard Uhler
1924d6dbb8 Expire rollback when apex is updated.
RollbackManager relies on package changed broadcasts to expire rollbacks
when an application is updated, but we don't receive package changed
broadcasts for apex.

This change adds an extra check when starting RollbackManager to see if
any apex versions have changed and expires rollbacks as appropriate.

Adds a test case to cover the scenario and refactors the test code
to properly set up the test apex in all cases with minimal reboots.

Bug: 126358044
Test: atest StagedRollbackTest, with new test added.
Change-Id: I7ea4953e4aff8d1c7560d6c61e6be5e4e8e1f194
2019-04-26 13:22:51 +01:00
Richard Uhler
8a9774550d Use test stubs for RollbackTests, not system stubs.
Adds @TestApi for all system apis needed for RollbackTests.

Removes @SystemApi for RollbackManager.expireRollbackForPackage and
RollbackManager.reloadPersistedData, which were always intended to be
used solely for testing.

Bug: 127282563
Test: atest RollbackTest StagedRollbackTest
Change-Id: I183b8a484b4a08f36fc19d64241ab408d28c64ca
2019-03-12 12:14:37 +00:00
Richard Uhler
a7291341e3 Avoid building RollbackTestApps into the device image.
The current approach for including built apks as java resources in
RollbackTest.apk appears to cause the RollbackTestApp apks to be
included in the device release image. Convert the Android.mk for
RollbackTest to Android.bp to work around this issue.

This breaks the split apk tests, but we can figure out how to address
that later. Marking the split apk tests @Ignore for now.

Bug: 123695037
Bug: 127520966
Test: make -j80 dist tests, verify no RollbackT*.apk is included in the
      built device image.
Test: atest RollbackTest; atest StagedRollbackTest, verify no
      RollbackT*.apk is included in the built system image.

Change-Id: Ib413785b0974faddf19ac8dd7387b2642dab37e4
2019-03-07 14:57:53 +00:00
Richard Uhler
4937fadf67 Revert "Convert RollbackTest Android.mk to an Android.bp."
This reverts commit 0145c883e0.

Reason for revert: Causes the RollbackTest apps to be installed to the system partition, which breaks the rollback tests.
Bug: 123695037

Change-Id: I3ee89ecb370144c67fe88bb389abafdda59dc502
2019-02-04 12:51:58 +00:00
Richard Uhler
0145c883e0 Convert RollbackTest Android.mk to an Android.bp.
Which is more convenient for building a dummy apex module to test
rollback of staged installs.

Bug: 112431924
Test: atest RollbackTest

Change-Id: I30c2fc7d37ca30e47b49012edc02a1fc637ba6f6
2019-01-29 16:14:36 +00:00