Skip to content

Commit

Permalink
zenbenchmark: attach perf results to allure report (#6395)
Browse files Browse the repository at this point in the history
## Problem

For PRs with `run-benchmarks` label, we don't upload results to the db,
making it harder to debug such tests. The only way to see some
numbers is by examining GitHub Action output which is really
inconvenient.
This PR adds zenbenchmark metrics to Allure reports.

## Summary of changes
- Create a json file with zenbenchmark results and attach it to allure
report
  • Loading branch information
bayandin authored Jan 18, 2024
1 parent a092127 commit c65ac37
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion test_runner/fixtures/benchmark_fixture.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,11 @@
# Type-related stuff
from typing import Callable, ClassVar, Dict, Iterator, Optional

import allure
import pytest
from _pytest.config import Config
from _pytest.config.argparsing import Parser
from _pytest.fixtures import FixtureRequest
from _pytest.terminal import TerminalReporter

from fixtures.log_helper import log
Expand Down Expand Up @@ -411,14 +413,32 @@ def record_pageserver_writes(


@pytest.fixture(scope="function")
def zenbenchmark(record_property: Callable[[str, object], None]) -> Iterator[NeonBenchmarker]:
def zenbenchmark(
request: FixtureRequest,
record_property: Callable[[str, object], None],
) -> Iterator[NeonBenchmarker]:
"""
This is a python decorator for benchmark fixtures. It contains functions for
recording measurements, and prints them out at the end.
"""
benchmarker = NeonBenchmarker(record_property)
yield benchmarker

results = {}
for _, recorded_property in request.node.user_properties:
name = recorded_property["name"]
value = str(recorded_property["value"])
if (unit := recorded_property["unit"].strip()) != "":
value += f" {unit}"
results[name] = value

content = json.dumps(results, indent=2)
allure.attach(
content,
"benchmarks.json",
allure.attachment_type.JSON,
)


def pytest_addoption(parser: Parser):
parser.addoption(
Expand Down

1 comment on commit c65ac37

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2330 tests run: 2240 passed, 0 failed, 90 skipped (full report)


Flaky tests (1)

Postgres 16

  • test_physical_replication: debug

Code coverage (full report)

  • functions: 54.5% (10577 of 19424 functions)
  • lines: 81.5% (60578 of 74337 lines)

The comment gets automatically updated with the latest test results
c65ac37 at 2024-01-18T21:40:08.782Z :recycle:

Please sign in to comment.