[WifiDppTest] Add retries to the test cases
CHERRY PICKED CHANGES FROM git_master
Add retries for flaky tests. Added the retry to WifiBaseTest.
Refer b/139374686#4. Though only some tests are flaky, the retries has been added to all tests.
Bug: 147150207
Test: Verified the changes
Change-Id: Ife9f04a933754f1f44d8d00bf5bde68ccdf0ebdd
Merged-In: Iad3738eb2113d3ecaed2ec138db516d50077c506
diff --git a/acts/framework/acts/test_utils/wifi/WifiBaseTest.py b/acts/framework/acts/test_utils/wifi/WifiBaseTest.py
index cb7ab80..82d655f 100644
--- a/acts/framework/acts/test_utils/wifi/WifiBaseTest.py
+++ b/acts/framework/acts/test_utils/wifi/WifiBaseTest.py
@@ -24,6 +24,7 @@
import acts.controllers.access_point as ap
from acts import asserts
+from acts import signals
from acts import utils
from acts.base_test import BaseTestClass
from acts.signals import TestSignal
@@ -608,3 +609,46 @@
hostapd_constants.BAND_5G, channel_5g)
if not result:
raise ValueError("Failed to configure channel for 5G band.")
+
+ @staticmethod
+ def wifi_test_wrap(fn):
+ def _safe_wrap_test_case(self, *args, **kwargs):
+ test_id = "%s:%s:%s" % (self.__class__.__name__, self.test_name,
+ self.log_begin_time.replace(' ', '-'))
+ self.test_id = test_id
+ self.result_detail = ""
+ tries = int(self.user_params.get("wifi_auto_rerun", 3))
+ for ad in self.android_devices:
+ ad.log_path = self.log_path
+ for i in range(tries + 1):
+ result = True
+ if i > 0:
+ log_string = "[Test Case] RETRY:%s %s" % (i, self.test_name)
+ self.log.info(log_string)
+ self._teardown_test(self.test_name)
+ self._setup_test(self.test_name)
+ try:
+ result = fn(self, *args, **kwargs)
+ except signals.TestFailure as e:
+ self.log.warn("Error msg: %s" % e)
+ if self.result_detail:
+ signal.details = self.result_detail
+ result = False
+ except signals.TestSignal:
+ if self.result_detail:
+ signal.details = self.result_detail
+ raise
+ except Exception as e:
+ self.log.exception(e)
+ asserts.fail(self.result_detail)
+ if result is False:
+ if i < tries:
+ continue
+ else:
+ break
+ if result is not False:
+ asserts.explicit_pass(self.result_detail)
+ else:
+ asserts.fail(self.result_detail)
+
+ return _safe_wrap_test_case
diff --git a/acts/tests/google/wifi/WifiDppTest.py b/acts/tests/google/wifi/WifiDppTest.py
index d7788db..42591b0 100644
--- a/acts/tests/google/wifi/WifiDppTest.py
+++ b/acts/tests/google/wifi/WifiDppTest.py
@@ -19,14 +19,14 @@
import time
from acts import asserts
-from acts import base_test
from acts import utils
from acts.test_decorators import test_tracker_info
from acts.test_utils.wifi import wifi_constants
from acts.test_utils.wifi import wifi_test_utils as wutils
+from acts.test_utils.wifi.WifiBaseTest import WifiBaseTest
from acts.test_utils.wifi.aware import aware_test_utils as autils
-class WifiDppTest(base_test.BaseTestClass):
+class WifiDppTest(WifiBaseTest):
"""This class tests the DPP API surface.
Attributes: The tests in this class require one DUT and one helper phone
@@ -84,8 +84,8 @@
wutils.reset_wifi(self.dut)
def on_fail(self, test_name, begin_time):
- self.dut.take_bug_report(test_name, begin_time)
- self.dut.cat_adb_log(test_name, begin_time)
+ self.dut.take_bug_report(test_name, begin_time)
+ self.dut.cat_adb_log(test_name, begin_time)
def create_and_save_wifi_network_config(self, security):
""" Create a config with random SSID and password.
@@ -625,6 +625,7 @@
""" Tests Begin """
@test_tracker_info(uuid="30893d51-2069-4e1c-8917-c8a840f91b59")
+ @WifiBaseTest.wifi_test_wrap
def test_dpp_as_initiator_configurator_with_psk_5G(self):
asserts.skip_if(not self.dut.droid.wifiIs5GHzBandSupported() or
not self.helper_dev.droid.wifiIs5GHzBandSupported(),
@@ -634,6 +635,7 @@
use_mac=True)
@test_tracker_info(uuid="54d1d19a-aece-459c-b819-9d4b1ae63f77")
+ @WifiBaseTest.wifi_test_wrap
def test_dpp_as_initiator_configurator_with_psk_5G_broadcast(self):
asserts.skip_if(not self.dut.droid.wifiIs5GHzBandSupported() or
not self.helper_dev.droid.wifiIs5GHzBandSupported(),
@@ -643,6 +645,7 @@
use_mac=False)
@test_tracker_info(uuid="18270a69-300c-4f54-87fd-c19073a2854e ")
+ @WifiBaseTest.wifi_test_wrap
def test_dpp_as_initiator_configurator_with_psk_no_chan_in_uri_listen_on_5745_broadcast(self):
asserts.skip_if(not self.dut.droid.wifiIs5GHzBandSupported() or
not self.helper_dev.droid.wifiIs5GHzBandSupported(),
@@ -651,6 +654,7 @@
security=self.DPP_TEST_SECURITY_PSK, responder_chan=None, responder_freq=5745, use_mac=False)
@test_tracker_info(uuid="fbdd687c-954a-400b-9da3-2d17e28b0798")
+ @WifiBaseTest.wifi_test_wrap
def test_dpp_as_initiator_configurator_with_psk_no_chan_in_uri_listen_on_5745(self):
asserts.skip_if(not self.dut.droid.wifiIs5GHzBandSupported() or
not self.helper_dev.droid.wifiIs5GHzBandSupported(),
@@ -658,42 +662,50 @@
self.start_dpp_as_initiator_configurator(
security=self.DPP_TEST_SECURITY_PSK, responder_chan=None, responder_freq=5745, use_mac=True)
- @test_tracker_info(uuid="570f499f-ab12-4405-af14-c9ed36da2e01 ")
+ @test_tracker_info(uuid="570f499f-ab12-4405-af14-c9ed36da2e01")
+ @WifiBaseTest.wifi_test_wrap
def test_dpp_as_initiator_configurator_with_psk_no_chan_in_uri_listen_on_2462_broadcast(self):
self.start_dpp_as_initiator_configurator(
security=self.DPP_TEST_SECURITY_PSK, responder_chan=None, responder_freq=2462, use_mac=False)
@test_tracker_info(uuid="e1f083e0-0878-4c49-8ac5-d7c6bba24625")
+ @WifiBaseTest.wifi_test_wrap
def test_dpp_as_initiator_configurator_with_psk_no_chan_in_uri_listen_on_2462(self):
self.start_dpp_as_initiator_configurator(
security=self.DPP_TEST_SECURITY_PSK, responder_chan=None, responder_freq=2462, use_mac=True)
@test_tracker_info(uuid="d2a526f5-4269-493d-bd79-4e6d1b7b00f0")
+ @WifiBaseTest.wifi_test_wrap
def test_dpp_as_initiator_configurator_with_psk(self):
self.start_dpp_as_initiator_configurator(
security=self.DPP_TEST_SECURITY_PSK, use_mac=True)
@test_tracker_info(uuid="6ead218c-222b-45b8-8aad-fe7d883ed631")
+ @WifiBaseTest.wifi_test_wrap
def test_dpp_as_initiator_configurator_with_sae(self):
self.start_dpp_as_initiator_configurator(
security=self.DPP_TEST_SECURITY_SAE, use_mac=True)
@test_tracker_info(uuid="1686adb5-1b3c-4e6d-a969-6b007bdd990d")
+ @WifiBaseTest.wifi_test_wrap
def test_dpp_as_initiator_configurator_with_psk_passphrase(self):
self.start_dpp_as_initiator_configurator(
security=self.DPP_TEST_SECURITY_PSK_PASSPHRASE, use_mac=True)
@test_tracker_info(uuid="3958feb5-1a0c-4487-9741-ac06f04c55a2")
+ @WifiBaseTest.wifi_test_wrap
def test_dpp_as_initiator_configurator_with_sae_broadcast(self):
self.start_dpp_as_initiator_configurator(
security=self.DPP_TEST_SECURITY_SAE, use_mac=False)
@test_tracker_info(uuid="fe6d66f5-73a1-46e9-8f49-73b8f332cc8c")
+ @WifiBaseTest.wifi_test_wrap
def test_dpp_as_initiator_configurator_with_psk_passphrase_broadcast(self):
self.start_dpp_as_initiator_configurator(
security=self.DPP_TEST_SECURITY_PSK_PASSPHRASE, use_mac=False)
@test_tracker_info(uuid="9edd372d-e2f1-4545-8d04-6a1636fcbc4b")
+ @WifiBaseTest.wifi_test_wrap
def test_dpp_as_initiator_configurator_with_sae_for_ap(self):
self.start_dpp_as_initiator_configurator(
security=self.DPP_TEST_SECURITY_SAE,
@@ -701,6 +713,7 @@
net_role=self.DPP_TEST_NETWORK_ROLE_AP)
@test_tracker_info(uuid="e9eec912-d665-4926-beac-859cb13dc17b")
+ @WifiBaseTest.wifi_test_wrap
def test_dpp_as_initiator_configurator_with_psk_passphrase_for_ap(self):
self.start_dpp_as_initiator_configurator(
security=self.DPP_TEST_SECURITY_PSK_PASSPHRASE,
@@ -708,26 +721,31 @@
net_role=self.DPP_TEST_NETWORK_ROLE_AP)
@test_tracker_info(uuid="8055694f-606f-41dd-9826-3ea1e9b007f8")
+ @WifiBaseTest.wifi_test_wrap
def test_dpp_as_initiator_enrollee_with_sae(self):
self.start_dpp_as_initiator_enrollee(
security=self.DPP_TEST_SECURITY_SAE, use_mac=True)
@test_tracker_info(uuid="c1e9f605-b5c0-4e53-8a08-1b0087a667fa")
+ @WifiBaseTest.wifi_test_wrap
def test_dpp_as_initiator_enrollee_with_psk_passphrase(self):
self.start_dpp_as_initiator_enrollee(
security=self.DPP_TEST_SECURITY_PSK_PASSPHRASE, use_mac=True)
@test_tracker_info(uuid="1d7f30ad-2f9a-427a-8059-651dc8827ae2")
+ @WifiBaseTest.wifi_test_wrap
def test_dpp_as_initiator_enrollee_with_sae_broadcast(self):
self.start_dpp_as_initiator_enrollee(
security=self.DPP_TEST_SECURITY_SAE, use_mac=False)
@test_tracker_info(uuid="0cfc2645-600e-4f2b-ab5c-fcee6d363a9a")
+ @WifiBaseTest.wifi_test_wrap
def test_dpp_as_initiator_enrollee_with_psk_passphrase_broadcast(self):
self.start_dpp_as_initiator_enrollee(
security=self.DPP_TEST_SECURITY_PSK_PASSPHRASE, use_mac=False)
@test_tracker_info(uuid="2e26b248-65dd-41f6-977b-e223d72b2de9")
+ @WifiBaseTest.wifi_test_wrap
def test_start_dpp_as_initiator_enrollee_receive_invalid_config(self):
self.start_dpp_as_initiator_enrollee(
security=self.DPP_TEST_SECURITY_PSK_PASSPHRASE,
@@ -735,6 +753,7 @@
invalid_config=True)
@test_tracker_info(uuid="ed189661-d1c1-4626-9f01-3b7bb8a417fe")
+ @WifiBaseTest.wifi_test_wrap
def test_dpp_as_initiator_configurator_fail_authentication(self):
self.start_dpp_as_initiator_configurator(
security=self.DPP_TEST_SECURITY_PSK_PASSPHRASE,
@@ -742,6 +761,7 @@
fail_authentication=True)
@test_tracker_info(uuid="5a8c6587-fbb4-4a27-9cba-af6f8935833a")
+ @WifiBaseTest.wifi_test_wrap
def test_dpp_as_initiator_configurator_fail_unicast_timeout(self):
self.start_dpp_as_initiator_configurator(
security=self.DPP_TEST_SECURITY_PSK_PASSPHRASE,
@@ -749,6 +769,7 @@
cause_timeout=True)
@test_tracker_info(uuid="b12353ac-1a04-4036-81a4-2d2d0c653dbb")
+ @WifiBaseTest.wifi_test_wrap
def test_dpp_as_initiator_configurator_fail_broadcast_timeout(self):
self.start_dpp_as_initiator_configurator(
security=self.DPP_TEST_SECURITY_PSK_PASSPHRASE,
@@ -756,6 +777,7 @@
cause_timeout=True)
@test_tracker_info(uuid="eeff91be-09ce-4a33-8b4f-ece40eb51c76")
+ @WifiBaseTest.wifi_test_wrap
def test_dpp_as_initiator_configurator_invalid_uri(self):
self.start_dpp_as_initiator_configurator(
security=self.DPP_TEST_SECURITY_PSK_PASSPHRASE,
@@ -763,6 +785,7 @@
invalid_uri=True)
@test_tracker_info(uuid="1fa25f58-0d0e-40bd-8714-ab78957514d9")
+ @WifiBaseTest.wifi_test_wrap
def test_start_dpp_as_initiator_enrollee_fail_timeout(self):
self.start_dpp_as_initiator_enrollee(
security=self.DPP_TEST_SECURITY_PSK_PASSPHRASE,