Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

logging error if any error in step #4759

Merged
merged 3 commits into from
Oct 20, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 26 additions & 22 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,31 +50,36 @@ def pytest_runtest_logreport(report):

def pytest_addoption(parser):
for config in all_configs:
parser.addoption(config,
dest=all_configs[config][0],
default=all_configs[config][1],
help=all_configs[config][2])
parser.addoption(
config,
dest=all_configs[config][0],
default=all_configs[config][1],
help=all_configs[config][2],
)

parser.addoption("--build_dir",
dest="build_dir",
default=BUILD_DIR,
help="NebulaGraph CMake build directory")
parser.addoption("--src_dir",
dest="src_dir",
default=NEBULA_HOME,
help="NebulaGraph workspace")
parser.addoption(
"--build_dir",
dest="build_dir",
default=BUILD_DIR,
help="NebulaGraph CMake build directory",
)
parser.addoption(
"--src_dir", dest="src_dir", default=NEBULA_HOME, help="NebulaGraph workspace"
)


def pytest_bdd_step_error(request, feature, scenario, step, step_func, step_func_args):
logging.info("=== more error information ===")
logging.info("feature is {}".format(feature.filename))
logging.info("step line number is {}".format(step.line_number))
logging.info("step name is {}".format(step.name))
if step_func_args.get("graph_spaces") is not None:
logging.error("Location: {}:{}".format(feature.filename, step.line_number))
logging.error("Step: {}".format(step.name))
graph_spaces = None
if graph_spaces is None and step_func_args.get("graph_spaces") is not None:
graph_spaces = step_func_args.get("graph_spaces")
if graph_spaces.get("space_desc") is not None:
logging.info("error space is {}".format(
graph_spaces.get("space_desc")))

if graph_spaces is None and step_func_args.get("exec_ctx") is not None:
graph_spaces = step_func_args.get("exec_ctx")

if graph_spaces is not None and graph_spaces.get("space_desc") is not None:
logging.error("Space: {}".format(graph_spaces.get("space_desc")))


def pytest_configure(config):
Expand Down Expand Up @@ -125,8 +130,7 @@ def get_ssl_config_from_tmp():

@pytest.fixture(scope="class")
def class_fixture_variables():
"""save class scope fixture, used for session update.
"""
"""save class scope fixture, used for session update."""
# cluster is the instance of NebulaService
# current_session is the session currently using
# sessions is a list of all sessions in the cluster
Expand Down
28 changes: 16 additions & 12 deletions tests/tck/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -405,21 +405,27 @@ def executing_query(query, exec_ctx, request):
ngql = combine_query(query)
exec_query(request, ngql, exec_ctx)

@when(parse("executing query and retrying it on failure every {secs:d} seconds for {retryTimes:d} times:\n{query}"))

@when(
parse(
"executing query and retrying it on failure every {secs:d} seconds for {retryTimes:d} times:\n{query}"
)
)
def executing_query_with_retry(query, exec_ctx, request, secs, retryTimes):
ngql = combine_query(query)
exec_query(request, ngql, exec_ctx)
res = exec_ctx["result_set"]
if not res.is_succeeded():
retryCounter = 0
while retryCounter < retryTimes:
time.sleep(secs)
exec_query(request, ngql, exec_ctx)
resRetry = exec_ctx["result_set"]
if not resRetry.is_succeeded():
retryCounter = retryCounter + 1
else:
break
retryCounter = 0
while retryCounter < retryTimes:
time.sleep(secs)
exec_query(request, ngql, exec_ctx)
resRetry = exec_ctx["result_set"]
if not resRetry.is_succeeded():
retryCounter = retryCounter + 1
else:
break


@when(parse("executing query with user {username} with password {password}:\n{query}"))
def executing_query(
Expand Down Expand Up @@ -572,13 +578,11 @@ def rowp(ds, i):
if not res:
scen = request.function.__scenario__
feature = scen.feature.rel_filename
location = f"{feature}:{line_number(scen._steps, result)}"
msg = [
f"Fail to exec: {ngql}",
f"Response: {dsp(rds)}",
f"Expected: {dsp(ds)}",
f"NotFoundRow: {rowp(ds, i)}",
f"Location: {location}",
f"Space: {str(space_desc)}",
f"vid_fn: {vid_fn}",
]
Expand Down