From 17d8883a399aea02193bc12d60f25a2837f16009 Mon Sep 17 00:00:00 2001 From: "chengtao.liu" Date: Wed, 23 Jul 2014 10:12:19 +0800 Subject: [PATCH] update for envrions for core test / webdriver cases --- testkit-lite | 22 ++++++++++++++++++---- testkitlite/capability/chrome_ubuntu.py | 4 ++-- testkitlite/capability/xw_android.py | 6 +++--- testkitlite/capability/xw_tizen.py | 6 +++--- testkitlite/commodule/androidmobile.py | 2 ++ testkitlite/commodule/localhost.py | 2 ++ testkitlite/commodule/tizenivi.py | 2 ++ testkitlite/commodule/tizenlocal.py | 2 ++ testkitlite/commodule/tizenmobile.py | 3 ++- testkitlite/engines/test_executer.py | 10 +++++----- testkitlite/engines/webdriver.py | 5 ++--- 11 files changed, 43 insertions(+), 21 deletions(-) diff --git a/testkit-lite b/testkit-lite index ea8fd27..a261917 100755 --- a/testkit-lite +++ b/testkit-lite @@ -26,6 +26,7 @@ import ConfigParser import xml.etree.ElementTree as etree from optparse import OptionParser, make_option from datetime import datetime +import json try: @@ -273,10 +274,6 @@ to resolve this issue" % (LOG_DIR) elif OPTIONS.bmanualonly: exec_types.remove("auto") - if OPTIONS.targetplatform and OPTIONS.targetplatform.upper().find('TIZEN') >= 0: - if not OPTIONS.debugip: - raise ValueError("tizen xwalk need a debugip input") - # connector options conn_opt = {} conn_opt['commodule'] = OPTIONS.commodule or "tizenmobile" @@ -286,12 +283,28 @@ to resolve this issue" % (LOG_DIR) sys.exit(1) device_id = CONNECTOR.get_device_info()['device_id'] + os.environ['DEVICE_ID'] = device_id if not OPTIONS.non_active: device_locked = get_device_lock(device_id) if not device_locked: LOGGER.error("[ Error: Failed to get device for current session... ]\n") sys.exit(1) + # load profile for wedrvier + if OPTIONS.targetplatform: + webdriver_vars = {} + exec 'from testkitlite.capability.%s import initCapability' % OPTIONS.targetplatform + if OPTIONS.targetplatform.upper().find('TIZEN') >= 0: + if not OPTIONS.debugip: + raise ValueError("tizen xwalk need a debugip value!") + webdriver_vars = initCapability('TEST_APP_ID', OPTIONS.debugip) + elif OPTIONS.targetplatform.upper().find('ANDROID') >= 0: + webdriver_vars = initCapability('TEST_APP_NAME') + else: + webdriver_vars = initCapability() + os.environ['WEBDRIVER_VARS'] = json.dumps(webdriver_vars) + + # load test defintion files if "device:" in OPTIONS.testxml[0]: if not CONNECTOR.is_support_remote(): raise ValueError("For '%s' mode, please test file without prefix 'device:' " % conn_opt['commodule']) @@ -342,6 +355,7 @@ to resolve this issue" % (LOG_DIR) break OPTIONS.testxml = LOCAL_TESTLISTS + # load test engine workername = OPTIONS.worker or 'default' try: diff --git a/testkitlite/capability/chrome_ubuntu.py b/testkitlite/capability/chrome_ubuntu.py index 6e94977..1a62c58 100644 --- a/testkitlite/capability/chrome_ubuntu.py +++ b/testkitlite/capability/chrome_ubuntu.py @@ -1,3 +1,3 @@ -def initCapability(test_app_name=None, appid=None): +def initCapability(test_app=None, debug_ip=None): capability = {'chrome.binary': '/usr/bin/chromium-browser'} - return {'desired_capabilities': capability, 'test_prefix': 'file:///'} + return {'webdriver_url': 'http://127.0.0.1:9515', 'desired_capabilities': capability, 'test_prefix': 'file:///'} diff --git a/testkitlite/capability/xw_android.py b/testkitlite/capability/xw_android.py index 4f25ecf..3430194 100644 --- a/testkitlite/capability/xw_android.py +++ b/testkitlite/capability/xw_android.py @@ -1,4 +1,4 @@ -def initCapability(test_app_name=None, appid=None): +def initCapability(test_app=None, debug_ip=None): capability = {'xwalkOptions': {'androidPackage': 'org.xwalk.%s' % - test_app_name, 'androidActivity': '.%sActivity' % test_app_name}} - return {'desired_capabilities': capability, 'test_prefix': 'file:///android_asset/www/'} + test_app, 'androidActivity': '.%sActivity' % test_app}} + return {'webdriver_url': 'http://127.0.0.1:9515', 'desired_capabilities': capability, 'test_prefix': 'file:///android_asset/www/'} diff --git a/testkitlite/capability/xw_tizen.py b/testkitlite/capability/xw_tizen.py index 7db08b3..e17bf85 100644 --- a/testkitlite/capability/xw_tizen.py +++ b/testkitlite/capability/xw_tizen.py @@ -1,3 +1,3 @@ -def initCapability(test_app_name=None, appid=None): - capability = {'xwalkOptions': {'tizenDebuggerAddress': test_app_name, 'tizenAppId': appid}} - return {'desired_capabilities': capability, 'test_prefix': ''} +def initCapability(test_app=None, debug_ip=None): + capability = {'xwalkOptions': {'tizenDebuggerAddress': debug_ip, 'tizenAppId': test_app}} + return {'webdriver_url': 'http://127.0.0.1:9515', 'desired_capabilities': capability, 'test_prefix': ''} diff --git a/testkitlite/commodule/androidmobile.py b/testkitlite/commodule/androidmobile.py index 4a863c9..a9be46c 100644 --- a/testkitlite/commodule/androidmobile.py +++ b/testkitlite/commodule/androidmobile.py @@ -29,6 +29,8 @@ from testkitlite.util.killall import killall from testkitlite.util.errors import InvalidDeviceException +os.environ['TEST_PLATFORM'] = 'android' +os.environ['CONNECT_TYPE'] = 'adb' LOCAL_HOST_NS = "127.0.0.1" APP_QUERY_STR = "adb -s %s shell ps | grep %s | awk '{print $2}' " APK_INSTALL = "adb -s %s shell pm install %s" diff --git a/testkitlite/commodule/localhost.py b/testkitlite/commodule/localhost.py index fb06359..7e99753 100644 --- a/testkitlite/commodule/localhost.py +++ b/testkitlite/commodule/localhost.py @@ -29,6 +29,8 @@ from testkitlite.util.autoexec import shell_command, shell_command_ext HOST_NS = "127.0.0.1" os.environ['no_proxy'] = HOST_NS +os.environ['TEST_PLATFORM'] = 'localhost' +os.environ['CONNECT_TYPE'] = 'local' APP_QUERY_STR = "ps aux | grep %s | grep -v grep" diff --git a/testkitlite/commodule/tizenivi.py b/testkitlite/commodule/tizenivi.py index 3980ed5..f1c9f4c 100644 --- a/testkitlite/commodule/tizenivi.py +++ b/testkitlite/commodule/tizenivi.py @@ -39,6 +39,8 @@ except ImportError, err: HOST_NS = "127.0.0.1" os.environ['no_proxy'] = HOST_NS +os.environ['TEST_PLATFORM'] = 'tizen' +os.environ['CONNECT_TYPE'] = 'ssh' # common constants RPM_INSTALL = "ssh %s rpm -ivh %s" diff --git a/testkitlite/commodule/tizenlocal.py b/testkitlite/commodule/tizenlocal.py index 104363a..f90fe82 100644 --- a/testkitlite/commodule/tizenlocal.py +++ b/testkitlite/commodule/tizenlocal.py @@ -30,6 +30,8 @@ from testkitlite.util.killall import killall HOST_NS = "127.0.0.1" os.environ['no_proxy'] = HOST_NS +os.environ['TEST_PLATFORM'] = 'tizen' +os.environ['CONNECT_TYPE'] = 'local' RPM_INSTALL = "rpm -ivh %s" RPM_UNINSTALL = "rpm -e %s" RPM_LIST = "rpm -qa | grep tct | grep -v grep" diff --git a/testkitlite/commodule/tizenmobile.py b/testkitlite/commodule/tizenmobile.py index 390da54..370949d 100644 --- a/testkitlite/commodule/tizenmobile.py +++ b/testkitlite/commodule/tizenmobile.py @@ -30,7 +30,8 @@ from testkitlite.util.autoexec import shell_command, shell_command_ext from testkitlite.util.killall import killall from testkitlite.util.errors import InvalidDeviceException - +os.environ['TEST_PLATFORM'] = 'tizen' +os.environ['CONNECT_TYPE'] = 'sdb' LOCAL_HOST_NS = "127.0.0.1" BUILD_INFO_FILE = '/opt/usr/media/Documents/tct/buildinfo.xml' RPM_INSTALL = "sdb -s %s shell rpm -ivh %s" diff --git a/testkitlite/engines/test_executer.py b/testkitlite/engines/test_executer.py index 19e425b..e08cd09 100644 --- a/testkitlite/engines/test_executer.py +++ b/testkitlite/engines/test_executer.py @@ -97,19 +97,19 @@ class TestExecuter: if self.wd_url == '': self.wd_url = DEFAULT_WD_URL - test_app_name = '' + test_app = '' appis = '' if self.target_platform.upper().find('ANDROID') >= 0: - test_app_name = self.suite_name.replace('-', '_') + test_app = self.suite_name.replace('-', '_') self.TE_LOG.debug( 'Got ANDROID platform, update the app name to %s' % test_app_name) elif self.target_platform.upper().find('TIZEN') >= 0: - test_app_name = self.debugip + test_app = self.appid else: - test_app_name = self.suite_name + test_app = self.suite_name exec 'from testkitlite.capability.%s import initCapability' % self.target_platform - driver_env = initCapability(test_app_name, self.appid) + driver_env = initCapability(test_app, self.debugip) self.test_prefix = driver_env['test_prefix'] self.web_driver = WebDriver( self.wd_url, driver_env['desired_capabilities']) diff --git a/testkitlite/engines/webdriver.py b/testkitlite/engines/webdriver.py index e4c7c9a..d41e47a 100644 --- a/testkitlite/engines/webdriver.py +++ b/testkitlite/engines/webdriver.py @@ -158,7 +158,7 @@ class TestWorker(object): #get tizen xw IP and appid if self.opts['target_platform'].upper().find('TIZEN') >= 0: _opts = self.conn.get_launcher_opt('xwalk', None, None, self.opts['suite_name'], self.opts['testset_name']) - self.opts['appid'] = _opts.get("test_app_id", '') + self.opts['appid'] = _opts.get("test_app_id", '') if _opts else '' self.opts['debugip'] = params.get("debugip", '') if not self.__exitExecuter(): @@ -183,7 +183,7 @@ class TestWorker(object): else: timecnt += 1 if not blaunched: - LOGGER.info("[ launch stub process failed! ]") + LOGGER.info("[ launch webdriver failed! ]") return None else: return str(uuid.uuid1()) @@ -257,7 +257,6 @@ class TestWorker(object): command = exe_json['COMMAND'] if exe_json['DATA']: data = exe_json['DATA'] - LOGGER.debug('Got: %s, %s' % (command, data)) except Exception, e: LOGGER.error('Talk with executer failed: %s, kill executer' % e) self.__exitExecuter() -- 2.7.4