Girish Moturu | f72690e | 2017-02-14 15:19:53 -0800 | [diff] [blame] | 1 | # |
| 2 | # Copyright 2017 - The Android Open Source Project |
| 3 | # |
| 4 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | # you may not use this file except in compliance with the License. |
| 6 | # You may obtain a copy of the License at |
| 7 | # |
| 8 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | # |
| 10 | # Unless required by applicable law or agreed to in writing, software |
| 11 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | # See the License for the specific language governing permissions and |
| 14 | # limitations under the License. |
| 15 | |
| 16 | import logging |
Girish Moturu | 2c21eb3 | 2017-05-25 14:37:55 +0530 | [diff] [blame] | 17 | import random |
Girish Moturu | f72690e | 2017-02-14 15:19:53 -0800 | [diff] [blame] | 18 | import socket |
Girish Moturu | 2c21eb3 | 2017-05-25 14:37:55 +0530 | [diff] [blame] | 19 | import time |
Girish Moturu | f72690e | 2017-02-14 15:19:53 -0800 | [diff] [blame] | 20 | |
| 21 | from acts import asserts |
Girish Moturu | f72690e | 2017-02-14 15:19:53 -0800 | [diff] [blame] | 22 | from acts import test_runner |
Girish Moturu | 8c77189 | 2019-11-07 08:33:57 -0800 | [diff] [blame] | 23 | from acts import utils |
Girish Moturu | f72690e | 2017-02-14 15:19:53 -0800 | [diff] [blame] | 24 | from acts.controllers import adb |
Girish Moturu | 2c21eb3 | 2017-05-25 14:37:55 +0530 | [diff] [blame] | 25 | from acts.test_decorators import test_tracker_info |
Xianyuan Jia | 63751fb | 2020-11-17 00:07:40 +0000 | [diff] [blame^] | 26 | from acts_contrib.test_utils.tel import tel_defines |
| 27 | from acts_contrib.test_utils.tel.tel_data_utils import wait_for_cell_data_connection |
| 28 | from acts_contrib.test_utils.tel.tel_test_utils import get_operator_name |
| 29 | from acts_contrib.test_utils.tel.tel_test_utils import verify_http_connection |
| 30 | from acts_contrib.test_utils.tel.tel_test_utils import WIFI_CONFIG_APBAND_2G |
| 31 | from acts_contrib.test_utils.tel.tel_test_utils import WIFI_CONFIG_APBAND_5G |
| 32 | from acts_contrib.test_utils.net import socket_test_utils as sutils |
| 33 | from acts_contrib.test_utils.net import arduino_test_utils as dutils |
| 34 | from acts_contrib.test_utils.net import net_test_utils as nutils |
| 35 | from acts_contrib.test_utils.wifi import wifi_test_utils as wutils |
| 36 | from acts_contrib.test_utils.wifi.WifiBaseTest import WifiBaseTest |
Girish Moturu | f72690e | 2017-02-14 15:19:53 -0800 | [diff] [blame] | 37 | |
Girish Moturu | 8d9741f | 2019-04-01 08:43:16 -0700 | [diff] [blame] | 38 | WAIT_TIME = 5 |
Girish Moturu | f72690e | 2017-02-14 15:19:53 -0800 | [diff] [blame] | 39 | |
Xianyuan Jia | 97a865e | 2020-11-10 02:09:40 +0000 | [diff] [blame] | 40 | class WifiTetheringTest(WifiBaseTest): |
Girish Moturu | f72690e | 2017-02-14 15:19:53 -0800 | [diff] [blame] | 41 | """ Tests for Wifi Tethering """ |
| 42 | |
| 43 | def setup_class(self): |
| 44 | """ Setup devices for tethering and unpack params """ |
Xianyuan Jia | 97a865e | 2020-11-10 02:09:40 +0000 | [diff] [blame] | 45 | super().setup_class() |
Girish Moturu | 2c21eb3 | 2017-05-25 14:37:55 +0530 | [diff] [blame] | 46 | self.hotspot_device = self.android_devices[0] |
| 47 | self.tethered_devices = self.android_devices[1:] |
Girish Moturu | 8c77189 | 2019-11-07 08:33:57 -0800 | [diff] [blame] | 48 | req_params = ("url", "open_network") |
Girish Moturu | f72690e | 2017-02-14 15:19:53 -0800 | [diff] [blame] | 49 | self.unpack_userparams(req_params) |
Girish Moturu | 8c77189 | 2019-11-07 08:33:57 -0800 | [diff] [blame] | 50 | self.network = {"SSID": "hotspot_%s" % utils.rand_ascii_str(6), |
| 51 | "password": "pass_%s" % utils.rand_ascii_str(6)} |
Girish Moturu | f10ed4c | 2020-06-13 11:03:43 -0700 | [diff] [blame] | 52 | self.new_ssid = "hs_%s" % utils.rand_ascii_str(6) |
Girish Moturu | 2c21eb3 | 2017-05-25 14:37:55 +0530 | [diff] [blame] | 53 | |
Girish Moturu | 95f2f45 | 2018-07-23 15:57:15 -0700 | [diff] [blame] | 54 | nutils.verify_lte_data_and_tethering_supported(self.hotspot_device) |
Girish Moturu | 2c21eb3 | 2017-05-25 14:37:55 +0530 | [diff] [blame] | 55 | for ad in self.tethered_devices: |
| 56 | wutils.wifi_test_device_init(ad) |
Girish Moturu | f72690e | 2017-02-14 15:19:53 -0800 | [diff] [blame] | 57 | |
jerry | 05261a2 | 2020-01-03 18:18:50 +0800 | [diff] [blame] | 58 | def setup_test(self): |
Xianyuan Jia | 97a865e | 2020-11-10 02:09:40 +0000 | [diff] [blame] | 59 | super().setup_test() |
Girish Moturu | f10ed4c | 2020-06-13 11:03:43 -0700 | [diff] [blame] | 60 | self.tethered_devices[0].droid.telephonyToggleDataConnection(False) |
jerry | 05261a2 | 2020-01-03 18:18:50 +0800 | [diff] [blame] | 61 | |
lutina | 8e26ac9 | 2019-11-25 18:38:11 +0800 | [diff] [blame] | 62 | def teardown_test(self): |
Xianyuan Jia | 97a865e | 2020-11-10 02:09:40 +0000 | [diff] [blame] | 63 | super().teardown_test() |
lutina | 8e26ac9 | 2019-11-25 18:38:11 +0800 | [diff] [blame] | 64 | if self.hotspot_device.droid.wifiIsApEnabled(): |
| 65 | wutils.stop_wifi_tethering(self.hotspot_device) |
Girish Moturu | f10ed4c | 2020-06-13 11:03:43 -0700 | [diff] [blame] | 66 | self.tethered_devices[0].droid.telephonyToggleDataConnection(True) |
lutina | 8e26ac9 | 2019-11-25 18:38:11 +0800 | [diff] [blame] | 67 | |
Girish Moturu | f72690e | 2017-02-14 15:19:53 -0800 | [diff] [blame] | 68 | def teardown_class(self): |
| 69 | """ Reset devices """ |
Girish Moturu | 9bd1e9a | 2017-12-14 10:10:25 -0800 | [diff] [blame] | 70 | for ad in self.tethered_devices: |
Girish Moturu | 95f2f45 | 2018-07-23 15:57:15 -0700 | [diff] [blame] | 71 | wutils.reset_wifi(ad) |
Girish Moturu | 2c21eb3 | 2017-05-25 14:37:55 +0530 | [diff] [blame] | 72 | |
Girish Moturu | f72690e | 2017-02-14 15:19:53 -0800 | [diff] [blame] | 73 | """ Helper functions """ |
| 74 | |
Girish Moturu | 2c21eb3 | 2017-05-25 14:37:55 +0530 | [diff] [blame] | 75 | def _is_ipaddress_ipv6(self, ip_address): |
Girish Moturu | f72690e | 2017-02-14 15:19:53 -0800 | [diff] [blame] | 76 | """ Verify if the given string is a valid IPv6 address |
| 77 | |
| 78 | Args: |
| 79 | 1. string which contains the IP address |
| 80 | |
| 81 | Returns: |
| 82 | True: if valid ipv6 address |
| 83 | False: if not |
| 84 | """ |
| 85 | try: |
| 86 | socket.inet_pton(socket.AF_INET6, ip_address) |
| 87 | return True |
| 88 | except socket.error: |
| 89 | return False |
| 90 | |
| 91 | def _supports_ipv6_tethering(self, dut): |
| 92 | """ Check if provider supports IPv6 tethering. |
| 93 | Currently, only Verizon supports IPv6 tethering |
| 94 | |
| 95 | Returns: |
| 96 | True: if provider supports IPv6 tethering |
| 97 | False: if not |
| 98 | """ |
| 99 | # Currently only Verizon support IPv6 tethering |
Girish Moturu | be552fd | 2019-08-29 12:58:16 -0700 | [diff] [blame] | 100 | carrier_supports_tethering = ["vzw", "tmo", "Far EasTone", "Chunghwa Telecom"] |
Girish Moturu | 2c21eb3 | 2017-05-25 14:37:55 +0530 | [diff] [blame] | 101 | operator = get_operator_name(self.log, dut) |
Girish Moturu | f72690e | 2017-02-14 15:19:53 -0800 | [diff] [blame] | 102 | return operator in carrier_supports_tethering |
| 103 | |
Girish Moturu | 2c21eb3 | 2017-05-25 14:37:55 +0530 | [diff] [blame] | 104 | def _carrier_supports_ipv6(self,dut): |
| 105 | """ Verify if carrier supports ipv6 |
| 106 | Currently, only verizon and t-mobile supports IPv6 |
| 107 | |
| 108 | Returns: |
| 109 | True: if carrier supports ipv6 |
| 110 | False: if not |
| 111 | """ |
sasahuang | b5f72c5 | 2019-08-23 17:33:22 +0800 | [diff] [blame] | 112 | carrier_supports_ipv6 = ["vzw", "tmo", "Far EasTone", "Chunghwa Telecom"] |
Girish Moturu | 2c21eb3 | 2017-05-25 14:37:55 +0530 | [diff] [blame] | 113 | operator = get_operator_name(self.log, dut) |
Girish Moturu | 7f28752 | 2017-09-25 13:33:06 -0700 | [diff] [blame] | 114 | self.log.info("Carrier is %s" % operator) |
Girish Moturu | 2c21eb3 | 2017-05-25 14:37:55 +0530 | [diff] [blame] | 115 | return operator in carrier_supports_ipv6 |
| 116 | |
Girish Moturu | 2c21eb3 | 2017-05-25 14:37:55 +0530 | [diff] [blame] | 117 | def _verify_ipv6_tethering(self, dut): |
Girish Moturu | f72690e | 2017-02-14 15:19:53 -0800 | [diff] [blame] | 118 | """ Verify IPv6 tethering """ |
| 119 | http_response = dut.droid.httpRequestString(self.url) |
Girish Moturu | f72690e | 2017-02-14 15:19:53 -0800 | [diff] [blame] | 120 | self.log.info("IP address %s " % http_response) |
Girish Moturu | 0fd0b94 | 2017-12-12 12:04:56 -0800 | [diff] [blame] | 121 | active_link_addrs = dut.droid.connectivityGetAllAddressesOfActiveLink() |
Girish Moturu | 2c21eb3 | 2017-05-25 14:37:55 +0530 | [diff] [blame] | 122 | if dut==self.hotspot_device and self._carrier_supports_ipv6(dut)\ |
| 123 | or self._supports_ipv6_tethering(self.hotspot_device): |
Girish Moturu | f72690e | 2017-02-14 15:19:53 -0800 | [diff] [blame] | 124 | asserts.assert_true(self._is_ipaddress_ipv6(http_response), |
| 125 | "The http response did not return IPv6 address") |
Girish Moturu | 0fd0b94 | 2017-12-12 12:04:56 -0800 | [diff] [blame] | 126 | asserts.assert_true( |
| 127 | active_link_addrs and http_response in str(active_link_addrs), |
| 128 | "Could not find IPv6 address in link properties") |
| 129 | asserts.assert_true( |
| 130 | dut.droid.connectivityHasIPv6DefaultRoute(), |
| 131 | "Could not find IPv6 default route in link properties") |
Girish Moturu | f72690e | 2017-02-14 15:19:53 -0800 | [diff] [blame] | 132 | else: |
Girish Moturu | 0fd0b94 | 2017-12-12 12:04:56 -0800 | [diff] [blame] | 133 | asserts.assert_true( |
| 134 | not dut.droid.connectivityHasIPv6DefaultRoute(), |
| 135 | "Found IPv6 default route in link properties") |
Girish Moturu | f72690e | 2017-02-14 15:19:53 -0800 | [diff] [blame] | 136 | |
Girish Moturu | 2c21eb3 | 2017-05-25 14:37:55 +0530 | [diff] [blame] | 137 | def _start_wifi_tethering(self, wifi_band=WIFI_CONFIG_APBAND_2G): |
| 138 | """ Start wifi tethering on hotspot device |
| 139 | |
| 140 | Args: |
| 141 | 1. wifi_band: specifies the wifi band to start the hotspot |
| 142 | on. The current options are 2G and 5G |
| 143 | """ |
| 144 | wutils.start_wifi_tethering(self.hotspot_device, |
| 145 | self.network[wutils.WifiEnums.SSID_KEY], |
| 146 | self.network[wutils.WifiEnums.PWD_KEY], |
| 147 | wifi_band) |
| 148 | |
| 149 | def _connect_disconnect_devices(self): |
| 150 | """ Randomly connect and disconnect devices from the |
| 151 | self.tethered_devices list to hotspot device |
| 152 | """ |
| 153 | device_connected = [ False ] * len(self.tethered_devices) |
| 154 | for _ in range(50): |
| 155 | dut_id = random.randint(0, len(self.tethered_devices)-1) |
| 156 | dut = self.tethered_devices[dut_id] |
Girish Moturu | 7df90e3 | 2017-10-16 12:49:56 -0700 | [diff] [blame] | 157 | # wait for 1 sec between connect & disconnect stress test |
| 158 | time.sleep(1) |
Girish Moturu | 2c21eb3 | 2017-05-25 14:37:55 +0530 | [diff] [blame] | 159 | if device_connected[dut_id]: |
| 160 | wutils.wifi_forget_network(dut, self.network["SSID"]) |
| 161 | else: |
| 162 | wutils.wifi_connect(dut, self.network) |
| 163 | device_connected[dut_id] = not device_connected[dut_id] |
| 164 | |
Girish Moturu | 4736606 | 2018-05-23 12:48:11 -0700 | [diff] [blame] | 165 | def _connect_disconnect_android_device(self, dut_id, wifi_state): |
| 166 | """ Connect or disconnect wifi on android device depending on the |
| 167 | current wifi state |
| 168 | |
| 169 | Args: |
| 170 | 1. dut_id: tethered device to change the wifi state |
| 171 | 2. wifi_state: current wifi state |
| 172 | """ |
| 173 | ad = self.tethered_devices[dut_id] |
| 174 | if wifi_state: |
| 175 | self.log.info("Disconnecting wifi on android device") |
| 176 | wutils.wifi_forget_network(ad, self.network["SSID"]) |
| 177 | else: |
| 178 | self.log.info("Connecting to wifi on android device") |
| 179 | wutils.wifi_connect(ad, self.network) |
| 180 | |
| 181 | def _connect_disconnect_wifi_dongle(self, dut_id, wifi_state): |
| 182 | """ Connect or disconnect wifi on wifi dongle depending on the |
| 183 | current wifi state |
| 184 | |
| 185 | Args: |
| 186 | 1. dut_id: wifi dongle to change the wifi state |
| 187 | 2. wifi_state: current wifi state |
| 188 | """ |
| 189 | wd = self.arduino_wifi_dongles[dut_id] |
| 190 | if wifi_state: |
| 191 | self.log.info("Disconnecting wifi on dongle") |
| 192 | dutils.disconnect_wifi(wd) |
| 193 | else: |
| 194 | self.log.info("Connecting to wifi on dongle") |
| 195 | dutils.connect_wifi(wd, self.network) |
| 196 | |
| 197 | def _connect_disconnect_tethered_devices(self): |
| 198 | """ Connect disconnect tethered devices to wifi hotspot """ |
| 199 | num_android_devices = len(self.tethered_devices) |
| 200 | num_wifi_dongles = 0 |
Girish Moturu | 95f2f45 | 2018-07-23 15:57:15 -0700 | [diff] [blame] | 201 | if hasattr(self, 'arduino_wifi_dongles'): |
Girish Moturu | 4736606 | 2018-05-23 12:48:11 -0700 | [diff] [blame] | 202 | num_wifi_dongles = len(self.arduino_wifi_dongles) |
| 203 | total_devices = num_android_devices + num_wifi_dongles |
| 204 | device_connected = [False] * total_devices |
| 205 | for _ in range(50): |
| 206 | dut_id = random.randint(0, total_devices-1) |
| 207 | wifi_state = device_connected[dut_id] |
| 208 | if dut_id < num_android_devices: |
| 209 | self._connect_disconnect_android_device(dut_id, wifi_state) |
| 210 | else: |
| 211 | self._connect_disconnect_wifi_dongle(dut_id-num_android_devices, |
| 212 | wifi_state) |
| 213 | device_connected[dut_id] = not device_connected[dut_id] |
| 214 | |
Girish Moturu | 7f28752 | 2017-09-25 13:33:06 -0700 | [diff] [blame] | 215 | def _verify_ping(self, dut, ip, isIPv6=False): |
Girish Moturu | 2c21eb3 | 2017-05-25 14:37:55 +0530 | [diff] [blame] | 216 | """ Verify ping works from the dut to IP/hostname |
| 217 | |
| 218 | Args: |
| 219 | 1. dut - ad object to check ping from |
| 220 | 2. ip - ip/hostname to ping (IPv4 and IPv6) |
| 221 | |
| 222 | Returns: |
| 223 | True - if ping is successful |
| 224 | False - if not |
| 225 | """ |
| 226 | self.log.info("Pinging %s from dut %s" % (ip, dut.serial)) |
Girish Moturu | 7f28752 | 2017-09-25 13:33:06 -0700 | [diff] [blame] | 227 | if isIPv6 or self._is_ipaddress_ipv6(ip): |
Girish Moturu | 2c21eb3 | 2017-05-25 14:37:55 +0530 | [diff] [blame] | 228 | return dut.droid.pingHost(ip, 5, "ping6") |
| 229 | return dut.droid.pingHost(ip) |
| 230 | |
| 231 | def _return_ip_for_interface(self, dut, iface_name): |
| 232 | """ Return list of IP addresses for an interface |
| 233 | |
| 234 | Args: |
| 235 | 1. dut - ad object |
| 236 | 2. iface_name - interface name |
| 237 | |
| 238 | Returns: |
| 239 | List of IPv4 and IPv6 addresses |
| 240 | """ |
| 241 | return dut.droid.connectivityGetIPv4Addresses(iface_name) + \ |
| 242 | dut.droid.connectivityGetIPv6Addresses(iface_name) |
| 243 | |
Girish Moturu | 4736606 | 2018-05-23 12:48:11 -0700 | [diff] [blame] | 244 | def _test_traffic_between_two_tethered_devices(self, ad, wd): |
Girish Moturu | 2c21eb3 | 2017-05-25 14:37:55 +0530 | [diff] [blame] | 245 | """ Verify pinging interfaces of one DUT from another |
| 246 | |
| 247 | Args: |
Girish Moturu | 4736606 | 2018-05-23 12:48:11 -0700 | [diff] [blame] | 248 | 1. ad - android device |
| 249 | 2. wd - wifi dongle |
Girish Moturu | 2c21eb3 | 2017-05-25 14:37:55 +0530 | [diff] [blame] | 250 | """ |
Girish Moturu | 4736606 | 2018-05-23 12:48:11 -0700 | [diff] [blame] | 251 | wutils.wifi_connect(ad, self.network) |
| 252 | dutils.connect_wifi(wd, self.network) |
| 253 | local_ip = ad.droid.connectivityGetIPv4Addresses('wlan0')[0] |
| 254 | remote_ip = wd.ip_address() |
| 255 | port = 8888 |
Girish Moturu | 2c21eb3 | 2017-05-25 14:37:55 +0530 | [diff] [blame] | 256 | |
Girish Moturu | 4736606 | 2018-05-23 12:48:11 -0700 | [diff] [blame] | 257 | time.sleep(6) # wait until UDP packets method is invoked |
Girish Moturu | f5d2b2a | 2018-05-30 10:07:32 -0700 | [diff] [blame] | 258 | socket = sutils.open_datagram_socket(ad, local_ip, port) |
| 259 | sutils.send_recv_data_datagram_sockets( |
Girish Moturu | 4736606 | 2018-05-23 12:48:11 -0700 | [diff] [blame] | 260 | ad, ad, socket, socket, remote_ip, port) |
Girish Moturu | f5d2b2a | 2018-05-30 10:07:32 -0700 | [diff] [blame] | 261 | sutils.close_datagram_socket(ad, socket) |
Girish Moturu | 2c21eb3 | 2017-05-25 14:37:55 +0530 | [diff] [blame] | 262 | |
| 263 | def _ping_hotspot_interfaces_from_tethered_device(self, dut): |
| 264 | """ Ping hotspot interfaces from tethered device |
| 265 | |
| 266 | Args: |
| 267 | 1. dut - tethered device |
| 268 | |
| 269 | Returns: |
| 270 | True - if all IP addresses are pingable |
| 271 | False - if not |
| 272 | """ |
| 273 | ifaces = self.hotspot_device.droid.connectivityGetNetworkInterfaces() |
| 274 | return_result = True |
| 275 | for interface in ifaces: |
| 276 | iface_name = interface.split()[0].split(':')[1] |
| 277 | if iface_name == "lo": |
| 278 | continue |
| 279 | ip_list = self._return_ip_for_interface( |
| 280 | self.hotspot_device, iface_name) |
| 281 | for ip in ip_list: |
| 282 | ping_result = self._verify_ping(dut, ip) |
| 283 | self.log.info("Ping result: %s %s %s" % |
| 284 | (iface_name, ip, ping_result)) |
| 285 | return_result = return_result and ping_result |
| 286 | |
| 287 | return return_result |
Girish Moturu | f72690e | 2017-02-14 15:19:53 -0800 | [diff] [blame] | 288 | |
Girish Moturu | b0768fa | 2018-02-13 15:24:27 -0800 | [diff] [blame] | 289 | def _save_wifi_softap_configuration(self, ad, config): |
| 290 | """ Save soft AP configuration |
| 291 | |
| 292 | Args: |
| 293 | 1. dut - device to save configuration on |
| 294 | 2. config - soft ap configuration |
| 295 | """ |
| 296 | asserts.assert_true(ad.droid.wifiSetWifiApConfiguration(config), |
| 297 | "Failed to set WifiAp Configuration") |
| 298 | wifi_ap = ad.droid.wifiGetApConfiguration() |
| 299 | asserts.assert_true(wifi_ap[wutils.WifiEnums.SSID_KEY] == config[wutils.WifiEnums.SSID_KEY], |
| 300 | "Configured wifi hotspot SSID does not match with the expected SSID") |
| 301 | |
| 302 | def _turn_on_wifi_hotspot(self, ad): |
| 303 | """ Turn on wifi hotspot with a config that is already saved |
| 304 | |
| 305 | Args: |
| 306 | 1. dut - device to turn wifi hotspot on |
| 307 | """ |
| 308 | ad.droid.wifiStartTrackingTetherStateChange() |
| 309 | ad.droid.connectivityStartTethering(tel_defines.TETHERING_WIFI, False) |
| 310 | try: |
| 311 | ad.ed.pop_event("ConnectivityManagerOnTetheringStarted") |
| 312 | ad.ed.wait_for_event("TetherStateChanged", |
| 313 | lambda x: x["data"]["ACTIVE_TETHER"], 30) |
| 314 | except: |
| 315 | asserts.fail("Didn't receive wifi tethering starting confirmation") |
| 316 | ad.droid.wifiStopTrackingTetherStateChange() |
| 317 | |
Girish Moturu | f72690e | 2017-02-14 15:19:53 -0800 | [diff] [blame] | 318 | """ Test Cases """ |
| 319 | |
Girish Moturu | 2c21eb3 | 2017-05-25 14:37:55 +0530 | [diff] [blame] | 320 | @test_tracker_info(uuid="36d03295-bea3-446e-8342-b9f8f1962a32") |
Girish Moturu | f72690e | 2017-02-14 15:19:53 -0800 | [diff] [blame] | 321 | def test_ipv6_tethering(self): |
| 322 | """ IPv6 tethering test |
| 323 | |
| 324 | Steps: |
Girish Moturu | 2c21eb3 | 2017-05-25 14:37:55 +0530 | [diff] [blame] | 325 | 1. Start wifi tethering on hotspot device |
Girish Moturu | 7df90e3 | 2017-10-16 12:49:56 -0700 | [diff] [blame] | 326 | 2. Verify IPv6 address on hotspot device (VZW & TMO only) |
Girish Moturu | 2c21eb3 | 2017-05-25 14:37:55 +0530 | [diff] [blame] | 327 | 3. Connect tethered device to hotspot device |
Girish Moturu | 7df90e3 | 2017-10-16 12:49:56 -0700 | [diff] [blame] | 328 | 4. Verify IPv6 address on the client's link properties (VZW only) |
| 329 | 5. Verify ping on client using ping6 which should pass (VZW only) |
Girish Moturu | 2c21eb3 | 2017-05-25 14:37:55 +0530 | [diff] [blame] | 330 | 6. Disable mobile data on provider and verify that link properties |
Girish Moturu | 7df90e3 | 2017-10-16 12:49:56 -0700 | [diff] [blame] | 331 | does not have IPv6 address and default route (VZW only) |
Girish Moturu | f72690e | 2017-02-14 15:19:53 -0800 | [diff] [blame] | 332 | """ |
| 333 | # Start wifi tethering on the hotspot device |
Girish Moturu | 2c21eb3 | 2017-05-25 14:37:55 +0530 | [diff] [blame] | 334 | wutils.toggle_wifi_off_and_on(self.hotspot_device) |
| 335 | self._start_wifi_tethering() |
Girish Moturu | f72690e | 2017-02-14 15:19:53 -0800 | [diff] [blame] | 336 | |
| 337 | # Verify link properties on hotspot device |
Girish Moturu | 7f28752 | 2017-09-25 13:33:06 -0700 | [diff] [blame] | 338 | self.log.info("Check IPv6 properties on the hotspot device. " |
| 339 | "Verizon & T-mobile should have IPv6 in link properties") |
Girish Moturu | f72690e | 2017-02-14 15:19:53 -0800 | [diff] [blame] | 340 | self._verify_ipv6_tethering(self.hotspot_device) |
| 341 | |
| 342 | # Connect the client to the SSID |
Girish Moturu | 2c21eb3 | 2017-05-25 14:37:55 +0530 | [diff] [blame] | 343 | wutils.wifi_connect(self.tethered_devices[0], self.network) |
Girish Moturu | f72690e | 2017-02-14 15:19:53 -0800 | [diff] [blame] | 344 | |
| 345 | # Need to wait atleast 2 seconds for IPv6 address to |
| 346 | # show up in the link properties |
Girish Moturu | 7f28752 | 2017-09-25 13:33:06 -0700 | [diff] [blame] | 347 | time.sleep(WAIT_TIME) |
Girish Moturu | f72690e | 2017-02-14 15:19:53 -0800 | [diff] [blame] | 348 | |
| 349 | # Verify link properties on tethered device |
Girish Moturu | 7f28752 | 2017-09-25 13:33:06 -0700 | [diff] [blame] | 350 | self.log.info("Check IPv6 properties on the tethered device. " |
| 351 | "Device should have IPv6 if carrier is Verizon") |
Girish Moturu | 2c21eb3 | 2017-05-25 14:37:55 +0530 | [diff] [blame] | 352 | self._verify_ipv6_tethering(self.tethered_devices[0]) |
Girish Moturu | f72690e | 2017-02-14 15:19:53 -0800 | [diff] [blame] | 353 | |
| 354 | # Verify ping6 on tethered device |
Girish Moturu | 2c21eb3 | 2017-05-25 14:37:55 +0530 | [diff] [blame] | 355 | ping_result = self._verify_ping(self.tethered_devices[0], |
Girish Moturu | 7f28752 | 2017-09-25 13:33:06 -0700 | [diff] [blame] | 356 | wutils.DEFAULT_PING_ADDR, True) |
Girish Moturu | f72690e | 2017-02-14 15:19:53 -0800 | [diff] [blame] | 357 | if self._supports_ipv6_tethering(self.hotspot_device): |
| 358 | asserts.assert_true(ping_result, "Ping6 failed on the client") |
| 359 | else: |
| 360 | asserts.assert_true(not ping_result, "Ping6 failed as expected") |
| 361 | |
| 362 | # Disable mobile data on hotspot device |
| 363 | # and verify the link properties on tethered device |
Girish Moturu | 2c21eb3 | 2017-05-25 14:37:55 +0530 | [diff] [blame] | 364 | self.log.info("Disabling mobile data to verify ipv6 default route") |
Girish Moturu | f72690e | 2017-02-14 15:19:53 -0800 | [diff] [blame] | 365 | self.hotspot_device.droid.telephonyToggleDataConnection(False) |
Girish Moturu | 2c21eb3 | 2017-05-25 14:37:55 +0530 | [diff] [blame] | 366 | asserts.assert_equal( |
| 367 | self.hotspot_device.droid.telephonyGetDataConnectionState(), |
| 368 | tel_defines.DATA_STATE_CONNECTED, |
| 369 | "Could not disable cell data") |
| 370 | |
Girish Moturu | 7f28752 | 2017-09-25 13:33:06 -0700 | [diff] [blame] | 371 | time.sleep(WAIT_TIME) # wait until the IPv6 is removed from link properties |
Girish Moturu | 2c21eb3 | 2017-05-25 14:37:55 +0530 | [diff] [blame] | 372 | |
Girish Moturu | 0fd0b94 | 2017-12-12 12:04:56 -0800 | [diff] [blame] | 373 | result = self.tethered_devices[0].droid.connectivityHasIPv6DefaultRoute() |
Girish Moturu | 2c21eb3 | 2017-05-25 14:37:55 +0530 | [diff] [blame] | 374 | self.hotspot_device.droid.telephonyToggleDataConnection(True) |
Girish Moturu | 7df90e3 | 2017-10-16 12:49:56 -0700 | [diff] [blame] | 375 | if result: |
Girish Moturu | 2c21eb3 | 2017-05-25 14:37:55 +0530 | [diff] [blame] | 376 | asserts.fail("Found IPv6 default route in link properties:Data off") |
Girish Moturu | 7df90e3 | 2017-10-16 12:49:56 -0700 | [diff] [blame] | 377 | self.log.info("Did not find IPv6 address in link properties") |
Girish Moturu | 2c21eb3 | 2017-05-25 14:37:55 +0530 | [diff] [blame] | 378 | |
| 379 | # Disable wifi tethering |
| 380 | wutils.stop_wifi_tethering(self.hotspot_device) |
| 381 | |
| 382 | @test_tracker_info(uuid="110b61d1-8af2-4589-8413-11beac7a3025") |
Girish Moturu | 4736606 | 2018-05-23 12:48:11 -0700 | [diff] [blame] | 383 | def test_wifi_tethering_2ghz_traffic_between_2tethered_devices(self): |
Girish Moturu | 2c21eb3 | 2017-05-25 14:37:55 +0530 | [diff] [blame] | 384 | """ Steps: |
| 385 | |
| 386 | 1. Start wifi hotspot with 2G band |
| 387 | 2. Connect 2 tethered devices to the hotspot device |
| 388 | 3. Ping interfaces between the tethered devices |
| 389 | """ |
Girish Moturu | 95f2f45 | 2018-07-23 15:57:15 -0700 | [diff] [blame] | 390 | asserts.skip_if(not hasattr(self, 'arduino_wifi_dongles'), |
| 391 | "No wifi dongles connected. Skipping test") |
Girish Moturu | 2c21eb3 | 2017-05-25 14:37:55 +0530 | [diff] [blame] | 392 | wutils.toggle_wifi_off_and_on(self.hotspot_device) |
| 393 | self._start_wifi_tethering(WIFI_CONFIG_APBAND_2G) |
| 394 | self._test_traffic_between_two_tethered_devices(self.tethered_devices[0], |
Girish Moturu | 4736606 | 2018-05-23 12:48:11 -0700 | [diff] [blame] | 395 | self.arduino_wifi_dongles[0]) |
Girish Moturu | 2c21eb3 | 2017-05-25 14:37:55 +0530 | [diff] [blame] | 396 | wutils.stop_wifi_tethering(self.hotspot_device) |
| 397 | |
| 398 | @test_tracker_info(uuid="953f6e2e-27bd-4b73-85a6-d2eaa4e755d5") |
Girish Moturu | 7df90e3 | 2017-10-16 12:49:56 -0700 | [diff] [blame] | 399 | def wifi_tethering_5ghz_traffic_between_2tethered_devices(self): |
Girish Moturu | 2c21eb3 | 2017-05-25 14:37:55 +0530 | [diff] [blame] | 400 | """ Steps: |
| 401 | |
| 402 | 1. Start wifi hotspot with 5ghz band |
| 403 | 2. Connect 2 tethered devices to the hotspot device |
| 404 | 3. Send traffic between the tethered devices |
| 405 | """ |
| 406 | wutils.toggle_wifi_off_and_on(self.hotspot_device) |
| 407 | self._start_wifi_tethering(WIFI_CONFIG_APBAND_5G) |
| 408 | self._test_traffic_between_two_tethered_devices(self.tethered_devices[0], |
Girish Moturu | 4736606 | 2018-05-23 12:48:11 -0700 | [diff] [blame] | 409 | self.arduino_wifi_dongles[0]) |
Girish Moturu | 2c21eb3 | 2017-05-25 14:37:55 +0530 | [diff] [blame] | 410 | wutils.stop_wifi_tethering(self.hotspot_device) |
| 411 | |
| 412 | @test_tracker_info(uuid="d7d5aa51-682d-4882-a334-61966d93b68c") |
| 413 | def test_wifi_tethering_2ghz_connect_disconnect_devices(self): |
| 414 | """ Steps: |
| 415 | |
| 416 | 1. Start wifi hotspot with 2ghz band |
| 417 | 2. Connect and disconnect multiple devices randomly |
| 418 | 3. Verify the correct functionality |
| 419 | """ |
| 420 | wutils.toggle_wifi_off_and_on(self.hotspot_device) |
| 421 | self._start_wifi_tethering(WIFI_CONFIG_APBAND_2G) |
Girish Moturu | 4736606 | 2018-05-23 12:48:11 -0700 | [diff] [blame] | 422 | self._connect_disconnect_tethered_devices() |
Girish Moturu | 2c21eb3 | 2017-05-25 14:37:55 +0530 | [diff] [blame] | 423 | wutils.stop_wifi_tethering(self.hotspot_device) |
| 424 | |
| 425 | @test_tracker_info(uuid="34abd6c9-c7f1-4d89-aa2b-a66aeabed9aa") |
| 426 | def test_wifi_tethering_5ghz_connect_disconnect_devices(self): |
| 427 | """ Steps: |
| 428 | |
| 429 | 1. Start wifi hotspot with 5ghz band |
| 430 | 2. Connect and disconnect multiple devices randomly |
| 431 | 3. Verify the correct functionality |
| 432 | """ |
| 433 | wutils.toggle_wifi_off_and_on(self.hotspot_device) |
| 434 | self._start_wifi_tethering(WIFI_CONFIG_APBAND_5G) |
| 435 | self._connect_disconnect_devices() |
| 436 | wutils.stop_wifi_tethering(self.hotspot_device) |
| 437 | |
| 438 | @test_tracker_info(uuid="7edfb220-37f8-42ea-8d7c-39712fbe9be5") |
Girish Moturu | f10ed4c | 2020-06-13 11:03:43 -0700 | [diff] [blame] | 439 | def test_wifi_tethering_wpapsk_network_2g(self): |
Girish Moturu | 2c21eb3 | 2017-05-25 14:37:55 +0530 | [diff] [blame] | 440 | """ Steps: |
| 441 | |
Girish Moturu | f10ed4c | 2020-06-13 11:03:43 -0700 | [diff] [blame] | 442 | 1. Start wifi tethering with wpapsk network 2G band |
| 443 | 2. Connect tethered device to the SSID |
| 444 | 3. Verify internet connectivity |
Girish Moturu | 2c21eb3 | 2017-05-25 14:37:55 +0530 | [diff] [blame] | 445 | """ |
Girish Moturu | f10ed4c | 2020-06-13 11:03:43 -0700 | [diff] [blame] | 446 | self._start_wifi_tethering() |
| 447 | wutils.connect_to_wifi_network(self.tethered_devices[0], |
| 448 | self.network, |
| 449 | check_connectivity=True) |
Girish Moturu | 2c21eb3 | 2017-05-25 14:37:55 +0530 | [diff] [blame] | 450 | |
| 451 | @test_tracker_info(uuid="17e450f4-795f-4e67-adab-984940dffedc") |
Girish Moturu | f10ed4c | 2020-06-13 11:03:43 -0700 | [diff] [blame] | 452 | def test_wifi_tethering_wpapsk_network_5g(self): |
Girish Moturu | 2c21eb3 | 2017-05-25 14:37:55 +0530 | [diff] [blame] | 453 | """ Steps: |
| 454 | |
Girish Moturu | f10ed4c | 2020-06-13 11:03:43 -0700 | [diff] [blame] | 455 | 1. Start wifi tethering with wpapsk network 5G band |
| 456 | 2. Connect tethered device to the SSID |
| 457 | 3. Verify internet connectivity |
Girish Moturu | 2c21eb3 | 2017-05-25 14:37:55 +0530 | [diff] [blame] | 458 | """ |
Girish Moturu | 2c21eb3 | 2017-05-25 14:37:55 +0530 | [diff] [blame] | 459 | self._start_wifi_tethering(WIFI_CONFIG_APBAND_5G) |
Girish Moturu | f10ed4c | 2020-06-13 11:03:43 -0700 | [diff] [blame] | 460 | wutils.connect_to_wifi_network(self.tethered_devices[0], |
| 461 | self.network, |
| 462 | check_connectivity=True) |
Girish Moturu | 2c21eb3 | 2017-05-25 14:37:55 +0530 | [diff] [blame] | 463 | |
Girish Moturu | 2c21eb3 | 2017-05-25 14:37:55 +0530 | [diff] [blame] | 464 | @test_tracker_info(uuid="2bc344cb-0277-4f06-b6cc-65b3972086ed") |
| 465 | def test_change_wifi_hotspot_ssid_when_hotspot_enabled(self): |
| 466 | """ Steps: |
| 467 | |
| 468 | 1. Start wifi tethering |
| 469 | 2. Verify wifi Ap configuration |
| 470 | 3. Change the SSID of the wifi hotspot while hotspot is on |
| 471 | 4. Verify the new SSID in wifi ap configuration |
| 472 | 5. Restart tethering and verify that the tethered device is able |
| 473 | to connect to the new SSID |
| 474 | """ |
Girish Moturu | 2c21eb3 | 2017-05-25 14:37:55 +0530 | [diff] [blame] | 475 | dut = self.hotspot_device |
| 476 | |
| 477 | # start tethering and verify the wifi ap configuration settings |
| 478 | self._start_wifi_tethering() |
| 479 | wifi_ap = dut.droid.wifiGetApConfiguration() |
| 480 | asserts.assert_true( |
| 481 | wifi_ap[wutils.WifiEnums.SSID_KEY] == \ |
| 482 | self.network[wutils.WifiEnums.SSID_KEY], |
| 483 | "Configured wifi hotspot SSID did not match with the expected SSID") |
Girish Moturu | f10ed4c | 2020-06-13 11:03:43 -0700 | [diff] [blame] | 484 | wutils.connect_to_wifi_network(self.tethered_devices[0], self.network) |
Girish Moturu | 2c21eb3 | 2017-05-25 14:37:55 +0530 | [diff] [blame] | 485 | |
| 486 | # update the wifi ap configuration with new ssid |
| 487 | config = {wutils.WifiEnums.SSID_KEY: self.new_ssid} |
| 488 | config[wutils.WifiEnums.PWD_KEY] = self.network[wutils.WifiEnums.PWD_KEY] |
lesl | 6d30a17 | 2020-03-05 15:05:22 +0800 | [diff] [blame] | 489 | config[wutils.WifiEnums.AP_BAND_KEY] = WIFI_CONFIG_APBAND_2G |
Girish Moturu | b0768fa | 2018-02-13 15:24:27 -0800 | [diff] [blame] | 490 | self._save_wifi_softap_configuration(dut, config) |
Girish Moturu | 2c21eb3 | 2017-05-25 14:37:55 +0530 | [diff] [blame] | 491 | |
| 492 | # start wifi tethering with new wifi ap configuration |
| 493 | wutils.stop_wifi_tethering(dut) |
Girish Moturu | b0768fa | 2018-02-13 15:24:27 -0800 | [diff] [blame] | 494 | self._turn_on_wifi_hotspot(dut) |
Girish Moturu | 2c21eb3 | 2017-05-25 14:37:55 +0530 | [diff] [blame] | 495 | |
| 496 | # verify dut can connect to new wifi ap configuration |
| 497 | new_network = {wutils.WifiEnums.SSID_KEY: self.new_ssid, |
| 498 | wutils.WifiEnums.PWD_KEY: \ |
| 499 | self.network[wutils.WifiEnums.PWD_KEY]} |
Girish Moturu | f10ed4c | 2020-06-13 11:03:43 -0700 | [diff] [blame] | 500 | wutils.connect_to_wifi_network(self.tethered_devices[0], new_network) |
Girish Moturu | b0768fa | 2018-02-13 15:24:27 -0800 | [diff] [blame] | 501 | |
| 502 | @test_tracker_info(uuid="4cf7ab26-ca2d-46f6-9d3f-a935c7e04c97") |
| 503 | def test_wifi_tethering_open_network_2g(self): |
| 504 | """ Steps: |
| 505 | |
| 506 | 1. Start wifi tethering with open network 2G band |
| 507 | (Not allowed manually. b/72412729) |
| 508 | 2. Connect tethered device to the SSID |
| 509 | 3. Verify internet connectivity |
| 510 | """ |
Girish Moturu | f10ed4c | 2020-06-13 11:03:43 -0700 | [diff] [blame] | 511 | open_network = { |
| 512 | wutils.WifiEnums.SSID_KEY: "hs_2g_%s" % utils.rand_ascii_str(6) |
| 513 | } |
Girish Moturu | b0768fa | 2018-02-13 15:24:27 -0800 | [diff] [blame] | 514 | wutils.start_wifi_tethering( |
Girish Moturu | f10ed4c | 2020-06-13 11:03:43 -0700 | [diff] [blame] | 515 | self.hotspot_device, |
| 516 | open_network[wutils.WifiEnums.SSID_KEY], |
| 517 | None, |
| 518 | WIFI_CONFIG_APBAND_2G) |
| 519 | wutils.connect_to_wifi_network(self.tethered_devices[0], |
| 520 | open_network, |
| 521 | check_connectivity=True) |
Girish Moturu | b0768fa | 2018-02-13 15:24:27 -0800 | [diff] [blame] | 522 | |
| 523 | @test_tracker_info(uuid="f407049b-1324-40ea-a8d1-f90587933310") |
| 524 | def test_wifi_tethering_open_network_5g(self): |
| 525 | """ Steps: |
| 526 | |
| 527 | 1. Start wifi tethering with open network 5G band |
| 528 | (Not allowed manually. b/72412729) |
| 529 | 2. Connect tethered device to the SSID |
| 530 | 3. Verify internet connectivity |
| 531 | """ |
Girish Moturu | f10ed4c | 2020-06-13 11:03:43 -0700 | [diff] [blame] | 532 | open_network = { |
| 533 | wutils.WifiEnums.SSID_KEY: "hs_5g_%s" % utils.rand_ascii_str(6) |
| 534 | } |
Girish Moturu | b0768fa | 2018-02-13 15:24:27 -0800 | [diff] [blame] | 535 | wutils.start_wifi_tethering( |
Girish Moturu | f10ed4c | 2020-06-13 11:03:43 -0700 | [diff] [blame] | 536 | self.hotspot_device, |
| 537 | open_network[wutils.WifiEnums.SSID_KEY], |
| 538 | None, |
| 539 | WIFI_CONFIG_APBAND_5G) |
| 540 | wutils.connect_to_wifi_network(self.tethered_devices[0], |
| 541 | open_network, |
| 542 | check_connectivity=True) |
Girish Moturu | b0768fa | 2018-02-13 15:24:27 -0800 | [diff] [blame] | 543 | |
| 544 | @test_tracker_info(uuid="d964f2e6-0acb-417c-ada9-eb9fc5a470e4") |
| 545 | def test_wifi_tethering_open_network_2g_stress(self): |
| 546 | """ Steps: |
| 547 | |
| 548 | 1. Save wifi hotspot configuration with open network 2G band |
| 549 | (Not allowed manually. b/72412729) |
| 550 | 2. Turn on wifi hotspot |
| 551 | 3. Connect tethered device and verify internet connectivity |
| 552 | 4. Turn off wifi hotspot |
| 553 | 5. Repeat steps 2 to 4 |
| 554 | """ |
| 555 | # save open network wifi ap configuration with 2G band |
| 556 | config = {wutils.WifiEnums.SSID_KEY: |
| 557 | self.open_network[wutils.WifiEnums.SSID_KEY]} |
lesl | 6d30a17 | 2020-03-05 15:05:22 +0800 | [diff] [blame] | 558 | config[wutils.WifiEnums.AP_BAND_KEY] = WIFI_CONFIG_APBAND_2G |
Girish Moturu | b0768fa | 2018-02-13 15:24:27 -0800 | [diff] [blame] | 559 | self._save_wifi_softap_configuration(self.hotspot_device, config) |
| 560 | |
| 561 | # turn on/off wifi hotspot, connect device |
| 562 | for _ in range(9): |
| 563 | self._turn_on_wifi_hotspot(self.hotspot_device) |
lutina | 8e26ac9 | 2019-11-25 18:38:11 +0800 | [diff] [blame] | 564 | wutils.connect_to_wifi_network(self.tethered_devices[0], self.open_network) |
Girish Moturu | b0768fa | 2018-02-13 15:24:27 -0800 | [diff] [blame] | 565 | wutils.stop_wifi_tethering(self.hotspot_device) |
| 566 | time.sleep(1) # wait for some time before turning on hotspot |
| 567 | |
| 568 | @test_tracker_info(uuid="c7ef840c-4003-41fc-80e3-755f9057b542") |
| 569 | def test_wifi_tethering_open_network_5g_stress(self): |
| 570 | """ Steps: |
| 571 | |
| 572 | 1. Save wifi hotspot configuration with open network 5G band |
| 573 | (Not allowed manually. b/72412729) |
| 574 | 2. Turn on wifi hotspot |
| 575 | 3. Connect tethered device and verify internet connectivity |
| 576 | 4. Turn off wifi hotspot |
| 577 | 5. Repeat steps 2 to 4 |
| 578 | """ |
| 579 | # save open network wifi ap configuration with 5G band |
| 580 | config = {wutils.WifiEnums.SSID_KEY: |
| 581 | self.open_network[wutils.WifiEnums.SSID_KEY]} |
lesl | 6d30a17 | 2020-03-05 15:05:22 +0800 | [diff] [blame] | 582 | config[wutils.WifiEnums.AP_BAND_KEY] = WIFI_CONFIG_APBAND_5G |
Girish Moturu | b0768fa | 2018-02-13 15:24:27 -0800 | [diff] [blame] | 583 | self._save_wifi_softap_configuration(self.hotspot_device, config) |
| 584 | |
| 585 | # turn on/off wifi hotspot, connect device |
| 586 | for _ in range(9): |
| 587 | self._turn_on_wifi_hotspot(self.hotspot_device) |
lutina | 8e26ac9 | 2019-11-25 18:38:11 +0800 | [diff] [blame] | 588 | wutils.connect_to_wifi_network(self.tethered_devices[0], self.open_network) |
Girish Moturu | b0768fa | 2018-02-13 15:24:27 -0800 | [diff] [blame] | 589 | wutils.stop_wifi_tethering(self.hotspot_device) |
| 590 | time.sleep(1) # wait for some time before turning on hotspot |