Commit Graph

3807 Commits

Author SHA1 Message Date
Lorenzo Colitti
2606d9c862 Merge "Mock resources used directly by LockdownVpnTracker." 2022-02-22 01:59:20 +00:00
Lorenzo Colitti
19e6171926 Mock resources used directly by LockdownVpnTracker.
LockdownVpnTracker directly uses resources from
com.android.internal.R. This is acceptable because it's platform
code. But ConnectivityServiceTest uses the LockdownVpnTracker
built from the module source tree, and when that code fetches
resources on a previous Android release, it crashes because the
resource IDs don't exist; non-public resource IDs aren't stable.

Fix this by mocking the resources used by LockdownVpnTracker.

Test: atest ConnectivityCoverageTests
Change-Id: I239a18a38d4f1082f76f5ff1b831c15ee753bdfd
2022-02-22 10:13:24 +09:00
Patrick Rohr
c6cf669b8d Merge "CTS for ingress rate limiting" 2022-02-21 19:57:37 +00:00
Patrick Rohr
96c1ff4ae9 CTS for ingress rate limiting
This test creates a TUN interface and registers it with
ConnectivityService. For 15 seconds, it continuously writes data to that
interface and measures at what rate it is received.

Data accounting is currently not covered by this test.

Test: atest RateLimitTest
Bug: 172053704
Change-Id: I74f891f3b7113855375c48a10cefbfe47221931b
2022-02-21 18:05:21 +01:00
Maciej Żenczykowski
fc67ee8c71 Merge "Skip NetworkStatsServiceTest before T" 2022-02-19 20:20:24 +00:00
Maciej Żenczykowski
8bf31e8061 Merge "Add tests for deleteKernelTagData" 2022-02-19 20:20:24 +00:00
Lorenzo Colitti
dbb9280abc Merge "Don't check validation state in waitForAvailable(..., Network)." 2022-02-18 17:04:27 +00:00
Taras Antoshchuk
d42d1645cb Merge "Fix HostsideVpnTest#testExcludedRoutes" 2022-02-18 13:25:21 +00:00
Patrick Rohr
e3b067f523 Skip NetworkStatsServiceTest before T
NetworkStatsService was mainlined in T, so the test does not need to be
run on previous Android versions.

Test: atest CtsNetTestCases:NetworkStatsServiceTest
Change-Id: I8e69746a03ef029b1121cc8fa71e299ac12c2905
2022-02-18 09:18:20 +01:00
Maciej Żenczykowski
bce8cbabbb Merge "Support "dumpsys connectivity trafficcontroller"" 2022-02-17 23:10:10 +00:00
Remi NGUYEN VAN
3035f6c554 Merge "Cleanup and refine connectivity test config" 2022-02-17 09:45:39 +00:00
Lorenzo Colitti
d2bd9db36a Don't check validation state in waitForAvailable(..., Network).
The version of ConnectivityManagerTest#waitForAvailable that
takes a callback and a Network implicitly requires that the
network be validated, because it calls expectAvailableCallbacks
with validated=true.

This is incorrect because a network can become available without
being validated. In particular, testMobileDataPreferredUids is
flaky due to this problem, because it calls connectToCell, which
does not wait for validation, and then calls waitForAvailable,
which expects that the network is already validated.

Fix it by not requiring any particular validation state. This
method is only used by a few tests and they should not be
affected by this change:
- The first two calls in testSetOemNetworkPreferenceForTestPref
  happen after waiting for validation, so the network is
  validated already. The third call waits for a test network,
  and test networks are always validated.
- The first call in testSetOemNetworkPreferenceForTestOnlyPref
  waits for a test network, which is always validated. The
  second is incorrect because ensureWifiConnected does not
  wait for validation, and is fixed by this CL.
- The calls in testMobileDataPreferredUids similarly incorrectly
  assume that wifi is validated and are fixed by this CL.

Test: atest CtsNetTestCases:android.net.cts.ConnectivityManagerTest#testMobileDataPreferredUids
Change-Id: I614d0ba87c3931fcbe4011fed379e1736f5c4a44
2022-02-17 18:29:11 +09:00
Ken Chen
e6d511f785 Support "dumpsys connectivity trafficcontroller"
Enable ConnectivityService to dump BPF maps from libtraffic_controller.

Bug: 202086915
Test: adb shell dumpsys connectivity trafficcontroller
Test: atest CtsNetTestCases:ConnectivityManagerTest#testDumpBpfNetMaps
Test: run CTS in I021789813f116940d581e2c4a1fd357ff47bfa08
Change-Id: Ib0e935ee2b714ac61daceba6d13fa7a20f97f68f
2022-02-17 16:58:47 +08:00
Treehugger Robot
5a2f079722 Merge "DscpPolicyTest Check Kernel Version" 2022-02-17 07:15:11 +00:00
James Mattis
700774f34e Merge "CTS tests for EthernetNetworkSpecifier" 2022-02-17 03:10:36 +00:00
James Mattis
deaeefb283 CTS tests for EthernetNetworkSpecifier
Bug: 210485380
Test: atest CtsNetTestCasesLatestSdk
:android.net.cts.EthernetNetworkSpecifierTest

Change-Id: I080bc111aa57c7889a6bf9564b8fc2c1dddd944d
2022-02-16 16:46:49 -08:00
Patrick Rohr
3226bfb631 Merge "Fix NetworkStatsServiceTest after adding deleteKernelTagData" 2022-02-16 19:59:14 +00:00
Remi NGUYEN VAN
73da478927 Cleanup and refine connectivity test config
Remove the include for Connectivity/Tethering TEST_MAPPING as there is
no such file in that directory, add comments on ConnectivityModuleTest
usage, and skip the whole NetworkAgentTest on non-connectivity module
MTS runs.

Bug: 218611855
Test: atest CtsNetTestCasesLatestSdk
Change-Id: Id96ab8a5ae631b0c64f20faedd4a0430eb9318d4
2022-02-16 20:34:31 +09:00
Maciej Żenczykowski
7d30b56f06 Merge "Skip BpfExistenceTest#TestPrograms on BPF unsupported device" 2022-02-16 11:22:47 +00:00
Hungming Chen
0456900bf2 Skip BpfExistenceTest#TestPrograms on BPF unsupported device
BPF is supported after kernel 4.9. Skip the test on BPF
unsupported device. Ex: walleye.

Bug: 219696135
Test: atest bpf_existence_test on walleye
Change-Id: I583a858587c0501582c9e77c8b584b3136312cd5
2022-02-16 16:06:59 +08:00
Patrick Rohr
f9888898e3 Add tests for deleteKernelTagData
Test: atest NetworkStatsServiceTest
Change-Id: I6db6b79314868271f877acf2a0b21699cbf02df5
2022-02-16 14:23:30 +08:00
Remi NGUYEN VAN
3b81323e4a Fix testing with/without connectivity module
Add missing @ConnectivityModuleTest annotations to tests that cover
functionalities that were introduced in a newer connectivity module
update.

Also add CtsNetTestCasesLatestSdk to postsubmit with only APK modules
installed, and with only the connectivity/tethering module installed.
This can then be moved to presubmit to catch such issues before they are
merged.

While doing this cleanup the TEST_MAPPING file in tests/ and merge its
contents into the root TEST_MAPPING file. This does not change anything
for "postsubmit" tests as they are run independently of changes. It only
causes FrameworksNetIntegrationTests to run in presubmit on any change
in modules/Connectivity/ instead of only on modules/Connectivity/tests/
changes, which is how it should be.

Bug: 218611855
Test: TH needs to test TEST_MAPPING
Change-Id: I26629a35d8c2df3db33180ecc22d49d538ad3b8b
2022-02-16 15:22:30 +09:00
Patrick Rohr
7c52b69b3e Fix NetworkStatsServiceTest after adding deleteKernelTagData
Test: atest NetworkStatsServiceTest
Change-Id: I667a5d86e0df8505fef549e598f3b4141637fb90
2022-02-16 14:01:29 +08:00
Tyler Wear
c2926f45f2 DscpPolicyTest Check Kernel Version
Check kernel version to ensure current kernel supports
BPF logic for testcase.

Bug: 217209172
Test: atest DscpPolicyTest
Change-Id: I9e0df7d2e4eb320bd5324e2d13410bd960b75174
2022-02-16 04:53:19 +00:00
Taras Antoshchuk
0817bb2906 Fix HostsideVpnTest#testExcludedRoutes
One of VpnTest#startVpn overloads didn't propagate "excludedRoutes"
param, due to mistake during conflict resolution in aosp/1941233.

Bug: 214398350
Test: atest HostsideVpnTests --iterations
Change-Id: Icbbe7394f1ff1f676cc671a1fa1c4449f4d585e3
2022-02-15 09:14:03 +00:00
Remi NGUYEN VAN
106569b856 Merge "Allow test+other networks to have specifiers" 2022-02-14 05:31:20 +00:00
Jean Chalard
d537aa42e1 Merge "Add new methods to redact NetworkCapabilities & LinkProperties" 2022-02-12 11:56:36 +00:00
lucaslin
c582d50b8e Add new methods to redact NetworkCapabilities & LinkProperties
Some system components like VPN need to know how to redact
NetworkCapabilities & LinkProperties that they received from
the system but need to send to third-party applications with
less privilege than themselves. To make sure the redaction is
consistent, expose system API methods to do it that are wired
to the same redaction code used by ConnectivityService.

Bug: 191413541
Test: atest CtsNetTestCases, which includes new CTS for these
Change-Id: Ia3ae4755b5192884c147d6828f96cedac000a25b
2022-02-12 15:21:13 +09:00
Treehugger Robot
5be94579d4 Merge "Refer to SDK constant defined in DevSdkIgnoreRule" 2022-02-11 09:23:02 +00:00
Chiachang Wang
137bbed860 Refer to SDK constant defined in DevSdkIgnoreRule
Refer to the same constant definition as other tests instead of
hard coding locally, so that it won't be missed as changing to
Build.VERSION_CODES.SC_V2.

Bug: 184750836
Test: atest FrameworksNetTests
Change-Id: I3c17c414d830af03e2719c5dab1a664c55f6df2a
2022-02-11 07:40:58 +00:00
Treehugger Robot
0fc2ec6d68 Merge "remove unneeded inclusions of libbpf_android" 2022-02-10 19:50:34 +00:00
Robert Horvath
3a33495992 Merge "Add Low Power Standby test to NetworkManagementServiceTest" 2022-02-10 11:17:44 +00:00
Maciej Żenczykowski
11ab996252 remove unneeded inclusions of libbpf_android
Test: TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I6aedf507e09effd9076de85a0acc7aaf1b8e4a1e
2022-02-09 22:10:22 -08:00
Chiachang Wang
84ad04f768 Merge "Change naming of excludeLocalRoutes" 2022-02-10 00:50:30 +00:00
Patrick Rohr
6b5b7b40d8 Merge changes from topic "bandwidth-limiting"
* changes:
  Add bandwidth limiting to CS
  Add setting that controls network rate limit
2022-02-09 18:00:04 +00:00
Jean Chalard
ec05b337aa Merge "Pass the NetworkAgentConfig to NetworkMonitor." 2022-02-09 16:55:59 +00:00
Patrick Rohr
2857ac4dd0 Add bandwidth limiting to CS
Adds ingress rate limiting functionality to ConnectivityService. The tc
rate limit is installed before we tell netd about the interface, and
removed after the network is removed from netd. When the setting
changes, the old rate limit needs to be removed before a new one can be
added (unfortunately, we cannot use NLM_F_REPLACE when configuring the
tc-police filter).

Currently, this functionality is always enabled, but may or may not work
based on kernel support.

Bug: 157552970
Test: atest FrameworksNetTests:ConnectivityServiceTest
Change-Id: I4e64b2c40490f061e42b40a1b1b3a6618c3d1a87
2022-02-09 14:46:26 +01:00
Patrick Rohr
a20843638f Add setting that controls network rate limit
The INGRESS_RATE_LIMIT_BYTES_PER_SECOND setting controls the rate limit
for internet networks. If set to -1, no rate limit applies.  There is
one global rate limit that will be applied to all networks with
NET_CAPABILITY_INTERNET.

Test: atest ConnectivitySettingsManagerTest
Bug: 157552970
Change-Id: Ia82aa867686d484ce46734f76d4a48bf864eff84
2022-02-09 14:46:26 +01:00
Treehugger Robot
0ad3becd60 Merge changes from topic "split-pre-jarjar"
* changes:
  Enable framework-connectivity-t-pre-jarjar for service-t
  Split out connectivity-t-pre-jarjar and tests
2022-02-09 12:54:46 +00:00
Remi NGUYEN VAN
2ba9dbe163 Split out connectivity-t-pre-jarjar and tests
The pre-jarjar variant is necessary so that service-t can depend on
hidden symbols in framework-t that reference (for example as parameter)
classes that are jarjared.
Without this, when depending on framework-connectivity-tiramisu.impl,
service-connectivity-t would see post-jarjar symbols that do not match
the classnames it uses in its code.

Also split FrameworksNetTestsLib so that the same jarjar rules can be
applied between the tests and the module, avoiding different errors
between FrameworksNetTests and ConnectivityCoverageTests.

Ignore-AOSP-First: Avoiding conflicts; cherry-pick will follow
Bug: 204830222
Test: m
Change-Id: I3d0c081c4a7422e128beee11c0156f01b0377c96
Merged-In: I3d0c081c4a7422e128beee11c0156f01b0377c96
2022-02-09 18:29:30 +08:00
Chiachang Wang
f890874970 Change naming of excludeLocalRoutes
Address API review feedback to change naming of
setExcludedLocalRoutesVpn and getter.

Bug: 217742354
Test: atest FrameworksNetTests
Change-Id: I57bbf55c7aba1c86ec8687d2431a50b37e63c6d0
2022-02-09 15:50:06 +08:00
Chalard Jean
d490072cd6 Pass the NetworkAgentConfig to NetworkMonitor.
When the network is a VPN, NetworkMonitor needs to know whether
the VPN requests validation, and that information is stored in
NetworkAgentConfig. Pass it.

Test: FrameworksNetTests
Change-Id: I3616f0796b69ce054d92213aafdef43ba7041596
2022-02-09 15:19:38 +09:00
Jean Chalard
4b66d4e244 Merge "Add and implement API for VpnManagers to request validation" 2022-02-09 06:03:45 +00:00
Michael Groover
0762151207 Merge "Marking test receiver as exported." 2022-02-09 05:38:41 +00:00
Chiachang Wang
865511a8c4 Add and implement API for VpnManagers to request validation
This adds a new API that lets VPN apps using VpnManager request
that the platform run its basic validation check on the resulting
network.

Bug: 184750836
Test: atest FrameworksNetTests
Change-Id: I00092eee857d3e33529b19461cfd5dd060a0fe20
2022-02-08 22:47:26 +09:00
Jacob Hobbie
4c06b3885d Marking test receiver as exported.
In order to follow the new dynamic receiver paradigm introduced in T, receivers will have to be specifically marked as exported or not exported when registering dynamically. Since this is in a test only, and the test says that it needs the broadcast to be in a different process, mark as exported.

Bug: 161145287
Change-Id: I112d56962e3a6c3043240f8dfab058dc5a728ba9
Test: atest HostsideRestrictBackgroundNetworkTests#testAppIdle_toast
2022-02-07 15:40:49 -08:00
Etan Cohen
1e86b3af26 Expose public APIs for IP & static IP configuration
Create public API for IP and static IP configuration.

Bug: 209840828
Test: atest android.net.cts.IpConfigurationTest
Test: atest android.net.cts.StaticIpConfigurationTest
Test: atest android.net.dhcp.DhcpResultsParcelableUtilTest
Change-Id: I720f168d1023806970919ca5dd44239a276826b6
2022-02-07 19:57:07 +00:00
Rambo Wang
e7036bec68 Merge "Reduce the flakiness of carrier privileges check" 2022-02-07 03:47:52 +00:00
Jean Chalard
d262e71965 Merge "Use RECEIVER_NOT_EXPORTED in CarrierPrivilegeAuthenticator." 2022-02-04 16:40:30 +00:00
Rambo Wang
4d64bd6b2a Reduce the flakiness of carrier privileges check
Monitoring carrier config change broadcast and then checking
carrier privileges status is racy. The component that updates CP
status (e.g. CarrierPrivilegeTracker) may monitor the same
broadcast and the status check result will be determined by the
fact who received it firstly.

This CL moves the CP check after the current sleep to reduce
the flakiness to unblock the CP migration. The follow CL
(aosp/1971439) will throughly resolve the flakiness by the
the help of CarrierPrivilegesListener.

Bug: 217557996
Test: atest android.net.cts.ConnectivityDiagnosticsManagerTest
Change-Id: Ib1ab554732b6bb25426a07a42043801a2d05c546
2022-02-04 07:55:45 -08:00