peek_cancellation.py 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  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.checks.actions import Testdrive
  11. from materialize.checks.checks import Check, disabled
  12. @disabled("due to database-issues#6249")
  13. class PeekCancellation(Check):
  14. def initialize(self) -> Testdrive:
  15. return Testdrive(
  16. dedent(
  17. """
  18. > CREATE TABLE peek_cancellation (f1 INTEGER);
  19. > CREATE DEFAULT INDEX ON peek_cancellation;
  20. > INSERT INTO peek_cancellation SELECT * FROM generate_series(1, 10000);
  21. """
  22. )
  23. )
  24. def manipulate(self) -> list[Testdrive]:
  25. return [
  26. Testdrive(dedent(s))
  27. for s in [
  28. """
  29. > SET statement_timeout = '10ms';
  30. ! INSERT INTO peek_cancellation SELECT * FROM peek_cancellation;
  31. contains: timeout
  32. """,
  33. """
  34. > SET statement_timeout = '10ms';
  35. ! INSERT INTO peek_cancellation SELECT * FROM peek_cancellation;
  36. contains: timeout
  37. """,
  38. ]
  39. ]
  40. def validate(self) -> Testdrive:
  41. return Testdrive(
  42. dedent(
  43. """
  44. > SET statement_timeout = '10ms';
  45. ! INSERT INTO peek_cancellation SELECT * FROM peek_cancellation;
  46. contains: timeout
  47. """
  48. )
  49. )