Commit graph android_packages_modules_Co.../staticlibs/testutils
Message SHA1
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 expect_throws() to assert_utils.py to check expected exception" into main
Jimi Chen   authored and   Gerrit Code Review   commited 2024-10-22 07:05:01 +00:00
7a4a85bf44
Add expect_throws() to assert_utils.py to check expected exception
Test: atest NetworkStaticLibHostPythonTests
Change-Id: I2e181f5b6f41e6de228d516dff970d47cfa3eaf6

Jimi Chen   commited 2024-10-22 03:06:47 +00:00
a0c0168ae6
Merge "Add report header to failure diagnostics" into main
Treehugger Robot   authored and   Gerrit Code Review   commited 2024-10-18 04:46:04 +00:00
40b2466b1d
Add report header to failure diagnostics
Add a one line header of JSON info about the failure in failure
diagnostics reports.

This can then be automatically collected to calculate statistics about
particular failures, for example how often they happen when wifi is not
connected, not validated etc.

Test: atest
Change-Id: Ic4c99c53fc2686aaf2f1651522aa2f0d82d0cb86

Remi NGUYEN VAN   commited 2024-10-18 09:41:33 +09:00
e980872140
Merge "Do not run diagnostics on assumption failures" into main
Treehugger Robot   authored and   Gerrit Code Review   commited 2024-10-16 07:16:44 +00:00
8eff4fd04b
Do not run diagnostics on assumption failures
Assumption failures are not actual failures, do not run connectivity
diagnostics for these.

Test: atest
Change-Id: I1d78eb6f12412e13cf4c29718ff8869ed089f491

Remi NGUYEN VAN   commited 2024-10-16 15:26:47 +09:00
3feb788aa5
Merge "Add options to disable diagnostics collector" into main
Treehugger Robot   authored and   Gerrit Code Review   commited 2024-10-16 06:02:22 +00:00
5024551d11
Add options to disable diagnostics collector
Disable by default on local builds (which generally have "eng.username"
as their INCREMENTAL version), and add an option to allow disabling
manually on other builds as well.

Test: atest

Change-Id: I2d406a55ba0e3d57ed30e740b6c011124905b8d7

Remi NGUYEN VAN   commited 2024-10-16 13:27:14 +09:00
2665f0a4d5
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
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
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
Retrieve IPv4 and IPv6 addresses for client and server device in test setup
Test: m connectivity_multi_devices_snippet && atest CtsConnectivityMultiDevicesTestCases
Change-Id: Icba82832fa1840ea1a3299f61027666d4dd90d46

Jimi Chen   commited 2024-10-07 13:34:02 +00:00
4c3a13c048
Add send and check reply packet function for multi-devices tests
The `send_packet_and_expect_reply_received` start capurting packets,
and then send out request packets, then get expected packets counts to validate.
In the end, stop capturing for the specified interface.

Test: m connectivity_multi_devices_snippet && atest CtsConnectivityMultiDevicesTestCases
Change-Id: I275534a45ce0ed363fa8ab9d12272d25845aa598

Jimi Chen   commited 2024-10-07 13:34:01 +00:00
d07d47b1d3
Add packet capture and match network_stack adb command to to apf_utils
It wraps the following 3 commands for multi-devices tests
- cmd network_stack capture start <interface>
- cmd network_stack capture stop <interface>
- cmd network_stack capture matched-packet-counts <interface> <pkt-in-hex>

Add a helper function `is_packet_capture_supported` as APFv6 precondition check.
Test: atest NetworkStaticLibHostPythonTests

Change-Id: I526c678c6e753cee3969b04a56ab33e5e3d1600d

Jimi Chen   commited 2024-10-07 13:33:57 +00:00
1644f95852
Support get multiple ipv4/ipv6 addresses in apf_utils
Test: atest NetworkStaticLibHostPythonTests
Change-Id: I806696437acf905c049762d59a46c866ff0584ef

Jimi Chen   commited 2024-09-27 06:55:54 +00:00
738bf999d5
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
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
Use unicast instead of broadcast as ethernet destination in test_apf_drop_ethercat
To prevent packet dropped earlier by multicast filtering,
use unicast ethernet destination instead

Bug: 360730207
Test: m connectivity_multi_devices_snippet && atest CtsConnectivityMultiDevicesTestCases:ApfV4Test
Change-Id: I4816b71f68f349abf1423c7013bb058ccc233d61

Jimi Chen   authored and   Maciej Å»enczykowski   commited 2024-09-25 19:42:01 +00:00
46102348e0
Merge "Add get ipv4/ipv6 address function to apf_utils" into main
Jimi Chen   authored and   Gerrit Code Review   commited 2024-09-24 13:38:54 +00:00
a0d22134b1
Merge "Add packet_utils for multi-devices tests" into main
Jimi Chen   authored and   Gerrit Code Review   commited 2024-09-24 13:38:44 +00:00
df2eadce09
Add get ipv4/ipv6 address function to apf_utils
Test: atest NetworkStaticLibHostPythonTests
Change-Id: I535bdca481f600b95603206bf368a106cbb45b42

Jimi Chen   commited 2024-09-20 05:45:19 +00:00
b756497e05
Add packet_utils for multi-devices tests
Test: atest NetworkStaticLibHostPythonTests
Change-Id: I211d071232d1730c043eef29e1bf2bce27a6e2a6

Jimi Chen   commited 2024-09-20 05:41:20 +00:00
0e1c1cc92d
Merge changes from topics "ddr-tests-in-networkstack", "move-fakedns" into main
* changes:
  Move to one unified implementation of FakeDns.
  Add test utils for SVCB packet generation.

Lorenzo Colitti   authored and   Gerrit Code Review   commited 2024-09-19 06:19:31 +00:00
3627907075
Move to one unified implementation of FakeDns.
Take the functionality from the (better) FakeDns in NetworkStack,
move it to the FakeDns in staticlibs, and port it to kotlin.

Test: test-only change
Change-Id: I6d0b4a348ca86ab69785cdf722c259ef6a92ce4b

Lorenzo Colitti   commited 2024-09-19 12:51:28 +09:00
5355fce9b2
Remove assert for R+
Mainline only ships to R+ devices, so this assertion is guaranteed to be
true.

Change-Id: I1fbc0a50dc35a306d782a0219955c51954deeca7
Test: TH

Patrick Rohr   commited 2024-09-12 04:32:59 +00:00
d393a9d8d4
Merge "Check APF version, VSR API level, and Android version" into main
Treehugger Robot   authored and   Gerrit Code Review   commited 2024-09-10 17:30:53 +00:00
6a5165a211
Check APF version, VSR API level, and Android version
This commit introduces checks for APF version, VSR API level,
and Android version to decide whether an APFv4 test should be
run, skipped, or fail:
* If Android version is less than V, skip the test
* If VSR API level is greater than or equal to 14 and APF
  version is less than 4, fail the test
* Otherwise, if APF version is less than 4, skip the test

Test: m connectivity_multi_devices_snippet && \
      atest CtsConnectivityMultiDevicesTestCases:ConnectivityMultiDevicesTest
Fix: 352132428
Change-Id: I023164fb59ad40f489abea2e0c45761efc39699b

Junyu Lai   commited 2024-09-10 18:06:28 +08:00
73711f7b41
Add test utils for SVCB packet generation.
This is based on patchset 22 of aosp/2453209.

Bug: 240259333
Test: test-only code, will be covered by NetworkMonitorTest
Change-Id: Ibede3fb519e6f1d0c3d99886f553ee006ddfebc9

Lorenzo Colitti   commited 2024-09-10 14:47:57 +09:00
93f2efbe86
Throw IllegalStateException when inserting an existing item
This commit throws IllegalStateException instead of
IllegalArgumentException when inserting an existing item
to TestBpfMap to fit the current behavior in the
production code.

This is safe given that this is only for test and no one is
currently check the exception.

Test: atest TetheringTests:com.android.networkstack.tethering.BpfCoordinatorTest
Bug: 354619988
Change-Id: I1e5c6e99a0d95b44dd556de8805bb16c3d1a4f61

Junyu Lai   commited 2024-09-04 18:48:56 +08:00
c1856de66e
Merge "Skip running restore default network monitor on instant mode." into main
Motomu Utsumi   authored and   Gerrit Code Review   commited 2024-08-20 06:14:30 +00:00
63488f4798
Skip running restore default network monitor on instant mode.
Instant mode does not have access to WifiManager

Test: atest MultinetworkApiTest --instant
Bug: 356644514
Change-Id: I310cd8a614006c391407829ada587d892a0ac3b4

Motomu Utsumi   commited 2024-08-20 13:41:12 +09:00
d3d139a80d
Add testutil to mock android.app.usage.NetworkStats
It's not possible to directly create a mocked `NetworkStats`
instance because of limitations with `NetworkStats#getNextBucket`.
As a workaround for testing, create a mock by controlling the
return values from the mocked service that provides the
`NetworkStats` data.

Test: atest FrameworksServicesTests:com.android.server.stats.pull.netstats.NetworkStatsUtilsTest
Bug: 335680025
Change-Id: I4be8420de50040781557587fba4a50b9c0587f61

Junyu Lai   commited 2024-08-19 17:39:15 +08:00
c51f71fb41
Merge "Revert "Use addEntries when creating NetworkStats"" into main
Sam Dubey   authored and   Gerrit Code Review   commited 2024-08-14 11:39:22 +00:00
d7f925facc
Revert "Use addEntries when creating NetworkStats"
This reverts commit 668560d85a.

Reason for revert: Devices failing to boot, see b/359795863 

Change-Id: I13dc629e2eb626bff1aed6ff262699c3f577ab9c

Sam Dubey   authored and   Gerrit Code Review   commited 2024-08-14 10:00:32 +00:00
c006797ed4
Merge changes I3286aeb1,I060509de into main
* changes:
  Add Wi-Fi P2P mdns tests
  Setup Wi-Fi P2P connection

Paul Hu   authored and   Gerrit Code Review   commited 2024-08-14 07:14:01 +00:00
71bba4e45f
Use addEntries when creating NetworkStats
In the current design, NetworkStats.addEntry is used within a
loop to create a NetworkStats instance from entries. This results
in a large memory footprint because the addEntry() method clones
the original NetworkStats instance each time it is called.

This change utilizes the newly created API to add a list of
entries at once. This approach only clones the instance once,
thereby reducing the required memory footprint.

Test: atest NetworkStaticLibTests:com.android.net.moduletests.util.NetworkStatsUtilsTest#testPublicStatsToAndroidNetStats
Test: atest ConnectivityCoverageTests:android.net.connectivity.com.android.net.module.util.NetworkStatsUtilsTest
      (on S device)
Test: atest ConnectivityCoverageTests:com.android.testutils.NetworkStatsUtilsTest
      (on S device)
Bug: 335680025
Change-Id: I5c635613ed3ba34d840ee71b6bef21d10105df0d

Junyu Lai   commited 2024-08-13 17:46:20 +08:00
668560d85a
Make assertNetworkStatsEquals supports null iface name
This change enables comparison of android.net.NetworkStats
instances even when their interface name is null. This scenario
arises when deriving a android.net.NetworkStats instance
from an app.usage.NetworkStats, which lacks interface name
information. However, the original utility method relies on
NetworkStats.Entry#equals, which is incompatible with null
interface names on T- devices, because they do not run
mainlined NetworkStats.

This change refactor assertEntryEquals and makes
assertNetworkStatsEquals to use it to compare android.net.NetworkStats
instances.

Test: atest NetworkStaticLibTests
Test: atest ConnectivityCoverageTests:com.android.testutils.NetworkStatsUtilsTest
      (on S device)
Test: atest ConnectivityCoverageTests:android.net.connectivity.com.android.net.module.util.NetworkStatsUtilsTest
      (on S device)
Bug: 335680025

Change-Id: I25a685e4c2d4cf70132b2c4374b2bb8129c844cb

Junyu Lai   commited 2024-08-13 17:02:33 +08:00
10fcc1761d
Setup Wi-Fi P2P connection
Add functionalities to setup Wi-Fi P2P connection for subsequent
Wi-Fi P2P mDns tests

Bug: 343311941
Test: atest CtsConnectivityMultiDevicesTestCases
Change-Id: I060509deb32c078829c1108f9ae2a29561e00d53

Paul Hu   commited 2024-08-13 07:20:21 +00:00
3e24dec82a
Improve staticlibs/Android.bp
- Add comments clarifying the use cases of
  net-utils-framework-connectivity and net-utils-service-connectivity
- Apply stricter visibility for the staticlibs

Bug: 357803496
Test: CI
Change-Id: I0d13b436976c3194c0fe350a905a8edf3e4df73a

Handa Wang   commited 2024-08-08 15:42:00 +00:00
8be10bfdff
Refactor Drop EtherCat packet test
This is a no-op refactoring, which is preparation for follow-up
changes to add more apf tests.

This includes:
1. Add a method to send packet and expect counter increases.
2. Inline the packet construction code in the test method.

Test: atest NetworkStaticLibHostPythonTests
Test: m connectivity_multi_devices_snippet && \
      atest CtsConnectivityMultiDevicesTestCases
Bug: 350880989
Change-Id: Iadcfd97740033306af1b6a474004cbf0699ddd1b

Junyu Lai   commited 2024-08-01 03:32:19 +00:00
6f6b1a4684
Refactor ApfV4Test
This is a no-op refactoring, which is preparation for follow-up
changes to add more apf test classes.

This includes:
1. Move initialization code to a base class, which setup a hotspot
   and a client connects to it, and enable doze mode to
   activate the apf.
2. Check whether send raw packet is supported before testing.

Test: m connectivity_multi_devices_snippet && \
  atest CtsConnectivityMultiDevicesTestCases
Test: atest NetworkStaticLibHostPythonTests
Bug: 350880989
Change-Id: I6376935883653182728e473e2f5533407d993d7b

Junyu Lai   commited 2024-08-01 03:32:19 +00:00
cf655869ba
Move apf test to a standalone file
This is a no-op refactoring, which is preparation for follow-up
changes to add more apfv4 tests.

This includes:
  1. Add a entry point for multi-device tests to collect
     test cases from different files.
  2. Move multi-device initialization code to a base class.
  3. Make different test classes inherit the base class.

Test: m connectivity_multi_devices_snippet && \
      atest CtsConnectivityMultiDevicesTestCases
Bug: 350880989
Change-Id: I294c85d8e09633bbf02ba1543b9f2ea3e988e20d

Junyu Lai   commited 2024-08-01 03:32:19 +00:00
32a2d151cc
Merge changes I44e85c09,I01810b54,I1c169311,I15f2aeac,I048512a1 into main
* changes:
  Use AutoCloseTestInterfaceRule in NsdManagerDownstreamTetheringTest
  Add auto close rule for test interfaces
  Add finalizer to check whether destroy was called
  Wrap use of test interface in EthernetTestInterface
  Add a class to properly manage ethernet test interfaces

Patrick Rohr   authored and   Gerrit Code Review   commited 2024-07-31 20:36:45 +00:00
74e3f5aa48
Increase timeout to expect CapabilitiesChanged callback
DefaultNetworkRestoreMonitor sometimes fails since the CapabilitiesChanged callback is not called within the timeout.
This CL fixes the issue by increasing the timeout.

Bug: 356132243
Test: TH
Change-Id: Id36d9166538070933fd62a03c6dd18bc84053bd8

Motomu Utsumi   commited 2024-07-30 06:10:27 +00:00
2ac329900b
Add auto close rule for test interfaces
This rule proxies calls to TestNetworkManager, keeps track of all
interfaces created by it, and closes them after running the test.

Test: builds
Change-Id: I01810b54929fea6e9c929a49bbf5e5268c6793af

Patrick Rohr   commited 2024-07-22 15:29:24 -07:00
ebb20c841f
Increase timeout to wait the default network is restored
3 seconds were too short to wait the network validation.
This CL also updates error message to include more information that
helps investigation.

Test: TH
Bug: 354475907
Bug: 354475880
Bug: 354104252
Change-Id: I513a5bd8af44df47f18773f8fa49323986757e0d

Motomu Utsumi   commited 2024-07-22 09:45:07 +00:00
7269856960
Merge "Add wifip2p_utils and Wifip2pMultiDevicesSnippet" into main
Paul Hu   authored and   Gerrit Code Review   commited 2024-07-17 05:39:25 +00:00
12c2599545
Merge "Add default network monitor to DevSdkIgnoreRunner" into main
Motomu Utsumi   authored and   Gerrit Code Review   commited 2024-07-17 02:47:06 +00:00
a9a27614cc