Ejemplo n.º 1
0
    def __init__(self, tc_name, global_config):
        """
        Constructor
        """
        # Call LAB_HSPA_BASE Init function
        LabHspaBase.__init__(self, tc_name, global_config)

        # Read the DL_FILE value from UseCase xml Parameter
        self._dlfilename = os.path.join(
            self._ftp_path,
            self._tc_parameters.get_param_value("DL_FILENAME", ""))

        # Read the UL_FILE value from UseCase xml Parameter
        self._filename = os.path.join(
            self._ftp_path,
            self._tc_parameters.get_param_value("UL_FILENAME", ""))

        # Read the XFER_TIMEOUT from UseCase xml Parameter
        self._xfer_timeout = \
            int(self._tc_parameters.get_param_value("XFER_TIMEOUT"))

        self._failure_targets = \
            str(self._tc_parameters.get_param_value("FAILURE_TARGETS", "FUTE"))

        # Update the failure targets
        self._throughput_targets.set_failure_throughput_from_config(self._dut_config,
                                                                    self._failure_targets)

        # Log Throughput targets for HSPA
        self._logger.info(throughput_targets_string(self._throughput_targets))
        self._ftp_api = self._device.get_uecmd("Ftp")
Ejemplo n.º 2
0
    def __init__(self, tc_name, global_config):
        """
        Constructor
        """
        # Set the default number of pings to do
        self._nb_pings = 10

        # Set the default data size of a packet
        self._packet_size = 32

        # Call LAB_HSPA_BASE Init function
        LabHspaBase.__init__(self, tc_name, global_config)

        # Getting the parameter WITH_PING from the testcase.
        # Default value is FALSE.
        self._do_ping = str(
            self._tc_parameters.get_param_value("WITH_PING", "FALSE"))
        # Getting the TARGET_PACKET_LOSS_RATE from the testcase.
        self._target_ping_packet_loss_rate = \
            self._tc_parameters.get_param_value("TARGET_PACKET_LOSS_RATE")

        # Getting the RRC_STATE parameter from testcase. Default value
        # is NONE.
        self._rrc_state = str(
            self._tc_parameters.get_param_value("RRC_STATE", "NONE"))

        self._msg = ""
Ejemplo n.º 3
0
    def run_test(self):
        """
        Execute the test
        """
        # Call LAB_HSPA_BASE Run function
        LabHspaBase.run_test(self)

        # Run FTP transfer using FTP parameters :
        # - LAB_SERVER parameters (ip, username, password)
        # - DIRECTION
        # - DL_FILE or UL_FILE
        # - XFER_TIMEOUT
        time.sleep(self._wait_btwn_cmd)
        return perform_ftp_transfer(self._direction,
                                    self._server_ip_address,
                                    self._username,
                                    self._password,
                                    self._filename,
                                    self._xfer_timeout,
                                    self._device.multimedia_path,
                                    self._ns_DUT_IP_Address,
                                    self._ftp_api,
                                    self._throughput_targets.ul_failure.value,
                                    self._logger,
                                    self._dlfilename,
                                    self._throughput_targets.dl_failure.value,
                                    self._device.binaries_path)
Ejemplo n.º 4
0
    def set_up(self):
        """
        Setup the test
        """
        # Call LAB_HSPA_BASE set_up function
        LabHspaBase.set_up(self)

        # PDP deactivation and CPC deactivation to be sure that PDP will be activated
        # without CPC feature enabled

        # Deactivate PDP context
        self._logger.info("Deactive PDP Context for...")
        self._networking_api.deactivate_pdp_context(self._ssid)

        # Deactivate CPC feature
        self._logger.info(
            "CPC deactivation on the equipment by setting CPC to OFF")
        self._ns_data_3g.set_cpc_state("OFF")
        time.sleep(2)

        # Check CPC activated state is Off
        self._cpc_state = self._ns_data_3g.get_cpc_state()

        # PDP activation without CPC feature enabled

        # Activate PDP context
        time.sleep(self._wait_btwn_cmd)
        self._logger.info("Active PDP Context...")
        self._networking_api.activate_pdp_context(self._ssid)

        # Check Data Connection State => PDP Active before timeout
        self._ns_data_3g.check_data_connection_state(
            "PDP_ACTIVE", self._registration_timeout, blocking=False)

        return Global.SUCCESS, "No errors"
Ejemplo n.º 5
0
    def tear_down(self):
        """
        End and dispose the test
        """
        # Stop properly FTP client on DUT side
        try:
            self._ftp_api.stop_ftp(self._ftp_task_id)
        except:
            pass

        # Call LAB_HSPA_BASE tear_down function
        LabHspaBase.tear_down(self)

        return Global.SUCCESS, "No errors"
Ejemplo n.º 6
0
    def __init__(self, tc_name, global_config):
        """
        Constructor
        """
        # Call LAB_HSPA_BASE Init function
        LabHspaBase.__init__(self, tc_name, global_config)

        self._check_data_transfer_state_timeout = 10
        self._timeout_between_commands = 2

        # Read the DL_FILE value from UseCase xml Parameter
        self._cpc_deact_type = self._tc_parameters.get_param_value("CPC_DEACT_TYPE")

        # Read the DL_FILE value from UseCase xml Parameter
        self._dlfilename = os.path.join(
            self._ftp_path,
            self._tc_parameters.get_param_value("DL_FILENAME", ""))

        # Read the UL_FILE value from UseCase xml Parameter
        self._ulfilename = os.path.join(
            self._ftp_path,
            self._tc_parameters.get_param_value("UL_FILENAME", ""))

        # Read the XFER_TIMEOUT from UseCase xml Parameter
        self._xfer_timeout = \
            int(self._tc_parameters.get_param_value("XFER_TIMEOUT"))

        self._ftp_api = self._device.get_uecmd("Ftp")
        self._ftp_task_id = 0

        if self._direction == "DL":
            # Read the DL_FILE value from UseCase xml Parameter
            self._ftp_filename = os.path.join(
                self._ftp_path,
                self._tc_parameters.get_param_value("DL_FILENAME"))
            self._direction = UECmdTypes.XFER_DIRECTIONS.DL
        elif self._direction == "UL":
            # Read the UL_FILE value from UseCase xml Parameter
            self._ftp_filename = os.path.join(
                self._ftp_path,
                self._tc_parameters.get_param_value("UL_FILENAME"))
            self._direction = UECmdTypes.XFER_DIRECTIONS.UL
        else:
            self._error.Msg = "%s is not a known xfer direction" % \
                self._direction
            raise TestEquipmentException(
                TestEquipmentException.INVALID_PARAMETER,
                self._error.Msg)
Ejemplo n.º 7
0
    def __init__(self, tc_name, global_config):
        """
        Constructor
        """
        # Call LAB_HSPA_BASE Init function
        LabHspaBase.__init__(self, tc_name, global_config)

        # Read the number of pings to do
        self._nb_pings = self._tc_parameters.get_param_value("PACKET_COUNT")

        # Read the data size of a packet
        self._packet_size = self._tc_parameters.get_param_value("PACKET_SIZE")

        # Get target % of received packet for ping
        self._target_ping_packet_loss_rate = \
            float(self._tc_parameters.get_param_value("TARGET_PACKET_LOSS_RATE"))
Ejemplo n.º 8
0
    def set_up(self):
        """
        Set up the test configuration
        """

        LabHspaBase.set_up(self)

        self._data_3g.set_cqi_test_set_up()

        if 0 == len(self._measure_cell_power_list):
            raise AcsConfigException(
                AcsConfigException.INVALID_PARAMETER,
                "MEASURE_CELL_POWER_LIST should contain"
                "at least one cell power value")

        return Global.SUCCESS, self._error.Msg
Ejemplo n.º 9
0
    def __init__(self, tc_name, global_config):
        """
        Constructor
        """
        # Call LAB_HSPA_BASE Init function
        LabHspaBase.__init__(self, tc_name, global_config)

        self._ns_fast_dormancy = "enable"
        self._timeout_between_commands = 5

        # Read the ftp file name from UseCase xml Parameter
        if self._direction == "DL":
            self._ftp_filename = os.path.join(
                self._ftp_path,
                self._tc_parameters.get_param_value("DL_FILENAME"))
        elif self._direction == "UL":
            # Read the UL_FILE value from UseCase xml Parameter
            self._ftp_filename = os.path.join(
                self._ftp_path,
                self._tc_parameters.get_param_value("UL_FILENAME"))

        # Read the XFER_TIMEOUT from UseCase xml Parameter
        self._xfer_timeout = \
            self._tc_parameters.get_param_value("XFER_TIMEOUT")
        if self._xfer_timeout is not None and \
                str(self._xfer_timeout).isdigit():
            self._xfer_timeout = int(self._xfer_timeout)
        else:
            self._xfer_timeout = None
        # Timeout to wait for RRC switch from RRC_DCH to Idle
        self._rrc_idle_timeout = \
            self._tc_parameters.get_param_value("RRC_IDLE_TIMEOUT")
        if self._rrc_idle_timeout is not None and \
                str(self._rrc_idle_timeout).isdigit():
            self._rrc_idle_timeout = int(self._rrc_idle_timeout)
        else:
            self._rrc_idle_timeout = None
        # inactivity timer for RRC state change
        self._rrc_inactivity_timer = \
            self._tc_parameters.get_param_value("RRC_INACTIVITY_TIMER")
        if self._rrc_inactivity_timer is not None and \
                str(self._rrc_inactivity_timer).isdigit():
            self._rrc_inactivity_timer = int(self._rrc_inactivity_timer)
        else:
            self._rrc_inactivity_timer = None
Ejemplo n.º 10
0
    def tear_down(self):
        """
        End and dispose the test
        """
        # Stop properly FTP client on DUT side
        try:
            self._ftp_api.stop_ftp(self._ftp_task_id)
        except:
            pass

        # Deactivate CPC feature
        self._logger.info("CPC deactivation on the equipment by setting CPC to Off")
        self._ns_data_3g.set_cpc_state("OFF")

        # Call LAB_HSPA_BASE tear_down function
        LabHspaBase.tear_down(self)

        return Global.SUCCESS, "No errors"
Ejemplo n.º 11
0
    def run_test(self):
        """
        Execute the test
        """
        test_result = Global.FAILURE
        # Call LAB_HSPA_BASE Run function
        LabHspaBase.run_test(self)

        time.sleep(self._wait_btwn_cmd)

        self._networking_api.ftp_xfer(self._direction,
                                      self._server_ip_address,
                                      self._username,
                                      self._password,
                                      self._ftp_filename,
                                      self._xfer_timeout,
                                      self._device.get_ftpdir_path())

        # TODO: For the moment, we can't stop all the google data services
        # and ntp service, we have to wait the service stop itself
        time.sleep(60)

        timer = 0
        # PDP should always stay activate and RRC should pass to IDLE state before timeout
        while timer < self._rrc_idle_timeout:
            data_connection_status = self._ns_data_3g.get_data_connection_status()
            rrc_states = self._ns_data_3g.get_rrc_states()
            states_msg = "data_connection_status: %s rrc_states: %s after %d " % \
                (data_connection_status,
                 rrc_states,
                 timer)
            self._logger.info(states_msg)
            if data_connection_status != "PDP_ACTIVE":
                self._error.Msg = "Failed to reach PDP_ACTIVE data state"
                raise DeviceException(DeviceException.OPERATION_FAILED, self._error.Msg)
            if rrc_states == "IDLE":
                self._error.Msg = states_msg
                test_result = Global.SUCCESS
                break
            time.sleep(1)
            timer += 1

        return test_result, self._error.Msg
Ejemplo n.º 12
0
    def __init__(self, tc_name, global_config):
        """
        Constructor
        """
        # Call LAB_HSPA_BASE Init function
        LabHspaBase.__init__(self, tc_name, global_config)

        # Read the DL_FILE value from UseCase xml Parameter
        self._dlfilename = os.path.join(
            self._ftp_path,
            self._tc_parameters.get_param_value("DL_FILENAME", ""))

        # Read the UL_FILE value from UseCase xml Parameter
        self._ulfilename = os.path.join(
            self._ftp_path,
            self._tc_parameters.get_param_value("UL_FILENAME", ""))

        # Read the XFER_TIMEOUT from UseCase xml Parameter
        self._xfer_timeout = \
            int(self._tc_parameters.get_param_value("XFER_TIMEOUT"))

        # Initializing the variable which will contain the IP address to use.
        self._check_data_transfer_state_timeout = 20
        self._ip_address_list = []
        self._ftp_task_id = 0
        self._timeout = None
        self._ftp_api = self._device.get_uecmd("Ftp")

        # IF DIRECTION is DL prepare for download FTP
        if self._direction == "DL":
            self._ftp_filename = self._dlfilename
            self._direction = UECmdTypes.XFER_DIRECTIONS.DL
        # IF DIRECTION is UL prepare for upload FTP
        elif self._direction == "UL":
            self._ftp_filename = self._ulfilename
            self._direction = UECmdTypes.XFER_DIRECTIONS.UL
        # ELSE raise an error
        else:
            # Raise an error in case the direction is not known
            msg = "Unknown ftp direction (%s)" % self._ftp_direction
            self._logger.error(msg)
            raise AcsConfigException(AcsConfigException.INVALID_PARAMETER, msg)
Ejemplo n.º 13
0
    def __init__(self, tc_name, global_config):
        """
        Constructor
        """
        # Call LAB_HSPA_BASE Init function
        LabHspaBase.__init__(self, tc_name, global_config)

        self._measure_cell_power_list = self._tc_parameters.\
                    get_param_value("MEASURE_CELL_POWER_LIST").split(",")
        # Read the ftp file name from UseCase xml Parameter
        if self._direction == "DL":
            self._ftp_filename = os.path.join(
                self._ftp_path,
                self._tc_parameters.get_param_value("DL_FILENAME"))
        elif self._direction == "UL":
            # Read the UL_FILE value from UseCase xml Parameter
            self._ftp_filename = os.path.join(
                self._ftp_path,
                self._tc_parameters.get_param_value("UL_FILENAME"))

        self._cqi_result_dico = {}
        self._ftp_data_transfer_state_timeout = 2
Ejemplo n.º 14
0
    def set_up(self):
        """
        Initialize the test
        """

        LabHspaBase.set_up(self)

        if self._xfer_timeout is None:
            raise AcsConfigException(AcsConfigException.INVALID_PARAMETER,
                                   "XFER_TIMEOUT should be int")
        if self._rrc_idle_timeout is None:
            raise AcsConfigException(AcsConfigException.INVALID_PARAMETER,
                                   "RRC_IDLE_TIMEOUT should be int")
        if self._rrc_inactivity_timer is None:
            raise AcsConfigException(AcsConfigException.INVALID_PARAMETER,
                                   "RRC_INACTIVITY_TIMER should be int")
        # We should stop all the applications which reques the data from the netwrok
        app_list = ["com.google.android.youtube"]
        for app in app_list:
            cmd = "adb shell am force-stop %s" % app
            self._device.run_cmd(cmd, 3)

        return Global.SUCCESS, self._error.Msg
Ejemplo n.º 15
0
    def set_up(self):
        """
        Initialize the test
        """
        LabHspaBase.set_up(self)

        # Reset KPI data needed for computing KPI test result
        if self._kpi_test:
            self._kpi_data = KPIUtil()
            self._current_iteration = 0

        # Update server and DUT IP address in iperf_settings
        set_iperf_ip_settings(self._iperf_settings, self._iperf_direction,
                              self._computer, self._networking_api,
                              self._device.get_cellular_network_interface(),
                              self._registration_timeout)

        # Get the iperf configuration corresponding to the target throughput to reach
        if self._tune_options:
            self._iperf_settings.update(
                get_iperf_configuration(self._throughput_targets,
                                        self._iperf_direction))
        else:
            self._iperf_settings.update({'direction': self._iperf_direction})

            self._iperf_settings.update(self._iperf_uldl_parameters)

            if self._iperf_protocol.upper() == "UDP":
                compute_iperf_bw(self._iperf_settings,
                                 self._throughput_targets)

        # Force screen on to avoid end of PDP context due to fast dormancy
        # setting screen timeout to 0 means set it to the maximum value possible
        self._phone_system.set_screen_timeout(0)
        self._phone_system.wake_screen()
        self._phone_system.set_phone_screen_lock_on(1)
        return Global.SUCCESS, "No errors"
Ejemplo n.º 16
0
 def set_up(self):
     # Calling the LabHspase set_up function.
     (code, msg) = LabHspaBase.set_up(self)
     if code == Global.FAILURE:
         # If the base setup fails return its fail, and exit.
         return code, msg
     # Check if ping is needed for the test.
     if self._do_ping.upper() in ("TRUE", "FALSE"):
         self._do_ping = str_to_bool(self._do_ping)
     else:
         raise AcsConfigException(
             AcsConfigException.INVALID_PARAMETER,
             "The DO_PING parameter should be TRUE or "
             "FALSE not %s" % self._do_ping)
     if self._do_ping:
         self._logger.info("The test will use ping to test the PDP during"
                           " this test.")
         # If yes check the target ping packet lost as a correct value.
         if isinstance(self._target_ping_packet_loss_rate, (int, float)):
             self._target_ping_packet_loss_rate = \
                 float(self._target_ping_packet_loss_rate)
         else:
             # if user doesn't enter the correct value, set the default
             # value 0
             self._target_ping_packet_loss_rate = 0
     else:
         self._logger.info("The test won't use ping to test the PDP during"
                           " this test.")
     # Checking the value of the RRC_STATUS parameter is in the expected
     # range.
     if not self._rrc_state in ("NONE", "IDLE", "DCH", "FACH"):
         raise AcsConfigException(
             AcsConfigException.INVALID_PARAMETER,
             "The RRC_STATUS parameter should be "
             "NONE, IDLE, DCH, FACH not %s" % self._rrc_state)
     return Global.SUCCESS, "No error"
Ejemplo n.º 17
0
    def run_test(self):
        """
        Execute the test
        """
        # Call LAB_HSPA_BASE Run function
        LabHspaBase.run_test(self)

        # init values
        self._error.Code = Global.FAILURE
        self._error.Msg = "ping failed"

        time.sleep(self._wait_btwn_cmd)

        if self._ip_version == "IPV6":
            # If IPV6 is chosen, use ping6 function
            packet_loss = self._networking_api.\
                ping6(self._server_ip_v6_address,
                      self._packet_size,
                      self._nb_pings)

            # Compute verdict depending on % of packet loss
            if packet_loss.value > self._target_ping_packet_loss_rate:
                self._error.Code = Global.FAILURE
            else:
                self._error.Code = Global.SUCCESS

            self._error.Msg = "Measured Packet Loss: %.0f%s (Target: %.0f%s)"\
                % (packet_loss.value,
                   packet_loss.units,
                   self._target_ping_packet_loss_rate,
                   packet_loss.units)

        elif self._ip_version == "IPV4V6":
            # If IPV4V6 is chosen, use also ping function
            packet_loss_ping = self._networking_api.\
                ping(self._server_ip_address,
                     self._packet_size,
                     self._nb_pings)
            # If IPV4V6 is chosen, use ping6 function
            packet_loss_ping6 = self._networking_api.\
                ping6(self._server_ip_v6_address,
                      self._packet_size,
                      self._nb_pings)

            # Compute verdict depending on % of packet loss
            if (packet_loss_ping.value > self._target_ping_packet_loss_rate) or \
                    (packet_loss_ping6.value > self._target_ping_packet_loss_rate):
                self._error.Code = Global.FAILURE
            else:
                self._error.Code = Global.SUCCESS

            self._error.Msg = "Measured IPV4 Packet Loss: %.0f%s (Target: %.0f%s) and Measured IPV6 Packet Loss: %.0f%s (Target: %.0f%s)"\
                % (packet_loss_ping.value,
                   packet_loss_ping.units,
                   self._target_ping_packet_loss_rate,
                   packet_loss_ping.units,
                   packet_loss_ping6.value,
                   packet_loss_ping6.units,
                   self._target_ping_packet_loss_rate,
                   packet_loss_ping6.units)

        else:
            # If IPV4 is chosen, use ping function
            packet_loss = self._networking_api.\
                ping(self._server_ip_address,
                     self._packet_size,
                     self._nb_pings)

            # Compute verdict depending on % of packet loss
            if packet_loss.value > self._target_ping_packet_loss_rate:
                self._error.Code = Global.FAILURE
            else:
                self._error.Code = Global.SUCCESS

            self._error.Msg = "Measured Packet Loss: %.0f%s (Target: %.0f%s)"\
                % (packet_loss.value,
                   packet_loss.units,
                   self._target_ping_packet_loss_rate,
                   packet_loss.units)

        self._logger.info("Test result : " + self._error.Msg)

        return self._error.Code, self._error.Msg
Ejemplo n.º 18
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
        LabHspaBase.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._random_port:
                # Get a randomly generated port
                self._port = get_random_iperf_port()
                self._iperf_settings["port_number"] = self._port

            self._networking_api.reactivate_pdp_context(self._ssid, False)
            if self._ns_data_3g.get_data_connection_status() != "PDP_ACTIVE":
                self._networking_api.reactivate_pdp_context(self._ssid, False)
                self._ns_data_3g.check_data_connection_state(
                    "PDP_ACTIVE", self._registration_timeout, blocking=False)

            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
Ejemplo n.º 19
0
    def run_test(self):
        """
        Execute the test
        """
        # Call LAB_HSPA_BASE Run function
        LabHspaBase.run_test(self)

        self._logger.info("FTP transfer " + str(self._direction) + " for " +
                          str(self._ftp_filename) + "...")

        self._ftp_task_id = self._networking_api.start_ftp_xfer(
            self._direction, self._server_ip_address, self._username,
            self._password, self._ftp_filename, self._device.get_ftpdir_path())

        # Measure the information_bit_throughput for all the cell powers in the list
        for cell_power in self._measure_cell_power_list:
            self._ns_cell_3g.set_cell_power(int(cell_power))
            # Wait for the device adjust to new cell power
            time.sleep(3)
            information_bit_throughput = 0
            measure_times = 0
            # Measure 5 times and calculate the average
            for i in xrange(5):
                # Ensure the data transfer is still ongoing before measurement
                self._data_3g.check_data_connection_transferring(
                    self._ftp_data_transfer_state_timeout, True)
                xfer_status = self._networking_api.get_ftp_xfer_status()
                # Quit from measurement,  once ftp tranfert stop
                if "transferring" != xfer_status:
                    msg = "FTP transfer is %s before measurement start " % xfer_status
                    self._logger.info(msg)
                    break

                try:
                    throughput = self._data_3g.get_information_bit_throughput()
                except TestEquipmentException:
                    self._logger.info("The %d th measurement of power %s is failed"\
                                       % (i, cell_power))
                    throughput = float("nan")

                if math.isnan(throughput):
                    self._logger.debug("throughput can't be retrieved")
                else:
                    information_bit_throughput = information_bit_throughput + throughput
                    measure_times += 1

            if 0 == measure_times:
                self._logger.info("The measurement of power %d is failed" %
                                  cell_power)
                self._cqi_result_dico.update({cell_power: "N/A"})
            else:
                average_bit_throughput = round(information_bit_throughput /
                                               measure_times)
                self._cqi_result_dico.update(
                    {cell_power: average_bit_throughput})
            self._logger.debug("cqi_results: %s " % str(self._cqi_result_dico))

        # Create the output message
        for key in self._measure_cell_power_list:
            self._error.Msg = self._error.Msg + " Power: " + str(key) + "db throughput: "\
                        + str(self._cqi_result_dico[key]) + " kbps "

        self._networking_api.stop_ftp_xfer(self._ftp_task_id)

        return Global.SUCCESS, self._error.Msg
Ejemplo n.º 20
0
    def __init__(self, tc_name, global_config):

        # Call LAB_HSPA_BASE Init function
        LabHspaBase.__init__(self, tc_name, global_config)

        # Read Iperf PORT
        self._port = self._tc_parameters.get_param_value("PORT")

        if self._port in (None, "", "None"):
            # If no port are specified use a randomly generated port
            self._random_port = True
        else:
            self._port = int(self._port)
            self._random_port = False

        # Read Iperf measurement duration
        self._duration = \
            int(self._tc_parameters.get_param_value("DURATION"))

        # Read Iperf protocol
        self._iperf_protocol = \
            self._tc_parameters.get_param_value("IPERF_PROTOCOL", "TCP").lower()

        # Get TCP window size
        # window size > tput_to_reach * round_trip_time (200ms for HSPA)
        # Iperf compute automatically the windows size.
        # It is better to not set a window size as result with iperf default size are pretty good
        self._iperf_uldl_parameters = retrieve_parameters_from_tc_params(
            self._tc_parameters)

        # Get computer type
        self._computer_temp = self._tc_parameters.get_param_value(
            "COMPUTER", "IPERF_SERVER")

        # Detect if it is a KPI test or not
        if self._kpi_test:
            self._logger.info("It is a KPI test")
            self._kpi_data = None
            self._current_iteration = 0

        # Read Iperf TUNE OPTIONS
        self._tune_options = self._tc_parameters.get_param_value(
            "IPERF_TUNE_OPTIONS", "0")
        if self._tune_options in (None, "", 0, '0', 'off', 'OFF'):
            self._tune_options = 0
        else:
            self._tune_options = 1

        # Load computer equipment
        if self._computer_temp is not None:
            self._computer = self._em.get_computer(self._computer_temp)

        self._computer_type = \
            global_config.benchConfig.get_parameters(self._computer_temp)

        # Get server IP address
        self._server_ip_address = self._computer_type.get_param_value("IP")

        # Set Iperf direction
        if self._direction in ("UL", "up", None):
            self._iperf_direction = "up"
        elif self._direction in ("DL", "down"):
            self._iperf_direction = "down"
        else:
            self._iperf_direction = "both"

        self._iperf_settings = {
            "server_ip_address": self._server_ip_address,
            "port_number": self._port,
            "duration": self._duration,
            "protocol": self._iperf_protocol,
            "computer": self._computer
        }

        # Get customized failure Targets
        self._failure_targets = \
            str(self._tc_parameters.get_param_value("FAILURE_TARGETS", ""))

        # Update the failure targets
        self._throughput_targets.set_failure_throughput_from_config(
            self._dut_config, self._failure_targets, self._kpi_test,
            tc_name._name)

        # Log Throughput targets for HSPA
        self._logger.info(throughput_targets_string(self._throughput_targets))
Ejemplo n.º 21
0
    def run_test(self):
        """
        Execute the test
        """
        # Call LAB_HSPA_BASE Run function
        LabHspaBase.run_test(self)

        # Activate PDP context
        time.sleep(self._wait_btwn_cmd)
        self._logger.info("Active PDP Context...")
        self._networking_api.activate_pdp_context(self._ssid)

        # Check Data Connection State => PDP Active before timeout
        self._ns_data_3g.check_data_connection_state(
            "PDP_ACTIVE", self._registration_timeout, blocking=False)

        # Get RAT from Equipment
        network_type = self._ns_data_3g.get_network_type()

        # Check that DUT is registered on the good RAT
        self._modem_api.check_network_type_before_timeout(
            network_type, self._registration_timeout)

        # Check IP protocol
        self._msg = self._networking_api.check_ip_protocol(self._ip_version)
        self._logger.info(self._msg)

        if self._rrc_state == "FACH":
            # If the RRC_STATE was set to FACH, set the RRC transition to
            # FACH
            self._logger.info("Setting the rrc_state transition to FACH")
            self._ns_cell_3g.set_rrc_state_transition("FACH")
            time.sleep(5)

        if self._do_ping:
            # Ping FTP server to verify PDP context activated.
            # Ping should be successful
            packet_loss = self._networking_api.ping(self._server_ip_address,
                                                    self._packet_size,
                                                    self._nb_pings)

            self._error.Msg = "Measured Packet Loss: %.0f%s (Target: %.0f%s)"\
                    % (packet_loss.value, packet_loss.units,
                       self._target_ping_packet_loss_rate,
                       packet_loss.units)

            # Compute verdict depending on % of packet loss
            # PDP Context active, ping should be successful
            if packet_loss.value > self._target_ping_packet_loss_rate:
                raise DeviceException(DeviceException.OPERATION_FAILED,
                                      self._error.Msg)
            else:
                self._logger.info("Ping successful:  %s" % self._error.Msg)

        # Deactivate PDP context
        self._logger.info("Deactivation of the PDP Context")
        self._networking_api.deactivate_pdp_context(self._ssid)

        # Check ATTACHED Data Connection State
        # We can't use check_data_connection_state function, because the UE
        # should switch from PDP_ACTIVE state to ATTACHED state, but in this function
        # "PDP_ACTIVE" means already "ATTACHED" in telephony context.
        timer = self._registration_timeout
        while (timer > 0) and (self._ns_data_3g.get_data_connection_status() !=
                               "ATTACHED"):
            timer -= 1
            time.sleep(1)

        # Check that DUT does not have any IP address
        self._networking_api.check_no_ip_address()

        if self._do_ping:
            # Ping FTP server to verify PDP context deactivated.
            # The test should be failed
            try:
                packet_loss = self._networking_api.ping(
                    self._server_ip_address, self._packet_size, self._nb_pings)
            except AcsBaseException as error:
                self._logger.info(error.get_error_message())
            else:
                raise DeviceException(
                    DeviceException.OPERATION_FAILED,
                    "PDP context isn't correctly "
                    "deactivated, ping packets reach the"
                    " server.")
        # Reactivate PDP context
        self._networking_api.activate_pdp_context(self._ssid)

        self._ns_data_3g.check_data_connection_state(
            "PDP_ACTIVE", self._registration_timeout, blocking=False)

        if self._do_ping:
            packet_loss = self._networking_api.ping(self._server_ip_address,
                                                    self._packet_size,
                                                    self._nb_pings)
            # Compute verdict depending on % of packet loss
            # PDP Context active, ping should be successful
            if packet_loss.value > self._target_ping_packet_loss_rate:
                raise DeviceException(DeviceException.OPERATION_FAILED,
                                      self._error.Msg)
            else:
                self._logger.info("Ping successful:  %s" % self._error.Msg)
        return Global.SUCCESS, "no errors"
Ejemplo n.º 22
0
    def run_test(self):
        """
        Execute the test
        """
        # Call LAB_HSPA_BASE run_test function
        LabHspaBase.run_test(self)

        # Run FTP transfer using FTP parameters :
        # - LAB_SERVER parameters (ip, username, password)
        # - DIRECTION
        # - DL_FILE or UL_FILE
        # - XFER_TIMEOUT
        # Start an ftp tranfer
        transfer_established_timeout = 20

        if self._cpc_state == "OFF":

            # Start FTP transfer if CPC is deactivated
            # Use private method __start_ftp_xfer
            self.__start_ftp_xfer()

        # CPC deactivation failed
        else:
            self._error.Msg = "CPC deactivation failed. CPC state is still active"
            raise TestEquipmentException(
                TestEquipmentException.OPERATION_FAILED, self._error.Msg)

        # wait 20 seconds for ensure that transfer is established
        self._logger.info(
            "Wait %i seconds for ensure that transfer is established",
            transfer_established_timeout)
        time.sleep(transfer_established_timeout)

        # Check that data transfer in on-going on DUT before CPC activation
        data_connection_state = self._ftp_api.get_ftp_status(self._ftp_task_id)
        self._logger.info("FTP transfer is %s !" % data_connection_state)

        if data_connection_state != "transferring":

            msg = self._logger.error("FTP connection lost on DUT !")
            raise DeviceException(DeviceException.CONNECTION_LOST, msg)

        # Activate CPC feature
        self._logger.info(
            "CPC activation on the equipment by setting CPC to On")
        self._ns_data_3g.set_cpc_state("ON")
        time.sleep(self._timeout_between_commands)

        # Check CPC activated state is On
        cpc_state = self._ns_data_3g.get_cpc_state()

        if cpc_state == "ON":
            # Check that CPC is active and wait for FTP transfer to finish
            # Use private method __activate_cpc
            self.__activate_cpc()

        # CPC activation failed
        else:
            self._error.Msg = "CPC activation failed. CPC state is still inactive"
            raise TestEquipmentException(
                TestEquipmentException.OPERATION_FAILED, self._error.Msg)

        # Deactivate CPC feature
        self._logger.info(
            "For BTB testing : CPC deactivation on the equipment by setting CPC to Off"
        )
        self._ns_data_3g.set_cpc_state("OFF")

        return Global.SUCCESS, "No errors"
Ejemplo n.º 23
0
    def run_test(self):
        """
        Execute the test
        """
        # Call LAB_MOBILITY_3G_HHO_BASE run_test function
        LabHspaBase.run_test(self)

        time.sleep(self._wait_btwn_cmd)

        self._logger.info("FTP transfer " + str(self._direction) + " for " +
                          str(self._ftp_filename) + "...")

        self._ftp_task_id = self._ftp_api.start_ftp(
            self._direction, self._server_ip_address, self._username,
            self._password, self._ftp_filename, self._device.multimedia_path,
            self._ns_DUT_IP_Address)

        timeout = time.time() + self._xfer_timeout
        # Check data state "TRANSFERRING" before timeout
        self._ns_data_3g.check_data_connection_transferring(
            self._check_data_transfer_state_timeout)

        # perfom a hard handover from cellA to cellB
        self.perform_hard_handover(self._ns_cell_3g)

        # Check data state "TRANSFERRING" before timeout
        self._ns_data_3g.check_data_connection_transferring(
            self._check_data_transfer_state_timeout)
        # Get RAT from Equipment
        network_type = self._ns_data_3g.get_network_type()
        # Check that DUT is registered on the good RAT
        self._modem_api.check_network_type_before_timeout(
            network_type, self._registration_timeout)

        # perfom a hard handover from cellB to cellA
        self.perform_hard_handover(self._ns_cell_3g)

        # Check data state "TRANSFERRING" before timeout
        self._ns_data_3g.check_data_connection_transferring(
            self._check_data_transfer_state_timeout, blocking=False)
        # Get RAT from Equipment
        network_type = self._ns_data_3g.get_network_type()
        # Check that DUT is registered on the good RAT
        self._modem_api.check_network_type_before_timeout(
            network_type, self._registration_timeout)
        # number of Hard Handover
        hh_number = 2 * self.get_b2b_iteration()

        # Create success_msg
        self._logger.info("Ftp success and %i Hard Handover(s) done" %
                          hh_number)

        data_connection_state = self._ftp_api.get_ftp_status(self._ftp_task_id)
        self._logger.info("FTP transfer is %s !" % data_connection_state)

        # No need to keep FTP transfer on going. Stop properly FTP client on DUT side
        try:
            self._ftp_api.stop_ftp(self._ftp_task_id)
            self._ftp_api.kill_ftp()
        except:
            pass
        # if ftp transfer is finished
        if data_connection_state in ("transfer successful", "transferring"):
            self._logger.info("FTP %s of file %s finish success !" %
                              (self._direction, self._ftp_filename))
            return Global.SUCCESS, "No Errors"
        else:
            self._error.Msg = "FTP transfer failed or have been too long! FTP status: %s" % (
                data_connection_state)
            return Global.FAILURE, self._error.Msg
Ejemplo n.º 24
0
    def run_test(self):
        """
        Execute the test
        """
        # Call LAB_HSPA_BASE run_test function
        LabHspaBase.run_test(self)

        # Run FTP transfer using FTP parameters :
        # - LAB_SERVER parameters (ip, username, password)
        # - DIRECTION
        # - DL_FILE or UL_FILE
        # - XFER_TIMEOUT
        # Start an ftp tranfer

        # Check CPC activated state is Off for UL DTX and DL DRX
        cpc_state = self._ns_data_3g.get_cpc_state()

        if cpc_state == "OFF":
            msg = self._logger.error("CPC has not been successfully enable on UL DTX and on DL DRX")
            raise TestEquipmentException(TestEquipmentException.OPERATION_FAILED, msg)

        else:
            self._logger.info("CPC has been successfully enable on UL DTX and on DL DRX")

        time.sleep(self._wait_btwn_cmd)

        self._logger.info("FTP transfer " + str(self._direction) +
                          " for " + str(self._ftp_filename) + "...")
        self._ftp_task_id = self._ftp_api.start_ftp(self._direction,
                                                    self._server_ip_address,
                                                    self._username,
                                                    self._password,
                                                    self._ftp_filename,
                                                    self._device.multimedia_path,
                                                    self._ns_DUT_IP_Address)

        # wait 20 seconds to ensure that transfer is established
        self._logger.info(
            "Wait 30 seconds to ensure that transfer is established")
        time.sleep(30)

        # Check data state "TRANSFERRING" before 10 seconds
        self._ns_data_3g.check_data_connection_transferring(self._check_data_transfer_state_timeout,
                                                            True,
                                                            blocking=False)

        if self._cpc_deact_type == "CPC_OFF":
            # Deactivate CPC feature
            self._logger.info(
                "CPC deactivation on the equipment by setting CPC to OFF")
            self._ns_data_3g.set_cpc_state("OFF")
            # wait 3 seconds for ensure that CPC deactivation has been made
            time.sleep(self._timeout_between_commands)

            # Check CPC activated state is OFF
            cpc_state = self._ns_data_3g.get_cpc_state()
            self._logger.info("CPC reported state is : %s", cpc_state)
            if cpc_state == "OFF":
                self._wait_end_of_ftp()
            # CPC deactivation failed
            else:
                self._error.Msg = "CPC deactivation failed. CPC state is still active"
                raise TestEquipmentException(TestEquipmentException.OPERATION_FAILED,
                                             self._error.Msg)

        elif self._cpc_deact_type == "HS_SCCH_ORDER":
            self._logger.info(
                "CPC deactivation on the equipment by sending a HS-SCCH ORDER")

            # Send the HS-SCCH ORDER
            self._ns_data_3g.send_hsscch_order()
            time.sleep(self._timeout_between_commands)

            # Check CPC activated state is ON
            cpc_state = self._ns_data_3g.get_cpc_state()
            self._logger.info("CPC reported state is : %s", cpc_state)
            if cpc_state == "ON":
                self._wait_end_of_ftp()
            # CPC deactivation failed
            else:
                self._error.Msg = "CPC deactivation failed. CPC is inactive"
                raise TestEquipmentException(TestEquipmentException.OPERATION_FAILED,
                                             self._error.Msg)

        elif self._cpc_deact_type == "PDP_DEACT":
            # deactivate PDP context
            self._logger.info(
                "CPC deactivation on the equipment by deactivating PDP context")
            self._networking_api.deactivate_pdp_context(self._ssid)

            time.sleep(self._timeout_between_commands)

            self._logger.info("Data transfer has stopped !")

            # Check CPC activated state is Off for UL DTX and DL DRX
            current_drx_activated_state = self._ns_data_3g.get_current_drx_activated_state()
            current_dtx_activated_state = self._ns_data_3g.get_current_dtx_activated_state()

            if current_drx_activated_state == "OFF" and current_dtx_activated_state == "OFF":

                self._logger.info("CPC has been successfully disable on UL DTX and on DL DRX")
                # Check Data Connection State => ATTACHED before TimeOut
                self._ns_data_3g.check_data_connection_state("ATTACHED",
                                                             self._registration_timeout,
                                                             blocking=False)
            else:
                self._error.Msg = "CPC deactivation on the equipment by deactivating PDP context has failed !"
                raise TestEquipmentException(TestEquipmentException.OPERATION_FAILED,
                                             self._error.Msg)

        else:
            self._error.Msg = "%s is not a known CPC deactivation type" % \
                self._cpc_deact_type
            raise TestEquipmentException(TestEquipmentException.INVALID_PARAMETER,
                                         self._error.Msg)

        # Activate CPC feature
        self._logger.info("For BTB testing : CPC activation on the equipment by setting CPC to On")
        self._ns_data_3g.set_cpc_state("ON")

        # deactivate PDP context
        self._logger.info(
            "For Back to Back testing : Reactivating PDP context")
        self._networking_api.activate_pdp_context(self._ssid)

        return Global.SUCCESS, "No errors"