Skip to content

Commit

Permalink
test_runner: move build_type to allure parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
bayandin committed Dec 5, 2024
1 parent 6e73376 commit 6429d1f
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 30 deletions.
23 changes: 3 additions & 20 deletions scripts/ingest_regress_test_result-new-format.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import json
import logging
import os
import re
import sys
from contextlib import contextmanager
from dataclasses import dataclass
Expand Down Expand Up @@ -65,9 +64,6 @@ class Row:
raw: str


TEST_NAME_RE = re.compile(r"[\[-](?P<build_type>debug|release)[-\]]")


def err(msg):
print(f"error: {msg}")
sys.exit(1)
Expand All @@ -94,20 +90,6 @@ def create_table(cur):
cur.execute(CREATE_TABLE)


def parse_test_name(test_name: str) -> tuple[str, str]:
build_type = None
if match := TEST_NAME_RE.search(test_name):
found = match.groupdict()
build_type = found["build_type"]
else:
# It's ok, we embed BUILD_TYPE and Postgres Version into the test name only for regress suite and do not for other suites (like performance)
build_type = "release"

unparametrized_name = re.sub(rf"{build_type}-?", "", test_name).replace("[]", "")

return build_type, unparametrized_name


def ingest_test_result(
cur,
reference: str,
Expand All @@ -134,13 +116,14 @@ def ingest_test_result(
arch = parameters.get("arch", "UNKNOWN").strip("'")
lfc = parameters.get("lfc", "False") == "True"
pg_version = int(parameters.get("pg_version", 17))
build_type = parameters.get("build_type", "debug").strip("'")

build_type, unparametrized_name = parse_test_name(test["name"])
name = test["name"]
labels = {label["name"]: label["value"] for label in test["labels"]}
row = Row(
parent_suite=labels["parentSuite"],
suite=labels["suite"],
name=unparametrized_name,
name=name,
status=test["status"],
started_at=datetime.fromtimestamp(test["time"]["start"] / 1000, tz=UTC),
stopped_at=datetime.fromtimestamp(test["time"]["stop"] / 1000, tz=UTC),
Expand Down
6 changes: 4 additions & 2 deletions test_runner/fixtures/neon_fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -1451,7 +1451,8 @@ def neon_simple_env(
repo_dir = get_test_repo_dir(request, top_output_dir)
combination = (
request._pyfuncitem.callspec.params["combination"]
if "combination" in request._pyfuncitem.callspec.params
if hasattr(request._pyfuncitem, "callspec")
and "combination" in request._pyfuncitem.callspec.params
else None
)

Expand Down Expand Up @@ -1516,7 +1517,8 @@ def neon_env_builder(
repo_dir = os.path.join(test_output_dir, "repo")
combination = (
request._pyfuncitem.callspec.params["combination"]
if "combination" in request._pyfuncitem.callspec.params
if hasattr(request._pyfuncitem, "callspec")
and "combination" in request._pyfuncitem.callspec.params
else None
)

Expand Down
12 changes: 4 additions & 8 deletions test_runner/fixtures/parametrize.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def pg_version() -> PgVersion | None:

@pytest.fixture(scope="function", autouse=True)
def build_type() -> str | None:
return None
return os.getenv("BUILD_TYPE", "debug").lower()


@pytest.fixture(scope="session", autouse=True)
Expand Down Expand Up @@ -59,13 +59,6 @@ def pageserver_default_tenant_config_compaction_algorithm() -> dict[str, Any] |


def pytest_generate_tests(metafunc: Metafunc):
if (bt := os.getenv("BUILD_TYPE")) is None:
build_types = ["debug", "release"]
else:
build_types = [bt.lower()]

metafunc.parametrize("build_type", build_types)

# A hacky way to parametrize tests only for `pageserver_virtual_file_io_engine=std-fs`
# And do not change test name for default `pageserver_virtual_file_io_engine=tokio-epoll-uring` to keep tests statistics
if (io_engine := os.getenv("PAGESERVER_VIRTUAL_FILE_IO_ENGINE", "")) not in (
Expand Down Expand Up @@ -113,4 +106,7 @@ def pytest_runtest_makereport(*args, **kwargs):
pg_version = int(PgVersion(os.getenv("DEFAULT_PG_VERSION", PgVersion.DEFAULT)))
allure.dynamic.parameter("__pg_version", pg_version)

build_type = os.getenv("BUILD_TYPE", "debug").lower()
allure.dynamic.parameter("__build_type", build_type)

yield

0 comments on commit 6429d1f

Please sign in to comment.