Commit Graph

137 Commits

Author SHA1 Message Date
Mohammad Samiul Islam
8474b608a7 Merge "Revert "Revert "Make RollbackPackageHealthObserver observe apk-in-apex""" 2020-01-16 17:59:33 +00:00
JW Wang
2d66ab9be8 Merge changes I7579d6c9,I329b1f1a,I46d08fe2
* changes:
  No need to call #updateRollbackLifetimeDurationInMillis (3/n)
  Register an OnPropertiesChangedListener in onBootCompleted (2/n)
  Squash runnables in onBootCompleted (1/n)
2020-01-16 14:21:13 +00: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
67d72581ac Merge "Make RollbackPackageHealthObserver observe apk-in-apex" 2020-01-16 12:48:16 +00: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
724b6028ef Merge changes from topic "rollback-all"
* changes:
  Allow handling of all pending staged rollback sessions before rebooting
  Add test for verifying all available rollbacks are triggered during native crash
2020-01-15 12:52:01 +00:00
JW Wang
4ff9d08435 No need to call #updateRollbackLifetimeDurationInMillis (3/n)
No need to call #updateRollbackLifetimeDurationInMillis manually inside
reloadPersistedData. Also fix tests since #reloadPersistedData no longer
pulls DeviceConfig changes.

Bug: 147712943
Test: atest StagedRollbackTest RollbackTest
Change-Id: I7579d6c969117189e01e0767decd1faeaa811eb9
2020-01-15 18:33:02 +08:00
Mohammad Samiul Islam
2f9fa5c9da Allow handling of all pending staged rollback sessions before rebooting
When there is an unattributable native service crash during boot, we
rollback all packages available for rollback. In the current
implementation, we reboot immediately when a staged rollback session
becomes ready, even though there can be other staged rollback sessions
which are still being handled.

In this CL, the logic is changed to allow the health observer wait for
all staged sessions to be handled before rebooting.

Bug: 141843321
Test: atest StagedRollbackTest#testNativeWatchdogTriggersRollbackForAll
Test: atest StagedRollbackTest
Change-Id: Ib2aaee22868e5502b68847aa7f64e428070f7e3c
2020-01-14 09:04:21 +00:00
Mohammad Samiul Islam
9481762932 Add test for verifying all available rollbacks are triggered during native crash
Bug: 135977463
Test: atest StagedRollbackTest#testNativeWatchdogTriggersRollbackForAll
Change-Id: Iaff10b39207753434c216de5d462211c9826e69c
2020-01-13 11:35:20 +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
557b2a5aa2 Clean up rollbacks after each test (2/n)
testNetworkPassedDoesNotRollback leaves a rollback for the network stack
and we need to clean up all rollbacks before running
testNativeWatchdogTriggersRollback otherwise the test will fail on
devices which doesn't support checkpoint.

See b/146991129 comment#2 for the detail.

Bug: 147259494
Test: atest StagedRollbackTest
Change-Id: Ib9c5e3f56bf31bfbf6f5a415879f9eb1b10d270e
2020-01-07 14:35:08 +08:00
JW Wang
f86cecf873 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
2020-01-07 12:28:21 +08:00
JW Wang
82768bf925 Respect the rollback data policy (3/n)
1. Don't snapshot user data when the policy is WIPE.
2. Add tests to verify user data is wiped/restored correctly.

Bug: 144683152
Test: atest RollbackStoreTest RollbackUnitTest AppDataRollbackHelperTest
Test: atest RollbackTest StagedRollbackTest
Change-Id: I470233080efbba724ace6f0dbf2ab5256db49054
2020-01-02 22:07:00 +08:00
JW Wang
b13131f10c Clean up the rollback when test is done
When multiple staged sessions are installed on a device which doesn't
support checkpoint, only the 1st will prevail. The test failed when
TestApp.A is not the 1st rollback to commit.

We need to clean up the rollback left by testRollbackWhitelistedApp so
TestApp.A is always the only and first one to commit.

Bug: 146991129
Test: atest StagedRollbackTest
Change-Id: I4afdace934b7b7e3b198169dc2eb0da66c65eb94
2019-12-30 19:52:06 +08:00
JW Wang
9b51b7319c Check the white list to decide whether to enable rollback (2/n)
Bug: 144680850
Test: atest RollbackTest StagedRollbackTest
Change-Id: I4b6b42d6a0fce836d7ebaca8bcde8c837c086e9b
2019-12-17 10:29:30 +08:00
Mohammad Samiul Islam
a3f650dc8d Mitigate native crash without depending on ModuleMetaData
Mitigation attempts should be made whenever rollbacks are available.

Bug: 141843321
Test: atest StagedRollbackTest#testNativeWatchdogTriggersRollback
Change-Id: I2dde8c6415191ff3787a82ea3abc0fcc9a3cd7b1
2019-12-11 09:43:54 +00:00
JW Wang
517bb2b25b Test child sessions time out in enabling rollback (2/n)
The rollback shouldn't be available if any of the child sessions times
out in enabling rollback.

Bug: 144732395
Test: atest RollbackTest
Change-Id: Id899f3c1ec100fcdcad1f24f2701f95b1c49bc69
2019-11-21 17:55:05 +08:00
Remi NGUYEN VAN
d02b13334b Merge "Autodetect NetworkStack path in rollback test" 2019-11-11 11:51:35 +00:00
Remi NGUYEN VAN
ce4cad87d2 Autodetect NetworkStack path in rollback test
The network stack module may be implemented by NetworkStack (updatable
version built against stable SDK) or NetworkStackNext (test version
shipped only in system images, built against in-development SDK).

Bug: 144168912
Test: atest RollbackTest
Change-Id: I1788e323f763ca88b69b082f38078bee3bfe480d
2019-11-11 16:14:39 +09:00
JW Wang
887b2574a2 Increase sleep timeout of testNetworkFailedRollback_Phase3 (4/n)
My local tests show that sometimes testNetworkFailedRollback_Phase3
fails to reboot within 120s. Since it takes 120s to fail the health
check and trigger rollback, there is not much time left to finish
shutdown and begin reboot before finishing sleeping.

Let's generously give it 120 more seconds so shutdown and reboot have
enough time to take place.

Bug: 143999213
Test: atest StagedRollbackTest
Change-Id: Icf3a5583a906da312189a6d027a5c269e2fd8d46
2019-11-06 13:58:54 +08:00
JW Wang
a42b66e39b Do a reboot before starting each test (3/n)
This patch improves test isolation.

Sometimes a previous test fails with reboot in progress. Then the next
test is in an unstable state since reboot could happen at any moment and
fail the device test.

Doing a reboot before each test starts protects us from pending reboot
from the last test and improve isolation.

Bug: 143999213
Test: atest StagedRollbackTest
Change-Id: Idd0fd1cc6810659990b406640efd7404de1dcd07
2019-11-06 13:58:54 +08:00
JW Wang
f8ff5bab26 Replace deprecated InstrumentationRegistry (2/n)
Bug: 143999213
Test: atest StagedRollbackTest
Change-Id: I647cecf343bdb43dbede677e015b4844f99e49ff
2019-11-06 13:58:54 +08:00
JW Wang
94b0adcf6d Rewrite testBadApkOnly_Phase3 (1/n)
1. Wait for 120s for reboot to happen. This improve the stablity of
   virtual devices which sometimes could be slow in shutdown.
2. Use assertThrows to catch exception when reboot doesn't happen which
   gives us better error messages than expecting next phase to fail.

Bug: 143999213
Test: atest StagedRollbackTest#testBadApkOnly
Change-Id: Ibafcbe7e003fb92991d6f8fe2fde7b344ffd6db6
2019-11-06 13:58:54 +08:00
TreeHugger Robot
9f4153da71 Merge "Remove Thread.sleep()" 2019-11-04 13:26:00 +00:00
JW Wang
7c64df5e7b Reconnect internet after testing
Reconnect internet so we won't break tests that assume internet is
available.

This is a patch to fix the regression caused by ag/9648483.

Bug: 143514090
Test: atest StagedRollbackTest CtsLibcoreTestCases:DatagramChannelMulticastTest
Change-Id: Ic0ef26027388500795b3555f5a56f82bfc1b975e
2019-11-04 10:17:59 +00:00
JW Wang
4cb97c5f47 Remove Thread.sleep()
Install#commit ensures a staged session is ready before the function
returns. So we don't need to sleep to wait for disk IO to complete.

Bug: 143211397
Test: atest StagedRollbackTest
Change-Id: Ic4b53dc5aaef7a22d7d64c14ee4f77bee84c26b1
2019-11-02 08:04:16 +08:00
JW Wang
eae2c7cdbe Rewrite testNetworkFailedRollback
This is an effort to fix flaky StagedRollbackTest.

ag/9614192 adds support for native file path to TestApp so now we can
install network stack package using install.lib which provides better
tools for logging and synchronization than shell commands. This will
facilitate debugging flakiness.

Also move other code to device tests for the same reason.

Bug: 143211397
Test: atest StagedRollbackTest
Change-Id: I971618da3defade4693be154ab523f1cbfea5b7c
2019-11-02 08:04:16 +08:00
JW Wang
282b6f505a Disable testNetworkPassedDoesNotRollback
This is an effort to fix flaky StagedRollbackTest.

My local tests show that the crash has something to do with repeatedly
turn on/off network connection for each test. Several things are done
below to reduce the flakiness:

1. Disable testNetworkPassedDoesNotRollback
   It sometimes takes more than 5 minutes for the device to be back
   online after turning on the network connection during the test. This
   test contributes a lot to the flakiness. Let's disable it for now so
   other tests can keep running.
2. Rewrite testNetworkFailedRollback so we only turn on/off network
   connection when necessary in the hope to reduce the WifiHandlerThread
   crash. The change works pretty well for my local tests which run over
   40 loops without a single failure.

Bug: 143514090
Test: atest StagedRollbackTest
Change-Id: I9aec5eafdd3368ef76517e3b8500970e60d07487
2019-11-01 01:31:13 +00:00
JW Wang
b4540e2d3c Reduce the health check timeout (2/n)
b/143035398 #3 shows the network stack will pass health check anyway
even there is not internet connected. We have to reduce the timeout and
finish the test before the health check is passed.

Bug: 143035398
Test: atest StagedRollbackTest
Change-Id: I39a84b06a19648a3ec19c5f334bed9ef4bce1533
2019-10-28 09:18:17 +08: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
37d37be851 Use shell command to uninstall network stack package (2/n)
Since install is done by shell command, uninstall must also use shell
command to succeed.

Bug: 143211397
Test: atest StagedRollbackTest
Change-Id: Ie81d793212b2b3dc00ff84037e6be8782695c499
2019-10-24 18:19:24 +08:00
JW Wang
9ba5f6b80a Close the returned file descriptior (1/n)
As suggested by the comment:
https://cs.corp.google.com/android/frameworks/base/core/java/android/app/UiAutomation.java?rcl=55a225ade4016b9dde04a3d4b4d25db761b1ccbf&l=1127

Bug: 143211397
Test: atest StagedRollbackTest
Change-Id: I45a5e5fe2188f3172b42f868fe2c4853173451bd
2019-10-24 18:19:18 +08:00
JW Wang
02e8f06e4c Remove some getDevice().waitForDeviceAvailable()s
Remove getDevice().waitForDeviceAvailable() that follows
getDevice().reboot() for reboot() has called waitForDeviceAvailable()
internally.

See b/143114522 #1 for more details.

Bug: 143114522
Test: atest StagedRollbackTest
Change-Id: I19d3648947435b8d5a10d09736b170fd8be8be47
2019-10-22 15:07:56 +08:00
JW Wang
9f7c1aa39d Test rollback not triggered when crashing under the threshold (2/n)
Move some code to testBadApkOnly_Phase2 so we also test rollback is not
triggered when we don't crash enough times.

Bug: 143052400
Test: atest StagedRollbackTest
Change-Id: If1e3fbbdc24e7e5e2c25c28a4c6b3b1980ac01fd
2019-10-22 09:43:38 +08:00
JW Wang
c6efb184cd Don't assume how many crashes to trigger rollback (1/n)
Set the device property so we know exactly how many crashes we need
to trigger rollback.

Bug: 143052400
Test: atest StagedRollbackTest
Change-Id: I0455d3ad6848bf3bfdbb238cfbf6b067deb89957
2019-10-22 09:43:38 +08:00
TreeHugger Robot
c086a4cd79 Merge "Code cleanup: StagedRollbackTest (6/n)" 2019-10-21 23:01:00 +00:00
TreeHugger Robot
2fc4bef2da Merge "Code cleanup: StagedRollbackTest (5/n)" 2019-10-21 14:08:54 +00:00
TreeHugger Robot
2b3c57a140 Merge "Code cleanup: StagedRollbackTest (4/n)" 2019-10-21 11:59:28 +00:00
Gavin Corkery
8b79ee70e9 Merge "Use userId and package installer name when committing rollbacks" 2019-10-18 07:08:15 +00:00
JW Wang
40f0dd2b70 Code cleanup: StagedRollbackTest (6/n)
Inline functions for clarity and readability at a small cost of
duplicate code.

Bug: 142697546
Test: atest StagedRollbackTest
Change-Id: Ic1dee953c101e002bd3b3b2c2e54835761823ee9
2019-10-18 14:42:36 +08:00
JW Wang
1f092a9a2d Code cleanup: StagedRollbackTest (5/n)
Rename and group device methods together that belong to the same host
side method.

Bug: 142697546
Test: atest StagedRollbackTest
Change-Id: Ib9ff6e4fb6b59e1fb5a3124569e7ec13b230fd86
2019-10-18 14:42:36 +08:00
JW Wang
3574194dff Code cleanup: StagedRollbackTest (4/n)
Add device side methods with names like testFoo_PhaseN to show they are
grouped and coordinated by the same host side method testFoo.

Bug: 142697546
Test: atest StagedRollbackTest
Change-Id: Ic001c94075cbf5fc455188f5ecbaf73d58306e5f
2019-10-18 14:42:36 +08:00
JW Wang
3bcb811cf6 Code cleanup: StagedRollbackTest (3/n)
Rename and group device methods together that belong to the same host
side method.

Bug: 142697546
Test: atest StagedRollbackTest
Change-Id: Iec49c141ef2b6c99c3a395c5287af562ee975942
2019-10-18 09:37:16 +08:00
Gavin Corkery
0987cb0333 Use userId and package installer name when committing rollbacks
Currently when committing a rollback, the system user is used
for the package context for the downgrade session, even when
the package was not installed as this user. This leads to a
package being installed to the system user in the cases where
it is only installed to a secondary user.

The installer package
name is also currently retrieved from package manager (and does
not work for apex), so storing this information when enabling
the rollback will be useful.

This change should be compatible with previous rollbacks stored
on the device.

Bug: 133210624
Test: atest RollbackTest
Test: atest SecondaryUserRollbackTest
Test: Install test APK v1 and v2 with rollback enabled for a secondary
user, rollback and verify the package is not installed for
the system user

Change-Id: I16346120cf9ba7b04254ab5e8fa5090be7d562ac
2019-10-17 17:04:34 +01:00
TreeHugger Robot
fa11d58974 Merge changes I3186d27c,I54f28f54
* changes:
  Code cleanup: StagedRollbackTest (2/n)
  Code cleanup: StagedRollbackTest (1/n)
2019-10-16 12:24:42 +00:00
JW Wang
f0a427719f Code cleanup: StagedRollbackTest (2/n)
Rename device side methods to testNativeWatchdogTriggersRollback_PhaseN
to show that they are grouped and coordinated by the same host side method.

Also put related methods together for readability.

Bug: 142697546
Test: atest StagedRollbackTest
Change-Id: I3186d27c4d3c5176f72d72f1682ed46ae0cb62ea
2019-10-15 16:23:46 +08:00
JW Wang
fa4c671066 Code cleanup: StagedRollbackTest (1/n)
Rename device side methods to testBadApkOnly_PhaseN to show that they
are grouped and coordinated by the host side method testBadApkOnly.

Bug: 142697546
Test: atest StagedRollbackTest
Change-Id: I54f28f545a7bd1fb4859421dbdaf1d95fd7c4a9d
2019-10-15 16:13:27 +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
6cb8fb485c Merge "Add multi-user test for the general non-staged case" 2019-09-09 11:05:41 +00:00