ci: tests: print server logs in case of scenario failure
This commit is contained in:
parent
c1b002e067
commit
cff7faaccb
1 changed files with 18 additions and 10 deletions
|
@ -33,16 +33,7 @@ def after_scenario(context, scenario):
|
||||||
print("\x1b[33;101mERROR: Server stopped listening\x1b[0m\n")
|
print("\x1b[33;101mERROR: Server stopped listening\x1b[0m\n")
|
||||||
|
|
||||||
if not pid_exists(context.server_process.pid):
|
if not pid_exists(context.server_process.pid):
|
||||||
print("Trying to find server logs:")
|
print_server_logs(context)
|
||||||
out, err = context.server_process.communicate()
|
|
||||||
if out:
|
|
||||||
print("Server stdout:\n")
|
|
||||||
print(out)
|
|
||||||
print("\n")
|
|
||||||
if err:
|
|
||||||
print("Server stderr:\n")
|
|
||||||
print(err)
|
|
||||||
print("\n")
|
|
||||||
assert False, f"Server not running pid={context.server_process.pid} ..."
|
assert False, f"Server not running pid={context.server_process.pid} ..."
|
||||||
|
|
||||||
server_graceful_shutdown(context)
|
server_graceful_shutdown(context)
|
||||||
|
@ -58,6 +49,9 @@ def after_scenario(context, scenario):
|
||||||
if attempts > 5:
|
if attempts > 5:
|
||||||
server_kill_hard(context)
|
server_kill_hard(context)
|
||||||
|
|
||||||
|
if scenario.status == "failed" or context.debug:
|
||||||
|
print_server_logs(context)
|
||||||
|
|
||||||
|
|
||||||
def server_graceful_shutdown(context):
|
def server_graceful_shutdown(context):
|
||||||
print(f"shutting down server pid={context.server_process.pid} ...\n")
|
print(f"shutting down server pid={context.server_process.pid} ...\n")
|
||||||
|
@ -108,3 +102,17 @@ def pid_exists(pid):
|
||||||
return e.errno == errno.EPERM
|
return e.errno == errno.EPERM
|
||||||
else:
|
else:
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
|
def print_server_logs(context):
|
||||||
|
print("Trying to find server logs:")
|
||||||
|
out, err = context.server_process.communicate()
|
||||||
|
if out:
|
||||||
|
print("Server stdout:\n")
|
||||||
|
print(out.decode("utf-8"))
|
||||||
|
print("\n")
|
||||||
|
if err:
|
||||||
|
print("Server stderr:\n")
|
||||||
|
print(err.decode("utf-8"))
|
||||||
|
print("\n")
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue