예제 #1
0
    def set_up(self):
        """
        Initializes this tests.
        """
        # Reset KPI data needed for computing KPI test result
        if self._kpi_test:
            self._kpi_data = KPIUtil()
            self._current_iteration = 0

        # if FTP transfer will be perform
        if self._perform_ftp:

            # check FTP_FILE or local path exist
            if self._direction == "UL":
                # should check local file to upload exist
                local_file_or_path = os.path.join(os.getcwd(), "_Embedded",
                                                  "USERDATA", self._ftp_file)
                msg = "FTP_FILE parameter: local file (%s) not exist" % str(
                    local_file_or_path)
            else:
                # should check local path use to store FTP file to download exist
                local_file_or_path = os.path.join(os.getcwd(), "_Embedded",
                                                  "USERDATA")
                msg = "LOCAL_FILE parameter: local path (%s) not exist" % str(
                    local_file_or_path)
            if os.path.exists(local_file_or_path):
                if self._direction == "UL":
                    self._ftp_file = os.path.join(os.getcwd(), "_Embedded",
                                                  "USERDATA", self._ftp_file)
            else:
                if self._direction == "UL":
                    # In case of UL file to transfer does not exist, create it from its name
                    self._logger.info(
                        "File %s does not exist, generate a file with a size based in its name"
                        % self._ftp_file)
                    self._ftp.retrieve_size_from_filename_and_create_it(
                        local_file_or_path)
                    self._ftp_file = os.path.join(os.getcwd(), "_Embedded",
                                                  "USERDATA", self._ftp_file)
                else:
                    raise AcsConfigException(AcsConfigException.FILE_NOT_FOUND,
                                             msg)

        # In case USB tethering is already activated
        self._disable_tethering()

        # Enable USB tethering connection for KPI tests
        # (no need to activate tethering before each FTP transfer)
        if 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"

        return Global.SUCCESS, "No errors"
    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
예제 #3
0
    def _extract_cts_results_from_cts_report(self, path_to_cts_report, previous_cts_results=None, publishInExternalReport=False):
        """
        Extract in a list the cts tests results from cts xml file

        return structure will be like this:
        {
        package1:
                  {
                  test1:
                        {
                         "NOT_EXECUTED": ["test7", "test8"],
                         "PASS": ["test4", "test6"],
                         "FAIL": ["test1", "test2"],
                  test2: ...
                  ...
                        }
        package2: ...
        }
        :type  path_to_cts_report: str
        :param path_to_cts_report: path to CTS report where result will be extracted

        :type  previous_cts_results: str
        :param previous_cts_results: path to a PREVIOUS CTS report in order to compare results

        :type  publishInExternalReport: str
        :param publishInExternalReport: do we add result in external report

        :rtype: dict
        :return: full cts result by package

        """
        cts_results = None

        self._logger.debug("CTS - _extract_cts_results_from_cts_report starts...")

        if not isinstance(previous_cts_results, dict):
            previous_cts_results = {}

        cts_report_path = ""
        if HttpDownloaderUtil.is_http_uri(path_to_cts_report):
            # Test is available thru URL => download it localy
            result, full_path = self._download_file(path_to_cts_report)
        else:
            result, full_path = self._get_file_path(path_to_cts_report)

        if result != Global.SUCCESS:
            self._logger.error("Cannot find %s" % path_to_cts_report)
        else:
            self._logger.debug("CTS - _extract_cts_results_from_cts_report - CTS report Download OK")
            cts_report_path = full_path

            try:
                cts_parsed_result = et.parse(cts_report_path)
                self._logger.debug("CTS - _extract_cts_results_from_cts_report - Parsing of the CTS report completed")
            except et.XMLSyntaxError:
                error_msg = "CTS report file " + str(
                    cts_report_path) + "- parsing-reading issue (exception= " + str(format_exception_info()) + ")"
                raise AcsToolException(AcsToolException.XML_PARSING_ERROR, error_msg)
            xpath_request_pck = "//TestPackage"
            package_list = cts_parsed_result.getroot().xpath(xpath_request_pck)
            cts_results = previous_cts_results
            results_tc = {}
            for package in package_list:
                self._logger.debug("CTS - _extract_cts_results_from_cts_report - Packages results processing")
                package_name = package.get('appPackageName')
                if package_name is not None:
                    xpath_request_tc = ".//TestCase"
                    tcs = package.xpath(xpath_request_tc)
                    cts_results[package_name] = {}
                    for tc_node in tcs:
                        tc_name = tc_node.get('name')
                        if tc_name is not None:
                            default_value = {"PASS": [], "FAIL": [], "NOT_EXECUTED": []}
                            results_tc = cts_results[package_name].get(tc_name, default_value)
                            xpath_request_test = ".//Test"
                            tests = tc_node.xpath(xpath_request_test)
                            for test_node in tests:
                                test_name = test_node.get('name')
                                if test_name is not None:
                                    test_result = test_node.get("result")
                                    if test_result is not None:
                                        test_result = test_result.lower()
                                    if test_result == "fail":
                                        if publishInExternalReport:
                                            self.__tc_report.add_result(test_name, self.__tc_report.verdict.FAIL,
                                                                        "cts test is FAIL", self.get_name(), self.tc_order)
                                        results_tc["FAIL"].append(test_name)
                                    elif test_result == "pass":
                                        if publishInExternalReport:
                                            self.__tc_report.add_result(test_name, self.__tc_report.verdict.PASS,
                                                                        "cts test is PASS", self.get_name(), self.tc_order)
                                        results_tc["PASS"].append(test_name)
                                    else:
                                        if publishInExternalReport:
                                            self.__tc_report.add_result(test_name, self.__tc_report.verdict.BLOCKED,
                                                                        "cts test has not been executed", self.get_name(
                                                                        ),
                                                                        self.tc_order)
                                        results_tc["NOT_EXECUTED"].append(test_name)
                            cts_results[package_name][tc_name] = results_tc
        return cts_results
예제 #4
0
    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
예제 #5
0
    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
예제 #6
0
    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