1#!/usr/bin/env python3.4
2#
3#   Copyright 2018 - The Android Open Source Project
4#
5#   Licensed under the Apache License, Version 2.0 (the "License");
6#   you may not use this file except in compliance with the License.
7#   You may obtain a copy of the License at
8#
9#       http://www.apache.org/licenses/LICENSE-2.0
10#
11#   Unless required by applicable law or agreed to in writing, software
12#   distributed under the License is distributed on an "AS IS" BASIS,
13#   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14#   See the License for the specific language governing permissions and
15#   limitations under the License.
16
17import pprint
18import queue
19import threading
20import time
21
22import acts.base_test
23import acts_contrib.test_utils.wifi.wifi_test_utils as wutils
24import acts_contrib.test_utils.tel.tel_test_utils as tutils
25
26from acts import asserts
27from acts import signals
28from acts import utils
29from acts.test_decorators import test_tracker_info
30from acts_contrib.test_utils.bt.bt_test_utils import enable_bluetooth
31from acts_contrib.test_utils.bt.bt_test_utils import disable_bluetooth
32from acts_contrib.test_utils.wifi.WifiBaseTest import WifiBaseTest
33WifiEnums = wutils.WifiEnums
34
35WAIT_FOR_AUTO_CONNECT = 40
36WAIT_BEFORE_CONNECTION = 30
37DEFAULT_TIMEOUT = 10
38PING_ADDR = 'www.google.com'
39BAND_2GHZ = 0
40BAND_5GHZ = 1
41
42class WifiStressTest(WifiBaseTest):
43    """WiFi Stress test class.
44
45    Test Bed Requirement:
46    * Two Android device
47    * Several Wi-Fi networks visible to the device, including an open Wi-Fi
48      network.
49    """
50    def __init__(self, configs):
51        super().__init__(configs)
52        self.enable_packet_log = True
53
54    def setup_class(self):
55        super().setup_class()
56
57        self.dut = self.android_devices[0]
58        # Note that test_stress_softAP_startup_and_stop_5g will always fail
59        # when testing with a single device.
60        if len(self.android_devices) > 1:
61            self.dut_client = self.android_devices[1]
62        else:
63            self.dut_client = None
64        wutils.wifi_test_device_init(self.dut)
65        req_params = []
66        opt_param = [
67            "open_network", "reference_networks", "iperf_server_address",
68            "stress_count", "stress_hours", "attn_vals", "pno_interval",
69            "iperf_server_port"]
70        self.unpack_userparams(
71            req_param_names=req_params, opt_param_names=opt_param)
72
73        if "AccessPoint" in self.user_params:
74            self.legacy_configure_ap_and_start(ap_count=2)
75        elif "OpenWrtAP" in self.user_params:
76            self.configure_openwrt_ap_and_start(open_network=True,
77                                                wpa_network=True,
78                                                ap_count=2)
79        asserts.assert_true(
80            len(self.reference_networks) > 0,
81            "Need at least one reference network with psk.")
82        self.wpa_2g = self.reference_networks[0]["2g"]
83        self.wpa_5g = self.reference_networks[0]["5g"]
84        self.open_2g = self.open_network[0]["2g"]
85        self.open_5g = self.open_network[0]["5g"]
86        self.networks = [self.wpa_2g, self.wpa_5g, self.open_2g, self.open_5g]
87
88    def setup_test(self):
89        super().setup_test()
90        self.dut.droid.wakeLockAcquireBright()
91        self.dut.droid.wakeUpNow()
92
93    def teardown_test(self):
94        super().teardown_test()
95        if self.dut.droid.wifiIsApEnabled():
96            wutils.stop_wifi_tethering(self.dut)
97        self.dut.droid.wakeLockRelease()
98        self.dut.droid.goToSleepNow()
99        wutils.reset_wifi(self.dut)
100        self.log.debug("Toggling Airplane mode OFF")
101        asserts.assert_true(
102            acts.utils.force_airplane_mode(self.dut, False),
103            "Can not turn airplane mode off: %s" % self.dut.serial)
104
105    def teardown_class(self):
106        wutils.reset_wifi(self.dut)
107        if "AccessPoint" in self.user_params:
108            del self.user_params["reference_networks"]
109            del self.user_params["open_network"]
110
111    """Helper Functions"""
112
113    def scan_and_connect_by_ssid(self, ad, network):
114        """Scan for network and connect using network information.
115
116        Args:
117            network: A dictionary representing the network to connect to.
118
119        """
120        ssid = network[WifiEnums.SSID_KEY]
121        wutils.start_wifi_connection_scan_and_ensure_network_found(ad, ssid)
122        wutils.wifi_connect(ad, network, num_of_tries=3)
123
124    def scan_and_connect_by_id(self, network, net_id):
125        """Scan for network and connect using network id.
126
127        Args:
128            net_id: Integer specifying the network id of the network.
129
130        """
131        ssid = network[WifiEnums.SSID_KEY]
132        wutils.start_wifi_connection_scan_and_ensure_network_found(self.dut,
133            ssid)
134        wutils.wifi_connect_by_id(self.dut, net_id)
135
136    def run_ping(self, sec):
137        """Run ping for given number of seconds.
138
139        Args:
140            sec: Time in seconds to run teh ping traffic.
141
142        """
143        self.log.info("Running ping for %d seconds" % sec)
144        result = self.dut.adb.shell("ping -w %d %s" %(sec, PING_ADDR),
145            timeout=sec+1)
146        self.log.debug("Ping Result = %s" % result)
147        if "100% packet loss" in result:
148            raise signals.TestFailure("100% packet loss during ping")
149
150    def start_youtube_video(self, url=None, secs=60):
151        """Start a youtube video and check if it's playing.
152
153        Args:
154            url: The URL of the youtube video to play.
155            secs: Time to play video in seconds.
156
157        """
158        ad = self.dut
159        ad.log.info("Start a youtube video")
160        ad.ensure_screen_on()
161        video_played = False
162        for count in range(2):
163            ad.unlock_screen()
164            ad.adb.shell('am start -a android.intent.action.VIEW -d "%s"' % url)
165            if tutils.wait_for_state(ad.droid.audioIsMusicActive, True, 15, 1):
166                ad.log.info("Started a video in youtube.")
167                # Play video for given seconds.
168                time.sleep(secs)
169                video_played = True
170                break
171        if not video_played:
172            raise signals.TestFailure("Youtube video did not start. Current WiFi "
173                "state is %d" % self.dut.droid.wifiCheckState())
174
175    def add_networks(self, ad, networks):
176        """Add Wi-Fi networks to an Android device and verify the networks were
177        added correctly.
178
179        Args:
180            ad: the AndroidDevice object to add networks to.
181            networks: a list of dicts, each dict represents a Wi-Fi network.
182        """
183        for network in networks:
184            ret = ad.droid.wifiAddNetwork(network)
185            asserts.assert_true(ret != -1, "Failed to add network %s" %
186                                network)
187            ad.droid.wifiEnableNetwork(ret, 0)
188        configured_networks = ad.droid.wifiGetConfiguredNetworks()
189        self.log.debug("Configured networks: %s", configured_networks)
190
191    def connect_and_verify_connected_ssid(self, expected_con, is_pno=False):
192        """Start a scan to get the DUT connected to an AP and verify the DUT
193        is connected to the correct SSID.
194
195        Args:
196            expected_con: The expected info of the network to we expect the DUT
197                to roam to.
198        """
199        connection_info = self.dut.droid.wifiGetConnectionInfo()
200        self.log.info("Triggering network selection from %s to %s",
201                      connection_info[WifiEnums.SSID_KEY],
202                      expected_con[WifiEnums.SSID_KEY])
203        self.attenuators[0].set_atten(0)
204        if is_pno:
205            self.log.info("Wait %ss for PNO to trigger.", self.pno_interval)
206            time.sleep(self.pno_interval)
207        else:
208            # force start a single scan so we don't have to wait for the scheduled scan.
209            wutils.start_wifi_connection_scan_and_return_status(self.dut)
210            self.log.info("Wait 60s for network selection.")
211            time.sleep(60)
212        try:
213            self.log.info("Connected to %s network after network selection"
214                          % self.dut.droid.wifiGetConnectionInfo())
215            expected_ssid = expected_con[WifiEnums.SSID_KEY]
216            verify_con = {WifiEnums.SSID_KEY: expected_ssid}
217            wutils.verify_wifi_connection_info(self.dut, verify_con)
218            self.log.info("Connected to %s successfully after network selection",
219                          expected_ssid)
220        finally:
221            pass
222
223    def run_long_traffic(self, sec, args, q):
224        try:
225            # Start IPerf traffic
226            self.log.info("Running iperf client {}".format(args))
227            result, data = self.dut.run_iperf_client(self.iperf_server_address,
228                args, timeout=sec+1)
229            if not result:
230                self.log.debug("Error occurred in iPerf traffic.")
231                self.run_ping(sec)
232            q.put(True)
233        except:
234            q.put(False)
235
236    """Tests"""
237
238    @test_tracker_info(uuid="cd0016c6-58cf-4361-b551-821c0b8d2554")
239    def test_stress_toggle_wifi_state(self):
240        """Toggle WiFi state ON and OFF for N times."""
241        for count in range(self.stress_count):
242            """Test toggling wifi"""
243            try:
244                self.log.debug("Going from on to off.")
245                wutils.wifi_toggle_state(self.dut, False)
246                self.log.debug("Going from off to on.")
247                startTime = time.time()
248                wutils.wifi_toggle_state(self.dut, True)
249                startup_time = time.time() - startTime
250                self.log.debug("WiFi was enabled on the device in %s s." %
251                    startup_time)
252            except:
253                signals.TestFailure(details="", extras={"Iterations":"%d" %
254                    self.stress_count, "Pass":"%d" %count})
255        raise signals.TestPass(details="", extras={"Iterations":"%d" %
256            self.stress_count, "Pass":"%d" %(count+1)})
257
258    @test_tracker_info(uuid="4e591cec-9251-4d52-bc6e-6621507524dc")
259    def test_stress_toggle_wifi_state_bluetooth_on(self):
260        """Toggle WiFi state ON and OFF for N times when bluetooth ON."""
261        enable_bluetooth(self.dut.droid, self.dut.ed)
262        for count in range(self.stress_count):
263            """Test toggling wifi"""
264            try:
265                self.log.debug("Going from on to off.")
266                wutils.wifi_toggle_state(self.dut, False)
267                self.log.debug("Going from off to on.")
268                startTime = time.time()
269                wutils.wifi_toggle_state(self.dut, True)
270                startup_time = time.time() - startTime
271                self.log.debug("WiFi was enabled on the device in %s s." %
272                    startup_time)
273            except:
274                signals.TestFailure(details="", extras={"Iterations":"%d" %
275                    self.stress_count, "Pass":"%d" %count})
276        disable_bluetooth(self.dut.droid)
277        raise signals.TestPass(details="", extras={"Iterations":"%d" %
278            self.stress_count, "Pass":"%d" %(count+1)})
279
280    @test_tracker_info(uuid="49e3916a-9580-4bf7-a60d-a0f2545dcdde")
281    def test_stress_connect_traffic_disconnect_5g(self):
282        """Test to connect and disconnect from a network for N times.
283
284           Steps:
285               1. Scan and connect to a network.
286               2. Run IPerf to upload data for few seconds.
287               3. Disconnect.
288               4. Repeat 1-3.
289
290        """
291        for count in range(self.stress_count):
292            try:
293                net_id = self.dut.droid.wifiAddNetwork(self.wpa_5g)
294                asserts.assert_true(net_id != -1, "Add network %r failed" % self.wpa_5g)
295                self.scan_and_connect_by_id(self.wpa_5g, net_id)
296                # Start IPerf traffic from phone to server.
297                # Upload data for 10s.
298                args = "-p {} -t {}".format(self.iperf_server_port, 10)
299                self.log.info("Running iperf client {}".format(args))
300                result, data = self.dut.run_iperf_client(self.iperf_server_address, args)
301                if not result:
302                    self.log.debug("Error occurred in iPerf traffic.")
303                    self.run_ping(10)
304                wutils.wifi_forget_network(self.dut,self.wpa_5g[WifiEnums.SSID_KEY])
305                time.sleep(WAIT_BEFORE_CONNECTION)
306            except:
307                raise signals.TestFailure("Network connect-disconnect failed."
308                    "Look at logs", extras={"Iterations":"%d" %
309                        self.stress_count, "Pass":"%d" %count})
310        raise signals.TestPass(details="", extras={"Iterations":"%d" %
311            self.stress_count, "Pass":"%d" %(count+1)})
312
313    @test_tracker_info(uuid="e9827dff-0755-43ec-8b50-1f9756958460")
314    def test_stress_connect_long_traffic_5g(self):
315        """Test to connect to network and hold connection for few hours.
316
317           Steps:
318               1. Scan and connect to a network.
319               2. Run IPerf to download data for few hours.
320               3. Run IPerf to upload data for few hours.
321               4. Verify no WiFi disconnects/data interruption.
322
323        """
324        self.scan_and_connect_by_ssid(self.dut, self.wpa_5g)
325        self.scan_and_connect_by_ssid(self.dut_client, self.wpa_5g)
326
327        q = queue.Queue()
328        sec = self.stress_hours * 60 * 60
329        start_time = time.time()
330
331        dl_args = "-p {} -t {} -R".format(self.iperf_server_port, sec)
332        dl = threading.Thread(target=self.run_long_traffic, args=(sec, dl_args, q))
333        dl.start()
334        dl.join()
335
336        total_time = time.time() - start_time
337        self.log.debug("WiFi state = %d" %self.dut.droid.wifiCheckState())
338        while(q.qsize() > 0):
339            if not q.get():
340                raise signals.TestFailure("Network long-connect failed.",
341                    extras={"Total Hours":"%d" %self.stress_hours,
342                    "Seconds Run":"%d" %total_time})
343        raise signals.TestPass(details="", extras={"Total Hours":"%d" %
344            self.stress_hours, "Seconds Run":"%d" %total_time})
345
346    @test_tracker_info(uuid="591d257d-9477-4a89-a220-5715c93a76a7")
347    def test_stress_youtube_5g(self):
348        """Test to connect to network and play various youtube videos.
349
350           Steps:
351               1. Scan and connect to a network.
352               2. Loop through and play a list of youtube videos.
353               3. Verify no WiFi disconnects/data interruption.
354
355        """
356        # List of Youtube 4K videos.
357        videos = ["https://www.youtube.com/watch?v=TKmGU77INaM",
358                  "https://www.youtube.com/watch?v=WNCl-69POro",
359                  "https://www.youtube.com/watch?v=dVkK36KOcqs",
360                  "https://www.youtube.com/watch?v=0wCC3aLXdOw",
361                  "https://www.youtube.com/watch?v=rN6nlNC9WQA",
362                  "https://www.youtube.com/watch?v=RK1K2bCg4J8"]
363        try:
364            self.scan_and_connect_by_ssid(self.dut, self.wpa_5g)
365            start_time = time.time()
366            for video in videos:
367                self.start_youtube_video(url=video, secs=10*60)
368        except:
369            total_time = time.time() - start_time
370            raise signals.TestFailure("The youtube stress test has failed."
371                "WiFi State = %d" %self.dut.droid.wifiCheckState(),
372                extras={"Total Hours":"1", "Seconds Run":"%d" %total_time})
373        total_time = time.time() - start_time
374        self.log.debug("WiFi state = %d" %self.dut.droid.wifiCheckState())
375        raise signals.TestPass(details="", extras={"Total Hours":"1",
376            "Seconds Run":"%d" %total_time})
377
378    @test_tracker_info(uuid="d367c83e-5b00-4028-9ed8-f7b875997d13")
379    def test_stress_wifi_failover(self):
380        """This test does aggressive failover to several networks in list.
381
382           Steps:
383               1. Add and enable few networks.
384               2. Let device auto-connect.
385               3. Remove the connected network.
386               4. Repeat 2-3.
387               5. Device should connect to a network until all networks are
388                  exhausted.
389
390        """
391        for count in range(int(self.stress_count/4)):
392            wutils.reset_wifi(self.dut)
393            ssids = list()
394            for network in self.networks:
395                ssids.append(network[WifiEnums.SSID_KEY])
396                ret = self.dut.droid.wifiAddNetwork(network)
397                asserts.assert_true(ret != -1, "Add network %r failed" % network)
398                self.dut.droid.wifiEnableNetwork(ret, 0)
399            self.dut.droid.wifiStartScan()
400            time.sleep(WAIT_FOR_AUTO_CONNECT)
401            cur_network = self.dut.droid.wifiGetConnectionInfo()
402            cur_ssid = cur_network[WifiEnums.SSID_KEY]
403            self.log.info("Cur_ssid = %s" % cur_ssid)
404            for i in range(0,len(self.networks)):
405                self.log.debug("Forget network %s" % cur_ssid)
406                wutils.wifi_forget_network(self.dut, cur_ssid)
407                time.sleep(WAIT_FOR_AUTO_CONNECT)
408                cur_network = self.dut.droid.wifiGetConnectionInfo()
409                cur_ssid = cur_network[WifiEnums.SSID_KEY]
410                self.log.info("Cur_ssid = %s" % cur_ssid)
411                if i == len(self.networks) - 1:
412                    break
413                if cur_ssid not in ssids:
414                    raise signals.TestFailure("Device did not failover to the "
415                        "expected network. SSID = %s" % cur_ssid)
416            network_config = self.dut.droid.wifiGetConfiguredNetworks()
417            self.log.info("Network Config = %s" % network_config)
418            if len(network_config):
419                raise signals.TestFailure("All the network configurations were not "
420                    "removed. Configured networks = %s" % network_config,
421                        extras={"Iterations":"%d" % self.stress_count,
422                            "Pass":"%d" %(count*4)})
423        raise signals.TestPass(details="", extras={"Iterations":"%d" %
424            self.stress_count, "Pass":"%d" %((count+1)*4)})
425
426    @test_tracker_info(uuid="2c19e8d1-ac16-4d7e-b309-795144e6b956")
427    def test_stress_softAP_startup_and_stop_5g(self):
428        """Test to bring up softAP and down for N times.
429
430        Steps:
431            1. Bring up softAP on 5G.
432            2. Check for softAP on teh client device.
433            3. Turn ON WiFi.
434            4. Verify softAP is turned down and WiFi is up.
435
436        """
437        ap_ssid = "softap_" + utils.rand_ascii_str(8)
438        ap_password = utils.rand_ascii_str(8)
439        self.dut.log.info("softap setup: %s %s", ap_ssid, ap_password)
440        config = {wutils.WifiEnums.SSID_KEY: ap_ssid}
441        config[wutils.WifiEnums.PWD_KEY] = ap_password
442        # Set country code explicitly to "US".
443        wutils.set_wifi_country_code(self.dut, wutils.WifiEnums.CountryCode.US)
444        wutils.set_wifi_country_code(self.dut_client, wutils.WifiEnums.CountryCode.US)
445        for count in range(self.stress_count):
446            initial_wifi_state = self.dut.droid.wifiCheckState()
447            wutils.start_wifi_tethering(self.dut,
448                ap_ssid,
449                ap_password,
450                WifiEnums.WIFI_CONFIG_APBAND_5G)
451            wutils.start_wifi_connection_scan_and_ensure_network_found(
452                self.dut_client, ap_ssid)
453            wutils.stop_wifi_tethering(self.dut)
454            asserts.assert_false(self.dut.droid.wifiIsApEnabled(),
455                                 "SoftAp failed to shutdown!")
456            # Give some time for WiFi to come back to previous state.
457            time.sleep(2)
458            cur_wifi_state = self.dut.droid.wifiCheckState()
459            if initial_wifi_state != cur_wifi_state:
460               raise signals.TestFailure("Wifi state was %d before softAP and %d now!" %
461                    (initial_wifi_state, cur_wifi_state),
462                        extras={"Iterations":"%d" % self.stress_count,
463                            "Pass":"%d" %count})
464        raise signals.TestPass(details="", extras={"Iterations":"%d" %
465            self.stress_count, "Pass":"%d" %(count+1)})
466
467    @test_tracker_info(uuid="eb22e26b-95d1-4580-8c76-85dfe6a42a0f")
468    def test_stress_wifi_roaming(self):
469        AP1_network = self.reference_networks[0]["5g"]
470        AP2_network = self.reference_networks[1]["5g"]
471        wutils.set_attns(self.attenuators, "AP1_on_AP2_off")
472        self.scan_and_connect_by_ssid(self.dut, AP1_network)
473        # Reduce iteration to half because each iteration does two roams.
474        for count in range(int(self.stress_count/2)):
475            self.log.info("Roaming iteration %d, from %s to %s", count,
476                           AP1_network, AP2_network)
477            try:
478                wutils.trigger_roaming_and_validate(self.dut, self.attenuators,
479                    "AP1_off_AP2_on", AP2_network)
480                self.log.info("Roaming iteration %d, from %s to %s", count,
481                               AP2_network, AP1_network)
482                wutils.trigger_roaming_and_validate(self.dut, self.attenuators,
483                    "AP1_on_AP2_off", AP1_network)
484            except:
485                raise signals.TestFailure("Roaming failed. Look at logs",
486                    extras={"Iterations":"%d" %self.stress_count, "Pass":"%d" %
487                        (count*2)})
488        raise signals.TestPass(details="", extras={"Iterations":"%d" %
489            self.stress_count, "Pass":"%d" %((count+1)*2)})
490
491    @test_tracker_info(uuid="e8ae8cd2-c315-4c08-9eb3-83db65b78a58")
492    def test_stress_network_selector_2G_connection(self):
493        """
494            1. Add one saved 2G network to DUT.
495            2. Move the DUT in range.
496            3. Verify the DUT is connected to the network.
497            4. Move the DUT out of range
498            5. Repeat step 2-4
499        """
500        for attenuator in self.attenuators:
501            attenuator.set_atten(95)
502        # add a saved network to DUT
503        networks = [self.reference_networks[0]['2g']]
504        self.add_networks(self.dut, networks)
505        for count in range(self.stress_count):
506            self.connect_and_verify_connected_ssid(self.reference_networks[0]['2g'])
507            # move the DUT out of range
508            self.attenuators[0].set_atten(95)
509            time.sleep(10)
510        wutils.set_attns(self.attenuators, "default")
511        raise signals.TestPass(details="", extras={"Iterations":"%d" %
512            self.stress_count, "Pass":"%d" %(count+1)})
513
514    @test_tracker_info(uuid="5d5d14cb-3cd1-4b3d-8c04-0d6f4b764b6b")
515    def test_stress_pno_connection_to_2g(self):
516        """Test PNO triggered autoconnect to a network for N times
517
518        Steps:
519        1. Save 2Ghz valid network configuration in the device.
520        2. Screen off DUT
521        3. Attenuate 5Ghz network and wait for a few seconds to trigger PNO.
522        4. Check the device connected to 2Ghz network automatically.
523        5. Repeat step 3-4
524        """
525        for attenuator in self.attenuators:
526            attenuator.set_atten(95)
527        # add a saved network to DUT
528        networks = [self.reference_networks[0]['2g']]
529        self.add_networks(self.dut, networks)
530        self.dut.droid.wakeLockRelease()
531        self.dut.droid.goToSleepNow()
532        for count in range(self.stress_count):
533            self.connect_and_verify_connected_ssid(self.reference_networks[0]['2g'], is_pno=True)
534            wutils.wifi_forget_network(
535                    self.dut, networks[0][WifiEnums.SSID_KEY])
536            # move the DUT out of range
537            self.attenuators[0].set_atten(95)
538            time.sleep(10)
539            self.add_networks(self.dut, networks)
540        wutils.set_attns(self.attenuators, "default")
541        raise signals.TestPass(details="", extras={"Iterations":"%d" %
542            self.stress_count, "Pass":"%d" %(count+1)})
543
544    @test_tracker_info(uuid="c880e742-8d20-4134-b717-5b6d45f6c337")
545    def test_2g_sta_wifi_on_off_under_airplane_mode(self):
546        """Toggle WiFi state ON and OFF for N times when airplane mode ON."""
547        self.scan_and_connect_by_ssid(self.dut, self.wpa_2g)
548        self.log.debug("Toggling Airplane mode ON")
549        asserts.assert_true(
550            acts.utils.force_airplane_mode(self.dut, True),
551            "Can not turn on airplane mode on: %s" % self.dut.serial)
552        time.sleep(DEFAULT_TIMEOUT)
553        for count in range(self.stress_count):
554            """Test toggling wifi"""
555            try:
556                self.log.debug("Going from on to off.")
557                wutils.wifi_toggle_state(self.dut, False)
558                self.log.debug("Going from off to on.")
559                startTime = time.time()
560                wutils.wifi_toggle_state(self.dut, True)
561                startup_time = time.time() - startTime
562                self.log.debug("WiFi was enabled on the device in %s s." %
563                    startup_time)
564                time.sleep(DEFAULT_TIMEOUT)
565                # Start IPerf traffic from phone to server.
566                # Upload data for 10s.
567                args = "-p {} -t {}".format(self.iperf_server_port, 10)
568                self.log.info("Running iperf client {}".format(args))
569                result, data = self.dut.run_iperf_client(self.iperf_server_address, args)
570                if not result:
571                    self.log.debug("Error occurred in iPerf traffic.")
572                    self.run_ping(10)
573            except:
574                signals.TestFailure(details="", extras={"Iterations":"%d" %
575                    self.stress_count, "Pass":"%d" %count})
576        raise signals.TestPass(details="", extras={"Iterations":"%d" %
577            self.stress_count, "Pass":"%d" %(count+1)})