Esempio n. 1
0
    def test_android_runner_task_install_android_apks(self):
        device_serial = '192.168.31.223:5555'
        app_id = 'com.chi.ssetest'
        release_version = 'release-20191016-0.0.3'

        with DAG(dag_id='any_dag', start_date=datetime.now()) as dag:

            def push_function(**kwargs):
                release_apk = ReleaseFile()
                release_apk.name = 'app-debug.apk'
                release_apk.type = 'application/vnd.android.package-archive'
                release_apk.url = 'https://github.com/stocksdktest/AndroidTestRunner/releases/download/release-20191016-0.0.3/app-debug.apk'
                release_testing = ReleaseFile()
                release_testing.name = 'app-debug-androidTest.apk'
                release_testing.type = 'application/vnd.android.package-archive'
                release_testing.url = 'https://github.com/stocksdktest/AndroidTestRunner/releases/download/release-20191016-0.0.3/app-debug-androidTest.apk'
                kwargs['ti'].xcom_push(key='android_release',
                                       value=[release_apk, release_testing])

            release_provider = PythonOperator(task_id='push_task',
                                              python_callable=push_function,
                                              provide_context=True)
            android_runner = AndroidRunnerOperator(task_id='android_runner',
                                                   provide_context=True,
                                                   apk_id=app_id,
                                                   apk_version=release_version,
                                                   target_device=device_serial,
                                                   runner_conf=RunnerConfig())
            release_provider >> android_runner

            execution_date = datetime.now()

            provider_instance = TaskInstance(task=release_provider,
                                             execution_date=execution_date)
            release_provider.execute(provider_instance.get_template_context())

            runner_instance = TaskInstance(task=android_runner,
                                           execution_date=execution_date)
            context = runner_instance.get_template_context()
            context['run_id'] = 'fake-run'
            android_runner.pre_execute(context)

            main_apk_version = get_app_version(device_serial, app_id)
            testing_apk_version = get_app_version(device_serial,
                                                  '%s.test' % app_id)

            self.assertEqual(release_version, main_apk_version,
                             'main app version not match')
            self.assertEqual(release_version, testing_apk_version,
                             'testing app version not match')
Esempio n. 2
0
    def test_android_ci_task_push_assets_to_xcom(self):
        with DAG(dag_id='any_dag', start_date=datetime.now()) as dag:
            android_release = AndroidReleaseOperator(
                task_id='android_release',
                provide_context=False,
                repo_name='stocksdktest/AndroidTestRunner',
                tag_id='release-20191016-0.0.3',
                tag_sha='16a5ad8d128df1b55f962b52e87bac481f98475f',
                runner_conf=RunnerConfig())

            task_instance = TaskInstance(task=android_release,
                                         execution_date=datetime.now())
            android_release.execute(task_instance.get_template_context())

            release_files = task_instance.xcom_pull(key='android_release')
            self.assertIsNotNone(release_files)
            print(release_files)
Esempio n. 3
0
    def test_android_ci_task_push_assets_to_xcom(self):
        with DAG(dag_id='any_dag', start_date=datetime.now()) as dag:
            android_release = AndroidReleaseOperator(
                task_id='android_release',
                provide_context=False,
                repo_name='stocksdktest/AndroidTestRunner',
                tag_id='release-20191028-0.0.1',
                tag_sha='83eab8326e7901d744599bff60defaea135f7bf0',
                runner_conf=RunnerConfig())

            task_instance = TaskInstance(task=android_release,
                                         execution_date=datetime.now())
            android_release.execute(task_instance.get_template_context())

            release_files = task_instance.xcom_pull(key='android_release')
            self.assertIsNotNone(release_files)
            print(release_files)
Esempio n. 4
0
import json

from protos_gen.config_pb2 import RunnerConfig, TestcaseConfig
from protos_gen.record_pb2 import TestExecutionRecord
from utils.base import generate_id, base64_encode, LogChunkCache
from utils.ios import config_plist, xctest_cmd, spawn_xcrun_log, parse_sim_log

if __name__ == '__main__':
    runner_conf = RunnerConfig()
    runner_conf.jobID = 'TJ-1'
    runner_conf.runnerID = generate_id('RUN-A')

    runner_conf.sdkConfig.appKeyIOS = 'VVW0Fno7BEZt1a/y6KLM36uj9qcjw7CAHDwWZKDlWDs='
    runner_conf.sdkConfig.appKeyAndroid = 'J6IPlk5AEU+2/Yi59rfYnsFQtdtOgAo9GAzysx8ciOM='

    # runner_conf.sdkConfig.serverSites["shl2"].CopyFrom(Site(ips=["http://114.80.155.50:22016"]))

    runner_conf.sdkConfig.marketPerm.Level = "2"
    # runner_conf.sdkConfig.marketPerm.CffLevel = "2"
    # runner_conf.sdkConfig.marketPerm.DceLevel = "2"
    # runner_conf.sdkConfig.marketPerm.CzceLevel = "2"
    # runner_conf.sdkConfig.marketPerm.FeLevel = "2"
    # runner_conf.sdkConfig.marketPerm.GILevel = "2"
    # runner_conf.sdkConfig.marketPerm.ShfeLevel = "2"
    # runner_conf.sdkConfig.marketPerm.HKPerms.extend(["hk10", "hka1"])

    case_conf = TestcaseConfig()
    case_conf.testcaseID = 'TESTCASE_1'
    case_conf.continueWhenFailed = False
    case_conf.roundIntervalSec = 3
    case_conf.paramStrs.extend([json.dumps({'QUOTE_NUMBERS': '600000.sh'})])
Esempio n. 5
0
def initRunnerConfig():
    runner_conf_list = []

    for i in range(2):
        runner_conf = RunnerConfig()

        runner_conf.sdkConfig.appKeyIOS = 'VVW0Fno7BEZt1a/y6KLM36uj9qcjw7CAHDwWZKDlWDs='
        runner_conf.sdkConfig.appKeyAndroid = 'J6IPlk5AEU+2/Yi59rfYnsFQtdtOgAo9GAzysx8ciOM='
        runner_conf.sdkConfig.marketPerm.Level = "1"
        runner_conf.sdkConfig.marketPerm.HKPerms.extend(["hk10"])

        if i == 0:
            runner_conf.sdkConfig.serverSites["sh"].CopyFrom(
                Site(ips=["http://114.80.155.61:22016"]))
            runner_conf.sdkConfig.serverSites["sz"].CopyFrom(
                Site(ips=["http://114.80.155.61:22016"]))
            runner_conf.sdkConfig.serverSites["bj"].CopyFrom(
                Site(ips=["http://114.80.155.61:22016"]))
            runner_conf.sdkConfig.serverSites["cf"].CopyFrom(
                Site(ips=["http://114.80.155.61:22016"]))
            runner_conf.sdkConfig.serverSites["nf"].CopyFrom(
                Site(ips=["http://114.80.155.61:22013"]))
            runner_conf.sdkConfig.serverSites["gf"].CopyFrom(
                Site(ips=["http://114.80.155.61:22013"]))
            runner_conf.sdkConfig.serverSites["pb"].CopyFrom(
                Site(ips=["http://114.80.155.61:22016"]))
            runner_conf.sdkConfig.serverSites["hk1"].CopyFrom(
                Site(ips=["http://114.80.155.133:22016"]))
            runner_conf.sdkConfig.serverSites["hk5"].CopyFrom(
                Site(ips=["http://114.80.155.133:22016"]))
            runner_conf.sdkConfig.serverSites["hk10"].CopyFrom(
                Site(ips=["http://114.80.155.133:22016"]))
            runner_conf.sdkConfig.serverSites["hka1"].CopyFrom(
                Site(ips=["http://114.80.155.133:22016"]))
            runner_conf.sdkConfig.serverSites["hkd1"].CopyFrom(
                Site(ips=["http://114.80.155.133:22016"]))
            runner_conf.sdkConfig.serverSites["hkaz"].CopyFrom(
                Site(ips=["http://114.80.155.133:22016"]))
            runner_conf.sdkConfig.serverSites["hkdz"].CopyFrom(
                Site(ips=["http://114.80.155.133:22016"]))
        else:
            runner_conf.sdkConfig.serverSites["sh"].CopyFrom(
                Site(ips=["http://114.80.155.61:22016"]))
            runner_conf.sdkConfig.serverSites["sz"].CopyFrom(
                Site(ips=["http://114.80.155.61:22016"]))
            runner_conf.sdkConfig.serverSites["bj"].CopyFrom(
                Site(ips=["http://114.80.155.61:22016"]))
            runner_conf.sdkConfig.serverSites["cf"].CopyFrom(
                Site(ips=["http://114.80.155.61:22016"]))
            runner_conf.sdkConfig.serverSites["nf"].CopyFrom(
                Site(ips=["http://114.80.155.61:22013"]))
            runner_conf.sdkConfig.serverSites["gf"].CopyFrom(
                Site(ips=["http://114.80.155.61:22013"]))
            runner_conf.sdkConfig.serverSites["pb"].CopyFrom(
                Site(ips=["http://114.80.155.61:22016"]))
            runner_conf.sdkConfig.serverSites["hk1"].CopyFrom(
                Site(ips=["http://114.80.155.133:22016"]))
            runner_conf.sdkConfig.serverSites["hk5"].CopyFrom(
                Site(ips=["http://114.80.155.133:22016"]))
            runner_conf.sdkConfig.serverSites["hk10"].CopyFrom(
                Site(ips=["http://114.80.155.133:22016"]))
            runner_conf.sdkConfig.serverSites["hka1"].CopyFrom(
                Site(ips=["http://114.80.155.133:22016"]))
            runner_conf.sdkConfig.serverSites["hkd1"].CopyFrom(
                Site(ips=["http://114.80.155.133:22016"]))
            runner_conf.sdkConfig.serverSites["hkaz"].CopyFrom(
                Site(ips=["http://114.80.155.133:22016"]))
            runner_conf.sdkConfig.serverSites["hkdz"].CopyFrom(
                Site(ips=["http://114.80.155.133:22016"]))
        case_list = []

        case_conf = TestcaseConfig()
        case_conf.testcaseID = 'OHLCTEST_1'
        case_conf.roundIntervalSec = 3
        case_conf.continueWhenFailed = False
        case_conf.paramStrs.extend(
            [json.dumps({
                'stk': '00700.hk',
                'type': 'dayk'
            })])
        case_list.append(case_conf)

        runner_conf.casesConfig.extend(case_list)
        print('i,case_list.length is ', case_list.__len__())
        runner_conf_list.append(runner_conf)

    return runner_conf_list
Esempio n. 6
0
def initRunnerConfig():
    runner_conf_list = []

    for i in range(2):
        runner_conf = RunnerConfig()

        runner_conf.sdkConfig.appKeyIOS = 'VVW0Fno7BEZt1a/y6KLM36uj9qcjw7CAHDwWZKDlWDs='
        runner_conf.sdkConfig.appKeyAndroid = 'J6IPlk5AEU+2/Yi59rfYnsFQtdtOgAo9GAzysx8ciOM='
        runner_conf.sdkConfig.marketPerm.Level = "1"
        runner_conf.sdkConfig.marketPerm.HKPerms.extend(["hk10"])

        if i == 0:
            runner_conf.sdkConfig.serverSites["sh"].CopyFrom(
                Site(ips=["http://114.80.155.134:22016"]))
            runner_conf.sdkConfig.serverSites["sz"].CopyFrom(
                Site(ips=["http://114.80.155.134:22016"]))
            runner_conf.sdkConfig.serverSites["bj"].CopyFrom(
                Site(ips=["http://114.80.155.134:22016"]))
            runner_conf.sdkConfig.serverSites["cf"].CopyFrom(
                Site(ips=["http://114.80.155.134:22016"]))
            runner_conf.sdkConfig.serverSites["nf"].CopyFrom(
                Site(ips=["http://114.80.155.134:22013"]))
            runner_conf.sdkConfig.serverSites["gf"].CopyFrom(
                Site(ips=["http://114.80.155.134:22013"]))
            runner_conf.sdkConfig.serverSites["pb"].CopyFrom(
                Site(ips=["http://114.80.155.134:22016"]))
            runner_conf.sdkConfig.serverSites["hk1"].CopyFrom(
                Site(ips=["http://114.80.155.133:22016"]))
            runner_conf.sdkConfig.serverSites["hk5"].CopyFrom(
                Site(ips=["http://114.80.155.133:22016"]))
            runner_conf.sdkConfig.serverSites["hk10"].CopyFrom(
                Site(ips=["http://114.80.155.133:22016"]))
            runner_conf.sdkConfig.serverSites["hka1"].CopyFrom(
                Site(ips=["http://114.80.155.133:22016"]))
            runner_conf.sdkConfig.serverSites["hkd1"].CopyFrom(
                Site(ips=["http://114.80.155.133:22016"]))
            runner_conf.sdkConfig.serverSites["hkaz"].CopyFrom(
                Site(ips=["http://114.80.155.133:22016"]))
            runner_conf.sdkConfig.serverSites["hkdz"].CopyFrom(
                Site(ips=["http://114.80.155.133:22016"]))
        else:
            runner_conf.sdkConfig.serverSites["sh"].CopyFrom(
                Site(ips=["http://114.80.155.61:22016"]))
            runner_conf.sdkConfig.serverSites["sz"].CopyFrom(
                Site(ips=["http://114.80.155.61:22016"]))
            runner_conf.sdkConfig.serverSites["bj"].CopyFrom(
                Site(ips=["http://114.80.155.61:22016"]))
            runner_conf.sdkConfig.serverSites["cf"].CopyFrom(
                Site(ips=["http://114.80.155.61:22016"]))
            runner_conf.sdkConfig.serverSites["nf"].CopyFrom(
                Site(ips=["http://114.80.155.61:22013"]))
            runner_conf.sdkConfig.serverSites["gf"].CopyFrom(
                Site(ips=["http://114.80.155.61:22013"]))
            runner_conf.sdkConfig.serverSites["pb"].CopyFrom(
                Site(ips=["http://114.80.155.61:22016"]))
            runner_conf.sdkConfig.serverSites["hk1"].CopyFrom(
                Site(ips=["http://114.80.155.133:22016"]))
            runner_conf.sdkConfig.serverSites["hk5"].CopyFrom(
                Site(ips=["http://114.80.155.133:22016"]))
            runner_conf.sdkConfig.serverSites["hk10"].CopyFrom(
                Site(ips=["http://114.80.155.133:22016"]))
            runner_conf.sdkConfig.serverSites["hka1"].CopyFrom(
                Site(ips=["http://114.80.155.133:22016"]))
            runner_conf.sdkConfig.serverSites["hkd1"].CopyFrom(
                Site(ips=["http://114.80.155.133:22016"]))
            runner_conf.sdkConfig.serverSites["hkaz"].CopyFrom(
                Site(ips=["http://114.80.155.133:22016"]))
            runner_conf.sdkConfig.serverSites["hkdz"].CopyFrom(
                Site(ips=["http://114.80.155.133:22016"]))
        case_list = []

        case_conf = TestcaseConfig()
        case_conf.testcaseID = 'CATESORTING_2'
        case_conf.roundIntervalSec = 3
        case_conf.continueWhenFailed = False
        case_conf.paramStrs.extend([
            #066代码
            json.dumps({
                'id': 'SH1001',
                'param': '0,100,1,0,1',
                'quoteCustom': '-1',
                'addvalueCustom': 'null',
            }),
            #067
            json.dumps({
                'id': 'SH1001',
                'param': '0,100,7,1,1',
                'quoteCustom': '-1',
                'addvalueCustom': 'null',
            }),
        ])
        case_list.append(case_conf)
        runner_conf.casesConfig.extend(case_list)
        print('i,case_list.length is ', case_list.__len__())
        runner_conf_list.append(runner_conf)

    return runner_conf_list
Esempio n. 7
0
def initRunnerConfig():
    runner_conf_list = []

    for i in range(2):
        runner_conf = RunnerConfig()

        runner_conf.sdkConfig.appKeyIOS = 'VVW0Fno7BEZt1a/y6KLM36uj9qcjw7CAHDwWZKDlWDs='
        runner_conf.sdkConfig.appKeyAndroid = 'J6IPlk5AEU+2/Yi59rfYnsFQtdtOgAo9GAzysx8ciOM='
        runner_conf.sdkConfig.marketPerm.Level = "1"
        runner_conf.sdkConfig.marketPerm.HKPerms.extend(["hk10"])

        if i == 0:
            # runner_conf.sdkConfig.serverSites["sh"].CopyFrom(Site(ips=["http://114.80.155.61:22016"]))
            # runner_conf.sdkConfig.serverSites["sz"].CopyFrom(Site(ips=["http://114.80.155.61:22016"]))
            # runner_conf.sdkConfig.serverSites["bj"].CopyFrom(Site(ips=["http://114.80.155.61:22016"]))
            # runner_conf.sdkConfig.serverSites["cf"].CopyFrom(Site(ips=["http://114.80.155.61:22016"]))
            # runner_conf.sdkConfig.serverSites["nf"].CopyFrom(Site(ips=["http://114.80.155.61:22013"]))
            # runner_conf.sdkConfig.serverSites["gf"].CopyFrom(Site(ips=["http://114.80.155.61:22013"]))
            # runner_conf.sdkConfig.serverSites["pb"].CopyFrom(Site(ips=["http://114.80.155.61:22016"]))
            # runner_conf.sdkConfig.serverSites["hk1"].CopyFrom(Site(ips=["http://114.80.155.133:22016"]))
            # runner_conf.sdkConfig.serverSites["hk5"].CopyFrom(Site(ips=["http://114.80.155.133:22016"]))
            # runner_conf.sdkConfig.serverSites["hk10"].CopyFrom(Site(ips=["http://114.80.155.133:22016"]))
            # runner_conf.sdkConfig.serverSites["hka1"].CopyFrom(Site(ips=["http://114.80.155.133:22016"]))
            # runner_conf.sdkConfig.serverSites["hkd1"].CopyFrom(Site(ips=["http://114.80.155.133:22016"]))
            # runner_conf.sdkConfig.serverSites["hkaz"].CopyFrom(Site(ips=["http://114.80.155.133:22016"]))
            # runner_conf.sdkConfig.serverSites["hkdz"].CopyFrom(Site(ips=["http://114.80.155.133:22016"]))

            runner_conf.sdkConfig.serverSites["sh"].CopyFrom(
                Site(ips=["http://114.80.155.134:22016"]))
            runner_conf.sdkConfig.serverSites["sz"].CopyFrom(
                Site(ips=["http://114.80.155.134:22016"]))
            runner_conf.sdkConfig.serverSites["bj"].CopyFrom(
                Site(ips=["http://114.80.155.134:22016"]))
            runner_conf.sdkConfig.serverSites["cf"].CopyFrom(
                Site(ips=["http://114.80.155.134:22016"]))
            runner_conf.sdkConfig.serverSites["nf"].CopyFrom(
                Site(ips=["http://114.80.155.134:22013"]))
            runner_conf.sdkConfig.serverSites["gf"].CopyFrom(
                Site(ips=["http://114.80.155.134:22013"]))
            runner_conf.sdkConfig.serverSites["pb"].CopyFrom(
                Site(ips=["http://114.80.155.134:22016"]))
            runner_conf.sdkConfig.serverSites["hk1"].CopyFrom(
                Site(ips=["http://114.80.155.133:22016"]))
            runner_conf.sdkConfig.serverSites["hk5"].CopyFrom(
                Site(ips=["http://114.80.155.133:22016"]))
            runner_conf.sdkConfig.serverSites["hk10"].CopyFrom(
                Site(ips=["http://114.80.155.133:22016"]))
            runner_conf.sdkConfig.serverSites["hka1"].CopyFrom(
                Site(ips=["http://114.80.155.133:22016"]))
            runner_conf.sdkConfig.serverSites["hkd1"].CopyFrom(
                Site(ips=["http://114.80.155.139:22016"]))
            runner_conf.sdkConfig.serverSites["hkaz"].CopyFrom(
                Site(ips=["http://114.80.155.133:22016"]))
            runner_conf.sdkConfig.serverSites["hkdz"].CopyFrom(
                Site(ips=["http://114.80.155.139:22016"]))

        else:
            runner_conf.sdkConfig.serverSites["sh"].CopyFrom(
                Site(ips=["http://117.184.225.151:22016"]))
            runner_conf.sdkConfig.serverSites["sz"].CopyFrom(
                Site(ips=["http://117.184.225.151:22016"]))
            runner_conf.sdkConfig.serverSites["bj"].CopyFrom(
                Site(ips=["http://117.184.225.151:22016"]))
            runner_conf.sdkConfig.serverSites["cf"].CopyFrom(
                Site(ips=["http://117.184.225.151:22016"]))
            runner_conf.sdkConfig.serverSites["nf"].CopyFrom(
                Site(ips=["http://140.207.241.197:22013"]))
            runner_conf.sdkConfig.serverSites["gf"].CopyFrom(
                Site(ips=["http://117.184.225.151:22016"]))
            runner_conf.sdkConfig.serverSites["pb"].CopyFrom(
                Site(ips=["http://117.184.225.151:22016"]))
            runner_conf.sdkConfig.serverSites["hk1"].CopyFrom(
                Site(ips=["http://58.63.252.56:22016"]))
            runner_conf.sdkConfig.serverSites["hk5"].CopyFrom(
                Site(ips=["http://58.63.252.56:22016"]))
            runner_conf.sdkConfig.serverSites["hk10"].CopyFrom(
                Site(ips=["http://58.63.252.56:22016"]))
            runner_conf.sdkConfig.serverSites["hka1"].CopyFrom(
                Site(ips=["http://58.63.252.56:22016"]))
            runner_conf.sdkConfig.serverSites["hkd1"].CopyFrom(
                Site(ips=["http://114.80.155.139:22016"]))
            runner_conf.sdkConfig.serverSites["hkaz"].CopyFrom(
                Site(ips=["http://58.63.252.56:22016"]))
            runner_conf.sdkConfig.serverSites["hkdz"].CopyFrom(
                Site(ips=["http://114.80.155.139:22016"]))
        case_list = []

        # #走势数据
        # case_conf = TestcaseConfig()
        # case_conf.testcaseID = 'CHARTV2TEST_2'
        # case_conf.continueWhenFailed = False
        # case_conf.roundIntervalSec = 3
        # case_conf.paramStrs.extend([
        #     json.dumps({
        # 		'CODES': '831814.bj',
        # 		'Chart_Types': 'ChartTypeOneDay',
        # 	}),
        # 	#005
        # 	json.dumps({
        # 		'CODES': '841004.bj',
        # 		'Chart_Types': 'ChartTypeOneDay',
        # 	}),
        # ])
        # case_list.append(case_conf)

        #排行
        case_conf = TestcaseConfig()
        case_conf.testcaseID = 'CATESORTING_2'
        case_conf.continueWhenFailed = False
        case_conf.roundIntervalSec = 3
        case_conf.paramStrs.extend([
            #010
            json.dumps({
                'id': 'SH1001',
                'param': '0,100,7,0,1',
                'quoteCustom': '-1',
                'addvalueCustom': 'null'
            }),
        ])
        case_list.append(case_conf)

        # #测试样例
        # case_conf = TestcaseConfig()
        # case_conf.testcaseID = 'QUOTEDETAIL_1'
        # case_conf.roundIntervalSec = 3
        # case_conf.continueWhenFailed = False
        # case_conf.paramStrs.extend([
        #     #001
        #     json.dumps({
        # 		'CODES': '600000.sh',
        #     }),
        # ])
        # case_list.append(case_conf)

        runner_conf.casesConfig.extend(case_list)
        print('i,case_list.length is ', case_list.__len__())
        runner_conf_list.append(runner_conf)

    return runner_conf_list
Esempio n. 8
0
def gen2confict_2():
    runner_conf_list = []
    for i in range(2):
        runner_conf = RunnerConfig()
        runner_conf.jobID = 'TJ-1'
        runner_conf.runnerID = generate_id('RUN-A')
        runner_conf.sdkConfig.appKeyIOS = 'VVW0Fno7BEZt1a/y6KLM36uj9qcjw7CAHDwWZKDlWDs='
        runner_conf.sdkConfig.appKeyAndroid = 'J6IPlk5AEU+2/Yi59rfYnsFQtdtOgAo9GAzysx8ciOM='
        runner_conf.sdkConfig.marketPerm.Level = "2"
        runner_conf.sdkConfig.marketPerm.HKPerms.extend(["hk10"])

        if i == 0:
            runner_conf.sdkConfig.serverSites["sh"].CopyFrom(
                Site(ips=["http://114.80.155.134:22016"]))
            runner_conf.sdkConfig.serverSites["sz"].CopyFrom(
                Site(ips=["http://114.80.155.134:22016"]))
            runner_conf.sdkConfig.serverSites["bj"].CopyFrom(
                Site(ips=["http://114.80.155.134:22016"]))
            runner_conf.sdkConfig.serverSites["cf"].CopyFrom(
                Site(ips=["http://114.80.155.134:22016"]))
            runner_conf.sdkConfig.serverSites["nf"].CopyFrom(
                Site(ips=["http://114.80.155.134:22013"]))
            runner_conf.sdkConfig.serverSites["gf"].CopyFrom(
                Site(ips=["http://114.80.155.134:22013"]))
            runner_conf.sdkConfig.serverSites["pb"].CopyFrom(
                Site(ips=["http://114.80.155.134:22016"]))
            runner_conf.sdkConfig.serverSites["hk1"].CopyFrom(
                Site(ips=["http://114.80.155.133:22016"]))
            runner_conf.sdkConfig.serverSites["hk5"].CopyFrom(
                Site(ips=["http://114.80.155.133:22016"]))
            runner_conf.sdkConfig.serverSites["hk10"].CopyFrom(
                Site(ips=["http://114.80.155.133:22016"]))
            runner_conf.sdkConfig.serverSites["hka1"].CopyFrom(
                Site(ips=["http://114.80.155.133:22016"]))
            runner_conf.sdkConfig.serverSites["hkd1"].CopyFrom(
                Site(ips=["http://114.80.155.133:22016"]))
            runner_conf.sdkConfig.serverSites["hkaz"].CopyFrom(
                Site(ips=["http://114.80.155.133:22016"]))
            runner_conf.sdkConfig.serverSites["hkdz"].CopyFrom(
                Site(ips=["http://114.80.155.133:22016"]))
        else:
            runner_conf.sdkConfig.serverSites["sh"].CopyFrom(
                Site(ips=["http://114.80.155.61:22016"]))
            runner_conf.sdkConfig.serverSites["sz"].CopyFrom(
                Site(ips=["http://114.80.155.61:22016"]))
            runner_conf.sdkConfig.serverSites["bj"].CopyFrom(
                Site(ips=["http://114.80.155.61:22016"]))
            runner_conf.sdkConfig.serverSites["cf"].CopyFrom(
                Site(ips=["http://114.80.155.61:22016"]))
            runner_conf.sdkConfig.serverSites["nf"].CopyFrom(
                Site(ips=["http://114.80.155.61:22013"]))
            runner_conf.sdkConfig.serverSites["gf"].CopyFrom(
                Site(ips=["http://114.80.155.61:22013"]))
            runner_conf.sdkConfig.serverSites["pb"].CopyFrom(
                Site(ips=["http://114.80.155.61:22016"]))
            runner_conf.sdkConfig.serverSites["hk1"].CopyFrom(
                Site(ips=["http://114.80.155.133:22016"]))
            runner_conf.sdkConfig.serverSites["hk5"].CopyFrom(
                Site(ips=["http://114.80.155.133:22016"]))
            runner_conf.sdkConfig.serverSites["hk10"].CopyFrom(
                Site(ips=["http://114.80.155.133:22016"]))
            runner_conf.sdkConfig.serverSites["hka1"].CopyFrom(
                Site(ips=["http://114.80.155.133:22016"]))
            runner_conf.sdkConfig.serverSites["hkd1"].CopyFrom(
                Site(ips=["http://114.80.155.133:22016"]))
            runner_conf.sdkConfig.serverSites["hkaz"].CopyFrom(
                Site(ips=["http://114.80.155.133:22016"]))
            runner_conf.sdkConfig.serverSites["hkdz"].CopyFrom(
                Site(ips=["http://114.80.155.133:22016"]))

        case_conf = TestcaseConfig()
        case_conf.testcaseID = 'CHARTSUB_2'
        case_conf.roundIntervalSec = 3
        case_conf.continueWhenFailed = False
        case_conf.paramStrs.extend([
            json.dumps({
                'quoteitem': '600000.sh',
                'type': 'ChartTypeOneDay',
                'begin': '0',
                'end': '100',
                'select': 'time,ddx,ddy,ddz'
            })
        ])

        runner_conf.casesConfig.extend([case_conf])
        runner_conf_list.append(runner_conf)
    return runner_conf_list
Esempio n. 9
0
def testAndroidCases(case_conf, market_level, hk_perms, server_sites):
    """
    测试安卓样例
    :param case_conf:       case_conf
    :param market_level:    runner_conf.sdkConfig.marketPerm.Level
    :param hk_perms:        runner_conf.sdkConfig.marketPerm.HKPerms.extend([ @param ])
    :param server_sites:    runner_conf.sdkConfig.serverSites[ @key ].CopyFrom(Site(ips=[ @value ]))
    """
    runner_conf = RunnerConfig()
    runner_conf.jobID = 'TJ-1'
    runner_conf.runnerID = generate_id('RUN-A')
    runner_conf.sdkConfig.appKeyIOS = 'VVW0Fno7BEZt1a/y6KLM36uj9qcjw7CAHDwWZKDlWDs='
    runner_conf.sdkConfig.appKeyAndroid = 'J6IPlk5AEU+2/Yi59rfYnsFQtdtOgAo9GAzysx8ciOM='
    runner_conf.sdkConfig.marketPerm.Level = market_level
    runner_conf.casesConfig.extend(case_conf)

    if hk_perms.__len__() != 0:
        runner_conf.sdkConfig.marketPerm.HKPerms.extend(hk_perms)

    if server_sites.__len__() != 0:
        for k, v in server_sites.items():
            runner_conf.sdkConfig.serverSites[k].CopyFrom(Site(ips=[v]))

    print(base64_encode(runner_conf.SerializeToString()))

    chunk_cache = LogChunkCache()

    def read_record(record_str):
        record = TestExecutionRecord()
        ''''''
        recordFromAndroid.append(record_str)
        chunk_cacheFromAndroid.append(chunk_cache)
        data = parse_logcat(chunk_cache, record_str)
        if data:
            record.ParseFromString(data)
        if len(record.ListFields()) > 0:
            print("*********Record Start****************")
            # print(record)
            test_db.append(record)
            test_out.append(data)
            print("*********Record End****************\n")

    spawn_logcat(serial=serial_str, logger=read_record)

    test_status_code = []

    def check_test_result(line):
        global test_result
        if 'INSTRUMENTATION_STATUS_CODE' in line:
            # find number in string, https://stackoverflow.com/a/29581287/9797889
            codes = re.findall(
                "[-+]?[.]?[\d]+(?:,\d\d\d)*[\.]?\d*(?:[eE][-+]?\d+)?", line)
            # check whether code ONLY contains '0' or '1'
            test_status_code.extend(codes)

    # 生成含有ADB测试命令的shell脚本
    # TODO(Ouyang): 将Shell脚本的存储位置作为参数
    command_to_script(args=[
        'am', 'instrument', '-w', '-r', '-e', 'debug', 'false', '-e', 'filter',
        'com.chi.ssetest.TestcaseFilter', '-e', 'listener',
        'com.chi.ssetest.TestcaseExecutionListener', '-e', 'collector_file',
        'test.log', '-e', 'runner_config',
        base64_encode(runner_conf.SerializeToString()),
        'com.chi.ssetest.test/android.support.test.runner.AndroidJUnitRunner'
    ],
                      script_path='/tmp/test.sh')
    # 将测试脚本push进设备并执行(因为binder传输1MB的限制)
    cmd_code_push = exec_adb_cmd(
        args="adb push E://adb//test.sh /data/local/tmp/", serial=serial_str)
    cmd_code_exec = exec_adb_cmd(args="adb shell sh /data/local/tmp/test.sh",
                                 serial=serial_str,
                                 logger=check_test_result)

    #
    print("status: ", (cmd_code_exec == 0) and \
          len(test_status_code) > 0 and \
          (test_status_code.count('0') + test_status_code.count('1') == len(test_status_code)))
Esempio n. 10
0
import json

import airflow
from airflow.models import DAG
from airflow.operators.bash_operator import BashOperator
from airflow.operators.dummy_operator import DummyOperator

from protos_gen.config_pb2 import RunnerConfig, TestcaseConfig
from operators.android_runner_operator import AndroidRunnerOperator
from operators.android_release_operator import AndroidReleaseOperator

# TODO init RunnerConfig
runner_conf = RunnerConfig()

runner_conf.sdkConfig.appKeyIOS = 'VVW0Fno7BEZt1a/y6KLM36uj9qcjw7CAHDwWZKDlWDs='
runner_conf.sdkConfig.appKeyAndroid = 'J6IPlk5AEU+2/Yi59rfYnsFQtdtOgAo9GAzysx8ciOM='
runner_conf.sdkConfig.marketPerm.Level = "2"

case_conf = TestcaseConfig()
case_conf.testcaseID = 'TESTCASE_0'
case_conf.continueWhenFailed = False
case_conf.roundIntervalSec = 3
case_conf.paramStrs.extend([json.dumps({'QUOTE_NUMBERS': '600028.sh'})])

runner_conf.casesConfig.extend([case_conf])

with DAG(
        dag_id='android_test',
        default_args={
            'owner': 'airflow',
            'start_date': airflow.utils.dates.days_ago(0)
Esempio n. 11
0
def initRunnerConfig():
    runner_conf_list = []

    for i in range(2):
        runner_conf = RunnerConfig()

        runner_conf.sdkConfig.appKeyIOS = 'VVW0Fno7BEZt1a/y6KLM36uj9qcjw7CAHDwWZKDlWDs='
        runner_conf.sdkConfig.appKeyAndroid = 'J6IPlk5AEU+2/Yi59rfYnsFQtdtOgAo9GAzysx8ciOM='
        runner_conf.sdkConfig.marketPerm.Level = "1"
        runner_conf.sdkConfig.marketPerm.HKPerms.extend(["hk10"])

        if i == 0:
            runner_conf.sdkConfig.serverSites["sh"].CopyFrom(
                Site(ips=["http://114.80.155.134:22016"]))
            runner_conf.sdkConfig.serverSites["sz"].CopyFrom(
                Site(ips=["http://114.80.155.134:22016"]))
            runner_conf.sdkConfig.serverSites["bj"].CopyFrom(
                Site(ips=["http://114.80.155.134:22016"]))
            runner_conf.sdkConfig.serverSites["cf"].CopyFrom(
                Site(ips=["http://114.80.155.134:22016"]))
            runner_conf.sdkConfig.serverSites["nf"].CopyFrom(
                Site(ips=["http://114.80.155.134:22013"]))
            runner_conf.sdkConfig.serverSites["gf"].CopyFrom(
                Site(ips=["http://114.80.155.134:22013"]))
            runner_conf.sdkConfig.serverSites["pb"].CopyFrom(
                Site(ips=["http://114.80.155.134:22016"]))
            runner_conf.sdkConfig.serverSites["hk1"].CopyFrom(
                Site(ips=["http://114.80.155.133:22016"]))
            runner_conf.sdkConfig.serverSites["hk5"].CopyFrom(
                Site(ips=["http://114.80.155.133:22016"]))
            runner_conf.sdkConfig.serverSites["hk10"].CopyFrom(
                Site(ips=["http://114.80.155.133:22016"]))
            runner_conf.sdkConfig.serverSites["hka1"].CopyFrom(
                Site(ips=["http://114.80.155.133:22016"]))
            runner_conf.sdkConfig.serverSites["hkd1"].CopyFrom(
                Site(ips=["http://114.80.155.133:22016"]))
            runner_conf.sdkConfig.serverSites["hkaz"].CopyFrom(
                Site(ips=["http://114.80.155.133:22016"]))
            runner_conf.sdkConfig.serverSites["hkdz"].CopyFrom(
                Site(ips=["http://114.80.155.133:22016"]))
        else:
            runner_conf.sdkConfig.serverSites["sh"].CopyFrom(
                Site(ips=["http://114.80.155.61:22016"]))
            runner_conf.sdkConfig.serverSites["sz"].CopyFrom(
                Site(ips=["http://114.80.155.61:22016"]))
            runner_conf.sdkConfig.serverSites["bj"].CopyFrom(
                Site(ips=["http://114.80.155.61:22016"]))
            runner_conf.sdkConfig.serverSites["cf"].CopyFrom(
                Site(ips=["http://114.80.155.61:22016"]))
            runner_conf.sdkConfig.serverSites["nf"].CopyFrom(
                Site(ips=["http://114.80.155.61:22013"]))
            runner_conf.sdkConfig.serverSites["gf"].CopyFrom(
                Site(ips=["http://114.80.155.61:22013"]))
            runner_conf.sdkConfig.serverSites["pb"].CopyFrom(
                Site(ips=["http://114.80.155.61:22016"]))
            runner_conf.sdkConfig.serverSites["hk1"].CopyFrom(
                Site(ips=["http://114.80.155.133:22016"]))
            runner_conf.sdkConfig.serverSites["hk5"].CopyFrom(
                Site(ips=["http://114.80.155.133:22016"]))
            runner_conf.sdkConfig.serverSites["hk10"].CopyFrom(
                Site(ips=["http://114.80.155.133:22016"]))
            runner_conf.sdkConfig.serverSites["hka1"].CopyFrom(
                Site(ips=["http://114.80.155.133:22016"]))
            runner_conf.sdkConfig.serverSites["hkd1"].CopyFrom(
                Site(ips=["http://114.80.155.133:22016"]))
            runner_conf.sdkConfig.serverSites["hkaz"].CopyFrom(
                Site(ips=["http://114.80.155.133:22016"]))
            runner_conf.sdkConfig.serverSites["hkdz"].CopyFrom(
                Site(ips=["http://114.80.155.133:22016"]))
        case_list = []

        # case_conf = TestcaseConfig()
        # case_conf.testcaseID = 'OHLCTEST_1'
        # case_conf.roundIntervalSec = 3
        # case_conf.continueWhenFailed = False
        # case_conf.paramStrs.extend([
        #     json.dumps({
        #         'stk': '00700.hk',
        #         'type': 'dayk'
        #     })
        # ])
        # case_list.append(case_conf)

        case_conf = TestcaseConfig()
        case_conf.testcaseID = 'CHARTSUB_2'
        case_conf.roundIntervalSec = 3
        case_conf.continueWhenFailed = False
        case_conf.paramStrs.extend([
            json.dumps({
                'quoteitem': '600000.sh',
                'type': 'ChartTypeOneDay',
                'begin': '0',
                'end': '100',
                'select': 'time,ddx,ddy,ddz'
            })
        ])
        case_list.append(case_conf)

        # 历史K线方法一
        case_conf = TestcaseConfig()
        case_conf.testcaseID = 'OHLCV3_1'
        case_conf.continueWhenFailed = False
        case_conf.roundIntervalSec = 3
        case_conf.paramStrs.extend(
            [json.dumps({
                'CODES': '00700.hk',
                'TYPES': 'dayk'
            })])
        case_list.append(case_conf)

        # 历史K线方法二
        case_conf = TestcaseConfig()
        case_conf.testcaseID = 'OHLCV3_2'
        case_conf.continueWhenFailed = False
        case_conf.roundIntervalSec = 3
        case_conf.paramStrs.extend([
            json.dumps({
                'CODES': '00700.hk',
                'TYPES': 'dayk',
                'FqTypes': '1',
                'DATES': 'null'
            })
        ])
        case_list.append(case_conf)

        # 历史K线方法五
        case_conf = TestcaseConfig()
        case_conf.testcaseID = 'OHLCV3_5'
        case_conf.continueWhenFailed = False
        case_conf.roundIntervalSec = 3
        case_conf.paramStrs.extend([
            json.dumps({
                'CODES': '00700.hk',
                'TYPES': 'dayk',
                'FqTypes': '2',
                'Dates': 'null',
                'Numbers': '300'
            })
        ])
        case_list.append(case_conf)

        runner_conf.casesConfig.extend(case_list)
        print('i,case_list.length is ', case_list.__len__())
        runner_conf_list.append(runner_conf)

    return runner_conf_list
Esempio n. 12
0
            if tmp['request_type'] == 'QuoteDetailRequest':
                params = {**app, **(json.loads(case))}
                suite.addTest(ParametrizedTestCase.parametrize(QuoteDetailRequest, param=params))
            elif tmp['request_type'] == 'TickRequest':
                params = {**app, **(json.loads(case))}
                for i in range(tmp['repeat']):
                    suite.addTest(ParametrizedTestCase.parametrize(TickRequest, param=params))
            else:  # login
                params = {**app, **(json.loads(case))}
                suite.addTest(ParametrizedTestCase.parametrize(Login, param=params))

    unittest.TextTestRunner(verbosity=2).run(suite)


if __name__ == '__main__':
    runner_conf = RunnerConfig()
    runner_conf.jobID = 'TJ-1'
    runner_conf.runnerID = generate_id('RUN-A')

    # case_conf = TestcaseConfig()
    # case_conf.testcaseID = 'Login'
    # case_conf.continueWhenFailed = False
    # case_conf.roundIntervalSec = 0
    # case_conf.paramStrs.extend([
    #     json.dumps({
    #         'request_type': 'login',
    #         'username': '******',
    #         'password': '******'
    #     })
    # ])
    # runner_conf.casesConfig.extend([case_conf])
Esempio n. 13
0
def initRunnerConfig():
    runner_conf_list = []

    for i in range(2):
        runner_conf = RunnerConfig()
        #appKeyAndroid,API:应用程序接口,接口验证序号
        runner_conf.sdkConfig.appKeyIOS = 'VVW0Fno7BEZt1a/y6KLM36uj9qcjw7CAHDwWZKDlWDs='
        runner_conf.sdkConfig.appKeyAndroid = 'J6IPlk5AEU+2/Yi59rfYnsFQtdtOgAo9GAzysx8ciOM='
        runner_conf.sdkConfig.marketPerm.Level = "1"
        runner_conf.sdkConfig.marketPerm.HKPerms.extend(["hk10"])
        #环境配置
        if i == 0:
            runner_conf.sdkConfig.serverSites["sh"].CopyFrom(
                Site(ips=["http://114.80.155.134:22016"]))
            runner_conf.sdkConfig.serverSites["sz"].CopyFrom(
                Site(ips=["http://114.80.155.134:22016"]))
            runner_conf.sdkConfig.serverSites["bj"].CopyFrom(
                Site(ips=["http://114.80.155.134:22016"]))
            runner_conf.sdkConfig.serverSites["cf"].CopyFrom(
                Site(ips=["http://114.80.155.134:22016"]))
            runner_conf.sdkConfig.serverSites["nf"].CopyFrom(
                Site(ips=["http://114.80.155.134:22013"]))
            runner_conf.sdkConfig.serverSites["gf"].CopyFrom(
                Site(ips=["http://114.80.155.134:22013"]))
            runner_conf.sdkConfig.serverSites["pb"].CopyFrom(
                Site(ips=["http://114.80.155.134:22016"]))
            runner_conf.sdkConfig.serverSites["hk1"].CopyFrom(
                Site(ips=["http://114.80.155.133:22016"]))
            runner_conf.sdkConfig.serverSites["hk5"].CopyFrom(
                Site(ips=["http://114.80.155.133:22016"]))
            runner_conf.sdkConfig.serverSites["hk10"].CopyFrom(
                Site(ips=["http://114.80.155.133:22016"]))
            runner_conf.sdkConfig.serverSites["hka1"].CopyFrom(
                Site(ips=["http://114.80.155.133:22016"]))
            runner_conf.sdkConfig.serverSites["hkd1"].CopyFrom(
                Site(ips=["http://114.80.155.133:22016"]))
            runner_conf.sdkConfig.serverSites["hkaz"].CopyFrom(
                Site(ips=["http://114.80.155.133:22016"]))
            runner_conf.sdkConfig.serverSites["hkdz"].CopyFrom(
                Site(ips=["http://114.80.155.133:22016"]))
        else:
            runner_conf.sdkConfig.serverSites["sh"].CopyFrom(
                Site(ips=["http://114.80.155.61:22016"]))
            runner_conf.sdkConfig.serverSites["sz"].CopyFrom(
                Site(ips=["http://114.80.155.61:22016"]))
            runner_conf.sdkConfig.serverSites["bj"].CopyFrom(
                Site(ips=["http://114.80.155.61:22016"]))
            runner_conf.sdkConfig.serverSites["cf"].CopyFrom(
                Site(ips=["http://114.80.155.61:22016"]))
            runner_conf.sdkConfig.serverSites["nf"].CopyFrom(
                Site(ips=["http://114.80.155.61:22013"]))
            runner_conf.sdkConfig.serverSites["gf"].CopyFrom(
                Site(ips=["http://114.80.155.61:22013"]))
            runner_conf.sdkConfig.serverSites["pb"].CopyFrom(
                Site(ips=["http://114.80.155.61:22016"]))
            runner_conf.sdkConfig.serverSites["hk1"].CopyFrom(
                Site(ips=["http://114.80.155.133:22016"]))
            runner_conf.sdkConfig.serverSites["hk5"].CopyFrom(
                Site(ips=["http://114.80.155.133:22016"]))
            runner_conf.sdkConfig.serverSites["hk10"].CopyFrom(
                Site(ips=["http://114.80.155.133:22016"]))
            runner_conf.sdkConfig.serverSites["hka1"].CopyFrom(
                Site(ips=["http://114.80.155.133:22016"]))
            runner_conf.sdkConfig.serverSites["hkd1"].CopyFrom(
                Site(ips=["http://114.80.155.133:22016"]))
            runner_conf.sdkConfig.serverSites["hkaz"].CopyFrom(
                Site(ips=["http://114.80.155.133:22016"]))
            runner_conf.sdkConfig.serverSites["hkdz"].CopyFrom(
                Site(ips=["http://114.80.155.133:22016"]))
        case_list = []

        #历史k线 方法6
        case_conf = TestcaseConfig()
        case_conf.testcaseID = 'F10_BNDNEWSHARESCAL_1'
        case_conf.roundIntervalSec = 3
        case_conf.continueWhenFailed = False
        case_conf.paramStrs.extend([
            #005
            json.dumps({
                'date': '2019-11-13',
                'src': 'd'
            }),
            #006
            json.dumps({
                'date': '2019-11-13',
                'src': 'd'
            }),
        ])
        case_list.append(case_conf)

        runner_conf.casesConfig.extend(case_list)
        print('i,case_list.length is ', case_list.__len__())
        runner_conf_list.append(runner_conf)

    return runner_conf_list