Commit Graph

801 Commits

Author SHA1 Message Date
Remi NGUYEN VAN
6dfe6412a2 Skip testTemporarilyNotMeteredCapability on Q
The capability did not exist on Q.

Bug: 155993662
Test: atest NetworkRequestTest
Change-Id: I94e874e37cadadd90397278bf519db68db48a50f
2020-05-25 19:21:21 +09:00
Remi NGUYEN VAN
aa660b56cf Use Q permission on Q for startCaptivePortalApp
on Q startCaptivePortalApp was guarded by CONNECTIVITY_INTERNAL instead
of NETWORK_SETTINGS: change the permission adopted by shell on Q to
match the platform.

Test: atest CaptivePortalTest on a Q device
Bug: 150904735

Change-Id: I24b6907d164aba07df0f5a1a3715669e99cddd88
2020-05-25 19:15:53 +09:00
Remi NGUYEN VAN
2f5879f6c7 Fix and deflake ConnectivityManagerTest
- Migrate the test to JUnit4, as JUnit3 cannot use assumeTrue
 - Skip IPv4 keepalive tests on networks that do not have native IPv4.
 - Refactor usage of adoptShellPermissionIdentity to use try / finally
   or runAsShellPermissionIdentity: test failures could lead to
   permission failures in other tests due to mismatched adopt/drop.
 - Fix ensureWifiConnected to support the "wifi enabled but not fully
   connected" case.

Bug: 150949391
Test: atest CtsNetTestCasesLatestSdk:ConnectivityManagerTest \
      --rerun-until-failure 50
Change-Id: I7459753b1068e1760a95337760db58d1df213fad
2020-05-25 19:15:39 +09:00
Remi NGUYEN VAN
c7cd60d9d4 Merge "Add a cts test for PermissionMonitor security problem" 2020-05-25 09:21:39 +00:00
Luke Huang
d6e36d820e Deflaky test for DnsResolverTest
It's possible that private DNS setting is not in the state we expected
when we tried to enable strict mode during tests. The problem here is
that there are 2 setting Uris(mode and specifier) relating to strict
mode, each of them might trigger private DNS setting changing evnet in
ConnectivityService.
Previously, we tried to enable strict mode with first set private DNS
mode and then private DNS specifier. This may result in 2 consecutive
private DNS changes events with very short intervals, which caused
conflicts between DnsResolver / NetworkMonitor and lead to flaky tests.

So
0. Use opportunistic as default mode if no default mode existed.
1. Change the order (mode and specifier) for enabling strict mode.
2. Change private DNS mode only when needed.
     (If original mode is "hostname", then we only need to set
     specifier)

Bug: 153624005
Bug: 151122313
Bug: 150952393
Test: atest DnsResolverTest --rerun-until-failure 100
Test: forrest (git_master, cts/networking/gce-all)
Test: forrest (git_rvc-dev, atest CtsNetTestCases)
Test: forrest (git_rvc-dev, mts/dnsresolver/device-all)
Change-Id: I224a6493c87cebaf0bf954c2644e2945ccd50db1
2020-05-21 16:04:49 +08:00
Sarah Chin
ae36797b69 Add cts for TEMPORARILY_NOT_METERED
Bug: 155993662
Test: atest NetworkRequestTest
Change-Id: I6838dff70e6608f166119b99750db3bc59c59e42
Merged-In: I6838dff70e6608f166119b99750db3bc59c59e42
2020-05-20 17:27:55 -07:00
Luke Huang
dfa5480414 Revert "Fix flaky test for DnsResolverTest"
This reverts commit fb735de0e8.

Reason for revert: This CL made whole test failed.

Bug: 153624005
Bug: 150952393
Bug: 151122313
Change-Id: I083529616dbf80421ea6a322bb57d2bb0f2bca62
2020-05-19 01:18:49 +00:00
Luke Huang
fb735de0e8 Fix flaky test for DnsResolverTest
It's possible that private DNS setting is not in the state we expected
when we tried to enable strict mode during tests. The problem here is
that there are 2 setting Uris(mode and specifier) relating to strict
mode, each of them might trigger private DNS setting changing evnet in
ConnectivityService.
Previously, we tried to enable strict mode with first set private DNS
mode and then private DNS specifier. This may result in 2 consecutive
private DNS changes events with very short intervals, which caused
conflicts between DnsResolver / NetworkMonitor and lead to flaky tests.

So
1. Change the order (mode and specifier) for enabling strict mode.
2. Change private DNS mode only when needed.
     (If original mode is "hostname", then we only need to set
     specifier)

Bug: 153624005
Bug: 153624702
Test: atest DnsResolverTest --rerun-until-failure 100
Change-Id: Iaed6285677f74a5ee6cc6684534ddc0758b25974
2020-05-15 23:39:19 +08:00
Chiachang Wang
8ddd0227a9 Move testInvariantInCanBeSatisfiedBy to be its own test
Bug: 154451660
Test: atest CtsNetTestCasesLatestSdk:android.net.cts.NetworkRequestTest
Change-Id: Id65b7189202108b232905535587f8a282e48007b
2020-05-12 09:39:16 +08:00
Chiachang Wang
a495965c67 Use local defined NetworkSpecifier to verify test
Test will be affected by logic modification from different
NetworkSpecifiers. Since this test tries to test the behavior
of NetworkRequest but not NetworkSpecifier, use local defined
NetworkSpecifier to test to prevent repeating noisy breaks.
Also update test for testing invariant.

Bug: 154451660
Test: atest CtsNetTestCasesLatestSdk:android.net.cts.NetworkRequestTest
Change-Id: I7e357c75a68244432231d59646ddf67c8d969c6d
2020-05-11 20:24:47 +08:00
Remi NGUYEN VAN
412c8a9f53 Merge "Add test for internet availability on portals" 2020-04-28 05:49:08 +00:00
Remi NGUYEN VAN
ecb661016f Add test for internet availability on portals
Add a test verifying that when the device has detected a captive portal,
or when the user is trying to login to a captive portal, the captive
portal network does not become the default network if another network
can provide internet access.
This follows R CDD requirements.

Test: atest CtsNetTestCases:android.net.cts.CaptivePortalTest
Bug: 152280218
Change-Id: I6a97ed26dba665efdc67abb2371e0fc30ede020c
2020-04-27 22:47:10 +09:00
Chiachang Wang
6f63ef0e47 Update logic for checking NetworkSpecifier
We cannot test using WifiNetworkSpecifier, because the matching
behaviour for null WifiNetworkSpecifier changed between Q and R.
Replace WifiNetworkSpecifier with MatchAllNetworkSpecifier and
TelephonyNetworkSpecifier that behave the same in both Q and R
to verify.

Bug: 154451660
Test: atest CtsNetTestCasesLatestSdk:android.net.cts.NetworkRequestTest
      on aosp and internal build
Change-Id: I14e2a5e629051e243f3b892b608cb1c6195cd8ed
2020-04-22 22:18:50 +08:00
Chiachang Wang
6aac2067f6 Check target transport type for meterness change
When test case updates the wifi network from unmetered to
metered, test case will wait for wifi network reconnect.
However, if other metered networks are also connected at
the same time, test case may mis-take the network as the
target network. Thus, add transport type check to ensure
the transport type of the network is the expected one.

Bug: 153400606
Test: atest CtsNetTestCasesLatestSdk:\
      android.net.cts.ConnectivityManagerTest#\
      testGetMultipathPreference
Change-Id: I75dab1a00bbe1a1c75b548a6ce4ae3eacd325d92
2020-04-22 05:51:39 +00:00
Remi NGUYEN VAN
8b5e3031fa Merge "Fix test initialization errors on Q" 2020-04-21 12:07:03 +00:00
Remi NGUYEN VAN
a7f8f2d01c Fix test initialization errors on Q
ConnectivityDiagnosticsManagerTest, MultinetworkApiTest,
NetworkAgentTest crashed before the runner could start them:
 - Ignore ConnectivityDiagnosticsManagerTest on Q: it tests an API that
   was introduced in R.
 - Build JNI libraries used by MultinetworkApiTest against the NDK to
   avoid errors loading the libraries on older platforms, when
   transitive dependencies have been added.
 - Do not attempt to override Handler#getLooper() (which is final) in
   NetworkAgentTest; it appears to have been overridden by accident by
   specifying "val looper" in the TestableNetworkAgent definition, which
   generates a getter.

Test: atest CtsNetTestCasesLatestSdk:ConnectivityDiagnosticsManagerTest
      atest CtsNetTestCasesLatestSdk:MultinetworkApiTest
      atest CtsNetTestCasesLatestSdk:NetworkAgentTest
Bug: 150918852
Change-Id: I262b54c6897ed755adaeb2b118c638320634f7a1
2020-04-21 15:16:44 +09:00
Junyu Lai
9eba1b2c1b Merge "Remove upper bound check of getTotal* APIs in TrafficStatsTest" 2020-04-21 03:07:58 +00:00
Chiachang Wang
db0b1c13e5 Merge "Update network object when wifi meterness is changed" 2020-04-20 13:35:54 +00:00
junyulai
5cfd8d6bb1 Remove upper bound check of getTotal* APIs in TrafficStatsTest
Currently, this cause flakiness since some background traffic
was counted when performing tests, or the traffic generated by
adb over network. While there is no good way to filter out all
reasonable cases, disable the upper bound checks.

Test: atest TrafficStatsTest
Bug: 142978584
Change-Id: I8140310c9caeff6069d1f55590bf40f83bf211e4
2020-04-20 15:44:32 +08:00
Chiachang Wang
21ec1de1ff Update network object when wifi meterness is changed
The new wifi disconnect behavior is introduced. When wifi
network is changed from unmetered to metered, the wifi
network will disconnect and reconnect. Update the test to
verify the same SSID wifi is connected and also update the
target network to verfiy the metered preference.

Bug: 153400606
Test: atest CtsNetTestCases:android.net.cts.ConnectivityManagerTest\
      #testGetMultipathPreference
Change-Id: Ic298d3d85d8c6b77c8df7614a945f2c22dcdff38
2020-04-20 09:50:17 +08:00
Aaron Huang
12b24407cf Merge "Move DhcpInfoTest to FrameworksNetCommonTests" 2020-04-17 14:35:41 +00:00
Aaron Huang
48e0812796 Move DhcpInfoTest to FrameworksNetCommonTests
Move to frameworks/base/tests/net/common so that it can
be run in cts test and presubmit test.

Bug: 154299158
Test: atest CtsNetTestCasesLatestSdk:android.net.DhcpInfoTest
Change-Id: I8d70565fe3388fd8351002f2ed87c43343879e57
2020-04-17 17:48:53 +08:00
Aaron Huang
bbc5554392 Add test for NetworkRequest#getRequestorUid()
Add test for new API.

Bug: 151110379
Test: atest CtsNetTestCasesLatestSdk:android.net.cts.NetworkRequestTest
Change-Id: I9602cac142b3e45d12e66a6f3f35ab594e6590c1
2020-04-16 21:43:15 +08:00
Aaron Huang
5585672f92 Add tests for NetworkRequest API
This change inculdes coverage of NetworkRequest#Builder().clearCapabilities()
and NetworkRequest#getRequestorPackageName()

Bug: 153614623
Test: atest CtsNetTestCasesLatestSdk:android.net.cts.NetworkRequestTest
Change-Id: Id4e31013cfae78c25abd27b557da4e3e9487870c
2020-04-16 18:51:44 +08:00
Chiachang Wang
a0e3d97f24 Merge "Add test for NetworkRequest#canBeSatisfiedBy" 2020-04-15 15:00:51 +00:00
Chiachang Wang
da03c6a3f5 Add test for NetworkRequest#canBeSatisfiedBy
Test: atest CtsNetTestCasesLatestSdk:android.net.cts.NetworkRequestTest
      on both Q and R device
Bug: 153972141
Change-Id: I614963cdd5f26bf3d47246fdc9eb11e74d05a460
2020-04-15 21:35:19 +08:00
Chalard Jean
2cef9f7da5 Address comments from aosp/1284557
Test: this
Bug: 139268426
Change-Id: I5edbff1d7eed2f939ba26f1ebd7ead49ac67b978
2020-04-13 14:52:29 +00:00
Chalard Jean
da5800cc86 Test Signal thresholds
Test: this
Bug: 139268426
Change-Id: I136f246d0e3ad6744989e7d6f4f8034cc6674def
2020-04-13 14:51:59 +00:00
Chalard Jean
80ee14e0e7 Test sendNetworkScore
Test: this
Bug: 139268426
Change-Id: I66cea443f0c6aa9235da577817787d764fbd030b
2020-04-13 14:51:37 +00:00
Chalard Jean
d5f249c24c Test sendCaps and sendProps
Test: this
Bug: 139268426
Change-Id: Idefce1174b82668d23c53dd1bf95bc660cb21c28
2020-04-13 14:51:03 +00:00
Chalard Jean
788d19d376 Test validation status
Test: this
Bug: 139268426
Change-Id: I8499d9da8643cf60c912570e7a2ac2207d662e16
2020-04-13 14:50:41 +00:00
Chalard Jean
3f138ef9d3 Test accept unvalidated
Test: this
Bug: 139268426
Change-Id: I3326a2119d66e67566fce0268ea4861729b1c64c
2020-04-13 20:47:18 +09:00
Chalard Jean
570b76b273 Test onStartSocketKeepalive
Test: this
Bug: 139268426
Change-Id: I4e251fa0203a1888badef9ed90495fe8b3340a1c
2020-04-13 20:45:19 +09:00
Chalard Jean
01f3fd3d80 Increase test independence
If a test fails without unregistering an agent, other tests will
see their requests match the old agent. That means any test failing
will fail all subsequent tests, which is not very helpful.

Solve this by making sure the agents are unregistered before the
test ends. Also ensure the requests are unregistered.

Test: NetworkAgentTest
Change-Id: I2c167803d478d31fd85dc6e6e621f35d36c68fb4
2020-04-13 20:25:30 +09:00
Chalard Jean
2a22d65235 Merge "Test onBandwidthUpdateRequested" 2020-04-12 13:15:57 +00:00
Chalard Jean
ab9f126270 Test onBandwidthUpdateRequested
Test: this
Bug: 139268426
Change-Id: I427ae6ac2c8910683e47f503ba71a05e35507571
2020-04-10 11:20:40 +09:00
Aaron Huang
078d412a6b Merge "Add cts test for traffic stats APIs" 2020-04-09 02:37:15 +00:00
Aaron Huang
56c89685c5 Merge "CTS test for DhcpInfo parcel/unparcel" 2020-04-08 07:13:52 +00:00
Aaron Huang
4bccdf841a Merge "Add ProxyInfoTest to test public APIs" 2020-04-08 07:03:02 +00:00
Aaron Huang
f483cc9679 Add cts test for traffic stats APIs
This change adds test for new public APIs.

Bug: 135998869
Test: atest CtsNetTestCasesLatestSdk:TrafficStatsTest

Change-Id: I6b4a6773e22a204b6267d28638b9f57a0d0eb65a
2020-04-08 12:53:18 +08:00
Aaron Huang
2648ad46fe CTS test for DhcpInfo parcel/unparcel
Bug: 139268426
Bug: 135998869
Test: atest CtsNetTestCasesLatestSdk:android.net.cts.DhcpInfoTest
Change-Id: I076241072688fca37b8451873183f9597bc5fe79
2020-04-07 14:27:17 +08:00
Treehugger Robot
a2b1460f89 Merge "CTS test for NetworkRequest#getSpecifier" 2020-04-07 05:47:20 +00:00
Chalard Jean
a18f6094e1 CTS test for NetworkRequest#getSpecifier
Bug: 135998869
Test: this
Change-Id: I339c62f0ce68cc3c19abbaef7f99d216362db4cb
2020-04-07 13:39:32 +09:00
Aaron Huang
b03df59c70 Add ProxyInfoTest to test public APIs
Add cts to test current public APIs and new public
APIs.

Bug: 151110319
Bug: 152617305
Test: atest CtsNetTestCasesLatestSdk:ProxyInfoTest
Change-Id: I451989f7312fb98ec2fa0b7b9ddc856ecf2087be
2020-04-06 18:40:42 +08:00
Chalard Jean
21793bad18 Add a first NetworkAgent CTS test
This is a basic test that only tests register(), markConnected(),
unregister and onNetworkUnwanted. It provides the backbone for
the tests, a harness to test callbacks on NetworkAgent, and
demonstrates how the instrumentation in
ConnectivityService can be used to test this API.

Test: this
Bug: 139268426
Change-Id: I022c9e237fdaec27338047c171c04e5a96cf89e3
2020-04-03 07:33:23 +09:00
paulhu
ff1b6ec2dc Add a cts test for PermissionMonitor security problem
Add a cts test to check whether app can have netd sytem
permission even the app didn't grant the
CONNECTIVITY_USE_RESTRICTED_NETWORKS permission.

Bug: 144679405
Test: atest android.net.cts.ConnectivityManagerTest
Change-Id: I2c717a11bda43db166a55d343eb752ab45947fe8
Merged-In: I2c717a11bda43db166a55d343eb752ab45947fe8
(cherry picked from commit ag/10285567)
2020-04-01 01:45:49 +08:00
David Su
7f922c9ccd Merge "CTS: Split Wifi tests out of CtsNetTestCases" 2020-03-27 18:44:29 +00:00
Treehugger Robot
0899d0b658 Merge "Fix AudioGroupTest on Q" 2020-03-25 10:09:54 +00:00
Paul Hu
34142fd60a Merge "Add NetworkInfo CTS tests" 2020-03-25 08:06:00 +00:00
Paul Hu
c85205fb26 Merge "Rewrite NetworkInfo CTS tests to Kotlin" 2020-03-25 08:05:39 +00:00