update for envrions for core test / webdriver cases
authorchengtao.liu <chengtaox.liu@intel.com>
Wed, 23 Jul 2014 02:12:19 +0000 (10:12 +0800)
committerchengtao.liu <chengtaox.liu@intel.com>
Wed, 23 Jul 2014 02:12:19 +0000 (10:12 +0800)
testkit-lite
testkitlite/capability/chrome_ubuntu.py
testkitlite/capability/xw_android.py
testkitlite/capability/xw_tizen.py
testkitlite/commodule/androidmobile.py
testkitlite/commodule/localhost.py
testkitlite/commodule/tizenivi.py
testkitlite/commodule/tizenlocal.py
testkitlite/commodule/tizenmobile.py
testkitlite/engines/test_executer.py
testkitlite/engines/webdriver.py

index ea8fd275d91381653e820f777e89c9d03c474424..a2619172850a67eaf590213cb1528e8ae212dde4 100755 (executable)
@@ -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:
index 6e94977782df3c98bc9b847e419f8bef342b4b97..1a62c58b33e2b2c68fc223110b54a2a9208c05f9 100644 (file)
@@ -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:///'}
index 4f25ecf325c3cdc9094c413cd9c9b383913e3955..3430194754d4240335033eea579f33a99c8fcccf 100644 (file)
@@ -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/'}
index 7db08b398d3cd3393b939aa51f22c60d10287e8f..e17bf859fae0a1ec2251841a1a8b2594081e3d28 100644 (file)
@@ -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': ''}
index 4a863c9717351d5ffadb789fa665a8a44459a527..a9be46c0714c44024a465ab802cade224929c056 100644 (file)
@@ -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"
index fb06359e09902a8eaabb49e8ee92587bf234b906..7e99753490ab7386a01e63f8b85e616ea18a5941 100644 (file)
@@ -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"
 
 
index 3980ed5566f7be5748da486d99f9e7148d455373..f1c9f4c6813c45fb787c6b7582d341a05561ccc4 100644 (file)
@@ -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"
index 104363af56557ce26d07ff728f6d7b4c9f219f63..f90fe82dd7aa0ee6a9bca05e9777415412484625 100644 (file)
@@ -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"
index 390da544a2503cb5734c2235cff005d86c5ce2d8..370949dc669fb4e75d0e3216775837828ac7decd 100644 (file)
@@ -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"
index 19e425b23356df035065e7e79dd19fa911c8fd9b..e08cd09bdc4ed94022dd078b4d4dcd3b533d6607 100644 (file)
@@ -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'])
index e4c7c9ad46f3350ee0e2a1beecbfdefe4712577c..d41e47a32c35b7da2d03c5a9c0328e303cba6a99 100644 (file)
@@ -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()