Exemple #1
0
    def set_up(self):
        """
        Initialize the test
        """
        # Call LAB_EGPRS_BASE set_up function
        LabEgprsBase.set_up(self)

        # 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)

        if self._computer is not None:
            self._iperf_settings.update({"computer": self._computer})

        if self._tune_options == 1:
            # Set Iperf settings depending on the expected throughput
            self._iperf_settings.update(
                get_iperf_configuration(self._throughput_targets))
        else:
            self._iperf_settings.update({'direction': self._iperf_direction})
            self._iperf_settings.update(self._iperf_uldl_parameters)

        return Global.SUCCESS, "No errors"
Exemple #2
0
    def __init__(self, tc_name, global_config):
        """
        Constructor
        """

        # Call LAB_EGPRS_BASE Init function
        LabEgprsBase.__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"))

        # Get customized failure Targets
        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 EGPRS
        self._logger.info(throughput_targets_string(self._throughput_targets))

        self._ftp_api = self._device.get_uecmd("Ftp")
Exemple #3
0
    def run_test(self):
        """
        Execute the test
        """

        # Call LAB_EGPRS_BASE Run function
        LabEgprsBase.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.multimedia_path)
    def run_test(self):
        """
        Execute the test
        """

        # Call LAB_EGPRS_BASE Run function
        LabEgprsBase.run_test(self)

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

        time.sleep(self._wait_btwn_cmd)

        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)

        return self._error.Code, self._error.Msg
Exemple #5
0
    def set_up(self):
        """
        Initialize the test
        """

        LabEgprsBase.set_up(self)

        if self._direction not in ["UL", "DL"]:
            self._error.Msg = "%s is not a known xfer direction" % \
                self._direction
            raise AcsConfigException(AcsConfigException.INVALID_PARAMETER,
                                     self._error.Msg)

        if self._measurement_duration is None:
            raise AcsConfigException(AcsConfigException.INVALID_PARAMETER,
                                     "MEASUREMENT_DURATION should be int")

        if self._xfer_timeout is None:
            raise AcsConfigException(AcsConfigException.INVALID_PARAMETER,
                                     "XFER_TIMEOUT should be int")

        if (self._measurement_duration + self._wait_time_before_measure)\
                > self._xfer_timeout:
            raise AcsConfigException(
                AcsConfigException.INVALID_PARAMETER,
                "XFER_TIMEOUT should be always greater than"
                "MEASUREMENT_DURATION+%d (measurement start after"
                " %d seconds ftp starts) " % (self._wait_time_before_measure,
                                              self._wait_time_before_measure))

        return Global.SUCCESS, self._error.Msg
Exemple #6
0
    def __init__(self, tc_name, global_config):
        """
        Constructor
        """
        # Call LAB_EGPRS_BASE Init function
        LabEgprsBase.__init__(self, tc_name, global_config)

        # 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 MEASUREMENT_DURATION from UseCase xml Parameter
        self._measurement_duration = self._tc_parameters.\
            get_param_value("MEASUREMENT_DURATION")
        if self._measurement_duration is not None and \
                str(self._measurement_duration).isdigit():
            self._measurement_duration = int(self._measurement_duration)
        else:
            self._measurement_duration = None

        # 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

        self._failure_throughput_dict = {}

        # Read the FAILURE_OTATX from UseCase xml Parameter

        failure_targets = self._tc_parameters.get_param_value("FAILURE_TARGETS").\
            replace(" ", "").split(",")

        for failure in failure_targets:
            self._failure_throughput_dict.update(
                {str(failure.split(":")[0]): float(failure.split(":")[1])})

        self._wait_time_before_measure = 5
        self._device_logger = None
        self._start_ftp_trigger_msg = ""
        self._ftp_task_id = None
        self._op_code_message = ""
        self._op_code = None
        self._timeout = None
Exemple #7
0
    def run_test(self):
        """
        Execute the test
        """

        # Call LAB_EGPRS_BASE Run function
        LabEgprsBase.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 __init__(self, tc_name, global_config):
        """
        Constructor
        """

        # Call LAB_EGPRS_BASE Init function
        LabEgprsBase.__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"))
Exemple #9
0
    def __init__(self, tc_name, global_config):
        """
        Constructor
        """

        # Call LAB_EGPRS_BASE Init function
        LabEgprsBase.__init__(self, tc_name, global_config)

        # Set the default number of pings to do
        self._nb_pings = 10

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

        # Get target % of received packet for ping
        self._target_ping_packet_loss_rate = \
            self._tc_parameters.get_param_value("TARGET_PACKET_LOSS_RATE")

        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
Exemple #10
0
    def run_test(self):
        """
        Execute the test
        """

        # Call LAB_EGPRS_BASE Run function
        LabEgprsBase.run_test(self)

        time.sleep(self._wait_btwn_cmd)

        # Ping ftp server to verify pdp context actived.
        # 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._networking_api.deactivate_pdp_context(self._ssid)

        # 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())
        except:
            raise DeviceException(
                DeviceException.OPERATION_FAILED,
                "PDP context isn't correctly deactivated,"
                " ping packets reach the server.")

        # Re-activate pdp context
        self._networking_api.activate_pdp_context(self._ssid)

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

        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"
Exemple #11
0
    def __init__(self, tc_name, global_config):

        # Call LAB_EGPRS_BASE Init function
        LabEgprsBase.__init__(self, tc_name, global_config)

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

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

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

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

        # Get TCP window size and number of iperf client threads to run concurrently
        # window size > tput_to_reach * round_trip_time (700ms for EDGE)
        # 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 customized failure Targets
        self._failure_targets = \
            str(self._tc_parameters.get_param_value("FAILURE_TARGETS", ""))

        self._iperf_settings = \
            {"server_ip_address": self._server_ip_address,
             "port_number": self._port,
             "duration": self._duration,
             "protocol": self._iperf_protocol.lower()}

        # Get computer type
        self._computer = self._tc_parameters.get_param_value("COMPUTER")
        if self._computer == "":
            self._computer = None
        # Load computer equipment
        if self._computer is not None:
            self._computer = self._em.get_computer(self._computer)

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

        # Log Throughput targets for EGPRS
        self._logger.info(throughput_targets_string(self._throughput_targets))

        # 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"
Exemple #12
0
    def run_test(self):
        """
        Execute the test
        """
        # Call LAB_HSPA_BASE Run function
        LabEgprsBase.run_test(self)

        result = Global.SUCCESS
        measure_throughput_msg = "Measured throughput:"
        failure_throughput_msg = "Failure throughput:"

        # 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)

        # Start to search the trigger_msg in the logcat log
        self._device_logger = self._device.get_device_logger()
        self._start_ftp_trigger_msg = "status::SUCCESS - output::RECEIVED - " \
            "function::startFtpXfer"
        self._device_logger.add_trigger_message(self._start_ftp_trigger_msg)

        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())

        # Get the ftp start log msg and retrieve the OP code from the message
        self._op_code_message = self._device_logger.\
            get_message_triggered_status(self._start_ftp_trigger_msg)
        self._device_logger.remove_trigger_message(self._start_ftp_trigger_msg)
        self._op_code = re.findall(r'ACS\_\d*', str(self._op_code_message))[0]

        # wait 5 seconds for ensure that transfer is established
        self._logger.info(
            "Wait %d seconds for ensure that transfer is established" %
            self._wait_time_before_measure)

        time.sleep(self._wait_time_before_measure)

        data_throughput_dict = self._ns.get_data_throughput(
            self._measurement_duration, self._failure_throughput_dict.keys())

        # Timeout to wait for the ftp success message
        self._timeout = self._xfer_timeout - self._measurement_duration\
            - self._wait_time_before_measure
        self._device_logger.add_trigger_message(self._op_code)

        # Create success_msg which send by ACS_AGENT.apk
        ftp_filename = os.path.split(self._ftp_filename)[1]
        success_msg = "Ftp %s of file %s finish success" % (self._direction,
                                                            ftp_filename)

        # Parse the logcat log, Wait for the success_msg
        while self._timeout > 0:
            triggered_status = self._device_logger.\
                get_message_triggered_status(self._op_code)
            # When the  success message  is in the message of ACS op code
            if success_msg in str(triggered_status):
                self._logger.info(str(triggered_status))
                self._device_logger.remove_trigger_message(self._op_code)
                break
            else:
                time.sleep(1)
                self._timeout -= 1
        else:
            self._device_logger.remove_trigger_message(self._op_code)
            self._networking_api.stop_ftp_xfer(self._ftp_task_id)
            self._error.Msg = "The FTP transfer doesn't finish in the timeout"
            raise DeviceException(DeviceException.TIMEOUT_REACHED,
                                  self._error.Msg)

        for data_type in data_throughput_dict.keys():

            if "Mbps" in data_throughput_dict[data_type][0]:
                # Convert to kbps for result compare
                if float(data_throughput_dict[data_type][0][0:-4]) * 1000 < \
                        self._failure_throughput_dict[data_type]:
                    result = Global.FAILURE
            elif "Kbps" in data_throughput_dict[data_type][0]:
                if float(data_throughput_dict[data_type][0][0:-4]) < \
                        self._failure_throughput_dict[data_type]:
                    result = Global.FAILURE
            elif "bps" in data_throughput_dict[data_type][0]:
                if float(data_throughput_dict[data_type][0][0:-4]) / 1000 < \
                        self._failure_throughput_dict[data_type]:
                    result = Global.FAILURE
            else:
                self._error.Msg = "unknown measure result unit: %s " % \
                    str(data_throughput_dict[data_type][0])
                raise DeviceException(DeviceException.PROHIBITIVE_MEASURE,
                                      self._error.Msg)

            measure_throughput_msg = measure_throughput_msg + str(data_type) \
                + ":" + str(data_throughput_dict[data_type][0]) + " "
            failure_throughput_msg = failure_throughput_msg + str(data_type) \
                + ":" + str(self._failure_throughput_dict[data_type]) + "Kbps" + " "

        self._error.Msg = measure_throughput_msg + "- " + failure_throughput_msg

        return result, self._error.Msg