system-cluster.td 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  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. $ set-arg-default replicas=1
  10. $ set-arg-default default-replica-size=1
  11. # The expected number of rows in system tables depends on the number of replicas
  12. $ skip-if
  13. SELECT ${arg.replicas} > 1;
  14. $ postgres-connect name=mz_system url=postgres://mz_system:materialize@${testdrive.materialize-internal-sql-addr}
  15. $ postgres-execute connection=mz_system
  16. > SELECT name FROM (SHOW CLUSTERS)
  17. mz_analytics
  18. mz_system
  19. mz_catalog_server
  20. quickstart
  21. mz_probe
  22. mz_support
  23. $ postgres-execute connection=mz_system
  24. > select managed from mz_catalog.mz_clusters where id like 's%';
  25. true
  26. true
  27. true
  28. true
  29. true
  30. $ postgres-execute connection=postgres://mz_system@${testdrive.materialize-internal-sql-addr}/materialize
  31. ALTER SYSTEM SET enable_rbac_checks TO false
  32. ! DROP CLUSTER mz_system CASCADE
  33. contains:must be owner of CLUSTER mz_system
  34. ! DROP CLUSTER mz_catalog_server CASCADE
  35. contains:must be owner of CLUSTER mz_catalog_server
  36. $ postgres-execute connection=postgres://mz_system@${testdrive.materialize-internal-sql-addr}/materialize
  37. ALTER SYSTEM SET enable_rbac_checks TO true
  38. ! DROP CLUSTER mz_joe CASCADE
  39. contains:unknown cluster 'mz_joe'
  40. ! CREATE CLUSTER mz_joe REPLICAS (r1 (size '1'))
  41. contains:cluster name "mz_joe" is reserved
  42. $ postgres-execute connection=postgres://mz_system@${testdrive.materialize-internal-sql-addr}/materialize
  43. ALTER SYSTEM SET enable_rbac_checks TO false
  44. ! CREATE CLUSTER REPLICA mz_system.r2 SIZE '1';
  45. contains: cannot modify managed cluster mz_system
  46. ! DROP CLUSTER REPLICA mz_system.r1;
  47. contains:must be owner of CLUSTER REPLICA mz_system.r1
  48. ! ALTER CLUSTER mz_system SET (SIZE='2');
  49. contains: must be owner of CLUSTER mz_system
  50. $ postgres-execute connection=postgres://mz_system@${testdrive.materialize-internal-sql-addr}/materialize
  51. ALTER SYSTEM SET enable_rbac_checks TO true
  52. > CREATE MATERIALIZED VIEW mv AS SELECT AVG(50)
  53. > SET CLUSTER TO mz_catalog_server
  54. > SHOW MATERIALIZED VIEWS
  55. mv quickstart ""
  56. #! CREATE MATERIALIZED VIEW mv1 AS SELECT MIN(1)
  57. #contains:system cluster 'mz_catalog_server' cannot be modified
  58. > SET CLUSTER TO mz_system
  59. # Query gets automatically run on mz_catalog_server, despite mz_system being set
  60. > SHOW MATERIALIZED VIEWS
  61. mv quickstart ""
  62. #! CREATE MATERIALIZED VIEW mv1 AS SELECT MIN(1)
  63. #contains:must be owner of CLUSTER mz_system
  64. > SET CLUSTER TO quickstart
  65. > CREATE TABLE temp (a INT)
  66. > INSERT INTO temp VALUES (1), (2)
  67. $ postgres-execute connection=mz_system
  68. SET CLUSTER TO mz_system
  69. INSERT INTO temp SELECT * FROM temp
  70. > SELECT * FROM temp
  71. 1
  72. 2
  73. 1
  74. 2
  75. # Ready is false in the process orchestrator, but true in K8s
  76. $ set-regex match=true|false replacement=<TRUE_OR_FALSE>
  77. > SHOW CLUSTER REPLICAS WHERE cluster = 'mz_system'
  78. mz_system r1 bootstrap <TRUE_OR_FALSE> ""
  79. > SELECT COUNT(*) FROM mz_catalog.mz_cluster_replicas as r, mz_catalog.mz_clusters as c WHERE r.cluster_id = c.id and c.name = 'mz_support';
  80. 0
  81. ! ALTER CLUSTER mz_support SET (replication factor 1, size '2');
  82. contains: must be owner of CLUSTER mz_support
  83. $ postgres-execute connection=postgres://mz_support@${testdrive.materialize-internal-sql-addr}/materializeI
  84. ALTER CLUSTER mz_support SET (replication factor 0, size '1');
  85. $ unset-regex
  86. > select name, introspection_debugging from mz_catalog.mz_clusters where name IN ('quickstart', 'mz_support');
  87. name introspection_debugging
  88. ------------------------
  89. quickstart false
  90. mz_support false
  91. ! ALTER CLUSTER quickstart SET (introspection debugging = TRUE);
  92. contains: must be owner of CLUSTER quickstart
  93. ! ALTER CLUSTER mz_support SET (introspection debugging = TRUE);
  94. contains: must be owner of CLUSTER mz_support
  95. $ postgres-execute connection=postgres://mz_support@${testdrive.materialize-internal-sql-addr}/materializeI
  96. ALTER CLUSTER mz_support SET (introspection debugging = TRUE);
  97. > select name, introspection_debugging from mz_catalog.mz_clusters where name IN ('quickstart', 'mz_support');
  98. quickstart false
  99. mz_support true
  100. $ postgres-execute connection=postgres://mz_support@${testdrive.materialize-internal-sql-addr}/materializeI
  101. ALTER CLUSTER mz_support SET (introspection interval = '10ms');
  102. > select name, introspection_debugging, introspection_interval from mz_catalog.mz_clusters where name = 'mz_support';
  103. mz_support true "00:00:00.01"
  104. $ postgres-execute connection=postgres://mz_support@${testdrive.materialize-internal-sql-addr}/materializeI
  105. ALTER CLUSTER mz_support SET (introspection interval = '0s');
  106. > select name, introspection_debugging, introspection_interval from mz_catalog.mz_clusters where name = 'mz_support';
  107. mz_support true <null>