def _perform_kpi_throughput_computation(self, msg): """ Perform KPI median throughput computation :type msg: str :param msg: msg to append to result :return: status result :rtype: integer :return: message result :rtype: str """ self._current_iteration += 1 # For KPI test verdict is computed only on median throughput computed on last iteration , # other reasons(exception, iteration not run, not last iteration ...) does not alter the verdict return_status = Global.SUCCESS return_message = msg # If we are in the latest iteration of a KPI test # compute throughput median value and compute verdict on this median value if self._current_iteration == self.get_b2b_iteration(): median_throughput = self._kpi_data.get_median_throughput() (return_status, return_message_tmp) = \ compute_iperf_verdict(median_throughput, self._throughput_targets, self._verdict_direction) return_message = "KPI median throughput: " + return_message_tmp return return_status, return_message
def run_test(self): """ Execute the test """ # Call LAB_WCDMA_BASE Run function LabWcdmaBase.run_test(self) # Start IPERF measurement using PORT # and DURATION and LAB_SERVER ip_address parameters time.sleep(self._wait_btwn_cmd) iperf_settings = \ {"server_ip_address": self._server_ip_address, "port_number": self._port, "duration": self._duration, "protocol": self._iperf_protocol.lower()} if self._tune_options: iperf_settings.update(get_iperf_configuration(self._throughput_targets)) else: iperf_settings.update({'direction': self._iperf_direction}) iperf_settings.update(self._iperf_uldl_parameters) # Update server and DUT IP address in iperf_settings set_iperf_ip_settings(iperf_settings, self._iperf_direction, self._computer, self._networking_api, self._device.get_cellular_network_interface(), self._registration_timeout) if self._computer is not None: iperf_settings.update({"computer": self._computer}) throughput = self._networking_api.iperf(iperf_settings) # Compute verdict depending on throughputs return compute_iperf_verdict(throughput, self._throughput_targets, self._iperf_direction)
def run_test(self): """ Execute the test """ # Call LIVE_WIFI_TETHERING_BASE Run function LiveWifiTetheringBase.run_test(self) # Run Iperf command throughput = self._networking_api.iperf(self._iperf_settings) # Compute verdict depending on throughputs return compute_iperf_verdict(throughput, self._throughput_targets, self._direction)
def run_test(self): """ Execute the test """ # Call LAB_WIFI_BASE Run function LabWifiBase.run_test(self) time.sleep(self._wait_btwn_cmd) # Run Iperf command throughput = self._networking_api.iperf(self._iperf_settings) # Compute verdict depending on throughputs return compute_iperf_verdict(throughput, self._throughput_targets, self._direction)
def run_test(self): """ Execute the test """ # Call LAB_GPRS_BASE Run function LabGprsBase.run_test(self) # Start IPERF measurement using PORT # and DURATION and LAB_SERVER ip_address parameters time.sleep(self._wait_btwn_cmd) throughput = self._networking_api.iperf(self._iperf_settings) # Compute verdict depending on throughputs return compute_iperf_verdict(throughput, self._throughput_targets, self._iperf_direction)
def run(self, context): """ Runs the test step :type context: TestStepContext :param context: test case context """ DeviceTestStepBase.run(self, context) throughput = DuplexThroughputMeasure() throughput.ul_throughput.set( self._pars.ul_value, ThroughputMeasure.parse_unit(self._pars.ul_units)) throughput.dl_throughput.set( self._pars.dl_value, ThroughputMeasure.parse_unit(self._pars.dl_units)) try: throughput_targets = ConfigsParser("BT_Throughput_Targets").\ parse_bt_targets(self._device.get_phone_model(), self._pars.bt_protocol) except IndexError: raise AcsConfigException( AcsConfigException.INVALID_BENCH_CONFIG, "BT_Throughput_Targets does not have targets for %s model and %s protocol" % (self._device.get_phone_model(), self._pars.protocol)) if throughput_targets is None: raise AcsConfigException(AcsConfigException.INVALID_BENCH_CONFIG, "Could not obtain throughput targets") if self._pars.strict_target: throughput_targets.dl_failure = throughput_targets.dl_target throughput_targets.ul_failure = throughput_targets.ul_target verdict, msg = compute_iperf_verdict(throughput, throughput_targets, self._pars.direction) if verdict == Global.FAILURE: self._logger.error("CheckBTIperfResults FAILED!") else: self._logger.info("CheckBTIperfResults PASSED!") self._logger.info("Bluetooth Throughput Measurement Results") self._logger.info(msg) if verdict == Global.FAILURE: raise DeviceException(DeviceException.OPERATION_FAILED, "CheckBTIperfResults failed")
def run_test(self): """ Execute the test """ # Call LAB_WCDMA_BASE Run function LiveCellularBase.run_test(self) time.sleep(self._wait_btwn_cmd) # Start IPERF measurement using PORT # and DURATION and WIFI SERVER ip_address parameters time.sleep(self._wait_btwn_cmd) iperf_settings = \ {"server_ip_address": self._server_ip_address, "port_number": self._port, "duration": self._duration, "protocol": self._iperf_protocol.lower()} iperf_settings.update(get_iperf_configuration(self._throughput_targets)) throughput = self._networking_api.iperf(iperf_settings) # Compute verdict depending on throughputs return compute_iperf_verdict(throughput, self._throughput_targets)
def run_test(self): """ Execute the test. Configuring the internal IPERF server of the equipment. Starting this IPERF server. Launching the IPERF client Computing the throughput to get a verdict. """ result_msg = "" # Call LAB_LTE_BASE Run function LabLteBase.run_test(self) time.sleep(self._wait_btwn_cmd) # Launch the IPERF test and get throughput try: if self._ns_cell_4g.get_cell_status() == "OFF": self._logger.info("4G cell is OFF, restarting it") self._ns_cell_4g.set_cell_on() if self._ns_cell_4g.get_cell_status() == "OFF": self._logger.error( "4G cell is OFF, cannot run test iteration") # raise Exception in order to get proper exit handling raise Exception self._connect_dut_to_4g_cell() # Start asynchronus Iperf iperf_async = self._networking_api.iperf_async( self._iperf_settings) # Throughput Target = PCC throughput targets throughput_targets = copy.deepcopy(self._pcc_throughput_targets) throughput_targets.set_failure_throughput_from_config( self._dut_config, self._failure_targets) # Iperf measure throughput = iperf_async.perform_continous_measure( self._iperf_duration) # Compute Iperf verdict (result_code, result_msg_tmp) = \ compute_iperf_verdict(throughput, throughput_targets, self._iperf_direction) self._logger.info(result_msg_tmp) result_msg += result_msg_tmp + "\n" if result_code == Global.FAILURE: return result_code, result_msg_tmp # Activate SCC self._ns_cell_4g.set_secondary_carrier_state("MACactivate") self._ns_cell_4g.check_secondary_carrier_state_before_timeout( "MACactivate", 30) # Throughput Target = PCC + SCC throughput targets # DL = PCC DL + SCC DL --- UL = PCC UL throughput_targets = copy.deepcopy(self._pcc_throughput_targets) throughput_targets.add_secondary_carrier_throughput_targets( self._scc_throughput_targets) throughput_targets.set_failure_throughput_from_config( self._dut_config, self._failure_targets) # Iperf measure throughput = iperf_async.perform_continous_measure( self._iperf_duration) # Compute Iperf verdict (result_code, result_msg_tmp) = \ compute_iperf_verdict(throughput, throughput_targets, self._iperf_direction) self._logger.info(result_msg_tmp) result_msg += result_msg_tmp + "\n" if result_code == Global.FAILURE: return result_code, result_msg_tmp if self._swap_carrier: # Swap SCC <-> PCC self._ns_cell_4g.swap_primary_and_secondary_carrier_settings() self._ns_cell_4g.check_secondary_carrier_state_before_timeout( "MACactivate", 30) # Throughput Target = SCC + PCC throughput targets # DL = SCC DL + PCC DL --- UL = SCC UL self._pcc_throughput_targets, self._scc_throughput_targets = \ self._scc_throughput_targets, self._pcc_throughput_targets throughput_targets = copy.deepcopy( self._pcc_throughput_targets) throughput_targets.add_secondary_carrier_throughput_targets( self._scc_throughput_targets) throughput_targets.set_failure_throughput_from_config( self._dut_config, self._failure_targets) # Iperf measure throughput = iperf_async.perform_continous_measure( self._iperf_duration) # Compute Iperf verdict (result_code, result_msg_tmp) = \ compute_iperf_verdict(throughput, throughput_targets, self._iperf_direction) self._logger.info(result_msg_tmp) result_msg += result_msg_tmp + "\n" if result_code == Global.FAILURE: return result_code, result_msg_tmp # Deactivate SCC self._ns_cell_4g.set_secondary_carrier_state("OFF") self._ns_cell_4g.check_secondary_carrier_state_before_timeout( "OFF", 30) # Throughput Target = PCC throughput targets throughput_targets = copy.deepcopy(self._pcc_throughput_targets) throughput_targets.set_failure_throughput_from_config( self._dut_config, self._failure_targets) # Iperf measure throughput = iperf_async.perform_continous_measure( self._iperf_duration) # Compute Iperf verdict (result_code, result_msg_tmp) = \ compute_iperf_verdict(throughput, throughput_targets, self._iperf_direction) self._logger.info(result_msg_tmp) result_msg += result_msg_tmp + "\n" if result_code == Global.FAILURE: return result_code, result_msg_tmp # Wait end of IPERF iperf_async.stop_iperf_async() except Exception: result_code = Global.FAILURE result_msg = "!!!! WARNING Exception occurred during iperf test!!! " exception_text = format_exception_info() self._logger.debug("Exception during iperf test: %s ", exception_text) self._logger.error("!!!! Exception occurred during iperf test!!! ") return result_code, result_msg # Return result return Global.SUCCESS, result_msg
def run_test(self): """ Execute the test """ result_code = Global.SUCCESS result_msg = "" result_msg_tmp = "" throughput = None # Call LAB_HSPA_BASE Run function LabTdscdmaBase.run_test(self) # Start IPERF measurement time.sleep(self._wait_btwn_cmd) # Launch the IPERF test and get throughput try: # Force screen on to avoid end of PDP context due to fast dormancy self._phone_system.wake_screen() self._phone_system.set_phone_screen_lock_on(1) if self._ns_data_3g.get_data_connection_status() != "PDP_ACTIVE": self._ns_data_3g.check_data_connection_state( "PDP_ACTIVE", self._registration_timeout, blocking=False) if self._random_port: # Get a randomly generated port self._port = get_random_iperf_port() self._iperf_settings["port_number"] = self._port throughput = self._networking_api.iperf(self._iperf_settings) (result_code, result_msg_tmp) = \ compute_iperf_verdict(throughput, self._throughput_targets, self._iperf_direction) if self._kpi_test: # In case of KPI test, store measured throughput # for final verdict (it will depend of the median value of all measured values) self._kpi_data.append(throughput) result_msg = "KPI test Iteration: %d " \ % (self._current_iteration + 1) + result_msg_tmp else: result_msg = result_msg_tmp except Exception as e: result_code = Global.FAILURE result_msg = "!!!! WARNING Exception occurred during iperf test !!!! " exception_text = format_exception_info() self._logger.warning( "!!!! WARNING Exception occurred during iperf test !!!! ") self._logger.debug("Exception during iperf test: %s ", exception_text) finally: if self._kpi_test: self._current_iteration += 1 # For KPI test verdict is computed only on median throughput computed on last # iteration, other reasons(exception, iteration not run, not last iteration ...) # does not alter the verdict result_code = Global.SUCCESS # If we are in the latest iteration of a KPI test # compute throughput median value and compute verdict on this median value if self._current_iteration == self.get_b2b_iteration(): median_throughput = self._kpi_data.get_median_throughput() self._logger.info("Median Throughput : DL: %s UL %s" % (str(median_throughput.dl_throughput), str(median_throughput.ul_throughput))) (result_code, result_msg_tmp) = compute_iperf_verdict( median_throughput, self._throughput_targets, self._iperf_direction) result_msg = "KPI median throughput: " + result_msg_tmp # Return result return result_code, result_msg
def run_test(self): """ Execute the test. Configuring the internal IPERF server of the equipment. Starting this IPERF server. Launching the IPERF client Computing the throughput to get a verdict. """ result_code = Global.SUCCESS result_msg = "" result_msg_tmp = "" throughput = None # Call LAB_LTE_BASE Run function LabLteBase.run_test(self) time.sleep(self._wait_btwn_cmd) # Launch the IPERF test and get throughput try: if self._ns_cell_4g.get_cell_status() == "OFF": self._logger.info("4G cell is OFF, restarting it") self._ns_cell_4g.set_cell_on() if self._ns_cell_4g.get_cell_status() == "OFF": self._logger.error( "4G cell is OFF, cannot run test iteration") # raise Exception in order to get proper exit handling raise Exception self._connect_dut_to_4g_cell() # If transfer starts from IDLE, reactivate PDP context for windows platform elif self._rrc_state == "RRC_IDLE": self._networking_api.reactivate_pdp_context(self._apn) if self._perform_bler: # IN case of LTE TDD and UDP data transfer, perform BLER measurement the following way: # Wait a quarter of iperf duration (+10 seconds to handle iperf start delays) then perform bler measurement during half of iperf duration bler_measure = BlerMeasurements( float(self._duration) / 2, float(self._duration) / 4 + 10, self._iperf_direction, self._ns_data_4g) bler_measure.start() # clean iperf environment on DUT side self._networking_api.clean_iperf_env() throughput = self._networking_api.iperf(self._iperf_settings) # Retrieve measured block error rate bler = 0.0 bler_msg = "" if self._perform_bler: bler_measure.join() if bler_measure.bler_status: bler = float(bler_measure.bler_measure) self._logger.info("Measured BLER: %s %%" % bler) else: bler = 100.0 bler_msg = "Error during BLER measurement!! " self._logger.error(bler_msg) (result_code, result_msg_tmp) = \ compute_iperf_verdict(throughput, self._throughput_targets, self._iperf_direction, bler) if self._kpi_test: # In case of KPI test, store measured throughput # for final verdict (it will depend of the median value of all measured values) self._kpi_data.append(throughput, bler) result_msg = "KPI test Iteration: %d " % ( self._current_iteration + 1) + result_msg_tmp + bler_msg self._logger.info(result_msg) else: result_msg = result_msg_tmp + bler_msg except Exception: result_code = Global.FAILURE result_msg = "!!!! WARNING Exception occurred during iperf test!!! " exception_text = format_exception_info() self._logger.debug("Exception during iperf test: %s ", exception_text) self._logger.error("!!!! Exception occurred during iperf test!!! ") # Wait end of BLER measurement if self._perform_bler: bler_measure.join() finally: if self._kpi_test: self._current_iteration += 1 # For KPI test verdict is computed only on median throughput computed on last iteration , # other reasons(exception, iteration not run, not last iteration ...) does not alter the verdict result_code = Global.SUCCESS # If we are in the latest iteration of a KPI test # compute throughput median value and compute verdict on this median value if self._current_iteration == self.get_b2b_iteration(): median_throughput = self._kpi_data.get_median_throughput() median_bler = self._kpi_data.get_median_bler() self._logger.info( "Median Throughput : DL: %s UL %s - Median BLER : %.2f" % (str(median_throughput.dl_throughput), str(median_throughput.ul_throughput), median_bler)) (result_code, result_msg_tmp) = compute_iperf_verdict( median_throughput, self._throughput_targets, self._iperf_direction, median_bler) result_msg = "KPI median throughput: " + result_msg_tmp # Return result return result_code, result_msg
def run_test(self): """ Executes the test """ return_status = Global.FAILURE return_message = "" return_message_tmp = "" throughput_value = 0 # Step 1 - Enable USB Tethering for non-KPI test # ----------------------------- if not self._kpi_test: try: self._enable_tethering() except: exception_text = format_exception_info() self._logger.error("Failed to enable USB tethering! ") self._logger.debug("%s ", exception_text) return Global.FAILURE, "Failed to enable USB tethering" # Step 2 (optional) - Perform Successful Ping # ------------------------------------------- if self._ping > 0: self._logger.info("Try to perform %s successful ping" % self._ping) try: packet = self._computer.ping(self._ftp_server, 32, self._ping, unreach_loss=True) self._logger.debug("Ping returned loss: %d%s" % (packet.value, packet.units)) return_message += "Ping: %d packets send and receive successfully and loss is %d%s" \ % (self._ping, packet.value, packet.units) if packet.value == 0: return_status = Global.SUCCESS else: return Global.FAILURE, return_message except TestEquipmentException as error: self._logger.error("Successful ping test Fail.") return_message += "Error: Failed to perform %d ping (%s)." % ( self._ping, str(error)) return Global.FAILURE, return_message self._logger.info("Successful ping test Pass.") # Step 3 (Optional) - Perform FTP upload or download if self._perform_ftp: msg = "Perform FTP transmission (%s) of file: %s" % ( self._direction, self._ftp_file) self._logger.info(msg) # Start FTP transmission try: self._ftp.start_ftp_xfer(self._direction, self._ftp_server, self._username, self._password, self._ftp_file, self._ftp_path) # Throughput is returned in B/s, transform it to Mbits/s # for comparison with targets throughput_value = 8 * self._ftp.get_data_throughput() / 1e6 throughput = DuplexThroughputMeasure() if self._direction.upper() == "UL": throughput.ul_throughput.set(throughput_value, ThroughputMeasure.MBPS_UNIT) if self._direction.upper() == "DL": throughput.dl_throughput.set(throughput_value, ThroughputMeasure.MBPS_UNIT) self._logger.info("FTP transmission Pass") return_message += "- FTP transmission Pass - " # In case of KPI test, store measured throughput # for final verdict (it will depend of the median value of all measured values) (return_status, return_message_tmp) = compute_iperf_verdict( throughput, self._throughput_targets, self._verdict_direction) return_message += return_message_tmp if self._kpi_test: return_message = "KPI test Iteration: %d " % ( self._current_iteration + 1) + return_message_tmp self._kpi_data.append(throughput) except Exception as e: return_message += "- FTP transmission Failed" return_status = Global.FAILURE exception_text = format_exception_info() self._logger.error("FTP transmission Failed: %s ", exception_text) # Restart tethering on KPI test if self._kpi_test: self._disable_tethering() self._enable_tethering() finally: if self._kpi_test: (return_status, return_message ) = self._perform_kpi_throughput_computation( return_message) # Step 4 - Disable USB tethering for non-KPI tests if not self._kpi_test: self._disable_tethering() # Step 5 (optional) - Perform Unsuccessful Ping if self._ping > 0: self._logger.info("Try to perform %s unsuccessful ping" % self._ping) try: packet = self._computer.ping(self._ftp_server, 32, self._ping, unreach_loss=True) self._logger.debug("Ping loss is: %d%%" % packet.value) return_message += "- Ping: %d packets send and receive and loss is %d%%" \ % (self._ping, packet.value) if packet.value >= 100: return_status = Global.SUCCESS else: return Global.FAILURE, return_message except: self._logger.error("Unsuccessful ping test Fail.") return_message += "- Failed to perform %d ping." % self._ping return_status = Global.SUCCESS self._logger.error("Unsuccessful ping test Pass.") # Final return value must be Global.SUCCESS if all steps are passed return return_status, return_message