Skip to content
Merged
Changes from all commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -295,19 +295,20 @@ def test_case_description(request: pytest.FixtureRequest) -> str:


@pytest.fixture(autouse=True)
def per_test_hive_test(hive_test: HiveTest) -> None:
def per_test_hive_test(client: Client, hive_test: HiveTest) -> None:
"""
Report each pytest test as an individual hive test case.

The client runs under the session-scoped base hive test; this
per-test entry only propagates the individual test result to hive.
The client runs under the session-scoped base hive test; register
it with each per-test entry so hive attaches the client and its
log segment to the individual test case and marks the base test
as the multi-test lifecycle owner.
"""
del hive_test
hive_test.register_multi_test_client(client)


@pytest.fixture(autouse=True, scope="session")
def base_hive_test(
request: pytest.FixtureRequest,
test_suite: HiveTestSuite,
session_temp_folder: Path,
) -> Generator[HiveTest, None, None]:
Expand Down Expand Up @@ -347,11 +348,17 @@ def base_hive_test(

yield test

test_pass = True
test_details = "All tests have completed"
if request.session.testsfailed > 0:
# Individual results are reported by the per-test hive test cases,
# and hive marks this test as the multi-test lifecycle owner, so it
# always passes unless the client failed to start (the client
# fixture leaves its error file behind on startup failure).
client_error_file = session_temp_folder / "hive_client.err"
if client_error_file.exists():
test_pass = False
test_details = "One or more tests have failed"
test_details = "Failed to start the client."
else:
test_pass = True
test_details = "Multi-test client context completed."

with FileLock(users_lock_file):
with open(users_file, "r") as f:
Expand Down Expand Up @@ -431,6 +438,11 @@ def client(
with open(users_file, "w") as f:
json.dump(users, f)

# Set on every worker (the client object is shared across xdist
# workers via JSON serialization) so that per-test hive test cases
# can register with the client.
client.multi_test = True

yield client

with FileLock(users_lock_file):
Expand Down
Loading