Commit Graph

10733 Commits

Author SHA1 Message Date
Paul Hu
ebbbf8f470 Stop the created handler threads on the tests
The created handler thread will stay there for a while until
all the tests are finished. This is considered as a leakage
which will take the resource from the devices. In low end
devices, this may possibly impact the performance. The created
threads should be closed explicitly.

Test: atest ConnectivityCoverageTests ConntrackSocketTest
Change-Id: Ic1beb2a210e7c8c80c66fc9e0727c47599150672
2023-10-12 10:25:03 +08:00
Jean Chalard
02193c0cce Merge changes Ibb8d33b7,Ie168fe1f,I9f699b63 into main
* changes:
  Prepare exposing Network{Request,Caps}.forbiddenCapabilities
  Add a keep connected for test reason
  Improvements to CSTest : legacy type, wait for LOST, permissions
2023-10-12 02:14:52 +00:00
Hansen Kurli
270813c4c5 Merge changes Ib24809ec,Id9d26435 into main
* changes:
  Remove the fail case on IPv6 in testLockdownVpn
  Remove LockdownVpnTracker from testLegacyLockdownVpn
2023-10-11 12:03:37 +00:00
Chalard Jean
cf7dbcae41 Prepare exposing Network{Request,Caps}.forbiddenCapabilities
This is useful going forward in particular because there will
be a default forbidden capability for LOCAL_NETWORKS. This
means it will be useful to be able to remove it.

It is also generally useful and we have been wanting to open
this API to the public, so this is a good opportunity to do so.

Test: new tests for NetworkRequest
      NetworkCapabilitiesTest already has tests because it
      already was @SystemApi
Change-Id: Ibb8d33b799f2d274326fd9cd0b05a2c33a18032a
2023-10-11 17:02:52 +09:00
Chalard Jean
c517fb1247 Add a keep connected for test reason
This has been sorely needed for a while. Instead of filing requests
for each of your networks in a CSTest, which is fiddly at best and
sometimes almost impossible (because you can't single out the network),
you can now add this flag and be done with it.

Test: CSKeepConnectedTest
Change-Id: Ie168fe1f3a17de035fdf05e3d6580d3262a3448e
2023-10-11 17:02:52 +09:00
Chalard Jean
026ca940d9 Improvements to CSTest : legacy type, wait for LOST, permissions
• Make sure all Agents have a legacy type. This is necessary to
  avoid crashes in LegacyNetworkTracker
• Wait for LOST when disconnecting a network
• Make sure the test package sees its own permissions (importantly
  it can't see background networks otherwise, because it lacks
  CHANGE_NETWORKING_STATE)

Test: in the followup
Change-Id: I9f699b6372a8fe0d5bcd5310d8f35f72e48a6c61
2023-10-11 17:02:51 +09:00
Chalard Jean
f70919fbec Reword a comment for accuracy
Test: none needed
Change-Id: I7e409827adc86fc13975f394100889a6bf0f1e50
2023-10-10 20:12:40 +09:00
Chalard Jean
eb66389d6a Allow for mocking an SDK in the tests
Test: in followup patches
Change-Id: I540ce2a455c92be52eb94fbd4b54a2081d04d25e
2023-10-10 14:57:22 +09:00
Jean Chalard
4dec273ab4 Merge "Expose the netd mock in CSTest to allow verifying calls on it" into main 2023-10-10 04:17:29 +00:00
Jean Chalard
e339c6b780 Merge "Add missing copyright notices to tests" into main 2023-10-10 04:16:52 +00:00
Krzysztof Kosiński
22d08770af Merge "Clean up obsolete aliases for Truth." into main 2023-10-09 23:08:57 +00:00
Kangping Dong
4a8977c452 Merge "[mdns] exclude mDNS advertiser code from standalone build test" into main 2023-10-08 12:21:24 +00:00
Kangping Dong
1a1beee654 [mdns] exclude mDNS advertiser code from standalone build test
service-connectivity-mdns-standalone-build-test builds the mDNS
discovery and advertisement implementation against API level 21.
This stops the advertisement code from calling new NsdServiceInfo
public or private APIs which are required by Thread.

This commit removes the mDNS advertisement code from the standalone
build to loose the check given this will never be used by GMS Core.

Bug: 265095929
Test: verified that it can build with aosp/2608627
Change-Id: I32cfce7b994d51a4b4ec468e9f79ffc2be6635ff
2023-10-08 17:22:14 +08:00
Chalard Jean
ff7edd36eb Expose the netd mock in CSTest to allow verifying calls on it
Test: manual
Change-Id: Ib39dc4dbf534f14d94923bb0026f18e47edabba2
2023-10-07 15:11:40 +09:00
Chalard Jean
52afbf2634 Add missing copyright notices to tests
Test: comment-only change
Change-Id: I63bada891757d7e991cc7538c56e4fc50074ee5d
2023-10-07 15:09:21 +09:00
Krzysztof Kosiński
739ed22507 Clean up obsolete aliases for Truth.
Bug: 255714762
Test: presubmit
Change-Id: If91e9af5409fed9d5ccdd13749a0f562c545d589
2023-10-07 00:48:10 +00:00
Maciej Żenczykowski
3cb494fd28 move BPF_CGROUP_INET*_BIND registration into BpfHandler
(in preparation for moving it into netbpfload)

The programs themselves (in bpf_progs/block.c) required a 5.4+ kernel.

We relax this restriction to 4.19+ as we don't have any 5.4 device coverage
(while the pixel 4a 5G / 5 / 5a are all 4.19 devices).

I believe we could relax it further to 4.14+ but Pixel 4/4xl/4a that
would exercise those code paths are EOL and probably have poor to
non existent test coverage, and we cannot do anything for 4.9 T devices
anyway.

Note: on <4.19 kernels (ie. T devices running 4.9/4.14, U running 4.14)
this results in ConnectivityNativeService going from null to initialized
(as the bpf map will exist).

This doesn't hurt as the set/clear port interfaces are only ever
called by vendor code on devices where the kernel doesn't support
the older mechanism.  And even if you call them it will just set/clear
the bits in the bpf bitmap, they just won't actually affect anything.

We could flag the map itself as being 4.19+ as well, but I think
I prefer the no-op map to exist...

Test: TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I1085addd22f4f3b709e1875049633832c5dac836
2023-10-06 14:31:20 -07:00
Paul Hu
87d128f43d Merge "Store transaction id in MdnsPacket" into main 2023-10-06 05:51:33 +00:00
Treehugger Robot
b3493eea05 Merge "Add PACKAGE_USAGE_STATS permission to ConnectivityServiceIntegrationTest" into main am: 6a5ab05e87
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/2774205

Change-Id: I476aa7fc7f839285e7a86596b06a0e4a7dbee316
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-10-05 07:18:41 +00:00
Treehugger Robot
6a5ab05e87 Merge "Add PACKAGE_USAGE_STATS permission to ConnectivityServiceIntegrationTest" into main 2023-10-05 06:44:32 +00:00
Paul Hu
f286ed5be1 Include A/AAAA records in probing packet
Per RFC6762#8.1, a host can simultaneously probe for uniqueness
of its "A" record and all its SRV records [RFC6763] in the same
query message. Add a flag to include the A/AAAA records in the
probing packet if necessary.

Test: atest FrameworksNetTestCases NsdManagerTest
Change-Id: I365a938a6c481df755a0598b175069b94905fa3b
2023-10-05 14:14:56 +08:00
Motomu Utsumi
aa2f4d839e Add PACKAGE_USAGE_STATS permission to ConnectivityServiceIntegrationTest
Bug: 303299687
Test: atest
Change-Id: Iad740804a59599dd33add1ea85aa4771e0e4bd35
2023-10-05 12:23:20 +09:00
Jean Chalard
ddd00cd23a Merge "Remove an NPE in tearDown" into main am: e7b7ceb70d
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/2770460

Change-Id: I017eafbc7dcf191cf6babcd3c43fa89a66546bbc
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-10-05 03:07:15 +00:00
Jean Chalard
e7b7ceb70d Merge "Remove an NPE in tearDown" into main 2023-10-05 02:44:59 +00:00
Maciej Żenczykowski
38cd577ed9 Merge "cts: fix android.net.cts.VpnServiceTest#testProtect_int flake" into main am: 99c8a5d1e2
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/2768572

Change-Id: I84417bfd7fcc5f86b86edf2c2640d60a2af45126
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-10-04 13:47:50 +00:00
Maciej Żenczykowski
99c8a5d1e2 Merge "cts: fix android.net.cts.VpnServiceTest#testProtect_int flake" into main 2023-10-04 13:10:54 +00:00
Junyu Lai
9272120c48 Adds more data points for benchmarking tests
To have better observation of overall improvement, more real
data points from the fields are needed.
This change adds more anonymous data points which are collected
from users who agreed to share the dataset for testing purpose.

Test: atest ConnectivityBenchmarkTests
Bug: 269409485
Change-Id: If7cb1cbb8215e4a4abcbf90c1fdcc141e19ecc44
2023-10-04 17:37:46 +08:00
Junyu Lai
56b03edede Move test zip file to assets
This is a no-op refactoring which move test data from resources
to assets, and repacking zip file to contain netstats sub-folder.

This is needed for later patches to put more test data points,
and having easier way to access them in batch.

Test: atest ConnectivityBenchmarkTests
Bug: 269409485
Change-Id: I1d09ac0187c9ce12982161243929d8e10483da45
2023-10-04 17:24:37 +08:00
Hansen Kurli
78b06ebe84 Make variables in testLegacyLockdownVpn() final.
Test: atest FrameworksNetTests
Change-Id: Ie852286275f0e377be582648f7766c077d9877e8
2023-10-04 16:50:05 +08:00
Hansen Kurli
b2764be9b6 Update testLegacyLockdownVpn to mock VPN.
Override more VPN methods to mock the VPN interaction of
testLegacyLockdownVpn instead of relying on the Vpn class.
This includes:
    1. Overriding startLegacyVpnPrivileged() and avoid creating
       a VpnRunner.
    2. Removing expectStartLegacyVpnRunner() since it is not
       used when startLegacyVpnPrivileged() is overridden.

Bug: 230548427
Test: atest FrameworksNetTests
Change-Id: Id55d8d6cd03b84bca815cd331eb0f7d584eaed5f
2023-10-04 16:47:10 +08:00
Hansen Kurli
acb5205558 Remove the fail case on IPv6 in testLockdownVpn
In testLegacyLockdownVpn, remove the fail check on IPv6 networks
and add coverage in VpnTest instead as this interaction relies
on the Vpn implementation, not ConnectivityService.

Bug: 230548427
Test: atest FrameworksNetTests
Change-Id: Ib24809ece2332c4c3d3e08c168e02ad859242eac
2023-10-04 16:45:45 +08:00
Hansen Kurli
35f6fef389 Remove LockdownVpnTracker from testLegacyLockdownVpn
The test coverage of LockdownVpnTracker has been moved to a
separate unit test file. testLegacyLockdownVpn now calls the Vpn
methods directly instead of creating a new LockdownVpnTracker.
Note this removes calls to expectStopVpnRunnerPrivileged since
stopVpnRunnerPrivileged is now directly called in the test so it
is already guaranteed to be called.

The expected calls/behavior of LockdownVpnTracker can be seen in
LockdownVpnTrackerTest.

Bug: 230548427
Test: atest FrameworksNetTests
Change-Id: Id9d26435bf62ffef954f6c7fa0558ce99540de1f
2023-10-04 16:44:09 +08:00
Motomu Utsumi
bbf74da2b5 Merge "Cleanup existing firewall rule on myUid before the test" into main am: 18520551db
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/2762791

Change-Id: I02664c27248091212dbfc094b2a8364fbfc2e7b8
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-10-04 02:44:40 +00:00
Motomu Utsumi
18520551db Merge "Cleanup existing firewall rule on myUid before the test" into main 2023-10-04 02:15:06 +00:00
Maciej Żenczykowski
ee20a09bdb cts: fix android.net.cts.VpnServiceTest#testProtect_int flake
This is written based on observation that
  testStartVpnProfileNoPreviousConsent()
appears to result in the right things happening when running
  adb logcat | egrep --color -i 'Switched from |protect'
ie. it results in:
  I netd    : networkSetProtectDeny(<ctsappuid>) <0.01ms>
  I Vpn     : Switched from android.net.cts to [Legacy VPN]
  I netd    : networkSetProtectAllow(1000) <0.00ms>

Which disallows the CTS uid, and allows AID_SYSTEM.

That in turn appears to be the 'default' state of things.

So this basically copies that logic into tearDown()

Test: atest android.net.cts.{Ikev2VpnTest,VpnServiceTest} --iterations 2
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: Ic9cca56097d78ae48157e808081de2ebb76635e8
2023-10-03 23:59:20 +00:00
Treehugger Robot
1032b1c039 Merge "Disable the remaining VPN CTS tests on watches." into main am: c8a42f6a39
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/2624254

Change-Id: I5999183d5d641ada0e1b477c2edcb73ee2c45d2f
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-10-03 17:46:04 +00:00
Treehugger Robot
c8a42f6a39 Merge "Disable the remaining VPN CTS tests on watches." into main 2023-10-03 16:39:31 +00:00
Jean Chalard
98f2f90a82 Merge "Prioritize non-slices over slices" into main am: d393732dba
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/2760328

Change-Id: Iba848062cefe19639fd104f03cd03d0dfddb634a
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-10-03 13:13:33 +00:00
Jean Chalard
d393732dba Merge "Prioritize non-slices over slices" into main 2023-10-03 12:39:11 +00:00
Chalard Jean
14499f0119 Prioritize non-slices over slices
For general internet access, a specialized slice is generally
not preferable to a non-specialized network.

Test: new test in this patch
Change-Id: I052ce923300566807999b2f20f5911181fb761dd
2023-10-03 21:30:49 +09:00
Chiachang Wang
1f47e6f2e6 Merge "Remove Ikev2VpnProfile related shims usage" into main am: 0509e0da16
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/2764585

Change-Id: I16a43aff0260fc52488cf18a75732def3cbb9e2b
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-10-03 08:16:09 +00:00
Chiachang Wang
0509e0da16 Merge "Remove Ikev2VpnProfile related shims usage" into main 2023-10-03 07:45:41 +00:00
Chalard Jean
ec0149f1ba Remove an NPE in tearDown
This is masking an exception in setUp() and makes debugging difficult

Test: treehugger
Change-Id: I8b5b80c4171d45076dd02bab5ff4b6dc81d98086
2023-10-03 16:01:00 +09:00
abdelrahmani
5bcbbc1ce9 Disable the remaining VPN CTS tests on watches.
- Watches don't support VPN apps.
- The HostsideVpnTests CTS tests are already skipped on watches.
- The tests for VpnManager VPNs do run on watches, but there isn't
  actually a way to start a VpnManager VPN on a watch because there is
  no way to display the consent dialog to the user.
- The VpnService CTS tests verify the VpnService API on watches
  bypassing the consent dialogs.
- Because there is no way to start a VPN app on a watch, there's no
  point requiring the VPN CTS tests to pass.

This CL disables the remaining VPN CTS tests on watches. This allows
watches to disable the VPN service, reducing startup time and memory
usage.

Bug: 286240194
Test: atest CtsNetTestCases FrameworksNetTests
Change-Id: Idb7110232ae7e45cafc265cd4f955c2a6b22361c
2023-10-02 06:29:46 +00:00
Maciej Żenczykowski
5d4d419b97 Lower CLAT max MTU from 65536 to 1528. am: 9f94648b7f
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/2677095

Change-Id: Ifb1bc76f95e8eef24ed12a65fdf0a8cd4b4d360c
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-09-30 19:58:41 +00:00
Maciej Żenczykowski
9f94648b7f Lower CLAT max MTU from 65536 to 1528.
Android's clat is for reaching the internet, which in general
never has an ipv4 L3 mtu higher than 1500.

(We could probably hit this on a jumboframe enabled IPv6-only
wifi network [ http://b/292057969#comment18 ] where RA claims
MTU of 9K [9170])

Bug: 292057969
Test: TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I7a32455571458b8a3f1121ad980d54323b2ef06b
2023-09-30 14:23:51 +00:00
Jean Chalard
af5fb4dfdc Merge changes I52fcfd3f,I6de4abdc,I1e8944de,I9525bfe0,Ife09fef8, ... into main am: 868859d4ef
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/2411144

Change-Id: I3be1739824cd0051db27a1c134de7f209bbf992b
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-09-30 05:10:20 +00:00
Treehugger Robot
abb723ab5e Merge "Remove debug only restrictions to network tracing" into main am: 06c8691fe0
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/2768925

Change-Id: I3a5de68794272cd076d8ab7f90b7c8659c2d2ab9
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-09-30 05:10:03 +00:00
Jean Chalard
868859d4ef Merge changes I52fcfd3f,I6de4abdc,I1e8944de,I9525bfe0,Ife09fef8, ... into main
* changes:
  Use carrier service changed callbacks when flag is on
  Delete slots as the listeners are unregistered.
  Have a full class (not inline) for privilege listener
  Update the carrier service UID when onCarrierServiceChanged
  Pass the modem count to registerCarrierPrivilegeListeners
  Reorder add/remove/register/unregister carrier listeners
2023-09-30 04:40:31 +00:00
Ryan Zuklie
9fb8f18c1b Remove debug only restrictions to network tracing
Network tracing was only available on userdebug and eng builds. This
change makes it available on all build types behind a flag.

Bug: 298197881
Test: flash & trace, toggle flag on/off
Change-Id: I75d854aee74adf7e23f7a970b20233790f9b0354
2023-09-29 16:52:11 -07:00