def __init__(self, controllers): TelephonyBaseTest.__init__(self, controllers) try: self.stress_test_number = int( self.user_params["stress_test_number"]) self.log.info( "Executing {} calls per test in stress test mode".format( self.stress_test_number)) except KeyError: self.stress_test_number = 0 self.log.info( "No 'stress_test_number' defined: running single iteration tests" ) self.ad = self.android_devices[0] self.ad.sim_card = getattr(self.ad, "sim_card", None) self.md8475a_ip_address = self.user_params[ "anritsu_md8475a_ip_address"] self.wlan_option = self.user_params.get("anritsu_wlan_option", False) self.md8475_version = self.user_params.get("md8475", "A") setattr(self, 'voice_call_number', DEFAULT_CALL_NUMBER) if 'voice_call_number' in self.user_params: self.voice_call_number = self.user_params['voice_call_number'] self.log.info("Using provided voice call number: {}".format( self.voice_call_number)) if self.ad.sim_card == "VzW12349": set_preferred_apn_by_adb(self.ad, "VZWINTERNET")
def setup_class(self): super().setup_class() try: self.stress_test_number = int( self.user_params["stress_test_number"]) self.log.info( "Executing {} calls per test in stress test mode".format( self.stress_test_number)) except KeyError: self.stress_test_number = 0 self.log.info( "No 'stress_test_number' defined: running single iteration tests" ) self.ad = self.android_devices[0] self.ad.sim_card = getattr(self.ad, "sim_card", None) self.md8475a_ip_address = self.user_params[ "anritsu_md8475a_ip_address"] self.wlan_option = self.user_params.get("anritsu_wlan_option", False) self.md8475_version = self.user_params.get("md8475", "A") setattr(self, 'emergency_call_number', DEFAULT_EMERGENCY_CALL_NUMBER) if 'emergency_call_number' in self.user_params: self.emergency_call_number = self.user_params[ 'emergency_call_number'] self.log.info("Using provided emergency call number: {}".format( self.emergency_call_number)) if not self.emergency_call_number in EMERGENCY_CALL_NUMBERS: self.log.warning("Unknown Emergency Number {}".format( self.emergency_call_number)) # Check for all adb devices on the linux machine, and set APM ON cmd = "|".join(("adb devices", "grep -i device$", "cut -f1")) output = exe_cmd(cmd) list_of_devices = output.decode("utf-8").split("\n") if len(list_of_devices) > 1: for i in range(len(list_of_devices) - 1): self.log.info("Serial %s", list_of_devices[i]) if check_apm_mode_on_by_serial(self.ad, list_of_devices[i]): self.log.info("Device is already in APM ON") else: self.log.info("Device is not in APM, turning it ON") set_apm_mode_on_by_serial(self.ad, list_of_devices[i]) if check_apm_mode_on_by_serial(self.ad, list_of_devices[i]): self.log.info("Device is now in APM ON") if self.ad.sim_card == "VzW12349": set_preferred_apn_by_adb(self.ad, "VZWINTERNET") try: self.anritsu = MD8475A(self.md8475a_ip_address, self.wlan_option, self.md8475_version) except AnritsuError: self.log.error("Error in connecting to Anritsu Simulator") return False return True
def __init__(self, controllers): TelephonyBaseTest.__init__(self, controllers) self.ad = self.android_devices[0] self.ad.sim_card = getattr(self.ad, "sim_card", None) self.md8475a_ip_address = self.user_params[ "anritsu_md8475a_ip_address"] self.wlan_option = self.user_params.get("anritsu_wlan_option", False) self.md8475_version = self.user_params.get("md8475", "A") if self.ad.sim_card == "VzW12349": set_preferred_apn_by_adb(self.ad, "VZWINTERNET")
def __init__(self, controllers): TelephonyBaseTest.__init__(self, controllers) self.ad = self.android_devices[0] self.ad.sim_card = getattr(self.ad, "sim_card", None) self.md8475a_ip_address = self.user_params[ "anritsu_md8475a_ip_address"] self.wlan_option = self.user_params.get("anritsu_wlan_option", False) self.md8475_version = self.user_params.get("md8475", "A") self.voice_call_number = self.user_params.get('voice_call_number', DEFAULT_CALL_NUMBER) self.ip_server = self.iperf_servers[0] self.port_num = self.ip_server.port self.log.info("Iperf Port is %s", self.port_num) if self.ad.sim_card == "VzW12349": set_preferred_apn_by_adb(self.ad, "VZWINTERNET")
def setup_class(self): super().setup_class() self.ad = self.android_devices[0] self.ad.sim_card = getattr(self.ad, "sim_card", None) self.md8475a_ip_address = self.user_params[ "anritsu_md8475a_ip_address"] self.wlan_option = self.user_params.get("anritsu_wlan_option", False) self.md8475_version = self.user_params.get("md8475", "A") if self.ad.sim_card == "VzW12349": set_preferred_apn_by_adb(self.ad, "VZWINTERNET") try: self.anritsu = MD8475A(self.md8475a_ip_address, self.wlan_option, self.md8475_version) except AnritsuError: self.log.error("Error in connecting to Anritsu Simulator") return False return True
def setup_class(self): super().setup_class() self.ad = self.android_devices[0] self.ad.sim_card = getattr(self.ad, "sim_card", None) self.md8475a_ip_address = self.user_params[ "anritsu_md8475a_ip_address"] self.wlan_option = self.user_params.get("anritsu_wlan_option", False) self.md8475_version = self.user_params.get("md8475", "A") self.voice_call_number = self.user_params.get('voice_call_number', DEFAULT_CALL_NUMBER) self.ip_server = self.iperf_servers[0] self.port_num = self.ip_server.port self.log.info("Iperf Port is %s", self.port_num) if self.ad.sim_card == "VzW12349": set_preferred_apn_by_adb(self.ad, "VZWINTERNET") try: self.anritsu = MD8475A(self.md8475a_ip_address, self.wlan_option, self.md8475_version) except AnritsuError: self.log.error("Error in connecting to Anritsu Simulator") return False return True
def setup_class(self): super().setup_class() try: self.stress_test_number = int( self.user_params["stress_test_number"]) self.log.info( "Executing {} calls per test in stress test mode".format( self.stress_test_number)) except KeyError: self.stress_test_number = 0 self.log.info( "No 'stress_test_number' defined: running single iteration tests" ) self.ad = self.android_devices[0] self.ad.sim_card = getattr(self.ad, "sim_card", None) self.md8475a_ip_address = self.user_params[ "anritsu_md8475a_ip_address"] self.wlan_option = self.user_params.get("anritsu_wlan_option", False) self.md8475_version = self.user_params.get("md8475", "A") setattr(self, 'voice_call_number', DEFAULT_CALL_NUMBER) if 'voice_call_number' in self.user_params: self.voice_call_number = self.user_params['voice_call_number'] self.log.info("Using provided voice call number: {}".format( self.voice_call_number)) if self.ad.sim_card == "VzW12349": set_preferred_apn_by_adb(self.ad, "VZWINTERNET") try: self.anritsu = MD8475A(self.md8475a_ip_address, self.wlan_option, self.md8475_version) except AnritsuError: self.log.error("Error in connecting to Anritsu Simulator") return False return True
def _setup_emergency_call(self, set_simulation_func, phone_setup_func, phone_idle_func_after_registration=None, is_ims_call=False, is_wait_for_registration=True, csfb_type=None, srlte_csfb=None, srvcc=None, emergency_number=DEFAULT_EMERGENCY_CALL_NUMBER, teardown_side=CALL_TEARDOWN_PHONE, wait_time_in_call=WAIT_TIME_IN_CALL): try: set_simulation_func(self.anritsu, self.user_params, self.ad.sim_card) set_usim_parameters(self.anritsu, self.ad.sim_card) if is_ims_call or srvcc or csfb_type: set_post_sim_params(self.anritsu, self.user_params, self.ad.sim_card) self.virtualPhoneHandle.auto_answer = (VirtualPhoneAutoAnswer.ON, 2) if csfb_type: self.anritsu.csfb_type = csfb_type if srlte_csfb == "lte_call_failure": self.anritsu.send_command("IMSPSAPAUTOANSWER 1,DISABLE") self.anritsu.start_simulation() self.anritsu.send_command("IMSSTARTVN 1") check_ims_reg = True check_ims_calling = True elif srlte_csfb == "ims_unregistered": self.anritsu.start_simulation() self.anritsu.send_command("IMSSTARTVN 1") self.anritsu.send_command( "IMSCSCFBEHAVIOR 1,SENDERRORRESPONSE603") check_ims_reg = False check_ims_calling = False elif srlte_csfb == "ps911_unsupported": self.anritsu.send_command("EMCBS NOTSUPPORT,BTS1") self.anritsu.start_simulation() self.anritsu.send_command("IMSSTARTVN 1") check_ims_reg = True check_ims_calling = False elif srlte_csfb == "emc_barred": self.anritsu.send_command("ACBARRED USERSPECIFIC,BTS1") self.anritsu.send_command("LTEEMERGENCYACBARRED BARRED,BTS1") self.anritsu.start_simulation() self.anritsu.send_command("IMSSTARTVN 1") check_ims_reg = True check_ims_calling = False elif srvcc == "InCall": self.anritsu.start_simulation() self.anritsu.send_command("IMSSTARTVN 1") self.anritsu.send_command("IMSSTARTVN 2") self.anritsu.send_command("IMSSTARTVN 3") check_ims_reg = True check_ims_calling = True else: self.anritsu.start_simulation() if is_ims_call or csfb_type: self.anritsu.send_command("IMSSTARTVN 1") self.anritsu.send_command("IMSSTARTVN 2") self.anritsu.send_command("IMSSTARTVN 3") iterations = 1 if self.stress_test_number > 0: iterations = self.stress_test_number successes = 0 for i in range(1, iterations + 1): if self.stress_test_number: self.log.info( "Running iteration {} of {}".format(i, iterations)) # FIXME: There's no good reason why this must be true; # I can only assume this was done to work around a problem self.ad.droid.telephonyToggleDataConnection(False) # turn off all other BTS to ensure UE registers on BTS1 sim_model = (self.anritsu.get_simulation_model()).split(",") no_of_bts = len(sim_model) for i in range(2, no_of_bts + 1): self.anritsu.send_command( "OUTOFSERVICE OUT,BTS{}".format(i)) if phone_setup_func is not None: if not phone_setup_func(self.ad): self.log.warning( "phone_setup_func failed. Rebooting UE") self.ad.reboot() time.sleep(30) if self.ad.sim_card == "VzW12349": set_preferred_apn_by_adb(self.ad, "VZWINTERNET") if not phone_setup_func(self.ad): self.log.error("phone_setup_func failed.") continue if is_wait_for_registration: self.anritsu.wait_for_registration_state() if phone_idle_func_after_registration: if not phone_idle_func_after_registration(self.log, self.ad): continue for i in range(2, no_of_bts + 1): self.anritsu.send_command( "OUTOFSERVICE IN,BTS{}".format(i)) time.sleep(WAIT_TIME_ANRITSU_REG_AND_CALL) if srlte_csfb or srvcc: if not ims_call_cs_teardown( self.log, self.ad, self.anritsu, emergency_number, CALL_TEARDOWN_PHONE, True, check_ims_reg, check_ims_calling, srvcc, WAIT_TIME_IN_CALL_FOR_IMS, WAIT_TIME_IN_CALL): self.log.error( "Phone {} Failed to make emergency call to {}" .format(self.ad.serial, emergency_number)) continue else: if not call_mo_setup_teardown( self.log, self.ad, self.anritsu, emergency_number, CALL_TEARDOWN_PHONE, True, WAIT_TIME_IN_CALL, is_ims_call): self.log.error( "Phone {} Failed to make emergency call to {}" .format(self.ad.serial, emergency_number)) continue successes += 1 if self.stress_test_number: self.log.info("Passed iteration {}".format(i)) if self.stress_test_number: self.log.info("Total of {} successes out of {} attempts". format(successes, iterations)) return True if successes == iterations else False except AnritsuError as e: self.log.error("Error in connection with Anritsu Simulator: " + str(e)) return False except Exception as e: self.log.error("Exception during emergency call procedure: " + str( e)) return False return True
def _setup_sms(self, set_simulation_func, phone_setup_func, rat, phone_number, message, mo_mt=DIRECTION_MOBILE_ORIGINATED): try: [self.bts1] = set_simulation_func(self.anritsu, self.user_params, self.ad.sim_card) set_usim_parameters(self.anritsu, self.ad.sim_card) if rat == RAT_LTE: set_post_sim_params(self.anritsu, self.user_params, self.ad.sim_card) self.anritsu.start_simulation() self.anritsu.send_command("IMSSTARTVN 1") self.anritsu.send_command("IMSSTARTVN 2") self.anritsu.send_command("IMSSTARTVN 3") if rat == RAT_LTE: preferred_network_setting = NETWORK_MODE_LTE_GSM_WCDMA rat_family = RAT_FAMILY_LTE elif rat == RAT_WCDMA: preferred_network_setting = NETWORK_MODE_GSM_UMTS rat_family = RAT_FAMILY_UMTS elif rat == RAT_GSM: preferred_network_setting = NETWORK_MODE_GSM_ONLY rat_family = RAT_FAMILY_GSM elif rat == RAT_1XRTT: preferred_network_setting = NETWORK_MODE_CDMA rat_family = RAT_FAMILY_CDMA2000 else: self.log.error("No valid RAT provided for SMS test.") return False if phone_setup_func is not None: if not phone_setup_func(self.ad): self.log.warning("phone_setup_func failed. Rebooting UE") self.ad.reboot() time.sleep(30) if self.ad.sim_card == "VzW12349": set_preferred_apn_by_adb(self.ad, "VZWINTERNET") if not phone_setup_func(self.ad): self.log.error("phone_setup_func failed.") return False self.anritsu.wait_for_registration_state() time.sleep(self.SETTLING_TIME) if mo_mt == DIRECTION_MOBILE_ORIGINATED: if not sms_mo_send(self.log, self.ad, self.virtualPhoneHandle, phone_number, message, rat): self.log.error("Phone {} Failed to send SMS".format( self.ad.serial)) return False else: if not sms_mt_receive_verify(self.log, self.ad, self.virtualPhoneHandle, phone_number, message, rat): self.log.error("Phone {} Failed to receive MT SMS".format( self.ad.serial)) return False except AnritsuError as e: self.log.error("Error in connection with Anritsu Simulator: " + str(e)) return False except Exception as e: self.log.error("Exception during emergency call procedure: " + str(e)) return False return True
def active_handover(self, set_simulation_func, phone_setup_func, phone_idle_func_after_registration=None, volte=True, iperf=True, all_bands=False, is_wait_for_registration=True, voice_number=DEFAULT_CALL_NUMBER, teardown_side=CALL_TEARDOWN_PHONE, wait_time_in_call=WAIT_TIME_IN_CALL): try: bts = set_simulation_func(self.anritsu, self.user_params, self.ad.sim_card) set_usim_parameters(self.anritsu, self.ad.sim_card) set_post_sim_params(self.anritsu, self.user_params, self.ad.sim_card) self.anritsu.start_simulation() self.anritsu.send_command("IMSSTARTVN 1") self.anritsu.send_command("IMSSTARTVN 2") self.anritsu.send_command("IMSSTARTVN 3") # turn off all other BTS to ensure UE registers on BTS1 simmodel = self.anritsu.get_simulation_model().split(',') no_of_bts = len(simmodel) for i in range(2, no_of_bts + 1): self.anritsu.send_command("OUTOFSERVICE OUT,BTS{}".format(i)) if phone_setup_func is not None: if not phone_setup_func(self.ad): self.log.warning("phone_setup_func failed. Rebooting UE") self.ad.reboot() time.sleep(30) if self.ad.sim_card == "VzW12349": set_preferred_apn_by_adb(self.ad, "VZWINTERNET") if not phone_setup_func(self.ad): self.log.error("phone_setup_func failed.") if is_wait_for_registration: self.anritsu.wait_for_registration_state() if phone_idle_func_after_registration: if not phone_idle_func_after_registration(self.log, self.ad): self.log.error("phone_idle_func failed.") for i in range(2, no_of_bts + 1): self.anritsu.send_command("OUTOFSERVICE IN,BTS{}".format(i)) time.sleep(WAIT_TIME_ANRITSU_REG_AND_CALL) if iperf: # setup iPerf server server_ip = self.iperf_setup() if not server_ip: self.log.error("iperf server can not be reached by ping") return False if volte: # make a VoLTE MO call if not make_ims_call(self.log, self.ad, self.anritsu, voice_number): self.log.error( "Phone {} Failed to make volte call to {}".format( self.ad.serial, voice_number)) return False if all_bands and (simmodel[1] == "WCDMA"): band = [] for rat in simmodel[:2]: band.append(self.anritsu.get_supported_bands(rat)) self.log.info("UE reported LTE bands are {}".format(band[0])) self.log.info("UE reported WCDMA bands are {}".format(band[1])) current_lte_band = bts[0].band # move current LTE band to the last in the list band[0].remove(current_lte_band) band[0].append(current_lte_band) n = max(len(band[0]), len(band[1])) else: n = 1 # n is the number of LTE->WCDMA->LTE handovers for i in range(n): if all_bands: bts[1].band = band[1][i % len(band[1])] if not iperf: # VoLTE only result = handover_tc(self.log, self.anritsu, WAITTIME_BEFORE_HANDOVER, BtsNumber.BTS1, BtsNumber.BTS2) time.sleep(WAITTIME_AFTER_HANDOVER) else: # with iPerf iperf_task = (self._iperf_task, (server_ip, WAITTIME_BEFORE_HANDOVER + WAITTIME_AFTER_HANDOVER - 10)) ho_task = (handover_tc, (self.log, self.anritsu, WAITTIME_BEFORE_HANDOVER, BtsNumber.BTS1, BtsNumber.BTS2)) result = run_multithread_func(self.log, [ho_task, iperf_task]) if not result[1]: self.log.error("iPerf failed.") return False self.log.info("handover test case result code {}.".format( result[0])) if volte: # check if the phone stay in call if not self.ad.droid.telecomIsInCall(): self.log.error("Call is already ended in the phone.") return False if not tear_down_call(self.log, self.ad, self.anritsu): self.log.error("Phone {} Failed to tear down".format( self.ad.serial, voice_number)) return False if simmodel[1] == "WCDMA" and iperf: if all_bands: bts[0].band = band[0][i % len(band[0])] iperf_task = (self._iperf_task, (server_ip, WAITTIME_BEFORE_HANDOVER + WAITTIME_AFTER_HANDOVER - 10)) ho_task = (handover_tc, (self.log, self.anritsu, WAITTIME_BEFORE_HANDOVER, BtsNumber.BTS2, BtsNumber.BTS1)) result = run_multithread_func(self.log, [ho_task, iperf_task]) if not result[1]: self.log.error("iPerf failed.") return False self.log.info("handover test case result code {}.".format( result[0])) except AnritsuError as e: self.log.error("Error in connection with Anritsu Simulator: " + str(e)) return False except Exception as e: self.log.error("Exception during voice call procedure: " + str(e)) return False return True
def LTE_WCDMA_data_roaming(self, mcc, mnc, lte_band, wcdma_band): try: [self.bts1, self.bts2] = set_system_model_lte_wcdma(self.anritsu, self.user_params, self.ad.sim_card) set_usim_parameters(self.anritsu, self.ad.sim_card) set_post_sim_params(self.anritsu, self.user_params, self.ad.sim_card) self.bts1.mcc = mcc self.bts1.mnc = mnc self.bts2.mcc = mcc self.bts2.mnc = mnc self.bts1.band = lte_band self.bts2.band = wcdma_band self.bts2.packet_rate = BtsPacketRate.WCDMA_DLHSAUTO_REL8_ULHSAUTO self.anritsu.start_simulation() self.bts2.service_state = BtsServiceState.SERVICE_STATE_OUT self.log.info("Toggle Mobile Data On") self.ad.droid.telephonyToggleDataConnection(True) if not self.phone_setup_data_roaming(): self.log.warning("phone_setup_func failed. Rebooting UE") self.ad.reboot() time.sleep(30) if self.ad.sim_card == "VzW12349": set_preferred_apn_by_adb(self.ad, "VZWINTERNET") if not self.phone_setup_data_roaming(): self.log.error( "Failed to set rat family {}, preferred network:{}". format(RAT_FAMILY_LTE, NETWORK_MODE_LTE_GSM_WCDMA)) return False toggle_cell_data_roaming(self.ad, True) self.anritsu.wait_for_registration_state(1) # for BTS1 LTE time.sleep(TIME_TO_WAIT_BEFORE_PING) for i in range(3): self.ad.log.info("Verify internet connection - attempt %d", i + 1) result = adb_shell_ping(self.ad, PING_DURATION, PING_TARGET) if result: self.ad.log.info("PING SUCCESS") break elif i == 2: self.log.error( "Test Fail: Phone {} can not ping {} with Data Roaming On" .format(self.ad.serial, PING_TARGET)) return False toggle_cell_data_roaming(self.ad, False) time.sleep(TIME_TO_WAIT_BEFORE_PING) if adb_shell_ping(self.ad, PING_DURATION, PING_TARGET): self.log.error( "Test Fail: Phone {} can ping {} with Data Roaming Off". format(self.ad.serial, PING_TARGET)) return False toggle_airplane_mode(self.log, self.ad, True) time.sleep(2) self.bts2.service_state = BtsServiceState.SERVICE_STATE_IN self.bts1.service_state = BtsServiceState.SERVICE_STATE_OUT toggle_airplane_mode(self.log, self.ad, False) toggle_cell_data_roaming(self.ad, True) self.anritsu.wait_for_registration_state(2) # for BTS2 WCDMA time.sleep(TIME_TO_WAIT_BEFORE_PING) for i in range(3): self.ad.log.info("Verify internet connection - attempt %d", i + 1) result = adb_shell_ping(self.ad, PING_DURATION, PING_TARGET) if result: self.ad.log.info("PING SUCCESS") break elif i == 2: self.log.error( "Test Fail: Phone {} can not ping {} with Data Roaming On" .format(self.ad.serial, PING_TARGET)) return False toggle_cell_data_roaming(self.ad, False) time.sleep(TIME_TO_WAIT_BEFORE_PING) if adb_shell_ping(self.ad, PING_DURATION, PING_TARGET): self.log.error( "Test Fail: Phone {} can ping {} with Data Roaming Off". format(self.ad.serial, PING_TARGET)) return False except AnritsuError as e: self.log.error("Error in connection with Anritsu Simulator: " + str(e)) return False except Exception as e: self.log.error("Exception during data roaming: " + str(e)) return False return True