diff --git a/doc/developer/platform-checks.md b/doc/developer/platform-checks.md index 214eccd75431f..954ee7af46471 100644 --- a/doc/developer/platform-checks.md +++ b/doc/developer/platform-checks.md @@ -105,6 +105,9 @@ All checks are located in the `misc/python/materialize/checks/all_checks` direct the creation of a particular type of resource is usually placed in the same file as the `Check` that validates the deletion of the same resource type. +## Ignoring a Check +To ignore a `Check`, annotate it with `@disabled(ignore_reason="due to #...")`. + # Writing a Scenario A Scenario is a list of sequential Actions that the framework will perform one after another: diff --git a/misc/python/materialize/checks/all_checks/peek_cancellation.py b/misc/python/materialize/checks/all_checks/peek_cancellation.py index 80f6daacb1852..d5365b6646f6c 100644 --- a/misc/python/materialize/checks/all_checks/peek_cancellation.py +++ b/misc/python/materialize/checks/all_checks/peek_cancellation.py @@ -9,9 +9,10 @@ from textwrap import dedent from materialize.checks.actions import Testdrive -from materialize.checks.checks import Check +from materialize.checks.checks import Check, disabled +@disabled("due to #20743") class PeekCancellation(Check): def initialize(self) -> Testdrive: return Testdrive( diff --git a/misc/python/materialize/checks/all_checks/pg_cdc.py b/misc/python/materialize/checks/all_checks/pg_cdc.py index 960392af7362a..8dcf41badb210 100644 --- a/misc/python/materialize/checks/all_checks/pg_cdc.py +++ b/misc/python/materialize/checks/all_checks/pg_cdc.py @@ -12,7 +12,7 @@ from typing import Any from materialize.checks.actions import Testdrive -from materialize.checks.checks import Check, CheckDisabled +from materialize.checks.checks import Check, disabled from materialize.util import MzVersion @@ -28,7 +28,7 @@ def __init__(self, wait: bool, **kwargs: Any) -> None: self.repeats = 1024 if wait else 16384 self.expects = 97350 if wait else 1633350 self.suffix = f"_{str(wait).lower()}" - super().__init__(**kwargs) # foward unused args to Check/CheckDisabled + super().__init__(**kwargs) # foward unused args to Check def initialize(self) -> Testdrive: return Testdrive( @@ -220,8 +220,8 @@ def __init__(self, base_version: MzVersion, rng: Random | None) -> None: super().__init__(wait=True, base_version=base_version, rng=rng) -# TODO(def-) Enable this check (with an adequate version limitation) when #18940 is fixed -class PgCdcNoWait(PgCdcBase, CheckDisabled): +@disabled("requires #18940 to be fixed") +class PgCdcNoWait(PgCdcBase, Check): def __init__(self, base_version: MzVersion, rng: Random | None) -> None: super().__init__(wait=False, base_version=base_version, rng=rng) diff --git a/misc/python/materialize/checks/checks.py b/misc/python/materialize/checks/checks.py index 65d84be095275..debcdcb79a1fb 100644 --- a/misc/python/materialize/checks/checks.py +++ b/misc/python/materialize/checks/checks.py @@ -8,6 +8,7 @@ # by the Apache License, Version 2.0. from random import Random +from typing import Any from materialize.checks.actions import Testdrive from materialize.checks.executors import Executor @@ -20,6 +21,7 @@ class Check: def __init__(self, base_version: MzVersion, rng: Random | None) -> None: self.base_version = base_version self.rng = rng + self.enabled = True def _can_run(self, e: Executor) -> bool: return True @@ -34,17 +36,17 @@ def validate(self) -> Testdrive: assert False def start_initialize(self, e: Executor) -> None: - if self._can_run(e): + if self._can_run(e) and self.enabled: self.current_version = e.current_mz_version self._initialize = self.initialize() self._initialize.execute(e) def join_initialize(self, e: Executor) -> None: - if self._can_run(e): + if self._can_run(e) and self.enabled: self._initialize.join(e) def start_manipulate(self, e: Executor, phase: int) -> None: - if self._can_run(e): + if self._can_run(e) and self.enabled: self.current_version = e.current_mz_version self._manipulate = self.manipulate() assert ( @@ -53,23 +55,29 @@ def start_manipulate(self, e: Executor, phase: int) -> None: self._manipulate[phase].execute(e) def join_manipulate(self, e: Executor, phase: int) -> None: - if self._can_run(e): + if self._can_run(e) and self.enabled: self._manipulate[phase].join(e) def start_validate(self, e: Executor) -> None: - if self._can_run(e): + if self._can_run(e) and self.enabled: self.current_version = e.current_mz_version self._validate = self.validate() self._validate.execute(e) def join_validate(self, e: Executor) -> None: - if self._can_run(e): + if self._can_run(e) and self.enabled: self._validate.join(e) -class CheckDisabled(Check): - def manipulate(self) -> list[Testdrive]: - return [Testdrive(TESTDRIVE_NOP), Testdrive(TESTDRIVE_NOP)] +def disabled(ignore_reason: str): + class ClassWrapper: + def __init__(self, cls: type[Check]): + assert issubclass(cls, Check) + self.check_class = cls - def validate(self) -> Testdrive: - return Testdrive(TESTDRIVE_NOP) + def __call__(self, *cls_ars: Any): + check = self.check_class(*cls_ars) + check.enabled = False + return check + + return ClassWrapper