Commit graph android_packages_modules_Co.../Tethering/tests
Message SHA1
[DON'T BLOCK] Test ownership migration rules
This CL is created as a best effort to migrate test targets
to the new android ownership model. If you find incorrect or unnecessary
attribution in this CL, please create a separate CL to fix that.

For more details please refer to the link below,
<add g3 doc link>

Bug: 304529413
Test: N/A
Change-Id: I243f17b3f0ad7af9ffa15ca242456e36688733f5
Merged-In: I243f17b3f0ad7af9ffa15ca242456e36688733f5

Aditya Choudhary   commited 2024-01-31 12:34:50 +00:00
01b5ede2b2
Merge "Add reconnectCell util, refactor reconnectWifi" into main
Remi NGUYEN VAN   authored and   Gerrit Code Review   commited 2024-01-30 02:44:28 +00:00
d7773093ee
Merge "Add experiment flag for enabling sync sm" into main
Mark Chien   authored and   Gerrit Code Review   commited 2024-01-30 02:18:24 +00:00
c1647a0efc
Add reconnectCell util, refactor reconnectWifi
Add a utility to reconnect mobile data, and refactor toggleWifi to match
it.

The new reconnectWifi utils do not support turning wifi on and back off
anymore, but this was dead code as no test was using it (wifi is
supposed to be connected before starting tests).

Bug: 253698734
Test: atest
Change-Id: I2b8b8d186d05bb57c6a45d872febc54def8c6d59

Remi NGUYEN VAN   commited 2024-01-24 17:49:06 +09:00
4d4664d207
Merge "Revert "Add experiment flag for tethering refactor"" into main
Mark Chien   authored and   Gerrit Code Review   commited 2024-01-24 07:41:19 +00:00
e48d106863
BpfMap - add R/W constructor alias
Test: TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I7cef2b19f55e6e056b46bb1b28f85c7f7376f6f4

Maciej Żenczykowski   commited 2024-01-23 16:16:44 -08:00
06155c8040
Add experiment flag for enabling sync sm
The logic is currently disabled by default, adding a flag so
that we can compare result with A/B rollout. Tethering only read
this flag once when it is created.

Bug: 319212113
Test: atest TetheringTests

Change-Id: I656b0389e56d29dd691738ee3abfa6418746846f

Mark   commited 2024-01-23 09:55:33 +00:00
c512ab7e23
Revert "Add experiment flag for tethering refactor"
This reverts commit cf11be9eb2.

Reason for revert: avoid some IpServer(s) running the new sync state machine while others use the async state machine.

Bug: 319212113
Change-Id: Ib086a7ccd102f38e579c79f94aceae9971f1853a

Mark Chien   authored and   Mark   commited 2024-01-22 11:34:14 +00:00
6e368d1bdd
Merge "Replace HashSet with ArraySet in RaParams" into main
Yuyang Huang   authored and   Gerrit Code Review   commited 2024-01-20 19:06:38 +00:00
86b8bf03d2
Merge "Migrate Tethering#dump to use runWithScissorsForDump" into main
Junyu Lai   authored and   Gerrit Code Review   commited 2024-01-10 09:46:12 +00:00
7b4ebdf2ef
Migrate Tethering#dump to use runWithScissorsForDump
This change includes:
  1. Refactor the logic in Tethering#dump into utils class.
  2. Move the utils class to a common place which could be referenced
     from other sub-modules.
  3. Add @MonitorThreadLeak annotation to enforce
     there is no thread leak problem.

Test: atest FrameworksNetTests NetworkStaticLibTests
Test: atest ConnectivityCoverageTests:com.android.networkstack.tethering.TetheringTest#testDumpTetheringLog
Test: adb shell dumpsys tethering (with hardcoded exception)
Fix: 312669345

Change-Id: Ia6fdfeeec2110afa0ec9e056e9db3843748845c3

Junyu Lai   commited 2024-01-10 13:56:55 +08:00
2ff42d264b
Start Ethernet tethering test once before testing
The first tethering test case might have a tethering restart when
handling IP conflicts. Currently, we start a hotspot once before
tethering, but the test is still flaky in Cuttlefish because it
doesn't support hotspots. Instead, we'll start ethernet tethering.

Bug: 254183718
Test: atest CtsTetheringTest
Change-Id: I695d4e1b3f961893bc30b3144faf7ad7d2d70574

Mark   authored and   Mark Chien   commited 2023-12-27 08:57:57 +00:00
2d0652a465
Make isInterfaceForTetheringAvailable and enableEthernetTethering static
Bug: 254183718
Test: atest CtsTetheringTest
Change-Id: Ie8bf908fc926a0b8b58559c8827951cbeaedc2c6

Mark   authored and   Mark Chien   commited 2023-12-27 08:57:48 +00:00
28b3ea4e06
EthernetTetheringTest: make some global variables static
Before making enableEthernetTethering a static function, make its
dependency variable static.

Bug: 254183718
Test: atest CtsTetheringTest
Change-Id: Id3781d67b3abc69b146fa704d4795bcfb2431a2a

Mark   authored and   Mark Chien   commited 2023-12-27 03:50:32 +00:00
1e6e272014
Merge "Add experiment flag for tethering refactor" into main
Mark Chien   authored and   Gerrit Code Review   commited 2023-12-12 05:14:51 +00:00
dbae5744a1
Add experiment flag for tethering refactor
The logic is currently disabled by default, adding a flag so
that we can compare result with A/B rollout.

Test: atest TetheringTests
Change-Id: If640b9a172b97aa67c49b2976cdef118218f1e0f

Mark   commited 2023-12-12 02:31:54 +00:00
cf11be9eb2
Get rid of any unnecessary reset calls
Calling resets at the beginning of setUp is unnecessary.

Bug: 315368147
Test: TH

Change-Id: I87030bc867d90752e745fd4a274581d1f3230f85

Mark Chien   commited 2023-12-08 06:34:09 +00:00
4d7b7ecd7e
Merge "Rename getXXX to makeXXX in TetheringDependencies" into main
Treehugger Robot   authored and   Gerrit Code Review   commited 2023-12-05 06:42:25 +00:00
ef41398c1f
Rename getXXX to makeXXX in TetheringDependencies
This fix the code review comment from aosp/2319853 that getXXX functions
should be renamed to makeXXX because it's actually creating the object.

Test: TH
Change-Id: Ife8e1cc3a90b835764a2dd9731388b05d8a5c964

Mark   authored and   Mark Chien   commited 2023-12-04 09:02:55 +00:00
b720d6d726
Random select started prefix range
Currently, PrivateAddressCoordinator always selects the /24 prefix
from the 192.168.x.x/16 range first. If the upstream is also a /24
prefix in the 192.168.x.x/16 range, there's a 1/256 chance of a
conflict (192.168.0.x/24 ~ 192.168.255.x/24). Since 192.168.x.x/16
is a popular range for home and small business networks, we should
randomize the starting prefix range to reduce the chance of a
conflict. The /8, /12, and /16 range selection rates are 0.39%,
5.86%, and 93.7%, respectively (see the inline comments for how
the rates are calculated).

The chance of selecting a /24 prefix is:
- 10.0.0.0/8: 1/(256*256) * 93.7% = 0.001429%
- 172.16.0.0/12: 1/(16*256) * 5.86% = 0.00143%
- 192.168.0.0/16: 1/256 * 0.39% = 0.001523%

Note: This change is currently turned off by the
tether_force_random_prefix_base_selection flag. We'll run experiments
to make sure tethering stays reliable with this change enabled.

Bug: 312647670
Test: atest TetheringTests
Change-Id: Iea03fdcf0fccad95410e79ae87fcb046d75da457

Mark   commited 2023-11-28 06:56:06 +00:00
c0b0f616d0
Merge "Clean up BpfCoordinatorTest" into main
KH Shi   authored and   Gerrit Code Review   commited 2023-11-22 03:35:42 +00:00
be2750fc3f
Merge "SyncSM09: Add Callback to UpstreamNetworkMonitor" into main
Mark Chien   authored and   Gerrit Code Review   commited 2023-11-21 17:29:10 +00:00
309365558c
SyncSM09: Add Callback to UpstreamNetworkMonitor
Instead of passing state machine to UpstreamNetworkMonitor, wrapped it
by an interface would have two benefits:
1. Easier for testing.
2. Isolate state machine operation in callback.

Test: atest TetheringTests
Change-Id: I2a97fd5cbc8c49df8c3c98428c6570916ab31ea5

Mark   commited 2023-11-21 05:53:29 +00:00
4465e4e2bd
Clean up BpfCoordinatorTest
1. assertEquals syntax is (expected, actual) and not the other way
   around
2. use assertArrayEquals to compare arrays

Test: atest TetheringTests
Bug: 312072637
Change-Id: I5eb0c270323253f648d3a8fd488506b9ad1ca6a1

KH Shi   commited 2023-11-20 13:39:12 +00:00
035bed35bb
Fix endian error when pass upstream prefixes to bpf
TetherUpstream6Key#src64 should be stored in network order. Use
a big-endian ByteBuffer to retrieve a value stored in network order
is actually converts it into native order, which is little-endian in
Android.

In this CL, we changed it to use byte[] instead of long to store the
top 64-bits of the source prefix.

Test: atest TetheringTests
      manual test with IPv6-only tethering upstream, check BPF stats.
Bug: 312072637
Change-Id: I79f9282d5eda28328aa6a764ea92b086d6285133

KH Shi   commited 2023-11-20 08:10:53 +00:00
84e3fb3afd
Replace HashSet with ArraySet in RaParams
ArraySet is designed to be more memory afficient than HashSet. It is
suitable to store small numbers of items.

Test: atest TetheringPrivilegedTests TetheringIntegrationTests \
      TetheringTests
Bug: 261923493
Change-Id: I2bd2eded801cc05ce53ef9f9486b13faf1772d22

KH Shi   commited 2023-11-13 03:12:53 +00:00
ff1400be4b
Merge "Remove unnecessary dropShellPermissionIdentity" into main
Mark Chien   authored and   Gerrit Code Review   commited 2023-11-08 02:18:53 +00:00
24eab1c274
Merge "[Refactor] move BPF tests to BpfCoordinatorTest" into main
KH Shi   authored and   Gerrit Code Review   commited 2023-11-08 01:30:12 +00:00
f9e70f9bf3
Remove unnecessary dropShellPermissionIdentity
The test doesn't explicitly call adoptShellPermissionIdentity anymore. Instead it use runAsShell everywhere. Remove the dead code.

Bug: 254183718
Change-Id: Ia949e0e315a3b3ae915752e95ef9fe896fdc0f5b
Test: TH

Mark Chien   commited 2023-11-07 08:25:53 +00:00
f05b4475cd
[Refactor] move BPF tests to BpfCoordinatorTest
Preparing for refactor of IpServer and BpfCoordinator. All BPF related
code are planned to migrate from IpServer to BpfCoordinator. This CL
moves BPF related tests from IpServerTest to BpfCoordinatorTest first.

Test: atest TetheringTests
Bug: 294025403
Change-Id: I000f27c463368202dbbe2ace188c8c5146669096

KH Shi   commited 2023-11-07 04:32:57 +00:00
cbee43da40
Merge "Extend tethering enable/disable timeout to 30 seconds" into main
Mark Chien   authored and   Gerrit Code Review   commited 2023-11-07 03:52:26 +00:00
9f76411b63
Add forwarding methods to RoutingCoordinator
Test: RoutingCoordinatorServiceTest
      TetheringTest
Change-Id: I2fa6250875d517c3452c85a3678d3feb0c0354d8

Chalard Jean   commited 2023-11-02 23:25:32 +09:00
820ce9df2d
Merge "SyncSM8.2: make IpServer support syncSM" into main
Mark Chien   authored and   Gerrit Code Review   commited 2023-10-30 07:51:54 +00:00
0b8bdb1074
Merge "SyncSM8.1 always call transitionTo under processMessage" into main
Mark Chien   authored and   Gerrit Code Review   commited 2023-10-30 07:51:06 +00:00
bdf6178a1a
Merge "Revert "Add forwarding methods to RoutingCoordinator"" into main
Maciej Żenczykowski   authored and   Gerrit Code Review   commited 2023-10-28 06:34:26 +00:00
e26f93318c
Revert "Add forwarding methods to RoutingCoordinator"
This reverts commit 55ccfe19e2.

Reason for revert: this must be introducing some sort of race
it appears to cause
  atest EthernetTetheringTest 'NetdBinderTest#TetherForwardAddRemove'
to no longer reliably pass.

Change-Id: I5281ab3f42c5ce268d97a12db24a6768db3f4354

Maciej Żenczykowski   authored and   Gerrit Code Review   commited 2023-10-28 02:10:52 +00:00
543d0d32e4
Merge changes Ibe22b300,I0b0f0bf1 into main
* changes:
  SyncSM08: handle IpServer requestEnableTethering callback in mainSM
  SyncSM07.1: Add a test that shows tethering restarts when disabling

Mark Chien   authored and   Gerrit Code Review   commited 2023-10-27 08:50:04 +00:00
2c7e2b8448
Merge "Pass upstream prefixes to bpf tethering offload" into main
KH Shi   authored and   Gerrit Code Review   commited 2023-10-27 07:23:52 +00:00
f92d211c71
Merge "Add forwarding methods to RoutingCoordinator" into main
Jean Chalard   authored and   Gerrit Code Review   commited 2023-10-27 05:12:07 +00:00
23376e6fe7
Pass upstream prefixes to bpf tethering offload
BPF needs upstream prefixes information to filter spoofing IPv6 source
addresses carried in downstream traffic.

We retrieve prefixes from upstream interface's LinkProperties and pass
it to the BpfCoordinator. Forwarding rules will also be updated when
upstream interface's IPv6 link addresses change.

Test: atest TetheringTests
Bug: 261923493
Change-Id: If8cfc3b191e520ca838654d1b5211ab9e9ec021d

KH Shi   commited 2023-10-26 13:13:38 +00:00
3f738fcd3d
Add forwarding methods to RoutingCoordinator
Test: RoutingCoordinatorServiceTest
      TetheringTest
Change-Id: Ic3b36ddc236e8615e7d931b6e526556bbd2dac17

Chalard Jean   commited 2023-10-26 20:18:48 +09:00
55ccfe19e2
SyncSM8.2: make IpServer support syncSM
After this change, IpServer could switch to use syncSM.

Test: atest TetheringTests
Change-Id: I2d7fa47cd020f3e76e7a8beaefb98852e93545f8

Mark   commited 2023-10-26 09:34:23 +00:00
be99f86ad9
SyncSM8.1 always call transitionTo under processMessage
As state transitions always occur after a message has been processed,
calling transitionTo only under processMessage makes the flow easier
to understand and less error-prone.

The risk of this change is very minimal since it is only about
handling the error, but tethering will stop regardless.

Test: atest TetheringTests

Change-Id: I56c6cf6cc989464ee84a8333ac131afc808a3d95

Mark   commited 2023-10-26 09:31:18 +00:00
50eef8316c
SyncSM08: handle IpServer requestEnableTethering callback in mainSM
This can make it easier to adopt SM shim replacement in follow up change,
as both SyncSM and AsyncSM will process the same message without any
difference.

This change also fix a problem that bring up downstream before it's
IpServer completely disabled.

Previous:
CMD_NOTIFY_PREFIX_CONFLICT -> requestEnableTethering(false) ->
requestEnableTethering(true) -> IpServer stopped ->
reportTetherStateChanged(downstream inactive) -> IpServer started
-> reportTetherStateChanged(downstream active)
New:
CMD_NOTIFY_PREFIX_CONFLICT -> requestEnableTethering(false) ->
IpServer stopped -> reportTetherStateChanged(downstream inactive)
-> requestEnableTethering(true) -> IpServer started
-> reportTetherStateChanged(downstream active)

Test: atest MtsTetheringTestLatestSdk
Change-Id: Ibe22b300c56125359f4fa452bd01a0a2381fda23

Mark   commited 2023-10-26 09:28:22 +00:00
5cc386bdef
SyncSM07.1: Add a test that shows tethering restarts when disabling
When tethering restarts due to an IP conflict, it starts to
bring up downstream before its IpServer is completely disabled.

Test: atest TetheringTests
Change-Id: I0b0f0bf1bb9ac8421c05fe512d5082d095fa7180

Mark   commited 2023-10-26 09:26:37 +00:00
d81f6ef4db
SyncSM07: Replace IpServer's state machine with StateMachineShim
A simple replacement without changing any behavior.

Test: atest TetheringTests
Change-Id: I34903b57df68081e974163edec82a851ee4ccc98

Mark   commited 2023-10-26 09:26:15 +00:00
2150296476
SyncSM06: Add StateMachineShim
Test: atest StateMachineShimTest

Change-Id: Ic818aa55e7e0fd7a62dfce50a6ad719e6e1c44ec

Mark   commited 2023-10-26 09:24:55 +00:00
2ec1595d0b
Merge "Add a routing coordinator class" into main
Jean Chalard   authored and   Gerrit Code Review   commited 2023-10-25 09:13:16 +00:00
4e47533688
Merge "Fix testRequestDownstreamAddressWithoutUsingLastAddress flaky" into main
Mark Chien   authored and   Gerrit Code Review   commited 2023-10-25 03:41:10 +00:00
cc26d678f2
Add a routing coordinator class
Test: In followup changes : RoutingCoordinatorManagerTest
Change-Id: Ia6811d614e02123a072c7638291828745abae051

Chalard Jean   commited 2023-10-24 22:12:26 +09:00
2fb66f1b28