cluster_unification.py 3.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  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 materialize.checks.actions import Testdrive
  10. from materialize.checks.checks import Check
  11. class UnifiedCluster(Check):
  12. def initialize(self) -> Testdrive:
  13. return Testdrive(
  14. """
  15. >[version>=13800] CREATE CLUSTER shared_cluster_compute_first SIZE '1', REPLICATION FACTOR 2;
  16. >[version<13800] CREATE CLUSTER shared_cluster_compute_first SIZE '1', REPLICATION FACTOR 1;
  17. >[version>=13800] CREATE CLUSTER shared_cluster_storage_first SIZE '1', REPLICATION FACTOR 2;
  18. >[version<13800] CREATE CLUSTER shared_cluster_storage_first SIZE '1', REPLICATION FACTOR 1;
  19. """
  20. )
  21. def manipulate(self) -> list[Testdrive]:
  22. return [
  23. # Create either a source or a view as first object in cluster
  24. Testdrive(
  25. """
  26. > CREATE SOURCE shared_cluster_storage_first_source
  27. IN CLUSTER shared_cluster_storage_first
  28. FROM LOAD GENERATOR COUNTER
  29. > CREATE MATERIALIZED VIEW shared_cluster_compute_first_mv
  30. IN CLUSTER shared_cluster_compute_first
  31. AS SELECT COUNT(*) AS cnt FROM shared_cluster_storage_first_source
  32. > CREATE DEFAULT INDEX
  33. IN CLUSTER shared_cluster_compute_first
  34. ON shared_cluster_compute_first_mv
  35. """
  36. ),
  37. # Create the other type of object as a second object in the cluster that
  38. # now already contains an object
  39. Testdrive(
  40. """
  41. > CREATE SOURCE shared_cluster_compute_first_source
  42. IN CLUSTER shared_cluster_compute_first
  43. FROM LOAD GENERATOR COUNTER
  44. > CREATE MATERIALIZED VIEW shared_cluster_storage_first_mv
  45. IN CLUSTER shared_cluster_storage_first
  46. AS SELECT COUNT(*) AS cnt FROM shared_cluster_compute_first_source
  47. > CREATE DEFAULT INDEX
  48. IN CLUSTER shared_cluster_storage_first
  49. ON shared_cluster_storage_first_mv
  50. """
  51. ),
  52. ]
  53. def validate(self) -> Testdrive:
  54. return Testdrive(
  55. """
  56. > SELECT COUNT(*) > 0 FROM shared_cluster_storage_first_source;
  57. true
  58. > SELECT cnt > 0 FROM shared_cluster_storage_first_mv;
  59. true
  60. > SELECT COUNT(*) > 0 FROM shared_cluster_compute_first_source;
  61. true
  62. > SELECT cnt > 0 FROM shared_cluster_compute_first_mv;
  63. true
  64. > SET cluster = shared_cluster_compute_first;
  65. > SELECT COUNT(*) > 0 FROM mz_tables;
  66. true
  67. > SET cluster = shared_cluster_storage_first;
  68. > SELECT COUNT(*) > 0 FROM mz_tables;
  69. true
  70. > SET cluster = default
  71. ! DROP CLUSTER shared_cluster_compute_first;
  72. contains: cannot drop cluster "shared_cluster_compute_first" because other objects depend on it
  73. ! DROP CLUSTER shared_cluster_storage_first;
  74. contains: cannot drop cluster "shared_cluster_storage_first" because other objects depend on it
  75. """
  76. )