Skip to content

Commit

Permalink
Add skip_on_build_type/skip_on_ci decorators
Browse files Browse the repository at this point in the history
  • Loading branch information
bayandin committed Nov 10, 2024
1 parent 5f49295 commit 6375e37
Show file tree
Hide file tree
Showing 21 changed files with 91 additions and 95 deletions.
23 changes: 0 additions & 23 deletions test_runner/fixtures/pg_version.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
from __future__ import annotations

import enum
import os
from typing import TYPE_CHECKING

import pytest
from typing_extensions import override

if TYPE_CHECKING:
Expand Down Expand Up @@ -62,24 +60,3 @@ def _missing_(cls, value: object) -> Optional[PgVersion]:
# Make mypy happy
# See https://github.com/python/mypy/issues/3974
return None


def skip_on_postgres(version: PgVersion, reason: str):
return pytest.mark.skipif(
PgVersion(os.environ.get("DEFAULT_PG_VERSION", PgVersion.DEFAULT)) is version,
reason=reason,
)


def xfail_on_postgres(version: PgVersion, reason: str):
return pytest.mark.xfail(
PgVersion(os.environ.get("DEFAULT_PG_VERSION", PgVersion.DEFAULT)) is version,
reason=reason,
)


def run_only_on_default_postgres(reason: str):
return pytest.mark.skipif(
PgVersion(os.environ.get("DEFAULT_PG_VERSION", PgVersion.DEFAULT)) is not PgVersion.DEFAULT,
reason=reason,
)
43 changes: 41 additions & 2 deletions test_runner/fixtures/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,11 @@
parse_delta_layer,
parse_image_layer,
)
from fixtures.pg_version import PgVersion

if TYPE_CHECKING:
from collections.abc import Iterable
from typing import IO, Optional
from typing import IO, Literal, Optional

from fixtures.common_types import TimelineId
from fixtures.neon_fixtures import PgBin
Expand All @@ -37,6 +38,7 @@


Fn = TypeVar("Fn", bound=Callable[..., Any])

COMPONENT_BINARIES = {
"storage_controller": ("storage_controller",),
"storage_broker": ("storage_broker",),
Expand Down Expand Up @@ -519,7 +521,7 @@ def assert_pageserver_backups_equal(left: Path, right: Path, skip_files: set[str
This is essentially:
lines=$(comm -3 \
<(mkdir left && cd left && tar xf "$left" && find . -type f -print0 | xargs sha256sum | sort -k2) \
<(mkdir left && cd left && tar xf "$left" && find . -type f -print0 | xargs sha256sum | sort -k2) \
<(mkdir right && cd right && tar xf "$right" && find . -type f -print0 | xargs sha256sum | sort -k2) \
| wc -l)
[ "$lines" = "0" ]
Expand Down Expand Up @@ -643,3 +645,40 @@ def allpairs_versions():
)
ids.append(f"combination_{''.join(cur_id)}")
return {"argnames": "combination", "argvalues": tuple(argvalues), "ids": ids}


def skip_on_postgres(version: PgVersion, reason: str):
return pytest.mark.skipif(
PgVersion(os.getenv("DEFAULT_PG_VERSION", PgVersion.DEFAULT)) is version,
reason=reason,
)


def xfail_on_postgres(version: PgVersion, reason: str):
return pytest.mark.xfail(
PgVersion(os.getenv("DEFAULT_PG_VERSION", PgVersion.DEFAULT)) is version,
reason=reason,
)


def run_only_on_default_postgres(reason: str):
return pytest.mark.skipif(
PgVersion(os.getenv("DEFAULT_PG_VERSION", PgVersion.DEFAULT)) is not PgVersion.DEFAULT,
reason=reason,
)


def skip_on_build_type(build_type: Literal["debug", "release"], reason: str):
return pytest.mark.skipif(
os.getenv("BUILD_TYPE", "debug") == build_type,
reason=reason,
)


def skip_on_ci(reason: str):
# `CI` variable is always set to `true` on GitHub
# Ref: https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/store-information-in-variables#default-environment-variables
return pytest.mark.skipif(
os.getenv("CI", "false") == "true",
reason=reason,
)
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
from __future__ import annotations

import json
import os
from pathlib import Path
from typing import TYPE_CHECKING

Expand All @@ -14,7 +13,7 @@
PgBin,
wait_for_last_flush_lsn,
)
from fixtures.utils import get_scale_for_db, humantime_to_ms
from fixtures.utils import get_scale_for_db, humantime_to_ms, skip_on_ci

from performance.pageserver.util import (
setup_pageserver_with_tenants,
Expand All @@ -38,9 +37,8 @@
@pytest.mark.parametrize("pgbench_scale", [get_scale_for_db(200)])
@pytest.mark.parametrize("n_tenants", [500])
@pytest.mark.timeout(10000)
@pytest.mark.skipif(
os.getenv("CI", "false") == "true",
reason="This test needs lot of resources and should run on dedicated HW, not in github action runners as part of CI",
@skip_on_ci(
"This test needs lot of resources and should run on dedicated HW, not in github action runners as part of CI"
)
def test_pageserver_characterize_throughput_with_n_tenants(
neon_env_builder: NeonEnvBuilder,
Expand All @@ -66,9 +64,8 @@ def test_pageserver_characterize_throughput_with_n_tenants(
@pytest.mark.parametrize("n_clients", [1, 64])
@pytest.mark.parametrize("n_tenants", [1])
@pytest.mark.timeout(2400)
@pytest.mark.skipif(
os.getenv("CI", "false") == "true",
reason="This test needs lot of resources and should run on dedicated HW, not in github action runners as part of CI",
@skip_on_ci(
"This test needs lot of resources and should run on dedicated HW, not in github action runners as part of CI"
)
def test_pageserver_characterize_latencies_with_1_client_and_throughput_with_many_clients_one_tenant(
neon_env_builder: NeonEnvBuilder,
Expand Down
5 changes: 2 additions & 3 deletions test_runner/regress/test_branch_and_gc.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from __future__ import annotations

import os
import threading
import time

Expand All @@ -9,7 +8,7 @@
from fixtures.log_helper import log
from fixtures.neon_fixtures import NeonEnv
from fixtures.pageserver.http import TimelineCreate406
from fixtures.utils import query_scalar
from fixtures.utils import query_scalar, skip_on_build_type


# Test the GC implementation when running with branching.
Expand Down Expand Up @@ -49,7 +48,7 @@
# Because the delta layer D covering lsn1 is corrupted, creating a branch
# starting from lsn1 should return an error as follows:
# could not find data for key ... at LSN ..., for request at LSN ...
@pytest.mark.skipif(os.getenv("BUILD_TYPE") != "release", reason="times out in debug builds")
@skip_on_build_type("debug", reason="times out in debug builds")
def test_branch_and_gc(neon_simple_env: NeonEnv):
env = neon_simple_env
pageserver_http_client = env.pageserver.http_client()
Expand Down
5 changes: 2 additions & 3 deletions test_runner/regress/test_compaction.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import enum
import json
import os
import time
from typing import TYPE_CHECKING

Expand All @@ -13,7 +12,7 @@
generate_uploads_and_deletions,
)
from fixtures.pageserver.http import PageserverApiException
from fixtures.utils import wait_until
from fixtures.utils import skip_on_build_type, wait_until
from fixtures.workload import Workload

if TYPE_CHECKING:
Expand All @@ -32,7 +31,7 @@
}


@pytest.mark.skipif(os.environ.get("BUILD_TYPE") == "debug", reason="only run with release build")
@skip_on_build_type("debug", reason="only run with release build")
def test_pageserver_compaction_smoke(neon_env_builder: NeonEnvBuilder):
"""
This is a smoke test that compaction kicks in. The workload repeatedly churns
Expand Down
3 changes: 2 additions & 1 deletion test_runner/regress/test_download_extensions.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
from fixtures.neon_fixtures import (
NeonEnvBuilder,
)
from fixtures.pg_version import PgVersion, skip_on_postgres
from fixtures.pg_version import PgVersion
from fixtures.utils import skip_on_postgres
from pytest_httpserver import HTTPServer
from werkzeug.wrappers.request import Request
from werkzeug.wrappers.response import Response
Expand Down
6 changes: 2 additions & 4 deletions test_runner/regress/test_ingestion_layer_size.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,19 @@
from __future__ import annotations

import os
from collections.abc import Iterable
from dataclasses import dataclass
from typing import TYPE_CHECKING

import pytest
from fixtures.log_helper import log
from fixtures.neon_fixtures import NeonEnvBuilder, wait_for_last_flush_lsn
from fixtures.pageserver.http import HistoricLayerInfo, LayerMapInfo
from fixtures.utils import human_bytes
from fixtures.utils import human_bytes, skip_on_build_type

if TYPE_CHECKING:
from typing import Union


@pytest.mark.skipif(os.getenv("BUILD_TYPE") != "release", reason="debug run is unnecessarily slow")
@skip_on_build_type("debug", reason="debug run is unnecessarily slow")
def test_ingesting_large_batches_of_images(neon_env_builder: NeonEnvBuilder):
"""
Build a non-small GIN index which includes similarly batched up images in WAL stream as does pgvector
Expand Down
3 changes: 2 additions & 1 deletion test_runner/regress/test_layer_bloating.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
logical_replication_sync,
wait_for_last_flush_lsn,
)
from fixtures.pg_version import PgVersion, skip_on_postgres
from fixtures.pg_version import PgVersion
from fixtures.utils import skip_on_postgres


@skip_on_postgres(
Expand Down
5 changes: 2 additions & 3 deletions test_runner/regress/test_layer_eviction.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
from __future__ import annotations

import os
import time

import pytest
from fixtures.log_helper import log
from fixtures.neon_fixtures import (
NeonEnvBuilder,
Expand All @@ -13,11 +11,12 @@
from fixtures.pageserver.common_types import parse_layer_file_name
from fixtures.pageserver.utils import wait_for_upload
from fixtures.remote_storage import RemoteStorageKind
from fixtures.utils import skip_on_build_type


# Crates a few layers, ensures that we can evict them (removing locally but keeping track of them anyway)
# and then download them back.
@pytest.mark.skipif(os.getenv("BUILD_TYPE") != "release", reason="times out in debug builds")
@skip_on_build_type("debug", reason="times out in debug builds")
def test_basic_eviction(neon_env_builder: NeonEnvBuilder):
neon_env_builder.enable_pageserver_remote_storage(RemoteStorageKind.LOCAL_FS)

Expand Down
3 changes: 1 addition & 2 deletions test_runner/regress/test_logging.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@
import pytest
from fixtures.log_helper import log
from fixtures.neon_fixtures import NeonEnvBuilder
from fixtures.pg_version import run_only_on_default_postgres
from fixtures.utils import wait_until
from fixtures.utils import run_only_on_default_postgres, wait_until


@pytest.mark.parametrize("level", ["trace", "debug", "info", "warn", "error"])
Expand Down
15 changes: 4 additions & 11 deletions test_runner/regress/test_neon_cli.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from __future__ import annotations

import os
import subprocess
from pathlib import Path
from typing import cast
Expand All @@ -15,7 +14,7 @@
parse_project_git_version_output,
)
from fixtures.pageserver.http import PageserverHttpClient
from fixtures.pg_version import run_only_on_default_postgres
from fixtures.utils import run_only_on_default_postgres, skip_on_build_type


def helper_compare_timeline_list(
Expand Down Expand Up @@ -196,9 +195,7 @@ def test_cli_start_stop_multi(neon_env_builder: NeonEnvBuilder):


@run_only_on_default_postgres(reason="does not use postgres")
@pytest.mark.skipif(
os.environ.get("BUILD_TYPE") == "debug", reason="unit test for test support, either build works"
)
@skip_on_build_type("debug", reason="unit test for test support, either build works")
def test_parse_project_git_version_output_positive():
commit = "b6f77b5816cf1dba12a3bc8747941182ce220846"

Expand All @@ -218,9 +215,7 @@ def test_parse_project_git_version_output_positive():


@run_only_on_default_postgres(reason="does not use postgres")
@pytest.mark.skipif(
os.environ.get("BUILD_TYPE") == "debug", reason="unit test for test support, either build works"
)
@skip_on_build_type("debug", reason="unit test for test support, either build works")
def test_parse_project_git_version_output_local_docker():
"""
Makes sure the tests don't accept the default version in Dockerfile one gets without providing
Expand All @@ -235,9 +230,7 @@ def test_parse_project_git_version_output_local_docker():


@run_only_on_default_postgres(reason="does not use postgres")
@pytest.mark.skipif(
os.environ.get("BUILD_TYPE") == "debug", reason="cli api sanity, either build works"
)
@skip_on_build_type("debug", reason="unit test for test support, either build works")
def test_binaries_version_parses(neon_binpath: Path):
"""
Ensures that we can parse the actual outputs of --version from a set of binaries.
Expand Down
12 changes: 4 additions & 8 deletions test_runner/regress/test_pageserver_layer_rolling.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
from __future__ import annotations

import asyncio
import os
import time
from typing import TYPE_CHECKING

Expand All @@ -16,7 +15,7 @@
)
from fixtures.pageserver.http import PageserverHttpClient
from fixtures.pageserver.utils import wait_for_last_record_lsn, wait_for_upload
from fixtures.utils import wait_until
from fixtures.utils import skip_on_build_type, wait_until

if TYPE_CHECKING:
from typing import Optional
Expand Down Expand Up @@ -227,12 +226,9 @@ def test_idle_checkpoints(neon_env_builder: NeonEnvBuilder):
assert get_dirty_bytes(env) >= dirty_after_write


@pytest.mark.skipif(
# We have to use at least ~100MB of data to hit the lowest limit we can configure, which is
# prohibitively slow in debug mode
os.getenv("BUILD_TYPE") == "debug",
reason="Avoid running bulkier ingest tests in debug mode",
)
# We have to use at least ~100MB of data to hit the lowest limit we can configure, which is
# prohibitively slow in debug mode
@skip_on_build_type("debug", reason="Avoid running bulkier ingest tests in debug mode")
def test_total_size_limit(neon_env_builder: NeonEnvBuilder):
"""
Test that checkpoints are done based on total ephemeral layer size, even if no one timeline is
Expand Down
5 changes: 2 additions & 3 deletions test_runner/regress/test_pageserver_restart.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from __future__ import annotations

import os
import random
from contextlib import closing
from typing import Optional
Expand All @@ -9,7 +8,7 @@
from fixtures.log_helper import log
from fixtures.neon_fixtures import NeonEnvBuilder
from fixtures.remote_storage import s3_storage
from fixtures.utils import wait_until
from fixtures.utils import skip_on_build_type, wait_until


# Test restarting page server, while safekeeper and compute node keep
Expand Down Expand Up @@ -156,7 +155,7 @@ def assert_complete():
# safekeeper and compute node keep running.
@pytest.mark.timeout(540)
@pytest.mark.parametrize("shard_count", [None, 4])
@pytest.mark.skipif(os.getenv("BUILD_TYPE") != "release", reason="times out in debug builds")
@skip_on_build_type("debug", reason="times out in debug builds")
def test_pageserver_chaos(neon_env_builder: NeonEnvBuilder, shard_count: Optional[int]):
# same rationale as with the immediate stop; we might leave orphan layers behind.
neon_env_builder.disable_scrub_on_exit()
Expand Down
Loading

0 comments on commit 6375e37

Please sign in to comment.