Reformatting GsmSimulation.py
am: bca26e8f0f

Change-Id: I3ff07557f90a02ae344f8b9c471a164388422335
diff --git a/acts/tests/google/wifi/WifiStressTest.py b/acts/tests/google/wifi/WifiStressTest.py
index b7eccf8..431016c 100755
--- a/acts/tests/google/wifi/WifiStressTest.py
+++ b/acts/tests/google/wifi/WifiStressTest.py
@@ -15,8 +15,6 @@
 #   limitations under the License.
 
 import pprint
-import queue
-import threading
 import time
 
 import acts.base_test
@@ -76,8 +74,6 @@
             self.iperf_server = self.iperf_servers[0]
         if hasattr(self, 'iperf_server'):
             self.iperf_server.start()
-            if(len(self.iperf_servers) > 1):
-                self.iperf_servers[1].start()
 
     def setup_test(self):
         self.dut.droid.wakeLockAcquireBright()
@@ -98,15 +94,13 @@
         wutils.reset_wifi(self.dut)
         if hasattr(self, 'iperf_server'):
             self.iperf_server.stop()
-            if(len(self.iperf_servers) > 1):
-                self.iperf_servers[1].stop()
         if "AccessPoint" in self.user_params:
             del self.user_params["reference_networks"]
             del self.user_params["open_network"]
 
     """Helper Functions"""
 
-    def scan_and_connect_by_ssid(self, ad, network):
+    def scan_and_connect_by_ssid(self, network):
         """Scan for network and connect using network information.
 
         Args:
@@ -114,8 +108,9 @@
 
         """
         ssid = network[WifiEnums.SSID_KEY]
-        wutils.start_wifi_connection_scan_and_ensure_network_found(ad, ssid)
-        wutils.wifi_connect(ad, network, num_of_tries=3)
+        wutils.start_wifi_connection_scan_and_ensure_network_found(self.dut,
+            ssid)
+        wutils.wifi_connect(self.dut, network, num_of_tries=3)
 
     def scan_and_connect_by_id(self, network, net_id):
         """Scan for network and connect using network id.
@@ -227,19 +222,6 @@
         finally:
             pass
 
-    def run_long_traffic(self, sec, args, q):
-        try:
-            # Start IPerf traffic
-            self.log.info("Running iperf client {}".format(args))
-            result, data = self.dut.run_iperf_client(self.iperf_server_address,
-                args, timeout=sec+1)
-            if not result:
-                self.log.debug("Error occurred in iPerf traffic.")
-                self.run_ping(sec)
-            q.put(True)
-        except:
-            q.put(False)
-
     """Tests"""
 
     @test_tracker_info(uuid="cd0016c6-58cf-4361-b551-821c0b8d2554")
@@ -324,38 +306,27 @@
            Steps:
                1. Scan and connect to a network.
                2. Run IPerf to download data for few hours.
-               3. Run IPerf to upload data for few hours.
-               4. Verify no WiFi disconnects/data interruption.
+               3. Verify no WiFi disconnects/data interruption.
 
         """
-        self.scan_and_connect_by_ssid(self.dut, self.wpa_5g)
-        self.scan_and_connect_by_ssid(self.dut_client, self.wpa_5g)
-
-        q = queue.Queue()
-        sec = self.stress_hours * 60 * 60
-        start_time = time.time()
-
-        dl_args = "-p {} -t {} -R".format(self.iperf_server.port, sec)
-        dl = threading.Thread(target=self.run_long_traffic, args=(sec, dl_args, q))
-        dl.start()
-        if(len(self.iperf_servers) > 1):
-            ul_args = "-p {} -t {}".format(self.iperf_servers[1].port, sec)
-            ul = threading.Thread(target=self.run_long_traffic, args=(sec, ul_args, q))
-            ul.start()
-
-        dl.join()
-        if(len(self.iperf_servers) > 1):
-            ul.join()
-
-        total_time = time.time() - start_time
-        self.log.debug("WiFi state = %d" %self.dut.droid.wifiCheckState())
-        while(q.qsize() > 0):
-            if not q.get():
-                raise signals.TestFailure("Network long-connect failed.",
-                    extras={"Total Hours":"%d" %self.stress_hours,
-                    "Seconds Run":"%d" %total_time})
+        try:
+            self.scan_and_connect_by_ssid(self.wpa_5g)
+            # Start IPerf traffic from server to phone.
+            # Download data for 5 hours.
+            sec = self.stress_hours * 60 * 60
+            args = "-p {} -t {} -R".format(self.iperf_server.port, sec)
+            self.log.info("Running iperf client {}".format(args))
+            result, data = self.dut.run_iperf_client(self.iperf_server_address,
+                args, timeout=sec+1)
+            if not result:
+                self.log.debug("Error occurred in iPerf traffic.")
+                self.run_ping(sec)
+        except:
+            raise signals.TestFailure("Network long-connect failed."
+                "Look at logs", extras={"Total Hours":"%d" %self.stress_hours,
+                    "Seconds Run":"UNKNOWN"})
         raise signals.TestPass(details="", extras={"Total Hours":"%d" %
-            self.stress_hours, "Seconds Run":"%d" %total_time})
+            self.stress_hours, "Seconds":"%d" %sec})
 
     @test_tracker_info(uuid="d367c83e-5b00-4028-9ed8-f7b875997d13")
     def test_stress_wifi_failover(self):
@@ -451,7 +422,7 @@
         AP1_network = self.reference_networks[0]["5g"]
         AP2_network = self.reference_networks[1]["5g"]
         wutils.set_attns(self.attenuators, "AP1_on_AP2_off")
-        self.scan_and_connect_by_ssid(self.dut, AP1_network)
+        self.scan_and_connect_by_ssid(AP1_network)
         # Reduce iteration to half because each iteration does two roams.
         for count in range(int(self.stress_count/2)):
             self.log.info("Roaming iteration %d, from %s to %s", count,