Commit Graph

43895 Commits

Author SHA1 Message Date
Patrick Rohr
3409b2ef6f Improve error reporting in RateLimitTest
This change moves the logic to read /proc/config.gz from the static
initializer to a function that runs the first time setUp is called. This
improves error reporting as exceptions thrown inside
ensureKernelConfigLoaded get reported as test failures.

Test: atest RateLimitTest
Change-Id: I3b7913c567507dec8ecad26602cfccdad3d6f4bd
2022-02-28 14:59:03 +01:00
Patrick Rohr
efa4039d01 Add null checks to RateLimitTest#tearDown improves error reporting
An NullPointerException in tearDown is a symptom of an initialization
error and should not be reported in the test failure result.

Test: atest RateLimitTest
Change-Id: I9c1d6294678cdc9cdf4beae597f8373b92b52077
2022-02-28 14:59:03 +01:00
Patrick Rohr
9fa0b3bf18 Move assumptions out of BeforeClass annotated method
Assumptions that are placed in BeforeClass annotated methods are not
reported correctly. See b/203722419 for more information.

Test: atest RateLimitTest
Bug: 220801455
Change-Id: Ia7f0eaddc75d0ee091e107615f1677c75865dbcb
2022-02-23 10:53:20 +01:00
Patrick Rohr
2140575fce Add proper kernel support assumption to RateLimitTest
As it turns out, /proc/config.gz can be accessed via shell command from
within a CTS test. This adds a proper kernel support check for the
RateLimitTest.

Bug: 220801455
Test: atest RateLimitTest
Change-Id: I4d3a6848c1c05c313cb74b235294cee982eecf57
2022-02-22 15:55:30 +01:00
Treehugger Robot
d6a5303cd8 Merge changes Ie68356a4,I2b63c24b
* changes:
  Attempt to deflake NetworkAgentTest#testRejectedUpdates.
  Fix a couple of JavaDoc errors in NetworkAgentInfo.
2022-02-22 10:41:37 +00:00
Treehugger Robot
1c5ce5542a Merge changes Ib1cd342a,Iab23d414
* changes:
  Add an IS_DESTROYED flag to FullScore.
  Use MessageUtils instead of hardcoded strings in policyNameOf.
2022-02-22 09:26:38 +00:00
Lorenzo Colitti
16040b1833 Merge "Mock more resources for VPNs." 2022-02-22 09:10:42 +00:00
Lorenzo Colitti
e3ef5a8024 Attempt to deflake NetworkAgentTest#testRejectedUpdates.
This test is highly flaky in presubmit with error messages that
look like:

java.lang.AssertionError: Did not receive callback after 200ms

The test itself looks correct, so it's possible that 200ms just
isn't enough time for the callbacks to be delivered. Set the
timeout to DEFAULT_TIMEOUT_MS like most of the other
TestableNetworkCallbacks in this class.

Fix: 218389790
Test: test-only change
Change-Id: Ie68356a48e9618e5fea3865aa06bfbfc457b89c4
2022-02-22 18:04:31 +09:00
Treehugger Robot
fa017ea2e4 Merge "Remove redundant "using" statement" 2022-02-22 08:23:24 +00:00
Lorenzo Colitti
8c7a8860f9 Add an IS_DESTROYED flag to FullScore.
This is being added as the lowest priority score factor, just
above the tie-breakers. It ensures that a network that has been
destroyed will lose to another identical network that has not
been destroyed, but will otherwise be scored identically.

The flag is a CS-managed flag that is stored in NetworkAgentInfo.
Currently it is always false, but it will be populated in
future CLs.

Bug: 216567577
Test: atest FrameworksNetTests
Change-Id: Ib1cd342ab7dfc4df45715da19b743d711fe8d605
2022-02-22 16:39:44 +09:00
Lorenzo Colitti
38bbdbd1aa Fix a couple of JavaDoc errors in NetworkAgentInfo.
These don't break compilation because NetworkAgentInfo doesn't
expose any APIs and thus doesn't generate javadoc, but they
are flagged by the IDE.

Test: treehugger
Change-Id: I2b63c24b2afbc98950f53c38f80d27474aab0622
2022-02-22 16:39:44 +09:00
Yi Kong
38c4cd90db Remove redundant "using" statement
Test: presubmit
Bug: 219872355
Change-Id: Ie4fc87e5231e31799644c26943bbc13000091e92
2022-02-22 13:37:51 +08:00
markchien
95cb089853 Fix EthernetTetheringTest testTestNetworkUpstream flaky
The test assume the first tethering upstream would be test network. But
if there are mutiple networks available, this is a wrong assumption
because of race condtion. If tethering choose upstream while wifi or
celluar is available but test network may not available for tethering yet
(it depend on the NetworkCallback from ConnenectivityService), the first
upstream may not be the test network.

Bug: 215224286

Test: atest EthernetTetheringTest
Change-Id: Idfa972008643f1fb5119179383b06e2c8f65c667
2022-02-22 12:42:15 +08:00
Lorenzo Colitti
2606d9c862 Merge "Mock resources used directly by LockdownVpnTracker." 2022-02-22 01:59:20 +00:00
Lorenzo Colitti
93a72d22a5 Mock more resources for VPNs.
These also cause ConnectivityCoverageTests to fail when built
from master and run on S. They are used in Vpn.java, not
LockdownVpnTracker.

They were not addressed in the previous CL because running this
test locally is difficult.

Test: forrest
Change-Id: I7d687338fd6bc7468b1abcae58898322554e647b
2022-02-22 10:17:09 +09: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
Lorenzo Colitti
85c1765b01 Remove out-of-date comment.
Test: m
Change-Id: I1575c85c382b4fb9e9e3c04b5e70dab55cef4c60
2022-02-21 12:50:11 +09:00
Lorenzo Colitti
b81abf3abe Merge "Run bpf_existence_test in presubmit." 2022-02-21 03:45:33 +00:00
Treehugger Robot
4b654c9038 Merge "Rename one of the two EVENT_NETWORK_TESTED messages." 2022-02-21 00:22:11 +00:00
Treehugger Robot
19ce06b05f Merge "reduce log level when no interface is present for rate limiting" 2022-02-19 21:31:05 +00: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
c6d3f3cf25 Use MessageUtils instead of hardcoded strings in policyNameOf.
This makes the code easier to maintain because we do not need to
manually add string representations, and because it will throw at
static initialization time if the clas contains duplicate
POLICY_xxx values. The memory overhead is likely negligible.

Bug: 216567577
Test: new coverage in FullScoreTest
Change-Id: Iab23d414c8e28ff7f26060ad44fa996f277d361f
2022-02-19 19:45:43 +09:00
Lorenzo Colitti
0261ced634 Rename one of the two EVENT_NETWORK_TESTED messages.
Currently, there are two EVENT_NETWORK_TESTED message types in
ConnectivityService. One is used by the ConnectivityService
handler to process validation results, and one is used by
ConnectivityDiagnosticsHandler to send connectivity reports.

The two messages have different contents so it is confusing that
they have the same integer and the same name. Rename the second
one to CMD_SEND_CONNECTIVITY_REPORT.

Test: atest ConnectivityServiceTest
Test: atest CtsNetTestCases:android.net.cts.ConnectivityDiagnosticsManagerTest
Change-Id: I77d63dad477315e1fcc7225a5ef03aff2bed8c35
2022-02-19 02:24:02 +09: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
Lorenzo Colitti
98c83d0148 Run bpf_existence_test in presubmit.
This has been green for a while. On S:

https://android-build.googleplex.com/builds/tests/view?invocationId=I42200010019333308&testResultId=TR79227903031586436

On R:
https://android-build.googleplex.com/builds/tests/view?invocationId=I28900010019347533&testResultId=TR73127903058200457

Test: treehugger
Change-Id: Iece7be238e069c7a71f150893a0f6cc155e7b09b
2022-02-18 17:35:04 +09:00
Patrick Rohr
a517f20ef0 reduce log level when no interface is present for rate limiting
TestNetworkAgentWrapper does not set the interface name in its
LinkProperties causing logwtf to fail tests on -eng build.

Test: atest FrameworksNetTests:ConnectivityServiceTest on -eng build
Change-Id: Ieba0453ce897aa1052cb98f1de4c7bb099383c8d
2022-02-18 09:18:20 +01: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
Wayne Ma
5545291ef5 Address comment from aosp/1948169
Bug: 202086915
Test: m; flash; boot;
Change-Id: I9bd627cc4ec77e1ab6da3e3acc7d4d8bba7d43de
2022-02-18 14:18:06 +08:00
Maciej Żenczykowski
b194d551bf Merge "BpfBitmap Test" 2022-02-18 01:55:43 +00:00
Maciej Żenczykowski
bce8cbabbb Merge "Support "dumpsys connectivity trafficcontroller"" 2022-02-17 23:10:10 +00:00
Maciej Żenczykowski
83acb39c6c Merge "libclat: Remove redundant "using android::net::.*"" 2022-02-17 22:59:44 +00:00
Maciej Żenczykowski
c301b4412b Merge changes Iddd50583,I7e6e84ba,If5ade0c0
* changes:
  Improve logging when using ingress rate limits
  Allow test networks to be rate limited
  Fix rate limiting settings observer
2022-02-17 22:14:04 +00:00
Patrick Rohr
64592df482 Improve logging when using ingress rate limits
Add some happy path logging that informs about active rate limits.

Test: TreeHugger
Bug: 218840346
Change-Id: Iddd50583ca2e90afe83a5c68611418fa794afb3f
2022-02-17 18:28:58 +01:00
Patrick Rohr
ff3b3f8d96 Allow test networks to be rate limited
Test: atest FrameworksNetTests
Change-Id: I7e6e84baf446ecf4b395f6a611e625871745a20e
2022-02-17 18:28:58 +01:00
Patrick Rohr
cdac749eb0 Fix rate limiting settings observer
The obvserver accidentally observed Settings.Secure instad of
Settings.Global.

Test: atest CtsNetTestCases:RateLimitTest
Bug: 218840346
Change-Id: If5ade0c0e269c01b76428d5635d0913330d7015e
2022-02-17 18:28:58 +01:00
Treehugger Robot
e7eb8b156f Merge "Ensure all NetworkMonitor messages store the netId in arg2." 2022-02-17 17:26:19 +00:00
Yi Kong
9de79582a2 libclat: Remove redundant "using android::net::.*"
They are already under the same namespace.

Test: presubmit
Bug: 219872355
Change-Id: I5f51cf2c38755c99f220870c2ffe66ee8c454514
2022-02-17 16:36:13 +00:00
Lorenzo Colitti
d1b11dc70f Ensure all NetworkMonitor messages store the netId in arg2.
All NetworkMonitor messages contain the netId of the source
NetworkMonitor. But the netId is in various places in the
message. It's most frequently in arg2, but sometimes it's boxed
into an Integer in obj, and sometimes it's in another object.

Always pass the netId into arg2. This allows us to write
common code at the beginning of the function that extracts the
netId and nai, and performs common actions on all messages.

Bug: 216567577
Test: atest FrameworksNetTests FrameworksNetIntegrationTests
Test: atest CtsNetTestCases:ConnectivityManageTest
Test: atest CtsNetTestCases:NetworkAgentTest
Change-Id: Idbbe3cddfc5475a2d56df387f840439dc4c9514c
2022-02-18 00:28:01 +09: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
Nucca Chen
dc62c75b1e Merge "Add test for IPv4 UDP forwarding rules in BPF map" 2022-02-17 02:59:07 +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