acloud: Wait for a long time and no any response message when create --local-instance fail
Add timeout mechanism
Bug: 118849630
Test: m acloud && atest acloud_test && acloud create --local-instance --local-image
Change-Id: Ie82b9e94dfbb4228c3239aad662c424bab50ca00
diff --git a/internal/lib/utils_test.py b/internal/lib/utils_test.py
index 79c1c6d..8c8a460 100644
--- a/internal/lib/utils_test.py
+++ b/internal/lib/utils_test.py
@@ -55,6 +55,7 @@
return self.width
+# pylint: disable=too-many-public-methods
class UtilsTest(driver_test_lib.BaseDriverTest):
"""Test Utils."""
@@ -376,5 +377,28 @@
utils.ScpPullFile, "/tmp/test", "/tmp/test_1.log", "192.168.0.1")
+ def testTimeoutException(self):
+ """Test TimeoutException."""
+ @utils.TimeoutException(1, "should time out")
+ def functionThatWillTimeOut():
+ """Test decorator of @utils.TimeoutException should timeout."""
+ time.sleep(5)
+
+ self.assertRaises(errors.FunctionTimeoutError,
+ functionThatWillTimeOut)
+
+
+ def testTimeoutExceptionNoTimeout(self):
+ """Test No TimeoutException."""
+ @utils.TimeoutException(5, "shouldn't time out")
+ def functionThatShouldNotTimeout():
+ """Test decorator of @utils.TimeoutException shouldn't timeout."""
+ return None
+ try:
+ functionThatShouldNotTimeout()
+ except errors.FunctionTimeoutError:
+ self.fail("shouldn't timeout")
+
+
if __name__ == "__main__":
unittest.main()