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