Skip to content

Commit

Permalink
Merge pull request #22682 from nrainer-materialize/ci/restore-ignores…
Browse files Browse the repository at this point in the history
…-in-checks
  • Loading branch information
nrainer-materialize authored Oct 26, 2023
2 parents 2939267 + 90519a8 commit 9e6530e
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 16 deletions.
3 changes: 3 additions & 0 deletions doc/developer/platform-checks.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
8 changes: 4 additions & 4 deletions misc/python/materialize/checks/all_checks/pg_cdc.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand All @@ -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(
Expand Down Expand Up @@ -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)

Expand Down
30 changes: 19 additions & 11 deletions misc/python/materialize/checks/checks.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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 (
Expand All @@ -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

0 comments on commit 9e6530e

Please sign in to comment.