def set_up(self):
        """
        Initialize the test
        """
        # Depending on IP version, set DUT IP address with IPV4 or IPV6 address
        if self._ip_version == "IPV6":
            if self._ns_dut_ipv6_Address not in (None, ""):
                self._ns_dut_ip_Address = self._ns_dut_ipv6_Address
                self._logger.info("IP version is %s, set DUT IP to: %s" %
                                  (self._ip_version, self._ns_dut_ip_Address))
            else:
                self._logger.error(
                    "IPV6 address for DUT is not defined in Callbox section of bench config!! Please update it"
                )
                return Global.FAILURE, "IPV6 address for DUT is not defined in Callbox section of bench config!! Please update it"
        else:
            self._logger.info("IP version is %s, keep DUT IP to: %s" %
                              (self._ip_version, self._ns_dut_ip_Address))
        # Call LAB_LTE_BASE set_up function
        LabLteBase.set_up(self)

        self._check_ip_version()

        # Set Cell on
        self._ns_cell_4g.set_cell_on(self._mimo)

        # Flight mode deactivation after LTE BASE Setup
        self._networking_api.set_flight_mode("off")

        if self._switch_mode in ("hardshutdown", "softshutdown"):
            # Switch off according to the mode chosen in XML file
            self.phoneonoff_util.switch_off(self._switch_mode)

        return Global.SUCCESS, "No errors"
    def __init__(self, tc_name, global_config):
        """
        Constructor
        """
        # Call LAB_LTE_BASE Init function
        # All the base config will be set for CELL A
        LabLteBase.__init__(self, tc_name, global_config)
        if self._cell_id == "A":
            self._alt_cell_id = "B"
        else:
            self._alt_cell_id = "A"
        # Read PHYSICAL_CELL_B_ID from test case xml file
        self._physical_cell_b_id = \
            str(self._tc_parameters.get_param_value("PHYSICAL_CELL_B_ID"))

        # Read SCENARIO_PATH for cell B from test case xml file
        self._scenario_path_b = \
            str(self._tc_parameters.get_param_value("SCENARIO_PATH_B"))

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

        self._rrc_state = self._tc_parameters.get_param_value(
            "RRC_STATE", "RRC_CONNECTED")
        if self._rrc_state == "RRC_CONNECTED":
            self._connection_state = "CON"
        else:
            self._connection_state = "IDLE"
        self._alt_cell_4g = self._ns.get_alt_cell_4g()
        self._alt_data_4g = self._alt_cell_4g.get_data()
Example #3
0
    def run_test(self):
        """
        Execute the test
        Test steps:
            Launch FTP.
            Wait for the transfer to finish.
            Measure FTP duration
            Get transferred file size on phone
            Compute throughput
            We are using here ftpput and ftpget methods because it is the only method
            which reach target throughput for LTE category 3&4
            For instance ftp_xfer is about 50% of LTE cat 3 max throughput
        """

        # Call LAB_LTE_BASE run_test function
        LabLteBase.run_test(self)
        # If transfer starts from IDLE, reactivate PDP context for windows platform
        if self._rrc_state == "RRC_IDLE":
            self._networking_api.reactivate_pdp_context(self._apn)

        return perform_ftp_transfer(self._direction, self._ip_address,
                                    self._username, self._password,
                                    self._ftp_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._dl_ftp_filename,
                                    self._throughput_targets.dl_failure.value,
                                    self._device.binaries_path)
Example #4
0
    def __init__(self, tc_name, global_config):
        """
        Constructor
        """
        # Call LAB_LTE_BASE Init function
        LabLteBase.__init__(self, tc_name, global_config)

        # Read mode from test case xml file (str)
        self._switch_mode = self._tc_parameters.get_param_value(
            "SWITCH_MODE", "hardshutdown")

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

        self._camp_timeout = self._registration_timeout

        # Instantiate Phone On/OFF utilities
        self.phoneonoff_util = PhoneOnOff(self._networking_api, self._device,
                                          self._logger)
Example #5
0
    def run_test(self):
        """
        Execute the test
        """
        LabLteBase.run_test(self)

        # Compute packet loss value
        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(self._error.Msg)

        return self._error.Code, self._error.Msg
Example #6
0
 def tear_down(self):
     """
     Finishing the test.
     Stopping the FTP service and releasing the equipment.
     """
     # Stopping the FTP service before releasing the equipment.
     self._ns_data_4g.stop_ftp_service()
     LabLteBase.tear_down(self)
     return Global.SUCCESS, "No errors"
Example #7
0
    def set_up(self):
        """
        Initialize the test
        """
        # Call LAB_LTE_BASE set_up function
        LabLteBase.set_up(self)

        # Set Cell on
        self._ns_cell_4g.set_cell_on(self._mimo)

        return Global.SUCCESS, "No errors"
    def __init__(self, tc_name, global_config):
        """
        Constructor
        """
        # Call LAB_LTE_BASE Init function
        LabLteBase.__init__(self, tc_name, global_config)

        # Read mode from test case xml file
        self._switch_mode = self._tc_parameters.get_param_value("SWITCH_MODE")
        # Read the IP version from test case xml file
        self._ip_version = self._tc_parameters.get_param_value(
            "IP_VERSION", "IPV4")

        # Read the IP version from test case xml file
        self._retry_different_ip_version = str_to_bool(
            self._tc_parameters.get_param_value("RETRY_ALTERNATIVE_VERSION",
                                                "False"))

        if self._retry_different_ip_version:
            if self._ip_version == "IPV4":
                self._alternate_ip_version = "IPV6"
                self._logger.info("The alternative IP version is V6 ")
            elif self._ip_version == "IPV6":
                self._alternate_ip_version = "IPV4"
                self._logger.info("the alternative IP version is V4")
            else:
                self._logger.error(
                    "Alternate only if IP version is V4 or V6 and not in DUAL MODE"
                )

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

        # Read the network registration timeout
        self._network_reg_timeout = self._tc_parameters.get_param_value(
            "NETWORK_REG_TIMEOUT", 0, int)
        if self._network_reg_timeout == 0:
            self._network_reg_timeout = self._registration_timeout

        # Instantiate Phone On/OFF utilities
        self.phoneonoff_util = PhoneOnOff(self._networking_api, self._device,
                                          self._logger)

        # Instantiate the IP version
        self._nw_ip_version = ""
Example #9
0
    def tear_down(self):
        """
        Finishing the test.
        Stopping the IPERF server and releasing the equipment.
        """
        # Stop and disable CMW500 IPERF server/client
        if self._computer is None:
            self._ns_data_4g.stop_iperf_service()
            self._ns_data_4g.disable_iperf_client()
            self._ns_data_4g.disable_iperf_server()

        LabLteBase.tear_down(self)
        return Global.SUCCESS, "No errors"
Example #10
0
    def set_up(self):
        """
        Initialize the test
        """
        # Call LAB_LTE_BASE set_up function
        LabLteBase.set_up(self)

        # Set Cell on
        self._ns_cell_4g.set_cell_on(self._mimo)

        # Flight mode deactivation
        self._networking_api.set_flight_mode("off")


        # Check data connection state is "CON"
        self._check_data_connection_state("CON")
        # Check registration state is connected using
        # registrationTimeout from Device_Catalog.xml
        self._logger.info("Check network registration status is %s on DUT" %
                          self._wanted_reg_state)

        self._modem_api.check_cdk_state_bfor_timeout(
            self._wanted_reg_state,
            self._registration_timeout)

        # Set APN for LTE and/or IMS depending on protocol IPv4 or IPv6
        self._set_apn_for_lte_and_ims()

        # move to her to wait for register then activate pdp
        time.sleep(self._wait_btwn_cmd)
        self._networking_api.activate_pdp_context(check = False)

        # Get RAT from Equipment
        network_type = self._ns_data_4g.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)

        # Set rrc state to the value defined in the TC
        current_rrc_state = self._ns_cell_4g.get_rrc_state()
        if self._rrc_state == "RRC_IDLE":
            self._networking_api.disable_output_traffic()
            self._ns_data_4g.ue_detach()
            self._networking_api.enable_output_traffic()
            current_rrc_state = self._ns_cell_4g.get_rrc_state()
            self._logger.info("The ping will start from %s state" % current_rrc_state)
        elif self._rrc_state == "RRC_CONNECTED":
            self._logger.info("The ping will start from %s state" % current_rrc_state)

        return Global.SUCCESS, "No errors"
Example #11
0
    def run_test(self):
        """
        Execute the test
        """
        # Call LAB_LTE_BASE run_test function
        LabLteBase.run_test(self)

        # Phone has to see the cell off!
        self._modem_api.check_cdk_no_registration_bfor_timeout(
            self._registration_timeout)

        # Flight mode deactivation
        self._networking_api.set_flight_mode("off")

        # Check registration state is connected using
        # registrationTimeout from Device_Catalog.xml
        self._logger.info("Check network registration status is %s on DUT" %
                          (self._wanted_reg_state))

        self._modem_api.check_cdk_state_bfor_timeout(
            self._wanted_reg_state, self._registration_timeout)

        # Set APN for LTE and/or IMS depending on protocol IPv4 or IPv6
        self._set_apn_for_lte_and_ims()

        # Enable Data Usage
        time.sleep(self._wait_btwn_cmd)
        self._networking_api.activate_pdp_context()

        # Get RAT from Equipment
        network_type = self._ns_data_4g.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 IMS connection state
        status = self._ns_data_4g.check_ims_connection_state(
            "REG", self._registration_timeout)
        if status == False:
            raise DeviceException(DeviceException.INVALID_DEVICE_STATE,
                                  "Failed to reach IMS registration")

        # Wait between two commands sending
        time.sleep(self._wait_btwn_cmd)

        # Flight mode activation
        self._networking_api.set_flight_mode("on")
        return (self._error.Code, self._error.Msg)
Example #12
0
    def __init__(self, tc_name, global_config):
        """
        Constructor
        """
        # Call LAB_LTE_BASE Init function
        LabLteBase.__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"))

        self._rrc_state = self._tc_parameters.get_param_value("RRC_STATE", "RRC_CONNECTED")
Example #13
0
 def __init__(self, tc_name, global_config):
     """
     Constructor
     """
     # Call LAB_LTE_BASE Init function
     LabLteBase.__init__(self, tc_name, global_config)
Example #14
0
    def set_up(self):
        """
        Initialize the test.
        """
        # configure RRC state after cell attach process (will be used on LabLteBase set_up)
        if "IDLE" in str(self._rrc_state):
            self._ns_cell_4g.keep_rrc_connection(False)
        else:
            self._ns_cell_4g.keep_rrc_connection(True)

        # Call LAB_LTE_BASE set_up function
        LabLteBase.set_up(self)

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

        if self._iperf_protocol is None:
            return Global.FAILURE, "The IPERF protocol parameter should be present."

        self._iperf_settings["direction"] = self._iperf_direction
        if self._iperf_protocol.lower() == "udp":
            # Compute IPERF bandwidth from target throughput and iperf bandwidth
            compute_iperf_bw(self._iperf_settings, self._throughput_targets,
                             self._iperf_bandwidth)

        # Set Cell on.
        self._ns_cell_4g.set_cell_on(self._mimo)

        # Activate 4G
        self._connect_dut_to_4g_cell()

        # Configuration for different LTE equipments:
        # Configuration for Rohde & Schwarz CMW500
        if "RS_CMW500" in self._ns_model:
            # Add CMW500 equipment api to perform settings on internal IPERF server/client.
            self._iperf_settings.update({
                "server_ip_address": self._server_ip_address,
                "equipment_api": self._ns_data_4g,
                "computer": None
            })
            # Be sure to use equipment api for IPERF and not Computer equipment
            self._computer = None
        else:
            # LTE equipment not supported
            return Global.FAILURE, "LTE equipment %s not supported (AGILENT_E6621A, RS_CMW500)." \
                                   % self._ns_model

        # Trying to get the DUT IP address as the CMW500 does not provide the
        # IP described in the Bench Config. The two checks are done because
        # platform can have different interface names.
        try:
            self._dut_ip_address = self._ns_dut_ip_Address
            if self._ip_version == "IPV4":
                self._dut_ip_address = wait_for_dut_ipv4_address(
                    self._registration_timeout, self._networking_api,
                    self._device.get_cellular_network_interface())
            if self._ip_version == "IPV6":
                # Transform IPV6 DUT Prefix (xxxx:xxxx:xxxx:xxxx::/64) => DUT IP Adress (xxxx:xxxx:xxxx:xxxx::1)
                self._dut_ip_address = self._dut_ip_address.split("/")[0] + "1"
        except (KeyboardInterrupt, SystemExit):
            raise

        # Setup the IPERF test.
        self._iperf_settings.update({
            "port_number": self._port,
            "duration": self._duration,
            "protocol": self._iperf_protocol.lower(),
            "dut_ip_address": self._dut_ip_address
        })
        if self._iperf_uldl_parameters != {}:
            # If it's a KPI test we should disable the setting of the window size on the CMW500
            #             if self._kpi_test:
            #                 self._ns_data_4g.config_window_size_off()
            self._iperf_settings.update(self._iperf_uldl_parameters)

        if self._buffer_length != 0:
            self._iperf_settings.update({"buffer_length": self._buffer_length})
        if self._ip_version == "IPV6":
            self._iperf_settings["ipv6_domain"] = True

        # Setup the IPERF server/client, if IPERF embedded on equipment (CMW500 equipment)
        if self._computer is None:
            # Stop FTP server on CMW
            self._ns_data_4g.stop_ftp_service()
            # Configure internal IPERF server/client of the equipment.
            if self._iperf_direction.upper() in ("UP"):
                self._logger.info("Enable CMW500 IPERF server.")
                self._ns_data_4g.disable_iperf_client()
                self._ns_data_4g.configure_iperf_server(self._iperf_settings)
            elif self._iperf_direction.upper() in ("BOTH"):
                # Configure first iperf server as iperf duration is set by server and client but the desired value is client duration
                self._logger.info("Enable CMW500 IPERF server.")
                self._ns_data_4g.configure_iperf_server(self._iperf_settings)
                self._logger.info("Enable CMW500 IPERF client.")
                # Add 30 more seconds to iperf service duration on CMW to allow concurrency transfer
                self._iperf_settings.update({"duration": self._duration + 15})
                # Change port for DL iperf
                self._iperf_settings.update({"port_number": self._port + 1})
                self._ns_data_4g.configure_iperf_client(self._iperf_settings)

                # Reset iperf duration and port for DUT iperf client
                self._iperf_settings.update({
                    "duration": self._duration,
                    "port_number": self._port
                })
            else:
                self._logger.info("Enable CMW500 IPERF client.")
                self._ns_data_4g.disable_iperf_server()
                self._ns_data_4g.configure_iperf_client(self._iperf_settings)

        return Global.SUCCESS, "No errors"
    def run_test(self):
        """
        Execute the test
        """
        LabLteBase.run_test(self)

        if self._switch_mode == "airplane":
            # Switch off according to the mode chosen in XML file
            self.phoneonoff_util.switch_off(self._switch_mode)

            # check phone is unregistered
            self._modem_api.check_cdk_no_registration_bfor_timeout(
                self._registration_timeout)
            self._networking_api.check_no_ip_address()

            self._check_ip_version()

        # Switch on according to the mode chosen
        self.phoneonoff_util.switch_on(self._switch_mode)

        # Check registration state is connected using
        # registrationTimeout from Device_Catalog.xml or timeout parameter from TC xml file
        self._logger.info(
            "Check network registration status is %s on DUT, before %d seconds"
            % (self._wanted_reg_state, self._network_reg_timeout))

        # Check registration on HPLMN
        self._modem_api.check_cdk_state_bfor_timeout(self._wanted_reg_state,
                                                     self._network_reg_timeout)

        # Set APN for LTE and/or IMS depending on protocol IPv4 or IPv6
        self._set_apn_for_lte_and_ims()

        # PDP activation
        time.sleep(self._wait_btwn_cmd)
        self._networking_api.activate_pdp_context(check=False)

        # Check data connection state is "CON"
        self._check_data_connection_state("CON", self._network_reg_timeout)

        # Get RAT from Equipment
        network_type = self._ns_data_4g.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)

        (self._error.Code,
         self._error.Msg) = self._start_ping(self._nw_ip_version)

        if self._error.Code == Global.SUCCESS and self._retry_different_ip_version:

            if self._nw_ip_version in ("IPV6", "IPV4"):
                self._logger.info("RETRY with %s version " %
                                  self._alternate_ip_version)
                # Switch off according to the mode chosen in XML file
                self.phoneonoff_util.switch_off(self._switch_mode)
                # check phone is unregistered
                self._modem_api.check_cdk_no_registration_bfor_timeout(
                    self._registration_timeout)
                # stop scenario in order to change version
                self._ns.stop_scenario()
                # Set the new IP version assigned by the NW
                self._ns_data_4g.set_ip_address_type(
                    self._alternate_ip_version)
                # Start scenario
                self._ns.start_scenario()
                # Switch off according to the mode chosen in XML file
                self.phoneonoff_util.switch_on(self._switch_mode)
                # Check data connection state is "CON"
                self._check_data_connection_state("CON",
                                                  self._network_reg_timeout)
                # Check registration state is connected using
                # registrationTimeout from Device_Catalog.xml
                self._logger.info(
                    "Check network registration status is %s on DUT, before %d seconds"
                    % (self._wanted_reg_state, self._network_reg_timeout))
                # Check registration on HPLMN
                self._modem_api.check_cdk_state_bfor_timeout(
                    self._wanted_reg_state, self._network_reg_timeout)
                # Get RAT from Equipment
                network_type = self._ns_data_4g.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)
                (self._Code,
                 self._Msg) = self._start_ping(self._alternate_ip_version)

                if self._Code == Global.SUCCESS:
                    # ping with both version has succeeded
                    self._error.Code = Global.SUCCESS
                    self._error.Msg = "TEST IS PASS ALL EXPECTED RESULTS ARE MET"
                    return self._error.Code, self._error.Msg

                else:
                    # ping with alternative version has failed
                    self._error.Code = Global.FAILURE
                    self._error.Msg += " and Ping with Alternative %s has failed"
                    return self._error.Code, self._error.Msg

            else:
                # ALternate between IPV4 & IPV6 only
                self._error.Code = Global.FAILURE
                self._error.Msg = "IP Version is set to DUAL MODE"
                return self._error.Code, self._error.Msg

        else:
            # No Need to retry
            return self._error.Code, self._error.Msg
Example #16
0
    def run_test(self):
        """
        Execute the test
        """
        # Call LAB_LTE_BASE run_test function
        LabLteBase.run_test(self)

        if self._switch_mode == "airplane":
            # Switch on according to the mode chosen
            self.phoneonoff_util.switch_on(self._switch_mode)
        elif self._switch_mode in ("hardshutdown", "softshutdown"):
            # Reboot according to the mode chosen
            self.phoneonoff_util.reboot(self._switch_mode)
            # Turn Off Airplane mode - Phone might still be ON due to previous test execution
            self._networking_api.set_flight_mode("off")
        else:
            self._logger.info("No actions required to do a switch On/Off")

        # Check registration state is connected using
        # registrationTimeout from Device_Catalog.xml
        self._logger.info("Check network registration status is %s on DUT" %
                          self._wanted_reg_state)

        self._modem_api.check_cdk_state_bfor_timeout(self._wanted_reg_state,
                                                     self._camp_timeout)

        # Set APN for LTE and/or IMS depending on protocol IPv4 or IPv6
        self._set_apn_for_lte_and_ims()

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

        # Check data connection state is "CON"
        self._ns_data_4g.check_data_connection_state("CON",
                                                     self._camp_timeout,
                                                     blocking=False,
                                                     cell_id=self._cell_id)

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

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

        # Wait between two commands sending
        time.sleep(self._wait_btwn_cmd)
        try:
            # Compute packet loss value
            packet_loss = self._networking_api.\
                ping(self._server_ip_address,
                     self._packet_size,
                     self._nb_pings,
                     source_address=self._ns_dut_ip_Address)

            # 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)
        except:
            self._logger.error("PING FAILURE!!!!")
            self._error.Code = Global.FAILURE
            self._error.Msg = "PING FAILURE!!!!"

        if self._switch_mode == "airplane":
            # Switch off according to the switch mode chosen
            self.phoneonoff_util.switch_off(self._switch_mode)
            # Check data connection is IDLE
            self._check_data_connection_state("IDLE")
            # Check that DUT is no longer camped on Network
            self._modem_api.check_cdk_no_registration_bfor_timeout(
                self._camp_timeout)

        if self._switch_tdd_fdd:
            # Switch configuration between TDD and FDD
            if self._duplex_type == "FDD":
                self._duplex_type = "TDD"
            elif self._duplex_type == "TDD":
                self._duplex_type = "FDD"

        return self._error.Code, self._error.Msg
Example #17
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
Example #18
0
    def __init__(self, tc_name, global_config):
        """
        Constructor
        """
        # Call LAB_LTE_BASE Init function
        LabLteBase.__init__(self, tc_name, global_config)
        # Get the IP of the Iperf LTE server
        self._server = \
            global_config.benchConfig.get_parameters("LAB_LTE_SERVER")
        self._server_ip_address = self._server.get_param_value("IP")
        # 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", "120"))
        # Read direction (Upload/Download/BOTH)
        self._direction = self._tc_parameters.get_param_value(
            "DIRECTION", "UL")

        self._rrc_state = self._tc_parameters.get_param_value(
            "RRC_STATE", "RRC_CONNECTED")

        ######################################################
        #                   IPERF SETTINGS                   #
        ######################################################

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

        self._iperf_bandwidth = \
            str(self._tc_parameters.get_param_value("IPERF_BANDWIDTH", None)).upper()

        self._computer = None
        if self._ns_model == "AGILENT_E6621A":
            # Get computer type
            self._computer = \
                self._tc_parameters.get_param_value("COMPUTER",
                                                    "IPERF_SERVER")
            self._computer_type = \
                global_config.benchConfig.get_parameters("IPERF_SERVER")

        # Get TCP window size and number of iperf client threads to run concurrently
        # TCP Window size shall be greater than:
        # - Expected throughput * LTE_RTT (round trip time)
        # Max LTE throughput is 150Mbps and LTE_RTT < 20ms
        # 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)

        self._buffer_length = \
            int(self._tc_parameters.get_param_value("BUFFER_LENGTH", 0))
        self._dut_ip_address = None

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

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

        # Detect if a BLER measurement is needed. It performs BLER measurement the following way:
        # Wait a quarter of IPERF duration then perform BLER measurement during half of IPERF duration
        self._perform_bler = self._tc_parameters.get_param_value(
            "BLER", False, "str_to_bool")

        self._iperf_settings = {}

        ######################################################
        #             LTE THROUGHPUT SETTINGS                #
        ######################################################
        self._set_lte_throughput_settings()

        # 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 LTE category
        self._logger.info(throughput_targets_string(self._throughput_targets))
    def run_test(self):
        """
        Execute the test.
        Configuring the internal IPERF server of the equipment.
        Starting this IPERF server.
        Launching the IPERF client
        Computing the throughput to get a verdict.
        """
        result_msg = ""

        # Call LAB_LTE_BASE Run function
        LabLteBase.run_test(self)
        time.sleep(self._wait_btwn_cmd)

        # Launch the IPERF test and get throughput
        try:
            if self._ns_cell_4g.get_cell_status() == "OFF":
                self._logger.info("4G cell is OFF, restarting it")
                self._ns_cell_4g.set_cell_on()
                if self._ns_cell_4g.get_cell_status() == "OFF":
                    self._logger.error(
                        "4G cell is OFF, cannot run test iteration")
                    # raise Exception in order to get proper exit handling
                    raise Exception
                self._connect_dut_to_4g_cell()

            # Start asynchronus Iperf
            iperf_async = self._networking_api.iperf_async(
                self._iperf_settings)

            # Throughput Target = PCC throughput targets
            throughput_targets = copy.deepcopy(self._pcc_throughput_targets)
            throughput_targets.set_failure_throughput_from_config(
                self._dut_config, self._failure_targets)

            # Iperf measure
            throughput = iperf_async.perform_continous_measure(
                self._iperf_duration)

            # Compute Iperf verdict
            (result_code, result_msg_tmp) = \
                compute_iperf_verdict(throughput,
                                      throughput_targets,
                                      self._iperf_direction)
            self._logger.info(result_msg_tmp)
            result_msg += result_msg_tmp + "\n"
            if result_code == Global.FAILURE:
                return result_code, result_msg_tmp

            # Activate SCC
            self._ns_cell_4g.set_secondary_carrier_state("MACactivate")
            self._ns_cell_4g.check_secondary_carrier_state_before_timeout(
                "MACactivate", 30)

            # Throughput Target = PCC + SCC throughput targets
            # DL = PCC DL + SCC DL --- UL = PCC UL
            throughput_targets = copy.deepcopy(self._pcc_throughput_targets)
            throughput_targets.add_secondary_carrier_throughput_targets(
                self._scc_throughput_targets)
            throughput_targets.set_failure_throughput_from_config(
                self._dut_config, self._failure_targets)

            # Iperf measure
            throughput = iperf_async.perform_continous_measure(
                self._iperf_duration)

            # Compute Iperf verdict
            (result_code, result_msg_tmp) = \
                compute_iperf_verdict(throughput,
                                      throughput_targets,
                                      self._iperf_direction)
            self._logger.info(result_msg_tmp)
            result_msg += result_msg_tmp + "\n"
            if result_code == Global.FAILURE:
                return result_code, result_msg_tmp

            if self._swap_carrier:
                # Swap SCC <-> PCC
                self._ns_cell_4g.swap_primary_and_secondary_carrier_settings()
                self._ns_cell_4g.check_secondary_carrier_state_before_timeout(
                    "MACactivate", 30)

                # Throughput Target = SCC + PCC throughput targets
                # DL = SCC DL + PCC DL --- UL = SCC UL
                self._pcc_throughput_targets, self._scc_throughput_targets = \
                    self._scc_throughput_targets, self._pcc_throughput_targets
                throughput_targets = copy.deepcopy(
                    self._pcc_throughput_targets)
                throughput_targets.add_secondary_carrier_throughput_targets(
                    self._scc_throughput_targets)
                throughput_targets.set_failure_throughput_from_config(
                    self._dut_config, self._failure_targets)

                # Iperf measure
                throughput = iperf_async.perform_continous_measure(
                    self._iperf_duration)

                # Compute Iperf verdict
                (result_code, result_msg_tmp) = \
                    compute_iperf_verdict(throughput,
                                          throughput_targets,
                                          self._iperf_direction)
                self._logger.info(result_msg_tmp)
                result_msg += result_msg_tmp + "\n"
                if result_code == Global.FAILURE:
                    return result_code, result_msg_tmp

            # Deactivate SCC
            self._ns_cell_4g.set_secondary_carrier_state("OFF")
            self._ns_cell_4g.check_secondary_carrier_state_before_timeout(
                "OFF", 30)

            # Throughput Target = PCC throughput targets
            throughput_targets = copy.deepcopy(self._pcc_throughput_targets)
            throughput_targets.set_failure_throughput_from_config(
                self._dut_config, self._failure_targets)

            # Iperf measure
            throughput = iperf_async.perform_continous_measure(
                self._iperf_duration)

            # Compute Iperf verdict
            (result_code, result_msg_tmp) = \
                compute_iperf_verdict(throughput,
                                      throughput_targets,
                                      self._iperf_direction)
            self._logger.info(result_msg_tmp)
            result_msg += result_msg_tmp + "\n"
            if result_code == Global.FAILURE:
                return result_code, result_msg_tmp

            # Wait end of IPERF
            iperf_async.stop_iperf_async()

        except Exception:
            result_code = Global.FAILURE
            result_msg = "!!!! WARNING Exception occurred during iperf test!!! "
            exception_text = format_exception_info()
            self._logger.debug("Exception during iperf test: %s ",
                               exception_text)
            self._logger.error("!!!! Exception occurred during iperf test!!! ")
            return result_code, result_msg

        # Return result
        return Global.SUCCESS, result_msg
Example #20
0
    def __init__(self, tc_name, global_config):
        """
        Constructor
        """
        # Call LAB_LTE_BASE Init function
        LabLteBase.__init__(self, tc_name, global_config)
        # Read the the direction file name from UseCase xml Parameter
        self._direction = self._tc_parameters.get_param_value("DIRECTION")
        # 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", ""))
            self._ftp_filename = self._ftp_filename.replace('\\', '/')
            self._dl_ftp_filename = None
        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._ftp_filename = self._ftp_filename.replace('\\', '/')
            self._dl_ftp_filename = None
        elif self._direction == "BOTH":
            self._dl_ftp_filename = os.path.join(
                self._ftp_path,
                self._tc_parameters.get_param_value("DL_FILENAME", ""))
            self._dl_ftp_filename = self._dl_ftp_filename.replace('\\', '/')
            # 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._ftp_filename = self._ftp_filename.replace('\\', '/')
        # 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._rrc_state = self._tc_parameters.get_param_value(
            "RRC_STATE", "RRC_CONNECTED")

        # Initializing the variable which will contain the IP address to use.
        self._ip_address = None

        self._phone_system = self._device.get_uecmd("PhoneSystem")

        ######################################################
        #             LTE THROUGHPUT SETTINGS                #
        ######################################################
        self._set_lte_throughput_settings()

        # LTE FTP Test are FUTE by default
        if self._failure_targets == "":
            self._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 LTE category
        self._logger.info(throughput_targets_string(self._throughput_targets))
        self._ftp_api = self._device.get_uecmd("Ftp")