peek_actions.py 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. # Copyright Materialize, Inc. and contributors. All rights reserved.
  2. #
  3. # Use of this software is governed by the Business Source License
  4. # included in the LICENSE file at the root of this repository.
  5. #
  6. # As of the Change Date specified in that file, in accordance with
  7. # the Business Source License, use of this software will be governed
  8. # by the Apache License, Version 2.0.
  9. from textwrap import dedent
  10. from materialize.mzcompose.composition import Composition
  11. from materialize.zippy.balancerd_capabilities import BalancerdIsRunning
  12. from materialize.zippy.framework import Action, Capability, State
  13. from materialize.zippy.mz_capabilities import MzIsRunning
  14. class PeekCancellation(Action):
  15. """Perfoms a peek cancellation."""
  16. @classmethod
  17. def requires(cls) -> set[type[Capability]]:
  18. return {BalancerdIsRunning, MzIsRunning}
  19. def run(self, c: Composition, state: State) -> None:
  20. c.testdrive(
  21. dedent(
  22. """
  23. > DROP TABLE IF EXISTS peek_cancellation;
  24. > CREATE TABLE IF NOT EXISTS peek_cancellation (f1 INTEGER);
  25. > INSERT INTO peek_cancellation SELECT generate_series(1, 1000);
  26. > SET statement_timeout = '10ms';
  27. ! INSERT INTO peek_cancellation
  28. SELECT 1 FROM peek_cancellation AS a1, peek_cancellation AS a2, peek_cancellation AS a3;
  29. contains: timeout
  30. """
  31. ),
  32. mz_service=state.mz_service,
  33. )