Skip to content

Commit

Permalink
test: adapt to changed mz_cluster_replica_metrics
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
teskje committed Aug 27, 2024
1 parent 7e236ec commit 351982c
Show file tree
Hide file tree
Showing 9 changed files with 25 additions and 18 deletions.
4 changes: 2 additions & 2 deletions src/environmentd/tests/sql.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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;
Expand Down
13 changes: 11 additions & 2 deletions test/cloudtest/test_metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
"""
Expand Down
11 changes: 3 additions & 8 deletions test/cluster/statement-logging/statement-logging.td
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -145,7 +146,6 @@ quickstart quickstart my_app 1 {} success <null> <null> <null> true "PREPARE p A
quickstart quickstart my_app 1 {} success <null> <null> <null> true "SET cluster TO c" "strict serializable" <null> materialize {public}
mz_catalog_server mz_catalog_server my_app 1 {} success <null> 1 constant true "SELECT 'beginning real test!'" "strict serializable" <null> materialize {public}
mz_catalog_server mz_catalog_server my_app 1 {} success <null> 1 constant true "SELECT 'serializable'" serializable <null> materialize {public}
mz_catalog_server mz_catalog_server my_app 1 {} success <null> 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)
Expand Down Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions test/sqllogictest/autogenerated/mz_internal.slt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion test/sqllogictest/information_schema_tables.slt
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ VIEW
materialize
mz_internal
mz_cluster_replica_metrics
BASE TABLE
SOURCE
materialize
mz_internal
mz_cluster_replica_statuses
Expand Down
1 change: 1 addition & 0 deletions test/sqllogictest/mz_catalog_server_index_accounting.slt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion test/sqllogictest/system-cluster.slt
Original file line number Diff line number Diff line change
Expand Up @@ -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]]
Expand Down
4 changes: 2 additions & 2 deletions test/testdrive/catalog.td
Original file line number Diff line number Diff line change
Expand Up @@ -565,6 +565,7 @@ name type cluster comment
-----------------------------------------------------------------------
mz_aws_privatelink_connection_status_history source <null> ""
mz_cluster_replica_frontiers source <null> ""
mz_cluster_replica_metrics source <null> ""
mz_compute_dependencies source <null> ""
mz_compute_error_counts_raw_unified source <null> ""
mz_compute_hydration_times source <null> ""
Expand All @@ -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 ""
Expand Down Expand Up @@ -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%'
Expand Down
4 changes: 2 additions & 2 deletions test/testdrive/metrics-cluster.td
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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 <null>
foo size_2_2 0 true true <null>
foo size_2_2 1 true true <null>
Expand Down

0 comments on commit 351982c

Please sign in to comment.