|
|
af8b30 |
From 0a1baf5a3c9eda9a827cbb69a3bb096983baf359 Mon Sep 17 00:00:00 2001
|
|
|
af8b30 |
From: Jan Scotka <jscotka@redhat.com>
|
|
|
af8b30 |
Date: Thu, 3 Mar 2016 16:40:19 +0100
|
|
|
af8b30 |
Subject: [PATCH] test: Fix selenium test
|
|
|
af8b30 |
|
|
|
af8b30 |
We shouldn't assume that we're the only ones working in /tmp during
|
|
|
af8b30 |
the tests, so take a bit more care with the filenames we choose.
|
|
|
af8b30 |
|
|
|
af8b30 |
Also:
|
|
|
af8b30 |
- Handle exceptions in avocado tests while fetching results
|
|
|
af8b30 |
- Limit length of selenium debug output
|
|
|
af8b30 |
|
|
|
af8b30 |
Reviewed-by: Dominik Perpeet <dperpeet@redhat.com>
|
|
|
af8b30 |
---
|
|
|
af8b30 |
test/avocado/run-tests | 13 +++++++++++--
|
|
|
af8b30 |
test/avocado/selenium-login.py | 31 +++++++++++++++++--------------
|
|
|
af8b30 |
test/avocado/seleniumlib.py | 3 ++-
|
|
|
af8b30 |
3 files changed, 30 insertions(+), 17 deletions(-)
|
|
|
af8b30 |
|
|
|
af8b30 |
diff --git a/test/avocado/run-tests b/test/avocado/run-tests
|
|
|
af8b30 |
index cc72fb1..e35b7e5 100755
|
|
|
af8b30 |
--- a/test/avocado/run-tests
|
|
|
af8b30 |
+++ b/test/avocado/run-tests
|
|
|
af8b30 |
@@ -55,7 +55,12 @@ def prepare_avocado_tests(machine):
|
|
|
af8b30 |
machine.upload([os.path.join(machine.test_dir, "avocado")], machine_test_dir)
|
|
|
af8b30 |
|
|
|
af8b30 |
def tap_output(machine):
|
|
|
af8b30 |
- json_info = json.loads(machine.execute(command="cat " + os.path.join(avocado_results_dir, "latest/results.json"), quiet=True))
|
|
|
af8b30 |
+ try:
|
|
|
af8b30 |
+ json_info = json.loads(machine.execute(command="cat " + os.path.join(avocado_results_dir, "latest/results.json"), quiet=True))
|
|
|
af8b30 |
+ except Exception as e:
|
|
|
af8b30 |
+ print "ERROR: Unable to fetch JSON from remote machine:", os.path.join(avocado_results_dir, "latest/results.json")
|
|
|
af8b30 |
+ print e
|
|
|
af8b30 |
+ return None
|
|
|
af8b30 |
print "\nTAP output -------------------------"
|
|
|
af8b30 |
print "1..%s" % len(json_info['tests'])
|
|
|
af8b30 |
counter = 1
|
|
|
af8b30 |
@@ -67,7 +72,11 @@ def tap_output(machine):
|
|
|
af8b30 |
print "# ----------------------------------------------------------------------"
|
|
|
af8b30 |
print "# %s (time %d secs)" % (test_name, test_time)
|
|
|
af8b30 |
print "#"
|
|
|
af8b30 |
- print machine.execute(command="cat " + test_log, quiet=True)
|
|
|
af8b30 |
+ try:
|
|
|
af8b30 |
+ print machine.execute(command="cat " + test_log, quiet=True)
|
|
|
af8b30 |
+ except Exception as e:
|
|
|
af8b30 |
+ print "ERROR: Unable to fetch testlog from remote machine:", test_log
|
|
|
af8b30 |
+ print e
|
|
|
af8b30 |
print "# TEST LOG END -------"
|
|
|
af8b30 |
if test_status == 'PASS':
|
|
|
af8b30 |
print "ok %s %s (time %d secs)" % (counter, test_name, test_time)
|
|
|
af8b30 |
diff --git a/test/avocado/selenium-login.py b/test/avocado/selenium-login.py
|
|
|
af8b30 |
index 29c4404..1e9e081 100755
|
|
|
af8b30 |
--- a/test/avocado/selenium-login.py
|
|
|
af8b30 |
+++ b/test/avocado/selenium-login.py
|
|
|
af8b30 |
@@ -174,20 +174,23 @@ class BasicTestSuite(SeleniumTest):
|
|
|
af8b30 |
self.wait_frame("terminal")
|
|
|
af8b30 |
self.wait_id('terminal')
|
|
|
af8b30 |
terminal = self.wait_xpath("//*[@class='terminal']")
|
|
|
af8b30 |
- self.send_keys(terminal, "touch /tmp/testabc\n", clear=False)
|
|
|
af8b30 |
- self.wait_text("touch /tmp/testabc", user, element="div")
|
|
|
af8b30 |
- self.send_keys(terminal, "touch /tmp/testabd\n", clear=False)
|
|
|
af8b30 |
- self.wait_text("touch /tmp/testabd",user, element="div")
|
|
|
af8b30 |
- self.send_keys(terminal, "ls /tmp/test*\n", clear=False)
|
|
|
af8b30 |
- self.wait_text("ls /tmp/test*",'/tmp/testabc /tmp/testabd', element="div")
|
|
|
af8b30 |
- process.run("ls /tmp/testabc", shell=True)
|
|
|
af8b30 |
- process.run("ls /tmp/testabd", shell=True)
|
|
|
af8b30 |
- self.send_keys(terminal, "rm /tmp/testabc /tmp/testabd\n", clear=False)
|
|
|
af8b30 |
- self.wait_text("rm /tmp/testabc /tmp/testabd",user, element="div")
|
|
|
af8b30 |
- self.send_keys(terminal, "ls /tmp/test*\n", clear=False)
|
|
|
af8b30 |
- self.wait_text("ls /tmp/test*",'cannot access', element="div")
|
|
|
af8b30 |
- process.run("ls /tmp/testabc |wc -l |grep 0", shell=True)
|
|
|
af8b30 |
- process.run("ls /tmp/testabd |wc -l |grep 0", shell=True)
|
|
|
af8b30 |
+ prefix = "/tmp/cockpitrndadr/"
|
|
|
af8b30 |
+ self.send_keys(terminal, "mkdir {0}\n".format(prefix), clear=False)
|
|
|
af8b30 |
+ self.wait_text("mkdir {0}".format(prefix), user, element="div")
|
|
|
af8b30 |
+ self.send_keys(terminal, "touch {0}abc\n".format(prefix), clear=False)
|
|
|
af8b30 |
+ self.wait_text("touch {0}abc".format(prefix), user, element="div")
|
|
|
af8b30 |
+ self.send_keys(terminal, "touch {0}abd\n".format(prefix), clear=False)
|
|
|
af8b30 |
+ self.wait_text("touch {0}abd".format(prefix), user, element="div")
|
|
|
af8b30 |
+ self.send_keys(terminal, "ls {0}*\n".format(prefix), clear=False)
|
|
|
af8b30 |
+ self.wait_text("ls {0}*".format(prefix), '{0}abc'.format(prefix), element="div")
|
|
|
af8b30 |
+ process.run("ls {0}abc".format(prefix), shell=True)
|
|
|
af8b30 |
+ process.run("ls {0}abd".format(prefix), shell=True)
|
|
|
af8b30 |
+ self.send_keys(terminal, "rm {0}abc {0}abd\n".format(prefix), clear=False)
|
|
|
af8b30 |
+ self.wait_text("rm {0}abc {0}abd".format(prefix), user, element="div")
|
|
|
af8b30 |
+ self.send_keys(terminal, "ls {0}*\n".format(prefix), clear=False)
|
|
|
af8b30 |
+ self.wait_text("ls {0}*".format(prefix), 'cannot access', element="div")
|
|
|
af8b30 |
+ process.run("ls {0}abc |wc -l |grep 0".format(prefix), shell=True)
|
|
|
af8b30 |
+ process.run("ls {0}abd |wc -l |grep 0".format(prefix), shell=True)
|
|
|
af8b30 |
self.mainframe()
|
|
|
af8b30 |
self.error=False
|
|
|
af8b30 |
|
|
|
af8b30 |
diff --git a/test/avocado/seleniumlib.py b/test/avocado/seleniumlib.py
|
|
|
af8b30 |
index 8d99cd3..e8e05f9 100755
|
|
|
af8b30 |
--- a/test/avocado/seleniumlib.py
|
|
|
af8b30 |
+++ b/test/avocado/seleniumlib.py
|
|
|
af8b30 |
@@ -111,8 +111,9 @@ class SeleniumTest(Test):
|
|
|
af8b30 |
self.log.info('ERR: Unable to close WEBdriver: {0}'.format(e))
|
|
|
af8b30 |
|
|
|
af8b30 |
def get_debug_logs(self, logs=['browser','driver','client','server']):
|
|
|
af8b30 |
+ max_line_log_count = 10
|
|
|
af8b30 |
for log in logs:
|
|
|
af8b30 |
- receivedlog = self.driver.get_log(log)
|
|
|
af8b30 |
+ receivedlog = [x for x in self.driver.get_log(log)][-max_line_log_count:]
|
|
|
af8b30 |
if receivedlog:
|
|
|
af8b30 |
self.log.info(">>>>> " + log)
|
|
|
af8b30 |
for line in receivedlog:
|
|
|
af8b30 |
--
|
|
|
af8b30 |
1.8.3.1
|
|
|
af8b30 |
|