def stop_iperf_server_on_shell(self): """Stops all the instances of iperf server on shell.""" try: for process in self.iperf_process: stop_standing_subprocess(process) except Exception: pass
def stop_tcpdump(ad, proc, test_name, adb_pull_timeout=adb.DEFAULT_ADB_PULL_TIMEOUT): """Stops tcpdump on any iface Pulls the tcpdump file in the tcpdump dir Args: ad: android device object. proc: need to know which pid to stop test_name: test name to save the tcpdump file adb_pull_timeout: timeout for adb_pull Returns: log_path of the tcpdump file """ ad.log.info("Stopping and pulling tcpdump if any") if proc is None: return None try: stop_standing_subprocess(proc) except Exception as e: ad.log.warning(e) log_path = os.path.join(ad.log_path, test_name) os.makedirs(log_path, exist_ok=True) ad.adb.pull("%s/. %s" % (TCPDUMP_PATH, log_path), timeout=adb_pull_timeout) ad.adb.shell("rm -rf %s/*" % TCPDUMP_PATH, ignore_status=True) file_name = "tcpdump_%s_%s.pcap" % (ad.serial, test_name) return "%s/%s" % (log_path, file_name)
def stop(self): """ Stops iperf server running. """ if not self.started: return utils.stop_standing_subprocess(self.iperf_process) self.started = False
def stop_capture(self): """See base class documentation """ if self._process is None: raise sniffer.InvalidOperationError( "Trying to stop a non-started process") utils.stop_standing_subprocess(self._process, kill_signal=signal.SIGINT) self._post_process()
def stop_adb_logcat(self): """Stops the adb logcat collection subprocess. """ if not self.is_adb_logcat_on: raise AndroidDeviceError( "Android device %s does not have an ongoing adb logcat collection." % self.serial) utils.stop_standing_subprocess(self.adb_logcat_process) self.adb_logcat_process = None
def stop(self): """ Stops iperf server running and get output in case of remote server. """ if not self.started: return if self.server_type == "local": utils.stop_standing_subprocess(self.iperf_process) self.started = False if self.server_type == "remote": self.ssh_session.run_async("kill {}".format(str( self.iperf_process))) iperf_result = self.ssh_session.run( "cat iperf_server_port{}.log".format(self.port)) with open(self.full_out_path, 'w') as f: f.write(iperf_result.stdout) self.ssh_session.run_async("rm iperf_server_port{}.log".format( self.port)) self.started = False
def browsing_test(self, stress_hour_time): """Continue stress http_request and capture log if any fail Args: stress_hour_time: hour of time to stress http_request """ t = threading.Thread(target=self.simulate_roaming) t.start() start_time = time.time() http_request_failed = False while time.time() < start_time + stress_hour_time * 3600: if not self.http_request(): http_request_failed = True self.simulation_thread_running = False t.join() if http_request_failed: self.catch_log() else: stop_standing_subprocess(self.tcpdump_pid) file_name = time.strftime("%Y-%m-%d_%H:%M:%S", time.localtime()) self.tcpdump_pid = start_tcpdump(self.dut, file_name)
def stop(self): if self.started: stop_standing_subprocess(self.iperf_process) self.started = False
def test_stop_standing_subproc(self): p = utils.start_standing_subprocess('sleep 0') time.sleep(0.1) with self.assertRaisesRegex(utils.ActsUtilsError, 'Process .* has terminated'): utils.stop_standing_subprocess(p)