| 23 | |
| 24 | |
| 25 | class Check: |
| 26 | # Has to be set for the class already, not just in the constructor, so that |
| 27 | # we can change the value for the entire class in the decorator |
| 28 | enabled: bool = True |
| 29 | externally_idempotent: bool = True |
| 30 | supports_forced_migrations: bool = True |
| 31 | |
| 32 | def __init__(self, base_version: MzVersion, rng: Random | None) -> None: |
| 33 | self.base_version = base_version |
| 34 | self.rng = rng |
| 35 | |
| 36 | def _can_run(self, e: Executor) -> bool: |
| 37 | return True |
| 38 | |
| 39 | def _kafka_broker(self) -> str: |
| 40 | return "BROKER '${testdrive.kafka-addr}', SECURITY PROTOCOL PLAINTEXT" |
| 41 | |
| 42 | def _unsafe_schema(self) -> str: |
| 43 | """ |
| 44 | :return: the schema containing unsafe functions, such as `mz_sleep`. |
| 45 | """ |
| 46 | return "mz_unsafe" |
| 47 | |
| 48 | def _default_cluster(self) -> str: |
| 49 | """ |
| 50 | :return: name of the cluster created in all environments. |
| 51 | """ |
| 52 | return "quickstart" |
| 53 | |
| 54 | def initialize(self) -> Testdrive | PyAction: |
| 55 | return Testdrive(TESTDRIVE_NOP) |
| 56 | |
| 57 | def manipulate(self) -> list[Testdrive] | list[PyAction]: |
| 58 | raise NotImplementedError |
| 59 | |
| 60 | def validate(self) -> Testdrive | PyAction: |
| 61 | """Note that the validation method may be invoked multiple times (depending on the scenario).""" |
| 62 | raise NotImplementedError |
| 63 | |
| 64 | def start_initialize(self, e: Executor, a: "Action") -> None: |
| 65 | if self._can_run(e) and self.enabled: |
| 66 | self.current_version = e.current_mz_version |
| 67 | self._initialize = self.initialize() |
| 68 | self._initialize.execute(e, a.mz_service) |
| 69 | |
| 70 | def join_initialize(self, e: Executor) -> None: |
| 71 | if self._can_run(e) and self.enabled: |
| 72 | self._initialize.join(e) |
| 73 | |
| 74 | def start_manipulate(self, e: Executor, a: "Action") -> None: |
| 75 | if self._can_run(e) and self.enabled: |
| 76 | self.current_version = e.current_mz_version |
| 77 | self._manipulate = self.manipulate() |
| 78 | assert ( |
| 79 | len(self._manipulate) == 2 |
| 80 | ), f"manipulate() should return a list with exactly 2 elements, but actually returns {len(self._manipulate)} elements" |
| 81 | |
| 82 | assert a.phase is not None |
no outgoing calls
no test coverage detected