From 351982c56ae40186950986dac2ede9c261c0d08d Mon Sep 17 00:00:00 2001 From: Jan Teske Date: Tue, 27 Aug 2024 15:52:39 +0200 Subject: [PATCH] test: adapt to changed mz_cluster_replica_metrics This commit adapts the tests to the changes made to the `mz_cluster_replica_metrics` system relation: * It's no longer a table but a source. * It has an extra column with the event time. * It is a log rather than a snapshot of the most recent state. The `statement-logging` cluster test runs into #29237 when querying the new `mz_cluster_replica_metrics` source, so that query has been disabled until the bug is fixed. --- src/environmentd/tests/sql.rs | 4 ++-- test/cloudtest/test_metrics.py | 13 +++++++++++-- test/cluster/statement-logging/statement-logging.td | 11 +++-------- test/sqllogictest/autogenerated/mz_internal.slt | 2 ++ test/sqllogictest/information_schema_tables.slt | 2 +- .../mz_catalog_server_index_accounting.slt | 1 + test/sqllogictest/system-cluster.slt | 2 +- test/testdrive/catalog.td | 4 ++-- test/testdrive/metrics-cluster.td | 4 ++-- 9 files changed, 25 insertions(+), 18 deletions(-) diff --git a/src/environmentd/tests/sql.rs b/src/environmentd/tests/sql.rs index 662260b0825d9..68f155204d17c 100644 --- a/src/environmentd/tests/sql.rs +++ b/src/environmentd/tests/sql.rs @@ -1372,7 +1372,7 @@ fn test_transactional_explain_timestamps() { assert_eq!(*explain_timestamp, mz_now_timestamp); } -// Test that the since for `mz_cluster_replica_utilization` is held back by at least +// Test that the since for `mz_cluster_replicas` is held back by at least // 30 days, which is required for the frontend observability work. // // Feel free to modify this test if that product requirement changes, @@ -1384,7 +1384,7 @@ async fn test_utilization_hold() { // `mz_catalog_server` tests indexes, `quickstart` tests tables. // The bool determines whether we are testing indexes. const CLUSTERS_TO_TRY: &[&str] = &["mz_catalog_server", "quickstart"]; - const QUERIES_TO_TRY: &[&str] = &["SELECT * FROM mz_internal.mz_cluster_replica_statuses"]; + const QUERIES_TO_TRY: &[&str] = &["SELECT * FROM mz_internal.mz_cluster_replicas"]; let now_millis = 619388520000; let past_millis = now_millis - THIRTY_DAYS_MS; diff --git a/test/cloudtest/test_metrics.py b/test/cloudtest/test_metrics.py index 863822fca992e..093ea46292450 100644 --- a/test/cloudtest/test_metrics.py +++ b/test/cloudtest/test_metrics.py @@ -21,8 +21,17 @@ def test_replica_metrics(mz: MaterializeApplication) -> None: """ > CREATE CLUSTER my_cluster REPLICAS (my_replica (SIZE '4-4')) - > SELECT COUNT(*) FROM mz_internal.mz_cluster_replica_metrics m JOIN mz_cluster_replicas cr ON m.replica_id = cr.id WHERE cr.name = 'my_replica' AND m.cpu_nano_cores IS NOT NULL AND m.memory_bytes IS NOT NULL - 4 + > SELECT DISTINCT process_id + FROM mz_internal.mz_cluster_replica_metrics m + JOIN mz_cluster_replicas cr ON m.replica_id = cr.id + WHERE + cr.name = 'my_replica' AND + m.cpu_nano_cores IS NOT NULL AND + m.memory_bytes IS NOT NULL + 0 + 1 + 2 + 3 > DROP CLUSTER my_cluster """ diff --git a/test/cluster/statement-logging/statement-logging.td b/test/cluster/statement-logging/statement-logging.td index 3a6bd675a9466..3a88f3aeacb79 100644 --- a/test/cluster/statement-logging/statement-logging.td +++ b/test/cluster/statement-logging/statement-logging.td @@ -94,8 +94,9 @@ contains: column "f_nonexistent" does not exist > DROP CLUSTER c # This will be executed on mz_catalog_server, due to auto-routing of catalog queries. -> SELECT count(*) > 0 FROM mz_internal.mz_cluster_replica_metrics -true +# Disabled until #29237 is fixed, as the query lifecycle check below is flaky otherwise. +#> SELECT count(*) > 0 FROM mz_internal.mz_cluster_replica_metrics +#true # Test that we're correctly recording transaction isolation > SET transaction_isolation TO serializable @@ -145,7 +146,6 @@ quickstart quickstart my_app 1 {} success true "PREPARE p A quickstart quickstart my_app 1 {} success true "SET cluster TO c" "strict serializable" materialize {public} mz_catalog_server mz_catalog_server my_app 1 {} success 1 constant true "SELECT 'beginning real test!'" "strict serializable" materialize {public} mz_catalog_server mz_catalog_server my_app 1 {} success 1 constant true "SELECT 'serializable'" serializable materialize {public} -mz_catalog_server mz_catalog_server my_app 1 {} success 1 standard true "SELECT count(*) > 0 FROM mz_internal.mz_cluster_replica_metrics" "strict serializable" true materialize {public} > WITH all_stmts AS (SELECT mseh.id, mseh.began_at, mst.sql FROM mz_internal.mz_statement_execution_history mseh JOIN mz_internal.mz_prepared_statement_history mpsh ON mseh.prepared_statement_id = mpsh.id JOIN (SELECT DISTINCT sql, sql_hash, redacted_sql FROM mz_internal.mz_sql_text) mst ON mpsh.sql_hash = mst.sql_hash), test_begin AS (SELECT began_at FROM all_stmts WHERE sql = 'SELECT ''beginning real test!''' ORDER BY began_at DESC LIMIT 1) @@ -199,11 +199,6 @@ COMMIT execution-finished "SELECT * FROM t" execution-finished "SELECT * FROM t" optimization-finished "SELECT * FROM t" storage-dependencies-finished -"SELECT count(*) > 0 FROM mz_internal.mz_cluster_replica_metrics" compute-dependencies-finished -"SELECT count(*) > 0 FROM mz_internal.mz_cluster_replica_metrics" execution-began -"SELECT count(*) > 0 FROM mz_internal.mz_cluster_replica_metrics" execution-finished -"SELECT count(*) > 0 FROM mz_internal.mz_cluster_replica_metrics" optimization-finished -"SELECT count(*) > 0 FROM mz_internal.mz_cluster_replica_metrics" storage-dependencies-finished "SELECT count(*) FROM t" compute-dependencies-finished "SELECT count(*) FROM t" compute-dependencies-finished "SELECT count(*) FROM t" execution-began diff --git a/test/sqllogictest/autogenerated/mz_internal.slt b/test/sqllogictest/autogenerated/mz_internal.slt index c0d9461d3a25b..76b064baaf4f5 100644 --- a/test/sqllogictest/autogenerated/mz_internal.slt +++ b/test/sqllogictest/autogenerated/mz_internal.slt @@ -116,6 +116,7 @@ SELECT position, name, type FROM objects WHERE schema = 'mz_internal' AND object 3 cpu_nano_cores uint8 4 memory_bytes uint8 5 disk_bytes uint8 +6 updated_at timestamp␠with␠time␠zone query ITT SELECT position, name, type FROM objects WHERE schema = 'mz_internal' AND object = 'mz_cluster_replica_statuses' ORDER BY position @@ -134,6 +135,7 @@ SELECT position, name, type FROM objects WHERE schema = 'mz_internal' AND object 3 cpu_percent double␠precision 4 memory_percent double␠precision 5 disk_percent double␠precision +6 updated_at timestamp␠with␠time␠zone query ITT SELECT position, name, type FROM objects WHERE schema = 'mz_internal' AND object = 'mz_cluster_replica_history' ORDER BY position diff --git a/test/sqllogictest/information_schema_tables.slt b/test/sqllogictest/information_schema_tables.slt index 1688e3432cf81..db292a92a555e 100644 --- a/test/sqllogictest/information_schema_tables.slt +++ b/test/sqllogictest/information_schema_tables.slt @@ -282,7 +282,7 @@ VIEW materialize mz_internal mz_cluster_replica_metrics -BASE TABLE +SOURCE materialize mz_internal mz_cluster_replica_statuses diff --git a/test/sqllogictest/mz_catalog_server_index_accounting.slt b/test/sqllogictest/mz_catalog_server_index_accounting.slt index 2260546bcd15b..1f8938fae3aad 100644 --- a/test/sqllogictest/mz_catalog_server_index_accounting.slt +++ b/test/sqllogictest/mz_catalog_server_index_accounting.slt @@ -208,6 +208,7 @@ mz_cluster_replica_metrics disk_bytes mz_cluster_replica_metrics memory_bytes mz_cluster_replica_metrics process_id mz_cluster_replica_metrics replica_id +mz_cluster_replica_metrics updated_at mz_cluster_replica_sizes cpu_nano_cores mz_cluster_replica_sizes credits_per_hour mz_cluster_replica_sizes disk_bytes diff --git a/test/sqllogictest/system-cluster.slt b/test/sqllogictest/system-cluster.slt index 33422c195d6ec..8f0b43bdde1bf 100644 --- a/test/sqllogictest/system-cluster.slt +++ b/test/sqllogictest/system-cluster.slt @@ -410,7 +410,7 @@ ORDER BY r.id; ---- Explained Query: Finish order_by=[#0 asc nulls_last] output=[#0..=#5] - Project (#0..=#3, #5, #29) + Project (#0..=#3, #5, #30) Map (((uint8_to_double(#27) / uint8_to_double(#21)) * 100)) Join on=(#0 = #15 = #24 AND #2 = #4 AND #16 = #17) type=delta ArrangeBy keys=[[#0], [#2]] diff --git a/test/testdrive/catalog.td b/test/testdrive/catalog.td index 730d17f666886..ab40c11436928 100644 --- a/test/testdrive/catalog.td +++ b/test/testdrive/catalog.td @@ -565,6 +565,7 @@ name type cluster comment ----------------------------------------------------------------------- mz_aws_privatelink_connection_status_history source "" mz_cluster_replica_frontiers source "" +mz_cluster_replica_metrics source "" mz_compute_dependencies source "" mz_compute_error_counts_raw_unified source "" mz_compute_hydration_times source "" @@ -587,7 +588,6 @@ name comment ------------------------------------------------ mz_aggregates "" mz_aws_connections "" -mz_cluster_replica_metrics "" mz_cluster_replica_statuses "" mz_cluster_schedules "" mz_cluster_workload_classes "" @@ -769,7 +769,7 @@ test_table "" # `SHOW TABLES` and `mz_tables` should agree. > SELECT COUNT(*) FROM mz_tables WHERE id LIKE 's%' -56 +55 # There is one entry in mz_indexes for each field_number/expression of the index. > SELECT COUNT(id) FROM mz_indexes WHERE id LIKE 's%' diff --git a/test/testdrive/metrics-cluster.td b/test/testdrive/metrics-cluster.td index ab72336a107e6..e88ecbcd7f4ca 100644 --- a/test/testdrive/metrics-cluster.td +++ b/test/testdrive/metrics-cluster.td @@ -11,7 +11,7 @@ > CREATE CLUSTER bar REPLICAS () > CREATE CLUSTER xyzzy REPLICAS (size_4 (SIZE '4')) -> SELECT +> SELECT DISTINCT ON (c.name, r.name, u.process_id) c.name, r.name, u.process_id, @@ -25,7 +25,7 @@ mz_internal.mz_cluster_replica_utilization AS u ON r.id = u.replica_id WHERE c.name IN ( 'foo', 'bar', 'xyzzy' ) - ORDER BY c.name, r.name, process_id + ORDER BY c.name, r.name, process_id, updated_at DESC foo size_1 0 true true foo size_2_2 0 true true foo size_2_2 1 true true