fix webdriver issues
authorliuct <liuchengtao1982@gmail.com>
Thu, 14 Aug 2014 11:58:51 +0000 (19:58 +0800)
committerliuct <liuchengtao1982@gmail.com>
Thu, 14 Aug 2014 11:58:51 +0000 (19:58 +0800)
packaging/testkit-lite.dsc
testkitlite/commodule/androidmobile.py
testkitlite/engines/pyunit.py
testkitlite/engines/test_executer.py
testkitlite/engines/webdriver.py
testkitlite/util/log.py

index 0003b00cb1d02ec39d675e255da3b4b74e2fc598..c3bc632c3ee7d6d3b6c7327233781852a4a4dbf0 100644 (file)
@@ -7,5 +7,5 @@ Standards-Version: 3.9.2
 Homepage: https://github.com/testkit/testkit-manager
 Version: 3.1.5
 Files:
12ff71e94baf4d76ab7ba89d9e4b3520 1397814 testkit-lite_3.1.5.tar.gz
cb61d7dc17c1c265e90e93227f352b16 1397823 testkit-lite_3.1.5.tar.gz
 
index a9be46c0714c44024a465ab802cade224929c056..08e1a300fedf983d54fd2b79893698464f92a3c3 100644 (file)
@@ -172,7 +172,9 @@ class AndroidMobile:
             if test_widget is not None and test_widget != "":
                 test_suite = test_widget
             test_suite = test_suite.replace('-', '_')
-            test_opt["test_app_id"] = XWALK_APP_STR % (test_suite, test_suite)
+            tmp_names = test_suite.split('_')
+            test_activity = ''.join([it.capitalize() for it in tmp_names if it])
+            test_opt["test_app_id"] = XWALK_APP_STR % (test_suite, test_activity)
         else:
             test_opt["test_app_id"] = test_launcher
         return test_opt
index f315f4d821edc6a839fc3397b16fe34f9befd05a..528fd6e08048957fa5faec54bd6ded51718e0d56 100644 (file)
@@ -73,7 +73,7 @@ def _pyunit_test_exec(test_session, test_set_path, result_obj):
     result_obj.set_status(0)
     LOGGER.info('[ pyunit test: %s ]' % test_set_path)
     try:
-        tests = unittest.TestLoader().discover(test_set_path)
+        tests = unittest.TestLoader().discover(test_set_path, pattern='*.py')
         unittest.TextTestRunner(resultclass=LiteTestResult, buffer=True).run(tests)
     except ImportError as error:
         pass
index 9b357e5bd6f35d6f5a4b08f21956406395affd58..7cd3f1b2e64fdd3e3da43ab2b6dde8b4e10411aa 100644 (file)
@@ -85,8 +85,9 @@ class TestExecuter:
             test_app = ''
             if self.target_platform.upper().find('ANDROID') >= 0:
                 test_app = self.suite_name.replace('-', '_')
-                self.TE_LOG.debug(
-                    'Got ANDROID platform, update the app name to %s' % test_app)
+                #tmp_names = test_app.split('_')
+                #test_app = ''.join([it.capitalize() for it in tmp_names if it])
+                self.TE_LOG.debug('ANDROID platform, update the app name to %s' % test_app)
             elif self.target_platform.upper().find('TIZEN') >= 0:
                 test_app = self.appid
             else:
@@ -110,10 +111,11 @@ class TestExecuter:
     def __talkWithRunnerRecv(self):
         try:
             exe_data = self.exe_socket.recv(self.exe_socket_buff_size)
+            if exe_data is None:
+                return (None, None)
             exe_json = json.loads(exe_data)
             command = exe_json['COMMAND']
             data = exe_json['DATA']
-            self.TE_LOG.debug('Receive Data: %s' % exe_json)
         except Exception, e:
             self.TE_LOG.debug('Receive data failed, %s' % e)
             time.sleep(2)
@@ -122,7 +124,6 @@ class TestExecuter:
 
     def __talkWithRunnerSend(self, data=None):
         try:
-            self.TE_LOG.debug('Send Data: %s' % data)
             self.exe_socket.send(json.dumps(data))
         except Exception, e:
             self.TE_LOG.debug('Send data failed, %s' % e)
@@ -203,8 +204,6 @@ class TestExecuter:
                     "document.getElementById(\"case-info-area\").className = \"READY\"")
                 if i_case_status in [STR_PASS, STR_FAIL, STR_BLOCK]:
                     self.tests_json['cases'][i_case]['result'] = i_case_status
-                    self.TE_LOG.info("Cases %s: %s" % (self.tests_json['cases'][i_case][
-                                     'case_id'], self.tests_json['cases'][i_case]['result']))
                     i_case = i_case + 1
                 elif i_case_status == "FORWARD":
                     i_case = i_case + 1
@@ -240,8 +239,6 @@ class TestExecuter:
                 "%Y-%m-%d %H:%M:%S", time.localtime())
             try:
                 i_case_timeout = i_case['timeout']
-                self.TE_LOG.debug(
-                    "Using special timeout value: %s" % i_case_timeout)
             except Exception, e:
                 i_case_timeout = DEFAULT_TIMEOUT
 
@@ -320,9 +317,6 @@ class TestExecuter:
             else:
                 i_case['result'] = STR_FAIL
 
-            self.TE_LOG.info("Cases %s: %s" %
-                             (i_case['case_id'], i_case['result']))
-
     def __getCaseIndex(self, url):
         try:
             value_pos = url.index('value')
@@ -376,8 +370,6 @@ class TestExecuter:
                         element_index - 1]['entry']
                     url_equal = self.__checkUrlSame(pre_url, i_case['entry'])
                 i_case_timeout = i_case['timeout']
-                self.TE_LOG.debug(
-                    "Using special timeout value: %s" % i_case_timeout)
             except Exception, e:
                 i_case_timeout = DEFAULT_TIMEOUT
 
@@ -440,8 +432,6 @@ class TestExecuter:
                     return False
             try:
                 i_case_timeout = int(i_case['timeout'])
-                self.TE_LOG.debug(
-                    "Using special timeout value: %s" % i_case_timeout)
             except Exception, e:
                 i_case_timeout = DEFAULT_TIMEOUT
 
@@ -466,8 +456,6 @@ class TestExecuter:
                         i_case['result'] = STR_FAIL
                         break
                     time.sleep(1)
-                self.TE_LOG.info("Cases %s: %s" %
-                                 (i_case['case_id'], i_case['result']))
             except Exception, e:
                 i_case['result'] = STR_BLOCK
                 self.TE_LOG.error(
index a07600bf7e9c9aa386e62d925fc972535478765b..bb7268afe3f80b65cc83ea11980644d0a9e25f7a 100644 (file)
@@ -67,6 +67,8 @@ def _run_webdrvier_test(self, cases, result_obj):
         else:
             end = idx * self.opts['block_size']
         block_data = cases[start:end]
+        for tc in block_data:
+            tc.pop('purpose')
         test_set_queues.append({'cases': block_data})
         idx += 1
 
@@ -77,8 +79,7 @@ def _run_webdrvier_test(self, cases, result_obj):
     for section_json in test_set_queues:
         if result_obj.get_status() == 1:
             break
-        LOGGER.info("Loading a new section for testing ...")
-        time.sleep(EXECUTER_POLLING_INTERVAL)
+        LOGGER.info("Load a new section for testing, please wait ...")
         get_result = False
         while True:
             if result_obj.get_status() == 1:
@@ -95,6 +96,7 @@ def _run_webdrvier_test(self, cases, result_obj):
                         break
                     continue
                 elif exe_data == 'RUNNING':
+                    time.sleep(EXECUTER_POLLING_INTERVAL)
                     continue
                 elif exe_data == 'DONE':
                     exe_command, exe_data = self.talkWithEXE(
@@ -114,7 +116,8 @@ def _run_webdrvier_test(self, cases, result_obj):
                 break
         if abort_from_set:
             LOGGER.error('Exit from current set execution')
-            break
+            return
+    ### normally exit
     result_obj.set_status(1)
     exe_command, exe_data = self.talkWithEXE(
         'TERMINAL', '', 1)
@@ -129,7 +132,7 @@ class TestWorker(object):
         self.conn = conn
         self.server_url = None
         self.result_obj = None
-        self.opts = dict({'block_size': 20,
+        self.opts = dict({'block_size': 10,
                           'test_type': None,
                           'exe_socket_buff_size': 20480,
                           'runner_proc': os.getpid(),
@@ -254,6 +257,8 @@ class TestWorker(object):
                 json.dumps({'COMMAND': command, 'DATA': data}))
             exe_data = self.exe_socket_connect.recv(
                 self.opts['exe_socket_buff_size'])
+            if not exe_data:
+                return (None, None)
             exe_json = json.loads(exe_data)
             if exe_json['COMMAND']:
                 command = exe_json['COMMAND']
index 648c34229da61e8bd790a7f96666093e68cc5b0f..fe98dbdf1ab7f5a61adb93142b1f5767bc95f89a 100644 (file)
@@ -41,6 +41,7 @@ class Logger:
     def __init__(self, level="DEBUG", format_str="%(message)s"):
         """Generate root logger"""
         self._logger = logging.getLogger("TCT")
+        self._level = LEVELS[level]
         self._logger.setLevel(LEVELS[level])
         self._formatter = logging.Formatter(format_str)
         self.add_print_logger()