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