Commit graph android_packages_modules_Co.../tests
Message SHA1
Merge "Bump tethering target sdk to 33"
Treehugger Robot   authored and   Gerrit Code Review   commited 2022-06-01 08:57:46 +00:00
d10244feb8
Merge "Add IpConfigStore testcase to improve the code coverage."
Xiao Ma   authored and   Gerrit Code Review   commited 2022-06-01 07:47:07 +00:00
c0e80ee9f9
Add IpConfigStore testcase to improve the code coverage.
Add new testcase in IpConfigStoreTest to cover the readIpConfiguration
usage, improve the code coverage for connectivity module.

To reduce the flakyness of test, this cl refactors DelayedDiskWriter
constructors by allowing to pass in a Dependencies instance, then
waitForIdle can be used to check if the delayed write operation
associated with the passed-in HandlerThread has completed in tests.

Bug: 234315786
Test: atest com.android.server.net.IpConfigStoreTest
Change-Id: I57c8bd02a771f1cca815252ba502cda0210d1385

Xiao Ma   commited 2022-06-01 14:47:47 +09:00
b4a8fd534a
Merge "Add test coverage for ConnectivityService.dump with arguments"
Chiachang Wang   authored and   Gerrit Code Review   commited 2022-06-01 05:41:50 +00:00
c0b2b37faa
Merge "Fix service resolve on tethering downstreams"
Remi NGUYEN VAN   authored and   Gerrit Code Review   commited 2022-06-01 05:31:14 +00:00
5eaefa21bf
Add test coverage for ConnectivityService.dump with arguments
Test: atest FrameworksNetTests
Change-Id: I389ef6e89a7570cb3e7f8cedab48517c25c4c0b0

chiachangwang   commited 2022-06-01 03:58:25 +00:00
9673c4ddad
Merge changes from topic "stats-migration"
* changes:
  Skip PersistentIntTest on S- device
  Don't clobber existing history entries.
  Ensure NetworkStats migrated snapshot is identical
  [MS82.1] Support network stats data migration process
  Add a PersistentInt class.

Natasha Lee   authored and   Gerrit Code Review   commited 2022-06-01 03:03:02 +00:00
bcdb3c12ee
Fix service resolve on tethering downstreams
Tethering downstreams do not have NetworkAgents, and although they have
a netid of 99, Networks with netId 99 are not usable by apps for most
connectivity APIs.

Recent refactoring in NsdService adds the Network of a found service
into its NsdServiceInfo, and uses that network to resolve the service.
In that case the Network has netId 99 and resolving the service fails.

Avoid that problem by:
 - Keeping the Network field null when a service is found on a tethering
   downstream; this avoids giving apps a confusing and unusable Network
   with netId 99
 - Using the interface index found during discovery to resolve the
   service, if the app uses the NsdServiceInfo that was obtained from
   discovery to resolve. If not, all interfaces will be used to resolve,
   as per legacy APIs.

Bug: 233979892
Test: atest NsdServiceTest
      Also manual test with 2 devices connected via hotspot
Change-Id: Idd176153b67ccbd1d4f1b1fd66dafaa2f3a9e27a

Remi NGUYEN VAN   commited 2022-05-31 13:06:22 +09:00
1a8ee102d3
Bump tethering target sdk to 33
Note: to avoid missing some dependeices change only happen in T+, below
testing verification is perform by internal branch.

Test: atest TetheringTests
      atest TetheringIntegrationTests
      atest CtsTetheringTest
      atest MtsTetheringLatestSdk
      manually change entitlement check recheck period to 1 min and
      monitor schedule alarm works.
      Dogfood this change personally 7 days, major use hotspot sharing network to notebook to work.
Bug: 232193147
Change-Id: I3cba98f42ac1a9c0c1db4b2ad036aff714a428f3

Mark Chien   commited 2022-05-31 03:31:18 +00:00
d25a1e05ae
Run testExcludedRoutesDisabled only in APKs with target SDK < T.
This test crashes if run from an APK that has target SDK 33 or
above because it tries to disable a compat change that on those
SDK versions is enabled by default.

Run it only in CtsNetTestCasesMaxTargetSdk31 and skip it in our
regular CTS modules.

Bug: 233553525
Test: test-only change
Change-Id: Iaf9c46591c13505c9d2a2a09994b9ee22a22390c

Lorenzo Colitti   commited 2022-05-30 23:36:23 +09:00
1c7a20c6c6
Create CtsNetTestCasesMaxTargetSdk31.
This APK will only run tests that require target SDK 31 or below.

Bug: 233553525
Test: test-only change
Change-Id: Ia86187de50107748d8053194d3f7a55b7947412e

Lorenzo Colitti   commited 2022-05-30 23:36:21 +09:00
9e61b82404
Merge "Add traffic_controller, networkstats, netd_updatable tests to MTS."
Ken Chen   authored and   Gerrit Code Review   commited 2022-05-27 17:46:54 +00:00
93ea4c3f5c
Add traffic_controller, networkstats, netd_updatable tests to MTS.
In order to get counted by mts code coverage, these native tests need to
be run as part of mts.

Bug: 233904825
Test: m mts && mts-tradefed run mts-tethering-coverage
Change-Id: I79313197b146c7043ffb5e164faa46c2e16dd1d2

Ken Chen   commited 2022-05-27 15:00:18 +00:00
b9266bf507
Merge "Fix crash when decrementing data usage request"
Treehugger Robot   authored and   Gerrit Code Review   commited 2022-05-27 10:02:33 +00:00
019e6eb2d7
Fix crash when decrementing data usage request
When unregistering, if the caller process is dead. The system
can unregsiter for the caller. But the request decrement should
be counted onto the caller uid instead of system uid.

Test: NetworkStatsObserversTest#testUnregister_knownRequest_invalidUid_doesNotUnregister
Bug: 233580307
Change-Id: I85aee8f395739929bc7086883ace81ac1ecd0730
Merged-In: I85aee8f395739929bc7086883ace81ac1ecd0730
  (pure cherry-picked from ag/18579047)

Junyu Lai   commited 2022-05-27 09:50:52 +00:00
a1970dafa1
Add some non-connectivity-module-test back to ConnectivityCoverageTests
In S, the tests are listed in the non-connectivity-module-test
where their testing files are not in the connectivity module.
But some files move into the connectivity module in T. So some
tests can be removed from non-connectivity-module-test and will
be running on ConnectivityCoverageTests to count their code
coverage.

Also update some tests to make them compatible with
mockito-extended and ignore some tests which need to test with
T apis.

Bug: 234000451
Test: atest FrameworksNetTests ConnectivityCoverageTests
Change-Id: I47fb59334d00ae7fee91c5694548b3cf89b09b2d

Paul Hu   commited 2022-05-27 07:16:46 +00:00
516d5dc0ea
Merge "CTS test for EthernetNetworkUpdateRequest"
Treehugger Robot   authored and   Gerrit Code Review   commited 2022-05-27 00:46:06 +00:00
30809dc4a1
Merge "Changing target_sdk for CtsNetTestCasesLatestSdk"
Treehugger Robot   authored and   Gerrit Code Review   commited 2022-05-26 10:47:01 +00:00
44ad28052c
Changing target_sdk for CtsNetTestCasesLatestSdk
Bug: 233553525
Test: Presubmit

Changing target_sdk of or CtsNetTestCasesLatestSdk to 33 to match with apps target_sdk

Change-Id: Id786f64956d52307e15b3cd3feaa02d585e7623e

preranap   commited 2022-05-26 03:00:02 +00:00
7a1639ff5f
Merge "Adding missing dependency for api23Test"
Treehugger Robot   authored and   Gerrit Code Review   commited 2022-05-25 23:06:58 +00:00
433f594bb6
Adding missing dependency for api23Test
Bug: 226950040
Test: Presubmit
Change-Id: I194d31e7b11b1a5efb652e2cecd3624a79d307a9

jahinimtiaz   commited 2022-05-25 17:02:46 +00:00
43d6a01d3b
Merge "Remove automotive restriction from enable/disableInterface"
Patrick Rohr   authored and   Gerrit Code Review   commited 2022-05-25 02:00:51 +00:00
345655f7bc
Merge "Skip VPN filtering tests on unsupported versions"
Motomu Utsumi   authored and   Gerrit Code Review   commited 2022-05-25 01:22:16 +00:00
badf2ebed7
Skip VPN filtering tests on unsupported versions
Lockdown filtering rule and interface filtering rule with null interface
were introduced to T+ devices.
So, skip related tests in pre-T devices.

Bug: 232902954
Test: atest ConnectivityServiceTest
Change-Id: I9ee76096c1bd04c9333bc561ffc8064a14780ce5

Motomu Utsumi   commited 2022-05-24 13:41:36 +00:00
ca314e7f77
Remove automotive restriction from enable/disableInterface
Allow calling enable/disableInterface on non-automotive devices. Also,
fixing the naming of these functions to be consistent with the API.

Test: atest EthernetManagerTest
Bug: 171872016
Bug: 225317990
Change-Id: Ic20185a855d0e639582132bf1103e0183f6f78c3

Patrick Rohr   commited 2022-05-24 03:54:38 +00:00
fd829a5cb2
Skip PersistentIntTest on S- device
This class is only used in the service runs on T+ devices.
Thus run this test on S- device does not make senses.

Bug: 230289468
Test: atest ConnectivityCoverageTests:PersistentIntTest
      on S device
Change-Id: I97a29df17ef9ee9ab373655f045cdb5c820e06ef
Merged-In: I97a29df17ef9ee9ab373655f045cdb5c820e06ef
  (pure cherry-picked from ag/18486287)

Junyu Lai   commited 2022-05-24 11:38:20 +08:00
1190ea3eb7
Don't clobber existing history entries.
Currently, adding a history to a NetworkStatsCollection.Builder
will overwrite any history that was previously passed in with the
same key. This breaks the importer (which is the primary/only
caller of this code), because the importer re-uses the same
NetworkStatsCollection object to import multiple files.

Instead, simply add any passed-in entries after the ones that
were already there. Require the caller to pass in entries in
order, because NetworkStatsHistory internally assumes that
entris are always sorted.

Bug: 230289468
Test: manually verified this unbreaks the importer
Change-Id: Ic8647ff28fca78d579d5f759f96a864877f8158b
Merged-In: Ic8647ff28fca78d579d5f759f96a864877f8158b
  (pure cherry-picked from ag/18453213)

Lorenzo Colitti   authored and   Junyu Lai   commited 2022-05-24 11:37:42 +08:00
ec2fbb7159
Ensure NetworkStats migrated snapshot is identical
Read migration snapshot both from the platform API and the legacy
method, and Log.wtf if they are different. Use the legacy method data if
they are.

This ensures that using the migration API is a no-op, and that errors
are reported (through Log.wtf) if it would not have been if used as-is.

Test: NetworkStatsServiceTest
Bug: 230289468
Change-Id: I857ad18183d63d1aa16e89f89eb24009648720a2
Merged-In: I857ad18183d63d1aa16e89f89eb24009648720a2
  (pure cherry-picked from ag/18452103)

Remi NGUYEN VAN   authored and   Junyu Lai   commited 2022-05-24 11:37:12 +08:00
c62261f140
[MS82.1] Support network stats data migration process
This includes:
1. Provide NetworkStatsRecorder#importCollectionLocked to
   allow caller to write a NetworkStatsCollection object to
   a standalone file.
2. Do not clear the collection in NetworkStatsRecorder#
   CombiningRewriter, this is safe since pending set will
   still be cleared during forcePersistLocked.
3. Implement the migration process, including recovery and
   safety measures.

Test: NetworkStatsServiceTest NetworkStatsCollectionTest
Test: manual test with
      adb shell device_config put tethering \
      netstats_store_files_in_apexdata true
      adb shell device_config put tethering \
      netstats_import_legacy_target_attempts 1
Bug: 230289468
Change-Id: Ic2002cbfd5a6b3c2226fa8dab22481f8ce656574
Merged-In: Ic2002cbfd5a6b3c2226fa8dab22481f8ce656574
  (pure cherry-picked from ag/18367994)

Junyu Lai   commited 2022-05-24 11:36:36 +08:00
a388d4bf06
Add a PersistentInt class.
This implements a simple integer written to disk backed by
AtomicFile.

Bug: 230289468
Test: new unit test
Change-Id: I1c73c8ac2429f92153cfba3b006b4374e75e65df
Merged-In: I1c73c8ac2429f92153cfba3b006b4374e75e65df
  (pure cherry-picked from ag/18437645)

Lorenzo Colitti   authored and   Junyu Lai   commited 2022-05-24 11:35:58 +08:00
2ce66fc8e6
Merge changes I8e806b3b,I5e8e4673,Id2a078da
* changes:
  Add CTS tests for EthernetNetworkProvider changes
  Move EthernetNetworkFactory to using the NetworkProvider API
  Improve waiting for interface added or removed

Patrick Rohr   authored and   Gerrit Code Review   commited 2022-05-24 03:34:25 +00:00
826bdb3ec4
Add CTS tests for EthernetNetworkProvider changes
Adds CTS test to validate behavior of EthernetNetworkProvider API.
These tests are currently still pretty slow due to the fact that newly
registered tracked interfaces are brought up, back down, and back up
before they are available (this is a bug and will hopefully get fixed in
the near future).

Test: atest EthernetManagerTest
Bug: 197548738
Change-Id: I8e806b3b884f2e0b6c1a1d2fffdb9a99c5dd60e8

Patrick Rohr   commited 2022-05-23 16:50:26 -07:00
97bdb655d9
Move EthernetNetworkFactory to using the NetworkProvider API
This CL makes EthernetNetworkFactory inherit from NetworkProvider rather
than NetworkFactory. The name of the class is purposefully unchanged to
make the code review easier (it will be changed to
EthernetNetworkProvider in a follow up).

As part of the conversion, NetworkInterfaceState now registers a
NetworkOffer when the link comes up and unregisters it when the link
goes down. It updates the existing offer when capabilities change (by
calling registerNetworkOffer with an already registered
NetworkOfferCallback).

This change should fix existing refCount issues. When a NetworkOffer is
first registered, it receives callbacks for all existing requests. This
is the main problem with the NetworkFactory implementation where only
one NetworkOffer is registered when the factory is first created; so
when interfaces come up, they do not receive callbacks for existing
requests.

Test: atest EthernetNetworkTest
Bug: 197548738
Change-Id: I5e8e4673d2ed04bc1a0c8d232a8772edfff65b5d

Patrick Rohr   commited 2022-05-23 15:07:36 -07:00
daca9ca74f
Remove the redundant sleep after turning on the screen.
We are checking for network access in onResume(), which
wouldn't be called until the screen is on. So, there
shouldn't be a need for the extra sleep after turning
on the screen.

Also, remove redundant waits after the last try when
doing verifications as the test is anyway to going to
fail at this point.

Bug: 231440256
Test: atest tests/tests/app.usage/src/android/app/usage/cts/UsageStatsTest.java
Change-Id: I28429c929142a95c19b1f8a5b7d28b9c8c4a45b9
Merged-In: I28429c929142a95c19b1f8a5b7d28b9c8c4a45b9

Sudheer Shanka   commited 2022-05-23 20:10:06 +00:00
c2edb9cbc4
Keep the screen on while the test activity is on top.
Bug: 231440256
Test: atest com.android.cts.net.HostsideConnOnActivityStartTest
Change-Id: Ibb0cc4c8a7cc2338ca938c775706f6b779fa96d3
Merged-In: Ibb0cc4c8a7cc2338ca938c775706f6b779fa96d3

Sudheer Shanka   commited 2022-05-23 20:07:54 +00:00
d1affb65da
Merge "Throw IAE when Network's LinkProperties is null"
Yan Yan   authored and   Gerrit Code Review   commited 2022-05-23 17:24:07 +00:00
5345fa1144
Merge "Fix test failure on S image + S module"
Paul Hu   authored and   Gerrit Code Review   commited 2022-05-23 13:45:58 +00:00
d6446263ce
Merge "Fix NsdManagerTest failures"
Remi NGUYEN VAN   authored and   Gerrit Code Review   commited 2022-05-23 02:19:36 +00:00
6235f6490e
Fix NsdManagerTest failures
- NsdManagerTest would fail on R device because the
  android.net.TestNetworkSpecifier is not existed when creating a
  test networks. Test networks are only used for those target T+
  tests. Thus, only create the test networks on T+ devices.
- Those target T+ NsdManagerTest would fail on S image because
  aosp/2098750 updated ConstantsShim to 33, so the
  ConstantsShim.VERSION check will be true. Then these tests
  will run on S image but fails with no api found. Thus, the
  pre-check should include platform check(T+).

Bug: 233200200
Bug: 232813132
Test: atest CtsNetTestCasesLatestSdk:android.net.NsdManagerTest\
      on R & S devices.
Change-Id: I246194e6e266a5e75d2f7053e0aa02ff06f11097

paulhu   authored and   Paul Hu   commited 2022-05-22 14:22:52 +00:00
2b89ae5fbb
Throw IAE when Network's LinkProperties is null
Improve the setUnderlyingNetwork method by throwing IAE
when Network's LinkProperties is null. Also update the
API doc to give caller more guidance in using this API

Bug: 232309601
Test: UT: IpSecServiceParameterizedTest, IpSecServiceTest,
      IpSecServiceRefcountedResourceTest, IpSecManagerTest, VpnTest
Test: CTS: IpSecManagerTest, IpSecManagerTunnelTest, Ikev2VpnTest
Test: make doc-comment-check-docs
Change-Id: Idab4706b0db42ed2222fb48b168589ed005d2f2f

Yan Yan   commited 2022-05-20 17:03:07 -07:00
be3eb3d56a
Improve waiting for interface added or removed
In a previous CL, code was added to wait for interfaces being properly
registered with the EthernetTracker before continuing the test. The same
logic applies to removingInterfaces (which prevents a previous tests
Lost callbacks to show up in a subsequent test).
The createInterface listener was improved to expect the down callback
first. EthernetTracker receives down and up callbacks from netd which it
posts on its handler. While the initial up-up callbacks (KI) can be
flaky, down-up should always be the correct signal that the interface is
ready and properly registered with the ethernet code.

Test: atest EthernetManagerTest
Bug: 227008268
Change-Id: Id2a078da732009411934166df7ae08bedd17a19d

Patrick Rohr   commited 2022-05-20 12:48:08 -07:00
3c089e67f1
Merge "Always wait for interface to be up in EthernetManagerTest"
Patrick Rohr   authored and   Gerrit Code Review   commited 2022-05-20 05:53:00 +00:00
adf8f72856
Merge "Move ipconfig file inside apex data directory"
Xiao Ma   authored and   Gerrit Code Review   commited 2022-05-20 05:43:40 +00:00
56c6392586
Always wait for interface to be up in EthernetManagerTest
Adds a global listener that is used to wait for an interface to show up
in EthernetTracker when it is newly created. This prevents races when
the interface is used directly after creation.

This test should fix the testCallback flakes.

Test: atest EthernetManagerTest
Bug: 227008268
Change-Id: I37d2ec63aea9f4de6010e13150bc236ee07e2f85

Patrick Rohr   commited 2022-05-19 20:21:44 -07:00
5f45a3742a
Move ipconfig file inside apex data directory
In order to support rollbacks, the ethernet ipconfig file needs to be
written to the data apex's data directory. We still need to support
reading from the legacy location to be backwards compatible.

If the apex file path already exists, then read the IP configuration
from there directly, otherwise, check if the legacy file path exists,
if yes, read the legacy IP configuration and copy it to the new apex
file path.

Support for default IpConfiguration is also being removed in this CL.
The default IpConfiguration (configuration entry for interface "0")
was a way to transition from supporting a single interface to
supporting multiple interfaces and was introduced in P. Every device
that has used such a configuration and has connected to an ethernet
network since upgrading to P+ has already removed the "0" config and
has assigned it to the first interface (probably "eth0"). There has
never been an API to set this, but if someone wanted to install a
default IpConfiguration, they could just configure "eth0" instead.

Bug: 224919694
Test: atest EthernetConfigStoreTest --iterations
Test: manually test
      - adb push <fake ipconfig.txt> /data/misc/ethernet/
      - adb reboot
      - read the IP config from legacy path and the same config
        file is created in the apex file path
      - adb reboot
      - read the IP config from the apex file path directly
Change-Id: Ifb82a5d7fa13d17ea8fd3a42a19cd020cb95e26a

Patrick Rohr   authored and   Xiao Ma   commited 2022-05-20 09:20:54 +09:00
47641d75d9
Merge "Assume all Ethernet interfaces have an MTU of 1500."
Treehugger Robot   authored and   Gerrit Code Review   commited 2022-05-19 15:40:03 +00:00
bd77794547
Merge "Changing automotive ethernet allowed UIDs check"
Treehugger Robot   authored and   Gerrit Code Review   commited 2022-05-19 13:29:16 +00:00
36cae536f0
Fix test failure on S image + S module
aosp/2085868 has not included in a tethering train build and it
probably will be included in a T module release. But the test in
that CL has been put to the S MTS test. Thus, fix the test failure
on S image + S module.

Bug: 233019430
Test: atest CtsNetTestCasesLatestSdk:android.net.cts\
      .ConnectivityManagerTest#testUidsAllowedOnRestrictedNetworks
      on the S image + S module device.
Change-Id: Iafb26a1c80c48232a76050d4c8c21e2de2c21207

Paul Hu   commited 2022-05-19 08:18:15 +00:00
3891ed5eba
bpf_existence_test: block & dscp_policy progs require 5.4+ kernel
Bug: 233119387
Test: TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I8df3c0c1b9f4b60a55472d2402dcea368020985b

Maciej Żenczykowski   commited 2022-05-19 08:06:41 +00:00
93b8cc1556
CTS test for EthernetNetworkUpdateRequest
Bug: 220030301
Bug: 210487893
Bug: 210485380
Test: atest CtsNetTestCasesLatestSdk
:android.net.cts.EthernetNetworkUpdateRequestTest

Change-Id: If341be56bf38a8cb1f7b17e2f8ebeda240c5a770

James Mattis   commited 2022-05-18 22:18:14 -07:00
ff0d261555