def cmd_run_local_main(): logger.info('testing environment: local') local_tests = get_test_cases() logger.info('AMOUNT_LOCAL_TESTS:{}'.format(len(local_tests))) logger.info('LOCAL_TESTS:{}'.format(local_tests)) if len(local_tests) > 0 and not settings.DRY_RUN: start_infra() local_tests_ok = [] local_tests_fail = [] results = [] for local_test in local_tests: result = exec_local_test(local_test) if result["result"] != "Failed" and result["data"] != "Failed" : local_tests_ok.append(local_test) else: local_tests_fail.append(local_test) # Exit on failure if settings.CATCH_FAIL: logger.error("Driver stops - Fix testcase {} and try again".format(local_test)) exit(1) results.append(result) logger.info('Local tests running OK: {}'.format(local_tests_ok)) logger.info('Local tests running Fail: {}'.format(local_tests_fail)) if settings.ENABLE_JUNIT: junit_report(results) logger.info('(*) TEST SUMMARY \n{}'.format(pretty_output(results))) elif len(local_tests) > 0 and settings.DRY_RUN: logger.info('DRY RUN')
def exec_bs_test_list(bs_tests): # Dry run skips executions if bs_tests and not settings.DRY_RUN: start_infra() bs_tests_ok = [] bs_tests_fail = [] results = [] for bs_test in bs_tests: object_dict = format_mongo_object(bs_test) result = exec_bs_test(bs_test) if result["result"] != "Failed" and result["data"] != "Failed" : bs_tests_ok.append(bs_test) # Remove from the list of failed tests if sucess if settings.DB.failed_tests.count_documents(object_dict): settings.DB.failed_tests.remove(object_dict) else: bs_tests_fail.append(bs_test) # Add to the list of failed tests for next run if not exist if not settings.DB.failed_tests.count_documents(object_dict): object_dict.update({'retry_count': 0}) if type(object_dict['variationId']) is dict and '$exists' in object_dict['variationId']: del object_dict['variationId'] settings.DB.failed_tests.insert(object_dict) # Increment retry_count if already else: settings.DB.failed_tests.find_one_and_update(object_dict, {'$inc': {'retry_count': 1}}) results.append(result) logger.info('BS tests running OK: {}'.format(bs_tests_ok)) logger.info('BS tests running Fail: {}'.format(bs_tests_fail)) if settings.ENABLE_JUNIT: junit_report(results) logger.info('(*) TEST SUMMARY \n{}'.format(pretty_output(results))) settings.BS_INSTANCE.stop() elif bs_tests and settings.DRY_RUN: logger.info('DRY RUN') settings.DB.close()
def runbs_bs_list(bs_tests): # Dry run skips executions if len(bs_tests) > 0 and not DRY_RUN: start_infra() bs_tests_ok = [] bs_tests_fail = [] results = [] for bs_test in bs_tests: object_dict = format_mongo_object(bs_test['info_browser'], bs_test['test_case']) result = run_test_bs( bs_test['info_browser'], bs_test['test_case']) if SAVE_DB else run_test_bs_notsave( bs_test['info_browser'], bs_test['test_case']) if result["result"] != "Failed" and result["data"] != "Failed": bs_tests_ok.append(bs_test) else: bs_tests_fail.append(bs_test) results.append(result) logger.info('BS tests running OK: {}'.format(bs_tests_ok)) logger.info('BS tests running Fail: {}'.format(bs_tests_fail)) logger.info('(*) TEST SUMMARY \n{}'.format(pretty_output(results))) BS_INSTANCE.stop() elif len(bs_tests) > 0 and DRY_RUN: logger.info('DRY RUN')
def run_bs_list(bs_tests): # Dry run skips executions if len(bs_tests) > 0 and not DRY_RUN: start_infra() bs_tests_ok = [] bs_tests_fail = [] results = [] for bs_test in bs_tests: object_dict = format_mongo_object(bs_test['info_browser'], bs_test['test_case']) if FORCE_RERUN: # Clear from the list of failed tests if DB.failed_tests.count_documents(object_dict): DB.failed_tests.remove(object_dict) # search for current result not deprecated current_results = DB.coll.find(object_dict) for current_result in current_results: DB.coll.find_one_and_update(current_result, {'$set': { 'deprecated': True }}) logger.debug("DEPRECATED: {}".format(current_result)) result = run_test_bs(bs_test['info_browser'], bs_test['test_case']) if result["result"] != "Failed" and result["data"] != "Failed": bs_tests_ok.append(bs_test) # Remove from the list of failed tests if sucess if DB.failed_tests.count_documents(object_dict): DB.failed_tests.remove(object_dict) else: bs_tests_fail.append(bs_test) # Add to the list of failed tests for next run if not exist if not DB.failed_tests.count_documents(object_dict): object_dict.update({'retry_count': 0}) DB.failed_tests.insert(object_dict) # Increment retry_count if already else: DB.failed_tests.find_one_and_update( object_dict, {'$inc': { 'retry_count': 1 }}) results.append(result) logger.info('BS tests running OK: {}'.format(bs_tests_ok)) logger.info('BS tests running Fail: {}'.format(bs_tests_fail)) logger.info('(*) TEST SUMMARY \n{}'.format(pretty_output(results))) BS_INSTANCE.stop() elif len(bs_tests) > 0 and DRY_RUN: logger.info('DRY RUN')
def run_local_main(): logger.info('Environment: Local') local_tests = [] if TESTCASES: logger.info('List test cases:{}'.format(TESTCASES)) for case in TESTCASES: if case not in dataJson: logger.error('Test case undefined: {}'.format(case)) continue else: local_tests.append(case) logger.info('AMOUNT_LOCAL_TESTS:{}'.format(len(local_tests))) logger.info('LOCAL_TESTS:{}'.format(local_tests)) if len(local_tests) > 0 and not DRY_RUN: start_infra() local_tests_ok = [] local_tests_fail = [] results = [] for local_test in local_tests: result = run_test_local(local_test) if result["result"] != "Failed" and result["data"] != "Failed": local_tests_ok.append(local_test) else: local_tests_fail.append(local_test) # Exit on failure if CATCH_FAIL: logger.error( "Driver stops - Fix testcase {} and try again".format( local_test)) exit(1) results.append(result) logger.info('Local tests running OK: {}'.format(local_tests_ok)) logger.info('Local tests running Fail: {}'.format(local_tests_fail)) logger.info('(*) TEST SUMMARY \n{}'.format(pretty_output(results))) elif len(local_tests) > 0 and DRY_RUN: logger.info('DRY RUN')