Commit graph android_packages_modules_Co.../staticlibs/testutils
Message SHA1
Merge "Quit NetworkMonitor threads in integration tests" into main
Treehugger Robot   authored and   Gerrit Code Review   commited 2024-03-15 09:17:11 +00:00
2fae00cb39
Quit NetworkMonitor threads in integration tests
Similarly to NetworkMonitorTest, terminate NetworkMonitor threads and
ExecutorServices after each test case in integration tests.

This should fix flakes where the HTTP probe from testValidation could
finish after mock probe responses are cleared in tearDown.

The utils used in NetworkMonitorTest are factored out to ConcurrentUtils
to achieve that.

Fixes: 292481238
Test: atest --rerun-until-failure 50
Change-Id: I5cdeee8d4f06ea40e338dd2cb1fdcc2fe0907a7d

Remi NGUYEN VAN   commited 2024-03-14 13:18:44 +09:00
b3fcdacfae
Use custom defined DNS/HTTP port
Refactor the test case to support listen custom DNS/HTTP port.
Avoid binding system restricted port (<1024).

Bug: 322113686
Test: atest NetworkStackIntegrationTests:android.net.NetworkStatsIntegrationTest
Change-Id: I5d3b966cdadc9321ca2ee0d04a5b8f71ee79bd8a

Jimi Chen   commited 2024-02-20 08:08:17 +00:00
45ac04442f
Merge "[DON'T BLOCK] Test ownership migration rules" into main
Treehugger Robot   authored and   Gerrit Code Review   commited 2024-01-31 23:38:03 +00:00
e7aa45cdf0
Merge "Add CtsConnectivityMultiDevicesTestCases for hotspot" into main
Junyu Lai   authored and   Gerrit Code Review   commited 2024-01-31 14:29:18 +00:00
9c3c120c6c
[DON'T BLOCK] Test ownership migration rules
This CL is created as a best effort to migrate test targets
to the new android ownership model. If you find incorrect or unnecessary
attribution in this CL, please create a separate CL to fix that.

For more details please refer to the link below,
<add g3 doc link>

Bug: 304529413
Test: N/A
Change-Id: I243f17b3f0ad7af9ffa15ca242456e36688733f5
Merged-In: I243f17b3f0ad7af9ffa15ca242456e36688733f5

Aditya Choudhary   commited 2024-01-31 12:34:50 +00:00
01b5ede2b2
clearInlineMocks from DevSdkIgnoreRunner after running test
Memory leak was observed and inline mock is one of the reasons.
This CL updates DevSdkIgnoreRunner to clear mock state if there is no
thread leak.

Test: TH
Bug: 321603955
Change-Id: I50fd03f14c6703bd38b5729f577d7ea516cd5b44

Motomu Utsumi   commited 2024-01-25 21:55:10 +09:00
05bf4f398f
Fix the dependency of CtsNetTestCasesMaxTargetSdk
Bug: 318958910
Change-Id: I71499f2a5244030c5c83c2102585c4c0c3da5db4

Tongbo Liu   commited 2024-01-23 09:24:49 +00:00
47524106d0
Add CtsConnectivityMultiDevicesTestCases for hotspot
This test is conducting two physical devices: a device
acting as the hotspot and a separate client device. The test
assesses whether the client can connect to the hotspot and utilize
its internet connection.

This test verifies the basic functionality of the hotspot feature
by exercising the entire system without mocking any component.
This is crucial because various system components, like cellular,
Wi-Fi, routing rules, tethering, and hardware offload, can have
regressions or design changes that impact the basic functionality.

Test: m connectivity_multi_devices_snippet && \
      atest CtsConnectivityMultiDevicesTestCases
      (2 physical devices near each other are needed
      to perform this test)
Bug: N/A
Change-Id: Ib97495c48f313889cedae03d59762482da10cfd8

Junyu Lai   commited 2024-01-22 15:13:11 +08:00
36e7626406
Merge changes from topics "remove-napt", "support-multipleaddr" into main
* changes:
  Support multiple addresses in PacketBridge
  Remove NAPT from PacketForwarder

Junyu Lai   authored and   Gerrit Code Review   commited 2024-01-16 07:47:47 +00:00
24b54c2285
Fix replying to queries via unicast
Instead of (wrongly) looking at the DNS message flags for the Query
Unicast bit, look at the flag in the question record.

The previous bug means that all queries would be replied multicast
instead of sometimes unicast. The fix is flagged off as this is a
behavior change that may affect performance and latency.

Bug: 289482497
Test: atest
Change-Id: I08e30c4ffa747c9073d631e8addca1278ea40648

Remi NGUYEN VAN   commited 2024-01-15 20:26:28 +09:00
0ca094b577
Support multiple addresses in PacketBridge
Test: atest NetworkStackIntegrationTests:android.net.NetworkStatsIntegrationTest
Bug: N/A
Change-Id: Icaef559d54f8d7ce06fb9bf231330235ee01ab8f

Junyu Lai   commited 2024-01-15 17:54:26 +08:00
3cc222dd76
Remove NAPT from PacketForwarder
Consider below scenario:
  Internal address: 1.2.3.4
  External address: 5.6.7.8
  Remote address: 8.8.8.8
When a packet was sent from 1.2.3.4 to 8.8.8.8, the current design
translate it to a packet from 8.8.8.8 to 5.6.7.8 and foward it
to the external interface. However, when the response is received
from the external interface, there is a need to remember what is
the original address to forward to. Thus, an address translation
mechanism was introduced in current design.

This change simplify PacketForwarder by removing the address
translation.
Consider, if the 2 interfaces are using the same address.
  Internal address: 1.2.3.4
  External address: 1.2.3.4
  Remote address: 8.8.8.8
When a packet was sent from 1.2.3.4 to 8.8.8.8, simply swap
source and destination and and foward it to the external
interface. When there is a response from the external interface,
the same process can be done, this removes the need of address
translation.

Test: atest NetworkStackIntegrationTests:android.net.NetworkStatsIntegrationTest
Test: atest CtsHostsideNetworkTests:com.android.cts.net.HostsideVpnTests
Bug: N/A

Change-Id: I86f2e774e9112905e5255b5a28c927562a42ab84

Junyu Lai   commited 2024-01-15 17:54:26 +08:00
74acb88d03
Add mcts tag to MainlineCTS networking test modules which is used for build all the mainline CTS tests.
Bug: 316436957

Change-Id: I0e7ab773075fb0dfd154dde45a710d1c1823c914

Tongbo Liu   commited 2023-12-19 11:03:50 +00:00
199357ba68
Merge "Improve message for SIM cards not supporting data" into main
Treehugger Robot   authored and   Gerrit Code Review   commited 2023-11-19 14:48:31 +00:00
10c33ca574
Make thread leak error message more readable
This change only outputs thread count differences instead of
listing all threads. Additionally, it ignores threads with 1
count, which effectively filter out threads created
by the test runner or other system components, such as
hwuiTask*, queued-work-looper, SurfaceSyncGroupTimer,
RenderThread, and Time-limited test.

Sample Output:
[1122/3060] android.net.connectivity.com.android.server.CSLocalAgentCreationTests#ThreadLeakMonitor: FAILED (1ms)

STACKTRACE:
java.lang.IllegalStateException: Unexpected thread changes: removed=[] added=[] updated=[TestAlarmManager=25,CSTestHandler=25]

Test: atest ConnectivityCoverageTests
      (with shouldThreadLeakFailTest set to true)
Bug: 310581973
Bug: 307693729
Change-Id: I085799ebbd69c29f833335684de208105302e012

Junyu Lai   commited 2023-11-17 15:05:19 +08:00
c034c7217e
Improve message for SIM cards not supporting data
The previous message is not clear about the fact that there is
a SIM card inserted. Clarify it.

Change-Id: I2391d9fa7762b6225438049199f9f178a8b24d41

Remi NGUYEN VAN   commited 2023-11-17 04:14:39 +00:00
1af3d90f24
Ensure no thread leak after NetworkStatsServiceTest
This change includes:
 1. A mechanism in DevSdkIngoreRunnrer to dump thread counts
    before/after tests, and compare thread counts to detect leaks.
 2. Add an annotation @MonitorThreadLeak for test classes to
    annotate the classes which should monitor thread leaks.
 3. Annotated NetworkStatsServiceTest to apply the enforcement.

Sample output:
[1/2] android.net.connectivity.com.android.server.net.NetworkStatsServiceTest#testDumpStatsMap: PASSED (1.187s)
[2/2] android.net.connectivity.com.android.server.net.NetworkStatsServiceTest#ThreadLeakMonitor: FAILED (7ms)

STACKTRACE:
java.lang.IllegalStateException: Expected threads: {binder:26055_3=1, Instr: androidx.test.runner.AndroidJUnitRunner=1, main=1, InstrumentationConnectionThread=1, binder:26055_2=1, binder:26055_1=1} but got: {binder:26055_3=1, NetworkStatsObservers=1, Instr: androidx.test.runner.AndroidJUnitRunner=1, main=1, InstrumentationConnectionThread=1, binder:26055_2=1, binder:26055_1=1}

Test: atest ConnectivityCoverageTests:android.net.connectivity.com.android.server.net.NetworkStatsServiceTest \
      --rerun-until-failure 100
Bug: 308544001
Bug: 307693729
Change-Id: Ia0bccb82c5985df608b8402009b32626b6b17c5a

Junyu Lai   commited 2023-11-15 14:03:45 +08:00
17f589cf47
Add LocalNetworkInfo and send callbacks when it changes
Test: CSLocalAgentTest
Change-Id: I8caca97b891081f9212a01d428a34ed1a08d5126

Chalard Jean   commited 2023-11-07 17:29:38 +09:00
22350c93b4
Merge "[BR01.1] Support BpfNetMapsReader" into main
Junyu Lai   authored and   Gerrit Code Review   commited 2023-10-24 05:56:33 +00:00
a62eed380c
[BR01.1] Support BpfNetMapsReader
A helper class to *read* java BpfMaps. This is designed to
provide direct bpf access in the caller process through
ConnectivityManager APIs.

The change also removes any statical link to
net-utils-device-common-struct from service-connectivity.
This is because net-utils-device-common-struct is already
included in framework-connectivity. Including it again in
service-connectivity would create a r8 build fail by circular
dependency.

Test: atest FrameworksNetTests:android.net.connectivity.com.android.server.BpfNetMapsTest
Test: atest ConnectivityCoverageTests:android.net.connectivity.com.android.net.module.util.StructTest
Test: atest FrameworksNetTests:android.net.connectivity.android.net.BpfNetMapsReaderTest
Bug: 297836825
Change-Id: I7a6d2eb816d0dc7343167bddd672806b199f44fe

Junyu Lai   commited 2023-10-23 20:11:02 +08:00
626045a601
Fix arg order to set-package-network-enabled in the CTS preparer
Test: manual
Change-Id: Ife55ed9dc152cd2c21e56b84201b9c34dbb04d46

Chalard Jean   commited 2023-10-23 17:26:53 +09:00
a27dca2fdc
Add hidden constants for communicating about local network agents
Test: FrameworksNetTests
Change-Id: Ic490fee6ee70d74acff0a290199b2946817173d0

Chalard Jean   commited 2023-10-12 13:30:49 +09:00
d6f4efb1a8
Address comments on aosp/2765367
Test: comment-only change
Change-Id: I788f6e9f5fdd913d4c5077b6bb82c19664d3cd3f

Chalard Jean   commited 2023-09-29 15:48:09 +09:00
2aa4412503
Have DevSdkIgnoreRunner support @Parameterized parameters
Test: aosp/2405723 uses this, TH is happy with existing tests
Change-Id: If47d7e239d8483716fb78a97bbc2da4e24731209

Chalard Jean   commited 2023-09-28 21:37:31 +09:00
a10ae005df
Merge changes I8843ce7c,I90566998 into main
* changes:
  Block the package updater while CTS are running
  Add a command to block networking for an app

Jean Chalard   authored and   Gerrit Code Review   commited 2023-09-22 02:26:19 +00:00
487191dbe6
Block the package updater while CTS are running
Test: manual
Bug: 284534251
Change-Id: I8843ce7c9e14cfe3f6f3439405d519587f2656ef

Chalard Jean   commited 2023-09-21 12:57:10 +09:00
3a6544fb1f
bump min_sdk_version from 29 (Q) to 30 (R)
Mainline no longer supports Q.
These files were recently moved into p/m/C as part of a refactor.

Test: TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I0f06ace921db6c79d63c0048bdb73d167ff606cf

Maciej Å»enczykowski   commited 2023-09-19 23:22:58 +00:00
127a1441c3
Check that wifi, cell validates before tests
Tests are sometimes run on hardware devices with wrongly configured wifi
or cell data. Ensure that this is reported as an infra error, and not a
test error, so the root cause is easier to identify.

Bug: 264170054
Test: atest
Change-Id: I4f964fbd4ee497e8ac92f7729375b75b6c4594a3

Remi NGUYEN VAN   commited 2023-09-19 17:26:20 +09:00
f1846ac13b
Merge remote-tracking branch 'remotes/aosp/tmp_libs_net_move' into libs_net_move_merge
frameworks/libs/net/common ->
packages/modules/Connectivity/staticlibs

frameworks/libs/net/client-libs ->
packages/modules/Connectivity/staticlbs/client-libs

Test: TH
Bug: 296014682
Change-Id: I5dc78f0c4653e20312ab3d488b1e69262dbb9840

Motomu Utsumi   commited 2023-09-11 11:53:46 +09:00
c480039309
Add class to help Kotlin to pass nullable to java @NonNull for testing
Follow up CL for aosp/2700076

Bug: 296972712
Test: build with aosp/2688146
Change-Id: Ib582ef41f34baf0bb896e32d681843358f928c87

Motomu Utsumi   commited 2023-08-23 13:01:29 +09:00
7bca2922b8
Merge "Fix kotlin nullable errors in net-test-utils and NetworkStaticLibTests" into main
Colin Cross   authored and   Gerrit Code Review   commited 2023-08-21 19:04:15 +00:00
1d1c0e7282
Merge "Improve test logs using TrackRecord backtrace" into main
Patrick Rohr   authored and   Gerrit Code Review   commited 2023-08-18 22:32:51 +00:00
10fe61b520
Improve test logs using TrackRecord backtrace
eventuallyExpect methods should print the received callbacks since
poll() was called for better debugging.

Test: atest EthernetManagerTest
Change-Id: Ia08abf2436b050a7e319b9f70694ce3d132b4fc3

Patrick Rohr   commited 2023-08-18 09:35:13 -07:00
5bf2947997
Merge "TrackRecord: add a method to return callbacks since last poll" into main
Patrick Rohr   authored and   Gerrit Code Review   commited 2023-08-18 14:10:21 +00:00
0622dafd75
Merge "Fix DevSdkIgnoreRule for Q-" into main
Remi NGUYEN VAN   authored and   Gerrit Code Review   commited 2023-08-14 03:15:37 +00:00
f3bd5e5a0a
Fix DevSdkIgnoreRule for Q-
UnboundedSdkLevel stopped working on Q as it now depends on Set.of,
which is an R+ API. Arguably this should be fixed as its minSdk is still
29, but long-term UnboundedSdkLevel may drop Q support as modules now
only need to support R+.

Avoid using UnboundedSdkLevel on Q- in DevSdkIgnoreRule: this avoids the
above problem, and also makes it compatible with even older builds,
which may happen in GTS.

Bug: 292868272
Test: all tests using this rule
Change-Id: I5e1559d841398a6c6763283f32c9f766a3661e21

Remi NGUYEN VAN   commited 2023-08-10 16:24:48 +09:00
a6e8a281a4
TrackRecord: add a method to return callbacks since last poll
This change adds a backtrace() method which returns a list of events
that were received since the last time a user called poll() on a
ReadHead. This is particularly useful for logging observed events while
a poll was in progress that did not end up matching an event.

Test: atest EthernetManagerTest
Change-Id: If019cf9eb5e3e9268c5e6b74edbd8f49959cc71c

Patrick Rohr   commited 2023-08-09 05:26:36 -07:00
533af6d72d
Fix kotlin nullable errors in net-test-utils and NetworkStaticLibTests
Fix kotlin nullable errors that were exposed by setting the retention
of android.annotation.NonNull and android.annotation.Nullable to
class retention.

Bug: 294110802
Test: builds
Change-Id: I2a2c91188b64619fca190a9bd7812d32f9610abd

Colin Cross   commited 2023-08-08 14:26:10 -07:00
d91c89ba51
Use requestNetwork for mobile data, not a callback
On devices that do not have always active mobile data, it needs
to be requested for onAvailable to be called.

Change-Id: Ic814684bcd06389c013a6e6636487d9b47627901
Test: TH

Remi NGUYEN VAN   commited 2023-08-01 08:48:32 +00:00
837837e0fe
Merge "Make SkipPresubmit annotation visible by HostsideVpnTests" into main
Junyu Lai   authored and   Gerrit Code Review   commited 2023-07-28 02:06:17 +00:00
3416eae310
Merge "Add an annotation for @SkipMainlinePresubmit" into main
Remi NGUYEN VAN   authored and   Gerrit Code Review   commited 2023-07-27 02:13:22 +00:00
7035b4418d
Make SkipPresubmit annotation visible by HostsideVpnTests
Test: TH
Bug: 291701394
Change-Id: I93d72a809b2779deec3c8182c5efed6d38393ab8

Junyu Lai   commited 2023-07-26 14:42:56 +08:00
af464eb494
Add an annotation for @SkipMainlinePresubmit
This will typically be used in mainline-presubmit TEST_MAPPING
configuration to exclude some tests.

This is necessary as some tests are flaky in mainline configurations
(when running on older devices), and they need to be disabled to meet
SLO requirements, but they are not flaky on presubmit using the latest
platform builds.

Test: m
Change-Id: Ia532d6d3f9833ddec613d79c0eb517d20a1c529a

Remi NGUYEN VAN   commited 2023-07-26 13:37:47 +09:00
5e4900dbbe
Add DnsResolverModuleTest annotation
This annotation can be used to mark a test case that requires
the latest resolv module. Tests that don't run with the latest
resolv module (for example CtsNetTestCasesLatestSdk) can exclude
the testcases being flaky due to some known issues in old resolv
module.

Bug: 279846955
Test: TreeHugger
Change-Id: Ie19eed1c4aa17645c4eec45493e7999027a01205

Mike Yu   commited 2023-06-26 07:40:18 +00:00
8f4debc3f9
Merge "Add NetworkStackModuleTest annotation."
Xiao Ma   authored and   Gerrit Code Review   commited 2023-06-05 01:45:01 +00:00
267467ec93
Merge "Fix crash when socket read is interrupted"
Junyu Lai   authored and   Gerrit Code Review   commited 2023-06-01 05:39:33 +00:00
14a8c7d913
Add NetworkStackModuleTest annotation.
This annotation can be used to exclude the testcases which requires the
latest NetworkStack module in the CTS/MTS suite.

Bug: 283200648
Test: atest CtsTetheringTestLatestSdk
Change-Id: Idaffed93af077c2998081142af7b3bfa311dcd90

Xiao Ma   commited 2023-06-01 13:34:01 +09:00
cff263aa10
Fix crash when socket read is interrupted
The exception is thrown in some normal cases e.g. interrupt()
called when Os.read is blocked and waiting for the input.
Ignore such events.

Test: 1. atest NetworkStackCoverageMtsConfigTests on S device
      2. atest com.android.cts.net.HostsideVpnTests
      3. atest NetworkStatsIntegrationTest
Bug: 259632210
Change-Id: Ibff41312d9c7431c2b19f780844ab3a81b48f9e8

Junyu Lai   commited 2023-05-31 14:14:01 +08:00
ab3fee4246
Merge "Use ThrowingSupplier for visibleOnHandlerThread."
Hansen Kurli   authored and   Gerrit Code Review   commited 2023-05-24 02:39:07 +00:00
8b39bca655