Commit graph android_packages_modules_Co.../tests
Message SHA1
Merge "Make the idle timer for network data tracking configurable" into main
Treehugger Robot   authored and   Gerrit Code Review   commited 2024-10-31 21:15:37 +00:00
cf3b26e3bf
Merge "Test races around NetworkAgent creation." into main
Treehugger Robot   authored and   Gerrit Code Review   commited 2024-10-31 15:41:15 +00:00
22bd86c584
Test races around NetworkAgent creation.
This adds tests for bugs that were introduced when we enabled
early native network creation. The tests pass on current builds
because the feature is disabled, but break if the feature is
re-enabled without fixing the races.

Specifically:
- Add a test that registers/unregister/registers agents in a
  loop. This checks for a race between unregister() and
  register() which exists because unlike register(),
  unregister() has to wait for the agent channel to be
  connected.
- Add a test for calling unregisterAfterReplacement multiple
  times on the same interface. This tests for the race seen
  in b/286649301#comment6 , where calling
  unregisterAfterReplacement twice and then registering a third
  agent will cause the second agent to be torn down after the
  third is registered.

Bug: 296355968
Test: test-only change
Change-Id: I3d798209740273e5ce59b278af41dd2ad9470916

Lorenzo Colitti   commited 2024-10-31 16:26:14 +09:00
fcb37cff82
Merge "Add config for client-side traffic stats rate-limit cache." into main
Junyu Lai   authored and   Gerrit Code Review   commited 2024-10-31 07:22:36 +00:00
30ff675df5
Merge changes Ia7ea051f,I38bdfe00 into main
* changes:
  Fix system caller cannot query stats for other uids
  Use device config to enable/disable the rate-limit cache feature

Treehugger Robot   authored and   Gerrit Code Review   commited 2024-10-31 06:23:58 +00:00
05be25b8ba
Merge "Address review comments at aosp/3249945" into main
Treehugger Robot   authored and   Gerrit Code Review   commited 2024-10-31 06:23:56 +00:00
457b54a1ae
Merge "Revert "Add UID and package name to TetheringRequest"" into main
Maciej Żenczykowski   authored and   Gerrit Code Review   commited 2024-10-30 19:00:22 +00:00
1a84e82bf5
Revert "Add UID and package name to TetheringRequest"
This reverts commit 462703c850.

Reason for revert: b/375535923

Change-Id: I7f77959490e8243bb95985bd28b67efcf0f3eb00

Patrick Rohr   authored and   Gerrit Code Review   commited 2024-10-30 16:29:15 +00:00
c8df03ffd7
Add config for client-side traffic stats rate-limit cache.
This is a no-op change since the config is not used yet, and
the feature flag will be gradually rolled out instead of enabled
by default.
However, this change is necessary for follow-up changes to enable
toggling the feature and configuring its behavior through device
configuration flags.

This change includes:

 1. Disable the service-side cache flag if the client-side flag
    is enabled.
 2. Since the apps don't have enough permission to check the
    feature flag from DeviceConfig. Provides a binder interface
    for returning per-UID config,
    which only returns cache enabled if the SDK level is V+
    or the app's target SDK is V+.

Test: atest FrameworksNetTests:android.net.connectivity.android.net.TrafficStatsTest \
      FrameworksNetTests:android.net.connectivity.com.android.server.net.NetworkStatsServiceTest \
      CtsNetTestCases:android.net.cts.NetworkStatsBinderTest \
      FrameworksNetIntegrationTests:com.android.server.net.integrationtests.NetworkStatsIntegrationTest
Bug: 343260158
Change-Id: Id9761e4aea65fabe6466c875b787e178317a1da2

Junyu Lai   commited 2024-10-30 23:02:59 +08:00
b9071f8512
Fix system caller cannot query stats for other uids
Follow-up from aosp/3249945. If the system caller queries stats
for other UIDs, the caller would get UNSUPPORTED.
This follows the official documentation, where the API would
not return stats for all other UIDs.

However, partners or other legacy callers might already depend
on this undocumented behavior. Changing this behavior might
damage existing apps.

Thus, this change reverts the behavior change introduced at
aosp/3249945 and allows a system caller to query stats for
other UIDs.

Test: atest ConnectivityCoverageTests:android.net.connectivity.android.net.TrafficStatsTest
Bug: 372851500
Change-Id: Ia7ea051f7b0b6349ffcb890c300362bbfbdee3dc

Junyu Lai   commited 2024-10-30 23:02:55 +08:00
e51bae6bdc
Make the idle timer for network data tracking configurable
Networks can use widely varying timeouts for their connections. Because
cellular modems use a lot of power, having this configurable is more
useful for tuning this to an optimal value for power drain.

Adding a similar configurable value for WiFi for parity.

Test: atest ConnectivityCoverageTests:\
android.net.connectivity.com.android.server.CSNetworkActivityTest

Bug: 373733012
Change-Id: I2418f09233b2e3fa4e9cdd8fbb6149a35106b735

Suprabh Shukla   commited 2024-10-29 19:06:42 -07:00
c623c946f5
Use device config to enable/disable the rate-limit cache feature
Currently, if the app's target SDK is V+, the rate-limit cache is
enabled regardless of whether the kill switch is enabled or not.
This creates problems if there is a need to disable the feature
entirely.

Thus, this change makes the kill switch override the target SDK
level. This is necessary for follow-up changes to enable
the client-side cache and disable the service-side cache
simultaneously.

This change also removes the need of initializing/clearing the
caches when the cache is entirely disabled.

Test: atest FrameworksNetTests:android.net.connectivity.android.net.TrafficStatsTest \
      FrameworksNetTests:android.net.connectivity.com.android.server.net.NetworkStatsServiceTest \
      CtsNetTestCases:android.net.cts.NetworkStatsBinderTest \
      FrameworksNetIntegrationTests:com.android.server.net.integrationtests.NetworkStatsIntegrationTest
Bug: 343260158
Change-Id: I38bdfe00220f59712ca4b095fe4e7a3731320708

Junyu Lai   commited 2024-10-28 14:43:15 +08:00
24fcc3668a
Add missing PacketReader.stop() call
The PacketReader should be stopped after the test completes.
Otherwise, it may lead to a memory leak due to the creation of
excessive file descriptors.

Test: atest NsdManagerTest
Change-Id: I3015dbe9d8a25e3370b32935787708e1e88fbbc7

Paul Hu   commited 2024-10-28 03:23:41 +00:00
a3cf536ffa
Add CTS for cached services removal
Bug: 355421878
Test: atest FrameworksNetTests NsdManagerTest
Change-Id: Ie9857c7c60efcd327fb49c701702fda3eab27959

Paul Hu   commited 2024-10-28 03:23:41 +00:00
af1c56c88f
Address review comments at aosp/3249945
This change includes:
  1. Rename binder interfaces.
  2. Use a dedicated class to pass the result of
     get{Total|Iface|Uid}Stats, as it is 25% faster than passing
     a NetworkStats object through the binder interface.
  3. Remove the binder interface only used by the test.
  4. Remove NetworkStatsBinderTest on R and S, since the binder
     interface is removed, the mainlined service does not run on
     those versions and the chance of breaking these tests on
     R and S is low.
  5. Remove useless TODO comments.

Test: atest FrameworksNetTests:android.net.connectivity.com.android.server.net.NetworkStatsServiceTest \
      CtsNetTestCases:android.net.cts.NetworkStatsBinderTest \
      FrameworksNetIntegrationTests:com.android.server.net.integrationtests.NetworkStatsIntegrationTest
Bug: 372851500
Bug: 343260158

Change-Id: Ibd79a17218f54f0117d8ef5d7b9ec6073356f923

Junyu Lai   commited 2024-10-28 10:59:35 +08:00
9fb574d0c3
Merge "Verify migration when multiple tunnels exist" into main
Yan Yan   authored and   Gerrit Code Review   commited 2024-10-25 23:06:51 +00:00
d83a614812
Merge "Refactor requestNetworkAndGenerateTraffic by using synchronized methods" into main
Treehugger Robot   authored and   Gerrit Code Review   commited 2024-10-25 10:06:35 +00:00
26b1df6644
Merge "Remove dependencies on the 1-variant fallback" into main
Treehugger Robot   authored and   Gerrit Code Review   commited 2024-10-24 06:56:10 +00:00
ed99321230
Merge "Fix flakes due to cell reconnecting on wifi toggle" into main
Treehugger Robot   authored and   Gerrit Code Review   commited 2024-10-24 04:02:13 +00:00
e486d1d6b2
Fix flakes due to cell reconnecting on wifi toggle
On some networks, telephony may teardown its network
(unregisterAfterReplacement) when wifi is toggled to change the MMS
capability.

Update testRejectUnvalidated_TearDownNetwork to take that into account:
right after toggling wifi to make it unvalidated, wifi may still be
default if mobile data is being reconnected. Wait for mobile data to
reconnect and validate in that case.

Bug: 296403855
Test: atest
Change-Id: Ief46bed41ecb23d75c9a1f58e7a272e7f3de7caf

Remi NGUYEN VAN   commited 2024-10-24 11:22:56 +09:00
c19e8a00cc
Merge "Add UID and package name to TetheringRequest" into main
Quang Luong   authored and   Gerrit Code Review   commited 2024-10-24 02:09:25 +00:00
bdc5960a1a
Add UID and package name to TetheringRequest
Add a uid and package name to TetheringRequest to keep track of which
app the request belongs to, and also convey this information to Wifi
for later use with resource conflicts.

Bug: 216524590
Test: atest TetheringManagerTest TetheringServiceTest
Change-Id: If963694cb1bbd831ba379a76043825c94ef9d67a

Quang Anh Luong   commited 2024-10-23 15:52:03 +09:00
462703c850
Merge changes I7184eaa0,I2c5951ab into main
* changes:
  Do not crash when adding UID ranges to a destroyed network.
  Test that UID ranges can incorrectly be added to a destroyed network.

Lorenzo Colitti   authored and   Gerrit Code Review   commited 2024-10-23 04:39:07 +00:00
6bf2ce44e4
Remove dependencies on the 1-variant fallback
When adding a dependencies, if the variants don't match, but the
dependency only has 1 variant anyways, soong will always use that
variant. This makes it hard to add new variants to soong, because the
1-variant fallback stops being used and you start getting missing
variant errors. Make changes to bp files such that all dependencies
correctly specify the variant to use.

Bug: 372091092
Flag: EXEMPT refactor
Test: m nothing
Change-Id: I8d4f59044f268088b44357d27322abbdcdc3001c

Cole Faust   commited 2024-10-22 16:31:00 -07:00
9ff8f4c81b
Do not crash when adding UID ranges to a destroyed network.
aosp/3218864 fixed the crash when ranges are removed from a
destroyed network, but did not fix the case where the ranges are
added to a destroyed network.

This can happen if a multilayer request is filed when a network
has already been destroyed.

Fix: 368989698
Test: updated existing tests for this bug
Change-Id: I7184eaa01141f56b7ad774277c7dee03d5812298

Lorenzo Colitti   commited 2024-10-22 11:41:21 +00:00
dfe98fc5be
Test that UID ranges can incorrectly be added to a destroyed network.
This will likely crash the system.

Bug: 368989698
Test: test-only change
Change-Id: I2c5951ab4ccb2c17c4e87912053130377b9941ba

Lorenzo Colitti   commited 2024-10-22 11:40:09 +00:00
a81bfafda5
Merge "Set diagnostics log-data-type to CONNDIAG" into main
Treehugger Robot   authored and   Gerrit Code Review   commited 2024-10-21 02:47:42 +00:00
e6f9b7cbbc
Set diagnostics log-data-type to CONNDIAG
This will mark connectivity diagnostics files collected on failure as
CONNDIAG type, so they can be easily identified in test results. Having
a separate type will also allow automatically filtering them so they can
be pulled across test results and flake stats can be aggregated (for
example to identify which wifi access points are typically flaky).

The CONNDIAG type was added in change ID:
Ib56decb7660e9f93844337fa7a5bf9b00610c1c6

See that change for details of the option on FilePullerLogCollector.

Test: atest
Change-Id: I00fe23acf308723583e8ec82a032b42475a68173

Remi NGUYEN VAN   commited 2024-10-21 09:25:46 +09:00
5714031dcc
Merge "Create a timerfd JNI class" into main
Paul Hu   authored and   Gerrit Code Review   commited 2024-10-18 02:01:25 +00:00
6911ab9dd9
Merge "Refactor shouldTestThisNetworkType" into main
Treehugger Robot   authored and   Gerrit Code Review   commited 2024-10-16 11:02:48 +00:00
507922a1e3
Refactor requestNetworkAndGenerateTraffic by using synchronized methods
This is a refactoring of the test to adopt synchronized methods.
This is needed for the follow-up changes to get attributes of
the network prior to generating the network traffic.

This change includes:
  1. Use synchronized methods in AutoReleaseNetworkCallbackRule for
     better managing request/release networks and also improves
     readability.
  2. Decouple the steps of requesting network, set attributes and
     generating network traffic.
  3. Clearer fail messages since the test can directly throw exceptions
     to reflect the failures of a specific procedure.
  4. Remove the global timeout, which makes the test more likely
     to be flaky when individual steps take longer to complete.
  5. Use capabilities in the callback instead of synchronous calls to
     fetch attributes.
  6. Use @RestoreDefaultNetwork annotation to enforce default network
     restoration.

Test: atest CtsNetTestCases:android.net.cts.NetworkStatsManagerTest \
      --rerun-until-failure 30
Bug: 368624224
Change-Id: I3effa3c032afb345f1c0c4b73b51397d18970a19

Junyu Lai   commited 2024-10-16 16:49:38 +08:00
33bb7fbfb7
Create a timerfd JNI class
The timerfd delivers timer expiration notifications via a file
descriptor, which can be used to implement delayed callbacks.
Create a JNI class to interface with the timerfd system calls.

Bug: 366373064
Test: m
Change-Id: I0ae7a4cf618838e614b2fa4523b55a4d0e8f74e2

Paul Hu   commited 2024-10-16 06:29:48 +00:00
eb73d4ddda
Merge "Add connectivity diagnostics on test failure" into main
Remi NGUYEN VAN   authored and   Gerrit Code Review   commited 2024-10-16 04:11:58 +00:00
c0ebf16036
Merge "Remove module tests from FrameworksNetTests" into main
Treehugger Robot   authored and   Gerrit Code Review   commited 2024-10-16 02:42:36 +00:00
679edb482f
Add connectivity diagnostics on test failure
When CtsNetTestCases tests fail, or when a tryTest statement fails,
collect connectivity diagnostics and output them as a test artifact.

tryTest must be followed by cleanup blocks, which often change the
configuration, so having diagnostics when the tryTest fails in addition
to after the test failure is useful.

The collected diagnostics will be available as individual test
artifacts. They should make it easier to investigate test failures, and
could be collected across test runs in an automated way.

Output files are currently limited at 20 per run, to avoid collecting
too much data in case everything is failing in the run.

Test: atest
Change-Id: Iaa48e519028dc61c03d387beeade7d41fca2ef48

Remi NGUYEN VAN   commited 2024-10-16 10:05:35 +09:00
43730b3f0f
Remove module tests from FrameworksNetTests
Connectivity module tests are currently included in both
FrameworksNetTests and ConnectivityCoverageTests. This causes confusion,
may cause tests to fail in one configuration but not the other, is
inefficient in terms of build time and infrastructure usage, and forces
developers to keep tests passing in two different configurations that
may use different libraries.

Only include non-connectivity-module-test in FrameworksNetTests, and
keep them excluded from ConnectivityUnitTestsLib (renamed from
FrameworksNetTestsLib).

Test: atest
Change-Id: I1c557c1b4c643b3eba3bffffd89634e1141d5c0e

Remi NGUYEN VAN   commited 2024-10-16 09:56:17 +09:00
96267ec798
Merge "Rename TapPacketReader to PollPacketReader for broader applicability" into main
Yuyang Huang   authored and   Gerrit Code Review   commited 2024-10-15 08:52:44 +00:00
9e13b32ede
Merge "Move buildMdnsServiceInfoFromResponse to MdnsUtils." into main
Paul Hu   authored and   Gerrit Code Review   commited 2024-10-15 05:08:14 +00:00
49bf74e8a3
Rename TapPacketReader to PollPacketReader for broader applicability
* Renamed TapPacketReader to PollPacketReader to better reflect its
  functionality beyond TAP interface interaction.
* The class includes general logic for polling and sending packets to
  file descriptors, making it suitable for wider use cases.

Test: TH
Change-Id: Icdf9a9d7ef6f49b589ed9cdbd05159ab95e7e5d9

Yuyang Huang   commited 2024-10-15 13:42:05 +09:00
eb3c631b89
Move buildMdnsServiceInfoFromResponse to MdnsUtils.
Move this utility method buildMdnsServiceInfoFromResponse from
MdnsServiceTypeClient to MdnsUtils so it can be used by other
classes.

Bug: 355421878
Test: atest FrameworksNetTests NsdManagerTest
Change-Id: I8ce1028de325da46f112a5ec58516453727151fe

Paul Hu   commited 2024-10-15 03:00:58 +00:00
f311b43bef
Verify migration when multiple tunnels exist
Bug: 367633876
Test: atest IpSecManagerTunnelTest#testMigrateWhenMultipleTunnelsExist
Flag: EXEMPT test code
Change-Id: Ie8f0c396f5b452303ddf7f805496c17c08eb0d9c

Yan Yan   commited 2024-10-10 18:01:36 -07:00
f33436962c
Merge "Validate cellular network in testSetAvoidUnvalidated() for accurate testing" into main
Treehugger Robot   authored and   Gerrit Code Review   commited 2024-10-09 08:36:26 +00:00
2f6d6421ad
Validate cellular network in testSetAvoidUnvalidated() for accurate testing
* Modified testSetAvoidUnvalidated() to ensure the cellular network is
  validated before proceeding with default network switching tests.
* This prevents inaccurate test results when the cellular network is not
  usable, as the connectivity service won't switch to it if the Wi-Fi
  network becomes invalid.

Bug: 371818866
Test: TH
Change-Id: I458903392605a44470d5f226a36cfa983ec71aea

Yuyang Huang   commited 2024-10-09 16:51:42 +09:00
99a17f99af
Remove useless mts/mcts tags for CtsTetheringTest.
CtsTetheringTest only appears in mts-tethering-tests-list-user.xml
and not in any other test lists. So remove the MCTS tags that refer to
other MTS suites.

Bug: 369758357
Test: test-only change
Change-Id: Ib75f9c287e011b770bddeee4fba3e6f6f699a93a

Tongbo Liu   authored and   Lorenzo Colitti   commited 2024-10-08 15:36:32 +00:00
d833d726da
Refactor shouldTestThisNetworkType
This is a no-op refactoring for test.

Currently, shouldTestThisNetworkType method check test
preconditions and generating network traffic for testing.
Decouple these two functionalities to allow follow-up
changes to capture data usage baseline prior to
generating network traffic.

Test: atest CtsNetTestCases:android.net.cts.NetworkStatsManagerTest \
      --rerun-until-failure 30
Bug: 368624224
Change-Id: I5510184ec0cf8afa05b46f78ebaf80e500abaeeb

Junyu Lai   commited 2024-10-02 23:07:01 +08:00
359d23059c
Merge "Fix the test flake in testRemoveServicesAfterSocketDestroyed" into main
Treehugger Robot   authored and   Gerrit Code Review   commited 2024-09-27 06:31:38 +00:00
8a0613cc9e
Merge "Revert "Use unicast instead of broadcast as ethernet destination in test_apf_drop_ethercat"" into main
Maciej Żenczykowski   authored and   Gerrit Code Review   commited 2024-09-26 18:12:15 +00:00
b437e753f7
Revert "Use unicast instead of broadcast as ethernet destination in test_apf_drop_ethercat"
This reverts commit 46102348e0.

Reason for revert: mistakenly submitted.

Change-Id: I6072a9828a8cc0633ca35ea2ecf7707f2b3573a1

Maciej Żenczykowski   authored and   Gerrit Code Review   commited 2024-09-26 18:11:41 +00:00
c3eccf9ef4
Fix the test flake in testRemoveServicesAfterSocketDestroyed
The removeServices() is running on a different handler, which
might take some time to complete. Therefore, the verification
should include a timeout to wait longer and prevent test flake.

Bug: 367429622
Test: atest MdnsDiscoveryManagerTests#testRemoveServicesAfter\
      SocketDestroyed --iteration
Change-Id: I79626bad680a62993c3e7d6b356acc10755257e3

Paul Hu   commited 2024-09-26 05:56:28 +00:00
78bd66003a
Merge "Use unicast instead of broadcast as ethernet destination in test_apf_drop_ethercat" into main
Maciej Żenczykowski   authored and   Gerrit Code Review   commited 2024-09-25 21:02:35 +00:00
aabad69006