Commit graph android_packages_modules_Co.../staticlibs/testutils
Message SHA1
Add missing mcts tags
Bug: 318608673
Change-Id: I9f7e3aee05af700881f145002fd9a076afd4db7a

Tongbo Liu   commited 2024-04-15 04:48:36 +00:00
65ce1f2aa2
Merge "Request INTERNET capability in ensureWifiConnected" into main
Remi NGUYEN VAN   authored and   Gerrit Code Review   commited 2024-04-11 08:20:51 +00:00
cbcbec8bc1
Merge changes from topic "rate-limit-trafficstats" into main
* changes:
  Make cache duration and max entries configurable
  Create TestRule: SetFeatureFlagsRule
  Rate-limit on TrafficStats#get*[Bytes|Packets] API calls
  Clear TrafficStats cache before getting readings from TrafficStats

Treehugger Robot   authored and   Gerrit Code Review   commited 2024-04-11 07:26:14 +00:00
47c819640d
Merge "Migrate ConnectivityManagerTest to callback rule" into main
Remi NGUYEN VAN   authored and   Gerrit Code Review   commited 2024-04-11 02:32:13 +00:00
2d23887beb
Request INTERNET capability in ensureWifiConnected
The intention of ensureWifiConnected is to connect to a "standard"
wifi network that has internet capability.

Add the capability to avoid selecting alternate wifi networks.

Test: atest
Change-Id: I20caa34feebe9d5449f4fcd8ae00fd91dd17dc5d

Remi NGUYEN VAN   commited 2024-04-10 15:29:30 +09:00
689f1cbb6d
Migrate ConnectivityManagerTest to callback rule
ConnectivityManagerTest has existing logic that is functionally
identical to AutoReleaseNetworkCallbackRule. Migrate it to use the rule
instead.

This just migrates callbacks to their Rule equivalents, except for
waitForActiveNetworkMetered which relied on the NetworkStack
ConnectivityManager shim for registerSystemDefaultNetworkCallback on R
to use a fallback implementation. Use the same NetworkRequest as
ConnectivityManagerShim as a direct fallback in this case.

Test: atest
Change-Id: I06501a5b7c05071667344bedb08e9b824c03b27c

Remi NGUYEN VAN   commited 2024-04-10 15:27:08 +09:00
93b08e202e
Create TestRule: SetFeatureFlagsRule
This rule works by reading the annotation and dynamically
invoking a user-specified method before evaluation to handle the feature flag configuration.

Usage:
class MyTestClass {
  @get:Rule
  val setFeatureFlagsRule = SetFeatureFlagsRule(setFlagsMethod = (name, enabled) -> {
    // Custom handling code.
  })

  // ... test methods with @FeatureFlag annotations
  @FeatureFlag("FooBar1", true)
  @FeatureFlag("FooBar2", false)
  @Test
  fun testFooBar() {}
}

Test: atest ConnectivityCoverageTests:android.net.connectivity.com.android.server.net.NetworkStatsServiceTest
Bug: N/A
Change-Id: I439e8ee40b8e81b6eb3857925912a3b843e8dfa1

Junyu Lai   commited 2024-04-08 10:43:42 +08:00
5ed8003915
Drop circular dependency
There was a circular dependency between net-tests-utils-host-common and
ConnectivityTestPreparer. This hasn't caught because Soong didn't track
the required dependency (ConnectivityTestPreparer requires the other).
However, as Soong is fixed to track the dependency type, this is caught
as an error.

Dropping the "required" dependency because net-tests-utils-host-common
is a host test module and is the entry point.

Bug: 321626681
Test: m
Change-Id: I539bbe2689be0af52bfec35966dd8210137d6c72

Jiyong Park   commited 2024-04-05 14:34:10 +09:00
093a4cfa95
Merge "Replace connectToCell -> NetworkCallbackRule" into main
Remi NGUYEN VAN   authored and   Gerrit Code Review   commited 2024-04-03 04:15:41 +00:00
d5a8d41172
Replace connectToCell -> NetworkCallbackRule
Developers often forget to unregister requests in tests, and cleanup
code also makes tests more verbose.

Add a rule that unregisters callbacks automatically when after each test
method.

Replace current usage of connectToCell with this rule, as well as
network callback usage in CaptivePortalTest (which is one example that
did not unregister its callback).

Test: atest
Change-Id: Ie3b9c5cf529004b7b3af04bc13a7e69acfbbaa18

Remi NGUYEN VAN   commited 2024-04-02 11:18:20 +09:00
e629bb7c84
Merge "Separate Struct.java into its own lib." into main
Yang Sun   authored and   Gerrit Code Review   commited 2024-03-28 06:23:57 +00:00
68d68d82ed
Separate Struct.java into its own lib.
* Struct.java is removed from net-utils-device-common-bpf and
  net-utils-device-common-struct's source list
* Created a lib net-utils-device-common-struct-base for Struct.java
* Updated libs that require Struct.java to include
  net-utils-device-common-struct-base.
* Replaced net-utils-multicast-forwarding-structs with
  net-utils-device-common-struct in service-connectivity

Bug: 323503345

Test: build tethering module.
Change-Id: I3f60715c3d8043b7569db7612dee9d4fa1ccba59

Yang Sun   commited 2024-03-27 20:15:17 +08:00
3aa62e6773
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