This is a no-op change since the config is not used yet, and
the feature flag will be gradually rolled out instead of enabled
by default.
However, this change is necessary for follow-up changes to enable
toggling the feature and configuring its behavior through device
configuration flags.
This change includes:
1. Disable the service-side cache flag if the client-side flag
is enabled.
2. Since the apps don't have enough permission to check the
feature flag from DeviceConfig. Provides a binder interface
for returning per-UID config,
which only returns cache enabled if the SDK level is V+
or the app's target SDK is V+.
Test: atest FrameworksNetTests:android.net.connectivity.android.net.TrafficStatsTest \
FrameworksNetTests:android.net.connectivity.com.android.server.net.NetworkStatsServiceTest \
CtsNetTestCases:android.net.cts.NetworkStatsBinderTest \
FrameworksNetIntegrationTests:com.android.server.net.integrationtests.NetworkStatsIntegrationTest
Bug: 343260158
Change-Id: Id9761e4aea65fabe6466c875b787e178317a1da2
The log should help investigate flakes, by knowing at which point
DeviceConfig is being reset and to which value.
Test: atest
Change-Id: Ia7392ad57d3df17b0d5194158b402f52bc90f7e3
Add a one line header of JSON info about the failure in failure
diagnostics reports.
This can then be automatically collected to calculate statistics about
particular failures, for example how often they happen when wifi is not
connected, not validated etc.
Test: atest
Change-Id: Ic4c99c53fc2686aaf2f1651522aa2f0d82d0cb86
Assumption failures are not actual failures, do not run connectivity
diagnostics for these.
Test: atest
Change-Id: I1d78eb6f12412e13cf4c29718ff8869ed089f491
Disable by default on local builds (which generally have "eng.username"
as their INCREMENTAL version), and add an option to allow disabling
manually on other builds as well.
Test: atest
Change-Id: I2d406a55ba0e3d57ed30e740b6c011124905b8d7
When CtsNetTestCases tests fail, or when a tryTest statement fails,
collect connectivity diagnostics and output them as a test artifact.
tryTest must be followed by cleanup blocks, which often change the
configuration, so having diagnostics when the tryTest fails in addition
to after the test failure is useful.
The collected diagnostics will be available as individual test
artifacts. They should make it easier to investigate test failures, and
could be collected across test runs in an automated way.
Output files are currently limited at 20 per run, to avoid collecting
too much data in case everything is failing in the run.
Test: atest
Change-Id: Iaa48e519028dc61c03d387beeade7d41fca2ef48
* Renamed TapPacketReader to PollPacketReader to better reflect its
functionality beyond TAP interface interaction.
* The class includes general logic for polling and sending packets to
file descriptors, making it suitable for wider use cases.
Test: TH
Change-Id: Icdf9a9d7ef6f49b589ed9cdbd05159ab95e7e5d9
Take the functionality from the (better) FakeDns in NetworkStack,
move it to the FakeDns in staticlibs, and port it to kotlin.
Test: test-only change
Change-Id: I6d0b4a348ca86ab69785cdf722c259ef6a92ce4b
Lorenzo Colitticommited 2024-09-19 12:51:28 +09:00
This is based on patchset 22 of aosp/2453209.
Bug: 240259333
Test: test-only code, will be covered by NetworkMonitorTest
Change-Id: Ibede3fb519e6f1d0c3d99886f553ee006ddfebc9
Lorenzo Colitticommited 2024-09-10 14:47:57 +09:00
This commit throws IllegalStateException instead of
IllegalArgumentException when inserting an existing item
to TestBpfMap to fit the current behavior in the
production code.
This is safe given that this is only for test and no one is
currently check the exception.
Test: atest TetheringTests:com.android.networkstack.tethering.BpfCoordinatorTest
Bug: 354619988
Change-Id: I1e5c6e99a0d95b44dd556de8805bb16c3d1a4f61
Instant mode does not have access to WifiManager
Test: atest MultinetworkApiTest --instant
Bug: 356644514
Change-Id: I310cd8a614006c391407829ada587d892a0ac3b4
It's not possible to directly create a mocked `NetworkStats`
instance because of limitations with `NetworkStats#getNextBucket`.
As a workaround for testing, create a mock by controlling the
return values from the mocked service that provides the
`NetworkStats` data.
Test: atest FrameworksServicesTests:com.android.server.stats.pull.netstats.NetworkStatsUtilsTest
Bug: 335680025
Change-Id: I4be8420de50040781557587fba4a50b9c0587f61
In the current design, NetworkStats.addEntry is used within a
loop to create a NetworkStats instance from entries. This results
in a large memory footprint because the addEntry() method clones
the original NetworkStats instance each time it is called.
This change utilizes the newly created API to add a list of
entries at once. This approach only clones the instance once,
thereby reducing the required memory footprint.
Test: atest NetworkStaticLibTests:com.android.net.moduletests.util.NetworkStatsUtilsTest#testPublicStatsToAndroidNetStats
Test: atest ConnectivityCoverageTests:android.net.connectivity.com.android.net.module.util.NetworkStatsUtilsTest
(on S device)
Test: atest ConnectivityCoverageTests:com.android.testutils.NetworkStatsUtilsTest
(on S device)
Bug: 335680025
Change-Id: I5c635613ed3ba34d840ee71b6bef21d10105df0d
This change enables comparison of android.net.NetworkStats
instances even when their interface name is null. This scenario
arises when deriving a android.net.NetworkStats instance
from an app.usage.NetworkStats, which lacks interface name
information. However, the original utility method relies on
NetworkStats.Entry#equals, which is incompatible with null
interface names on T- devices, because they do not run
mainlined NetworkStats.
This change refactor assertEntryEquals and makes
assertNetworkStatsEquals to use it to compare android.net.NetworkStats
instances.
Test: atest NetworkStaticLibTests
Test: atest ConnectivityCoverageTests:com.android.testutils.NetworkStatsUtilsTest
(on S device)
Test: atest ConnectivityCoverageTests:android.net.connectivity.com.android.net.module.util.NetworkStatsUtilsTest
(on S device)
Bug: 335680025
Change-Id: I25a685e4c2d4cf70132b2c4374b2bb8129c844cb
* changes:
Use AutoCloseTestInterfaceRule in NsdManagerDownstreamTetheringTest
Add auto close rule for test interfaces
Add finalizer to check whether destroy was called
Wrap use of test interface in EthernetTestInterface
Add a class to properly manage ethernet test interfaces
Patrick Rohrauthored and Gerrit Code Reviewcommited 2024-07-31 20:36:45 +00:00
DefaultNetworkRestoreMonitor sometimes fails since the CapabilitiesChanged callback is not called within the timeout.
This CL fixes the issue by increasing the timeout.
Bug: 356132243
Test: TH
Change-Id: Id36d9166538070933fd62a03c6dd18bc84053bd8
This rule proxies calls to TestNetworkManager, keeps track of all
interfaces created by it, and closes them after running the test.
Test: builds
Change-Id: I01810b54929fea6e9c929a49bbf5e5268c6793af
3 seconds were too short to wait the network validation.
This CL also updates error message to include more information that
helps investigation.
Test: TH
Bug: 354475907
Bug: 354475880
Bug: 354104252
Change-Id: I513a5bd8af44df47f18773f8fa49323986757e0d
Some tests reconnect wifi and don't wait wifi is validated.
So default network is changed while later tests are running.
This CL adds RestoreDefaultNetwork annotation to monitor default network
changes and wait to default network is restored to previous state.
If the default network is not restored within timeout, test fails.
Bug: 328870515
Test: atest MultinetworkApiTest NetworkAgentTest
Change-Id: I01e858109ac274ff60769bd558b91654298290ff
For tests that register multiple callbacks, like ConnectivityService
tests, this can make it easier to figure out which callback is getting
called in logs.
Test: atest CtsNetTestCases (tests using this callback)
Bug: 327038794
Bug: 279392981
Change-Id: Ifea5a8180f9667feaadf94c8b927469bafe29590
This is a no-op refactoring to move MdnsTestUtils to the
net-tests-utils library.
Bug: 343311941
Test: build pass
Change-Id: I009f421da47771cf4d4d3673db1a807e555ce86f
Currently, expect method only use the given error message
when predicate is not matched. In some cases, it could cause
some confusions where we might just want the tester to
ensure the data subscription is valid.
Make other fail cases use the error message if provided.
This would provide more clear error message for the callers
e.g. NetworkCallbackHelper#requestCell
Exmaple output:
java.lang.AssertionError: Cell network not available. Please
ensure the device has working mobile data. : Did not receive
Available after 30000ms.
Test: Manual
Bug: N/A
Change-Id: If00c84d622a69d9b7bab7b333da9d1449ba747c2
In current design, this class is risky because developers might
assume that it's safe to set real device flags with it. This is
unsafe because the class does not restore the previous value.
Test: atest ConnectivityCoverageTests:android.net.connectivity.com.android.server.net.NetworkStatsServiceTest
Fix: 339154394
Change-Id: I2a12e7892eaf66e7572928de39e00de3faf5fa60
* 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 Robotauthored and Gerrit Code Reviewcommited 2024-04-11 07:26:14 +00:00
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
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
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
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
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
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
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
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