Commit Graph

1763 Commits

Author SHA1 Message Date
Chalard Jean
9033477aa7 Fix flake : testVpnSetUnderlyingNetworks
When the device is very slow to run this test, cell might end
its lingering period in the middle of the test while wifi is
the default. VPN will then ignore it as an underlying network,
causing the test to fail.

Test: testVpnSetUnderlyingNetworks
      Added sleep in a strategic place to make sure the problem
      was correctly identified, and observed the test failing.
      After the fix, the test passes with the sleep.
Fixes: 280627836
Fixes: 293844384
Change-Id: Iaf56de963eb17845c1d76a0310b55f7f9321f7e4
2023-08-07 14:20:13 +09:00
Chiachang Wang
89b25779e3 Merge "Add version control for packet address translation design" into main 2023-08-03 06:58:28 +00:00
chiachangwang
144dd51761 Add version control for packet address translation design
This commit adds the version control for keepalive packet address
translation design to prevent device crash if the network stack
is not updated to a newer version. This commit also adds a
DeviceConfig to control the design in newer module version.

Bug: 291870956
Test: atest FrameworksNetTests CtsNetTestCases
Change-Id: Id4efbf51dae9154d2bc3a1ee405e2139d5c91e36
2023-08-02 12:16:31 +00:00
Treehugger Robot
865bfacab7 Merge "Deduplicate items after clear interface in NetworkStats" into main 2023-08-01 07:40:57 +00:00
Motomu Utsumi
dc9cb1da23 Merge "Revert isDefaultNetworkActive behavior when there is no default network" into main 2023-08-01 05:49:47 +00:00
Junyu Lai
23d89c0bbf Deduplicate items after clear interface in NetworkStats
Follow-up from commit Ie60829a65d0d9b5b63ad353695a820c0586e3665,
the interface field was cleared before returning the result to
the caller. However, this can cause problems in the
NetworkStats#subtract method. If the interface field is cleared,
the findIndexHinted method can match to a wrong entry.
This is because the keys of multiple entries will now be the
same. This can cause the subtract result to be unexpectedly
large and the return value of getUidStatsForTransport to be
mismatched with the values retrieved from other APIs.

Test: atest FrameworksNetTests:android.net.connectivity.com.android.server.net.NetworkStatsServiceTest \
      FrameworksNetTests:android.net.connectivity.android.net.NetworkStatsTest
Bug: 290728278
Change-Id: I891ab29b8a2902663febc7c32b04417caf510926
2023-08-01 13:38:26 +08:00
Motomu Utsumi
51e7a60359 Revert isDefaultNetworkActive behavior when there is no default network
aosp/2605757 updated isDefaultNetworkActive returns false when there is
no default network.
But this change was not merged to U release branch and this change was
not well tested by dogfooding.
So this CL reverts the isDefaultNetworkActivity behavior change.

Bug: 279380356
Bug: 291870075
Test: atest FrameworksNetTests
Change-Id: Id88662faea9eeaba93d59ab2729f6204a3631ab1
2023-08-01 12:50:00 +09:00
Motomu Utsumi
3f35bb2fce Merge "Revert onNetworkActive callback behavior on U+" into main 2023-07-31 10:34:41 +00:00
Motomu Utsumi
1e51a64988 Revert onNetworkActive callback behavior on U+
aosp/2605757 changed onNetworkActive callback behavior on U+ but this
change was not merged to U release branch.
This CL reverts the behavior change and keep the current behavior on U+.

Bug: 279380356
Bug: 291870075
Test: atest FrameworksNetTests
Change-Id: I91ccc7ee93f0827986401f316997b4a2df11318f
2023-07-31 19:33:24 +09:00
Chiachang Wang
52f3e8f29e Merge "Deflake doTestPlatformVpnWithException related tests" into main 2023-07-31 08:54:14 +00:00
chiachangwang
9f9a4dc69c Deflake doTestPlatformVpnWithException related tests
This commit updates test to
- Execute IkeSessionCallback inside executor. The callback should
  be called from executor in production code but test trigger the
  callback from test main thread which will result in unexpected
  code interaction.
- Verify the timer directly. The origin design verifies
  interactions with Captor with uncertain interaction. Test
  should be able to verify the schedule() calls with the expected
  timeout value. Also, in lower performance device, device may
  still process previous interaction. Add longer timeout to reduce
  flakes.

Bug: 293233390
Test: atest FrameworksNetTests
Test: atest VpnTest#testStartPlatformVpnFailedWithRecoverableError
      --rerun-until-failure 100
Change-Id: Ie42a2597a382800d6484a086b6d808490dfbdd32
2023-07-31 04:59:58 +00:00
Hansen Kurli
ebdda22240 Merge changes Ia5fc3e53,Ie1ab6013,I1cd5acb3 into main
* changes:
  Unregister BroadcastReceiver and OnSubscriptionsChangedListener.
  Disable KeepaliveStatsTracker before T.
  Disable KeepaliveStatsTracker instead of throwing.
2023-07-28 11:20:21 +00:00
Junyu Lai
a6be6cd48a Merge changes from topic "hostsidevpntestflaky" into main
* changes:
  Skip presubmit for flaky tests in FrameworksNetTests due to Out of SLO
  Skip presubmit for flaky tests in HostsideVpnTests due to Out of SLO
2023-07-28 02:06:17 +00:00
Chiachang Wang
32a8cbce6f Merge "Increase timeout to deflake tests" into main 2023-07-28 00:37:42 +00:00
chiachangwang
595fac0840 Increase timeout to deflake tests
In failed log, VPN still process the migration which does not
send the network capabilities update to network agent.
In low performance devices like cuttlefish, it may sometimes
cause flaky. Specify a longer timeout to deflake the test.

Bug: 293233390
Test: atest FrameworksNetTests
Change-Id: I4e6c80c03e19efb448ee2806c5a250425b0e068f
2023-07-27 09:17:00 +00:00
Junyu Lai
b8fc755259 Skip presubmit for flaky tests in FrameworksNetTests due to Out of SLO
Test: TH
Bug: 293233390
Change-Id: Ic1d0d86b3f8dfc8e8122c6b05973fab8b57e52b4
2023-07-26 16:31:46 +08:00
Paul Hu
6be7db441c Merge "Report registration metrics data" into main 2023-07-26 00:45:34 +00:00
Treehugger Robot
9a9852d782 Merge "Add polling and logging when launcher is settings" into main 2023-07-25 08:12:30 +00:00
Treehugger Robot
4525688b2d Merge "Move QueryTaskConfig to a standalone class" into main 2023-07-25 04:51:55 +00:00
Yuyang Huang
54125ef545 Merge "Ensure the ServiceTypeClient Executor threads can be shutdown" into main 2023-07-25 03:05:08 +00:00
Yuyang Huang
bbd573b92f Move QueryTaskConfig to a standalone class
Bug: 292470176
Test: atest FrameworksNetTests CtsNetTestCases
Change-Id: Iff15e7b59277444bbaa92b98318bb4f910eea070
2023-07-24 18:34:09 +09:00
Yuyang Huang
66cd57f2d8 Ensure the ServiceTypeClient Executor threads can be shutdown
When ServiceTypeClient is not used, the Executor threads should be
shutdown as well.

Bug: 287013457
Test: atest CtsNetTestCases FrameworksNetTests
Change-Id: I9dae01e7b6c2bcd395a98f4362f0c36f1535b2a6
2023-07-24 16:14:19 +09:00
Paul Hu
777ed05c73 Report registration metrics data
Collect information about registration successes, failures, and
unregistrations, then build metrics data from this information
and report it.

Bug: 287546772
Test: atest FrameworksNetTestCases NsdManagerTest
Change-Id: I6324279b479da2e61b7519d96df5ad24a432e54a
2023-07-24 14:50:48 +08:00
Paul Hu
2048dd2ad3 Address leftover comments
- Rename QuerySentResult to QuerySentArguments
- Add constants INVALID_TRANSACTION_ID
- Remove useSessionIdToScheduleMdnsTask check
- Update subtype in MdnsServiceTypeClientTests

Bug: 265787401
Test: atest FrameworksNetTests
Change-Id: I5e544d505c645262c213d40cdd94a79088ac4886
2023-07-20 05:34:57 +00:00
Remi NGUYEN VAN
6c3f4160df Add polling and logging when launcher is settings
getLauncherPackageName sometimes returns "com.android.settings", causing
the test to fail.

Add polling for the launcher to not return settings, and logging to
try to understand why this happens, especially if polling does not solve
the issue.

Bug: 286550950
Test: atest

Change-Id: I90963d5db326732dfc82db07f36676190ffdcce9
2023-07-19 18:49:59 +09:00
Paul Hu
e85479a1eb Move MdnsResponseDecoder.Clock to MdnsUtils
This is a no-op change. The Clock class is a wrapper that is
used for testing. So move it from MdnsResponseDecoder to
MdnsUtils for subsequence metrics changes.

Bug: 287546772
Test: m
Change-Id: If4c8c0061c76ae26fc78a5ff463a31d57470fba0
2023-07-17 11:35:27 +08:00
Hansen Kurli
1363cf4e43 Unregister BroadcastReceiver and OnSubscriptionsChangedListener.
1. Unregister BroadcastReceiver of default subscription id.
2. Use a CompletableFuture to store and unregister the
   OnSubscriptionsChangedListener. Note this has to be done since the
   listener cannot be constructed in the handler thread.

Bug: 288059409
Test: atest FrameworksNetTests
Change-Id: Ia5fc3e53305a99c32ad2f6d5b1b6a367dc20c1d7
2023-07-14 07:47:04 +00:00
Hansen Kurli
21eae05622 Disable KeepaliveStatsTracker instead of throwing.
Avoid throwing errors when something unexpected occurs with the
keepalive state since metrics should not cause a crash. Instead, disable
the tracker and skip writing the metrics.

Bug: 288059409
Test: atest FrameworksNetTests
Change-Id: I1cd5acb32eb062ccdf7d1ac3e25a21309ad011c2
2023-07-13 09:56:20 +00:00
Chiachang Wang
c21ccc8399 Merge "Use utility method to execute things on the handler" into main 2023-07-13 03:24:29 +00:00
chiachangwang
26bd4adfc2 Use utility method to execute things on the handler
Replace Handler.post() with visibleOnHandlerTread().

Test: atest FrameworksNetTests
Change-Id: I3a2f166d939db8ed6ac7fbb1cb9306256ae22189
2023-07-12 11:33:51 +00:00
Paul Hu
9f353f9cc6 Merge "Deal with responses on MdnsServiceCache" into main 2023-07-12 10:54:00 +00:00
Paul Hu
cd57c783f5 Merge "Remove synchronized lock in MdnsServiceTypeClient" into main 2023-07-12 09:48:48 +00:00
Paul Hu
639e3c70bb Deal with responses on MdnsServiceCache
To cache services and respond quickly, the MdnsServiceTypeClient
should add all services to the MdnsServiceCache and remove any
services from there as well.

Bug: 265787401
Test: atest FrameworksNetTests
Change-Id: If0a9e6b563a0992ac25b8cde7f3beb00700f1c11
2023-07-12 08:12:54 +00:00
Paul Hu
2118d33da8 Remove synchronized lock in MdnsServiceTypeClient
Now that all access to MdnsServiceTypeClient parameters is
running on the handler thread, the synchronized lock is no
longer necessary. Therefore, the synchronized lock can be
safely removed from MdnsServiceTypeClient.

Bug: 265787401
Test: atest FrameworksNetTests
Change-Id: I5cd28aa738ea3c199b75097f4583e98be86a6ee7
2023-07-12 08:10:22 +00:00
Paul Hu
8abd1be521 Merge "Use a delayed message to schedule the query task" into main 2023-07-10 08:53:20 +00:00
Paul Hu
cd39d81fe1 Use a delayed message to schedule the query task
To reduce the multi-thread access to MdnsServiceTypeClient, the
query task scheduling should be replaced with a delayed message.
This will allow the synchronized lock to be removed in future
changes.

Bug: 265787401
Test: atest FrameworksNetTests
Change-Id: I340fe1a407947be860cdcd9c7c76829417a32e4c
2023-07-10 05:45:37 +00:00
Chiachang Wang
7f8015fe9e Merge "Limit the translation code on NAT-T keepalive" into main 2023-07-10 00:28:10 +00:00
chiachangwang
9d494ca5f7 Limit the translation code on NAT-T keepalive
Limit the translation code on NAT-T keepalive because the
intention of the translation is design for NAT-T keepalive.
The translated packets is also NAT-T packet data which should
not apply to TCP keepalive.

Bug: 196453719
Test: atest FrameworksNetTests
Change-Id: I0951621edc9f918199d82365a6f1c03617ddd806
2023-07-07 07:54:07 +00:00
Chiachang Wang
f5025ba1a4 Merge "Vertify the exact interactions with mocking object" into main 2023-07-07 01:12:13 +00:00
chiachangwang
a607674033 Vertify the exact interactions with mocking object
There are more than 1 interaction inside verifySetupPlatformVpn.
The original code does not actually wait for the target
interaction with Executor.schedule(). The interact may happen
after reset the mocking object. This will leave a unexpected
interaction in the follow up verification and cause a flaky
test.

This test was fine in the initial patch, but becomes failed
after the time unit used in Executor.schedule() was changed
to milliseconds for data stall recovery. Both interactions
for data stall ones and non-data stall ones will be captured
together after that.

Bug: 289961869
Test: atest VpnTest --rerun-until-failure 20
Change-Id: If24e323b366bb15b81fe9fa554fa7ccc852ba6f1
2023-07-06 09:16:04 +00:00
Paul Hu
d5b24b4855 Add a handler thread check to all public methods
To ensure that all access to the MdnsServiceTypeClient is done on
the handler thread, a handler thread check must be added to all
public methods in the MdnsServiceTypeClient. This will allow the
synchronized lock to be removed in future changes, and it will
also ensure that MdnsServiceTypeClient can access MdsServiceCache
properly.

Bug: 265787401
Test: atest FrameworksNetTests
Change-Id: I0206874eb0acdf0272b8ad23d29f3e764bfdec38
2023-07-05 07:46:36 +00:00
Paul Hu
775840e1b4 Use SocketKey in MdnsServiceCache
The MdnsServiceTypeClient is now created using a SocketKey, so
the MdnsServiceCache should also use the SocketKey to deal with
the caching services.

Bug: 265787401
Test: atest FrameworksNetTests
Change-Id: I6165ffd420a39e750c06778b4851142a3ba3cf44
2023-07-05 06:38:41 +00:00
Treehugger Robot
e59d30bc2a Merge "Adjust query frequency based on remaining TTL" 2023-07-05 06:19:38 +00:00
Yuyang Huang
f56c92f3ff Adjust query frequency based on remaining TTL
After numOfQueriesBeforeBackoff query, the mDNS discovery logic will
enter backoff mode. In backoff mode,  the query frequency will be
updated to max(20, 0.8 * shortest remaining TTL) seconds. It will help
to reduce mDNS query frequency in certain use cases.

Bug: 284480315
Test: atest CtsNetTest FrameworksNetTests
Change-Id: Iac8baaaf58cf9b3b8e67e1cd80402fdecde1d3d4
2023-07-05 13:01:19 +09:00
chiachangwang
d34aac4123 Update tests to reflect the time unit change in Vpn
Test: atest FrameworksNetTests
Change-Id: I84a3f75bb527136bd0319f5af1bc43d2575495dd
2023-07-04 08:27:44 +00:00
chiachangwang
42ba18ca1e Update tests for VPN data stall recovery
Data stall recovery in VPN does not rely on the data stall
event now. Update the tests accordingly.

Bug: 289746779
Test: atest FrameworksNetTests
Change-Id: I4d2d96fe2f76706512325b6653b3e7cced10f207
2023-07-04 05:49:49 +00:00
Hansen Kurli
ab85de69b1 Skip writing the metrics before T.
Repeated fields are only supported on T+ and the metrics in
KeepaliveStatsTracker contains repeated fields. Hence, guard the write
with a T+ check.

Bug: 289344384
Test: Manual test
Change-Id: If3be75292b5a79aa753bddb772fe2c52c9dde994
2023-07-03 10:43:28 +00:00
Chiachang Wang
7e1076e174 Merge "Translate v4 keepalive packet on clat started network to v6" 2023-07-03 09:14:09 +00:00
Paul Hu
f51a0139a2 Merge "Move NsdServiceInfoTest to common tests" 2023-07-03 06:24:43 +00:00
chiachangwang
c5c5c84f4c Translate v4 keepalive packet on clat started network to v6
This commit translates the address of keepalive packet to v6
in order to make NATT keepalive work on v6 only network.

Sending a v4 NATT keepalive on a v6 only network is bogus if
hardware does not translate the packet automatically. Network
may drop the packet or reject the attempt by hardware. This
results in ERROR_INVALID_IP_ADDRESS and stop the keepalive
request.

Bug: 196453719
Test: atest FrameworksNetTests
Test: Manually connect to v6 only network and check if the
      keepalive packets are sent
Change-Id: I798c5d48661d8151b19902435732f465b5aa725b
2023-06-29 12:43:59 +00:00