Exemple #1
0
 def _take_bug_report(self, test_name, begin_time):
     test_log_path = os.path.join(self.log_path, test_name)
     utils.create_dir(test_log_path)
     # Extract test_run_info.txt, test_run_detail.txt
     for file_name in ("test_run_info.txt", "test_run_details.txt"):
         extract_test_log(
             self.log, os.path.join(self.log_path, file_name),
             os.path.join(test_log_path, "%s_%s" % (test_name, file_name)),
             "\[Test Case\] %s " % test_name)
     if self._skip_bug_report():
         return
     dev_num = getattr(self, "number_of_devices", None) or len(
         self.android_devices)
     tasks = [(self._ad_take_bugreport, (ad, test_name, begin_time))
              for ad in self.android_devices[:dev_num]]
     tasks.extend([(self._ad_take_extra_logs, (ad, test_name, begin_time))
                   for ad in self.android_devices[:dev_num]])
     run_multithread_func(self.log, tasks)
     for ad in self.android_devices[:dev_num]:
         if getattr(ad, "reboot_to_recover", False):
             reboot_device(ad)
             ad.reboot_to_recover = False
     # Zip log folder
     if not self.user_params.get("zip_log", False): return
     src_dir = os.path.join(self.log_path, test_name)
     file_name = "%s_%s" % (src_dir, begin_time)
     self.log.info("Zip folder %s to %s.zip", src_dir, file_name)
     shutil.make_archive(file_name, "zip", src_dir)
     shutil.rmtree(src_dir)
    def _take_bug_report(self, test_name, begin_time):
        if "no_bug_report_on_fail" in self.user_params:
            return

        tasks = [(self._ad_take_reports, (ad, test_name, begin_time))
                 for ad in self.android_devices]
        run_multithread_func(self.log, tasks)
Exemple #3
0
 def volte_modechange_volte_test(self):
     sub_id = self.dut.droid.subscriptionGetDefaultSubId()
     result = True
     while time.time() < self.finishing_time:
         try:
             if self._prefnetwork_mode_change(sub_id):
                 run_multithread_func(
                     self.log,
                     [(self._data_download, [["5MB"]]),
                      (self._make_phone_call, [is_phone_in_call_volte]),
                      (self._send_message, [])])
             else:
                 result = False
             if self._mobile_data_toggling():
                 run_multithread_func(
                     self.log,
                     [(self._data_download, [["5MB"]]),
                      (self._make_phone_call, [is_phone_in_call_volte]),
                      (self._send_message, [])])
             else:
                 result = False
         except Exception as e:
             self.log.error("Exception error %s", str(e))
             self.result_info["Exception Errors"] += 1
         self.log.info(dict(self.result_info))
         if self.result_info["Exception Errors"] >= EXCEPTION_TOLERANCE:
             self.log.error("Too many exception errors, quit test")
             return False
     return result
Exemple #4
0
 def parallel_tests(self, setup_func=None, call_verification_func=None):
     self.log.info(self._get_result_message())
     if setup_func and not setup_func():
         msg = "%s setup %s failed" % (self.test_name, setup_func.__name__)
         self.log.error(msg)
         self._take_bug_report("%s%s" % (self.test_name,
                                         setup_func.__name__),
                               self.begin_time)
         return False
     if not call_verification_func:
         call_verification_func = is_phone_in_call
     self.finishing_time = time.time() + self.max_run_time
     if self.check_incall_data():
         self.log.info(
             "==== Start parallel voice/message/data stress test ====")
         self.perf_data["testing method"] = "parallel"
         results = run_multithread_func(
             self.log, [(self.call_test, [call_verification_func]),
                        (self.message_test, []), (self.data_test, []),
                        (self.crash_check_test, [])])
     else:
         self.log.info(
             "==== Start sequential voice/message/data stress test ====")
         self.perf_data["testing method"] = "sequential"
         results = run_multithread_func(
             self.log, [(self.sequential_tests, [call_verification_func]),
                        (self.crash_check_test, [])])
     result_message = self._get_result_message()
     self.log.info(result_message)
     self._update_perf_json()
     self.result_detail = result_message
     return all(results)
Exemple #5
0
 def test_data_call_stress(self):
     """ Default state stress test"""
     self.finishing_time = time.time() + self.max_run_time
     results = run_multithread_func(self.log,
                                    [(self.data_call_stress_test, []),
                                     (self.crash_check_test, [])])
     result_message = self._get_result_message()
     self.log.info(result_message)
     self._update_perf_json()
     self.result_detail = result_message
     return all(results)
Exemple #6
0
    def test_wifi_cell_irat_stress_ping_continuous(self):
        """Test for data switch between WiFi and Cell. DUT go in and out WiFi
        coverage for multiple times.

        Steps:
        1. Set WiFi and Cellular signal to good (attenuation value to MIN).
        2. Make sure DUT get Cell data coverage (LTE) and WiFi connected.
        3. Set WiFi RSSI to MAX (WiFi attenuator value to MIN).
        4. Verify DUT report WiFi connected and Internet access OK.
        5. Set WiFi RSSI to MIN (WiFi attenuator value to MAX).
        6. Verify DUT report Cellular Data connected and Internet access OK.
        7. Repeat Step 3~6 for stress number.

        Expected Results:
        4. DUT report WiFi connected and Internet access OK.
        6. DUT report Cellular Data connected and Internet access OK.
        7. Stress test should pass.

        Returns:
        True if Pass. False if fail.
        """
        if not self._basic_connectivity_check():
            self.log.error("Basic Connectivity Check Failed")
            return False

        total_iteration = self.stress_test_number
        ad = self.android_devices[0]
        ping_task = (adb_shell_ping, (ad, DEFAULT_PING_DURATION,
                                      "www.google.com", 200, 40))
        irat_task = (self._wifi_cell_irat_task, (ad, DEFAULT_IRAT_DURATION))
        current_iteration = 1
        while (current_iteration <= total_iteration):
            self.log.info(">----Current iteration = %d/%d----<",
                          current_iteration, total_iteration)
            results = run_multithread_func(self.log, [ping_task, irat_task])
            if not results[1]:
                ad.log.error("Data IRAT failed in active ICMP transfer")
                break
            if results[0]:
                ad.log.info("ICMP transfer succeeded with parallel IRAT")
            else:
                ad.log.error("ICMP transfer failed with parallel IRAT")
                break
            self.log.info(">----Iteration : %d/%d succeed.----<",
                          current_iteration, total_iteration)
            current_iteration += 1
        if current_iteration <= total_iteration:
            self.log.info(">----Iteration : %d/%d failed.----<",
                          current_iteration, total_iteration)
            return False
        else:
            return True
Exemple #7
0
 def parallel_with_network_change_tests(self, setup_func=None):
     if setup_func and not setup_func():
         self.log.error("Test setup %s failed", setup_func.__name__)
         return False
     self.finishing_time = time.time() + self.max_run_time
     results = run_multithread_func(self.log,
                                    [(self.volte_modechange_volte_test, []),
                                     (self.crash_check_test, [])])
     result_message = self._get_result_message()
     self.log.info(result_message)
     self._update_perf_json()
     self.result_detail = result_message
     return all(results)
 def _take_bug_report(self, test_name, begin_time):
     if self._skip_bug_report(test_name):
         return
     dev_num = getattr(self, "number_of_devices", None) or len(
         self.android_devices)
     tasks = [(self._ad_take_bugreport, (ad, test_name, begin_time))
              for ad in self.android_devices[:dev_num]]
     tasks.extend([(self._ad_take_extra_logs, (ad, test_name, begin_time))
                   for ad in self.android_devices[:dev_num]])
     run_multithread_func(self.log, tasks)
     for ad in self.android_devices[:dev_num]:
         if getattr(ad, "reboot_to_recover", False):
             reboot_device(ad)
             ad.reboot_to_recover = False
     # Zip log folder
     if not self.user_params.get("zip_log", False): return
     src_dir = os.path.join(self.log_path, test_name)
     os.makedirs(src_dir, exist_ok=True)
     file_name = "%s_%s" % (src_dir, begin_time)
     self.log.info("Zip folder %s to %s.zip", src_dir, file_name)
     shutil.make_archive(file_name, "zip", src_dir)
     shutil.rmtree(src_dir)
Exemple #9
0
 def parallel_volte_tests(self, setup_func=None):
     if setup_func and not setup_func():
         self.log.error("Test setup %s failed", setup_func.__name__)
         return False
     self.result_info = collections.defaultdict(int)
     self.finishing_time = time.time() + self.max_run_time
     results = run_multithread_func(
         self.log, [(self.volte_modechange_volte_test, []),
                    (self.message_test, []), (self.crash_check_test, [])])
     self.log.info(dict(self.result_info))
     error_message = " ".join(results).strip()
     if error_message:
         self.log.error(error_message)
         fail(error_message)
     return True
Exemple #10
0
def multithread_func(log, tasks):
    """Multi-thread function wrapper.

    Args:
        log: log object.
        tasks: tasks to be executed in parallel.

    Returns:
       List of results of tasks
    """
    results = run_multithread_func(log, tasks)
    for res in results:
        if not res:
            return False
    return True
 def parallel_tests(self, change_env_func, setup_func=None):
     if setup_func and not setup_func():
         self.log.error("Test setup %s failed", setup_func.__name__)
         return False
     self.result_info = collections.defaultdict(int)
     self.finishing_time = time.time() + self.max_run_time
     results = run_multithread_func(self.log, [(self.call_test, []), (
         self.message_test, []), (self.data_test, []), (
             self.crash_check_test, []), (change_env_func, [])])
     result_message = "%s" % dict(self.result_info)
     self.log.info(result_message)
     if all(results):
         explicit_pass(result_message)
     else:
         fail(result_message)
Exemple #12
0
    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