Python test famework should log only relevant exception and exit with a non-zero code on error. #6157

This commit is contained in:
Aditya Toshniwal 2023-04-20 13:27:12 +05:30
parent d6ecc531e0
commit 7e2add8db1
2 changed files with 71 additions and 76 deletions

View File

@ -145,7 +145,6 @@ def clear_node_info_dict():
def create_database(server, db_name, encoding=None): def create_database(server, db_name, encoding=None):
"""This function used to create database and returns the database id""" """This function used to create database and returns the database id"""
db_id = '' db_id = ''
try:
connection = get_db_connection( connection = get_db_connection(
server['db'], server['db'],
server['username'], server['username'],
@ -198,9 +197,6 @@ def create_database(server, db_name, encoding=None):
connection.close() connection.close()
return db_id return db_id
except Exception:
traceback.print_exc(file=sys.stderr)
return db_id
def create_table(server, db_name, table_name, extra_columns=[]): def create_table(server, db_name, table_name, extra_columns=[]):
@ -1173,7 +1169,6 @@ def get_server_type(server):
:param server: :param server:
:return: :return:
""" """
try:
connection = get_db_connection( connection = get_db_connection(
server['db'], server['db'],
server['username'], server['username'],
@ -1195,8 +1190,6 @@ def get_server_type(server):
return 'ppas' return 'ppas'
return 'pg' return 'pg'
except Exception:
traceback.print_exc(file=sys.stderr)
def check_binary_path_or_skip_test(cls, utility_name): def check_binary_path_or_skip_test(cls, utility_name):

View File

@ -477,6 +477,7 @@ def execute_test(test_module_list_passed, server_passed, driver_passed,
:param parallel_ui_test: parallel ui tests :param parallel_ui_test: parallel ui tests
:return: :return:
""" """
server_information = None
try: try:
print("\n=============Running the test cases for '%s' =============" print("\n=============Running the test cases for '%s' ============="
% server_passed['name'], file=sys.stderr) % server_passed['name'], file=sys.stderr)
@ -568,11 +569,12 @@ def execute_test(test_module_list_passed, server_passed, driver_passed,
threading.current_thread().ident, threading.current_thread().ident,
threading.current_thread().name)) threading.current_thread().name))
# Mark failure as true # Mark failure as true
if str(exc).find('other sessions using the database.') != -1: if 'other sessions using the database.' not in str(exc):
global failure global failure
failure = True failure = True
finally: finally:
# Delete test server # Delete test server
if server_information:
test_utils.delete_server(test_client, server_information) test_utils.delete_server(test_client, server_information)
# Delete web-driver instance # Delete web-driver instance
thread_name = "parallel_tests" + server_passed['name'] thread_name = "parallel_tests" + server_passed['name']