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