summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJingjing Liu <jingjingliu@google.com>2017-03-23 09:48:31 -0700
committerJingjing Liu <jingjingliu@google.com>2017-03-23 09:48:31 -0700
commitd06abd405ff6356101af23ba7e719a7970cb4d88 (patch)
treee2123c4fbdeb73cd801005873f395a8303c4a45d
parentbeac150a420955a3f4feda689c1dbe95ac013ee5 (diff)
downloadadt-infra-d06abd405ff6356101af23ba7e719a7970cb4d88.tar.gz
Stabilize test: test_auth_empty_auth_token_file
Reset the emulator's auth token file back when having IO errors. Test: run auth tests locally, passed; will also monitor it on buildbot Change-Id: Ia83504f194ec5f5c848c504c4e51dee4bcdad99d
-rw-r--r--emu_test/test_console/testcase_auth.py37
1 files changed, 24 insertions, 13 deletions
diff --git a/emu_test/test_console/testcase_auth.py b/emu_test/test_console/testcase_auth.py
index 72364942..d506f233 100644
--- a/emu_test/test_console/testcase_auth.py
+++ b/emu_test/test_console/testcase_auth.py
@@ -174,20 +174,31 @@ class AuthTest(testcase_base.BaseConsoleTest):
# save auth token value and empty contents of auth token file
valid_auth_token = util.get_auth_token()
- f = open(util.TOKEN_PATH, 'w')
- f.close()
- # telnet and verify
- self.telnet = util.telnet_emulator()
- self._verify_auth_command_by_enter_help_command(
- util.REGEX_HELP_DISPLAY_AUTH)
-
- # reset auth token file
- f = open(util.TOKEN_PATH, 'w')
- f.write(valid_auth_token)
- f.close()
-
- util.exit_emulator_console(self.telnet)
+ try:
+ f = open(util.TOKEN_PATH, 'w')
+ f.close()
+
+ # telnet and verify
+ self.telnet = util.telnet_emulator()
+ self._verify_auth_command_by_enter_help_command(
+ util.REGEX_HELP_DISPLAY_AUTH)
+
+ # reset auth token file
+ f = open(util.TOKEN_PATH, 'w')
+ f.write(valid_auth_token)
+ f.close()
+
+ util.exit_emulator_console(self.telnet)
+ except IOError as e:
+ print 'IOError on auth token file.'
+ finally:
+ print ('The failure on resetting auth token file back will affact other '
+ 'tests running after this test. Hence, reset it again when '
+ 'failure happens.')
+ f = open(util.TOKEN_PATH, 'w')
+ f.write(valid_auth_token)
+ f.close()
def test_auth_change_auth_token_file_permissions(self):
"""Test command for: auth <auth_token>.