Skip to content

Commit

Permalink
test: add tests for mz_wallclock_lag_history
Browse files Browse the repository at this point in the history
  • Loading branch information
teskje committed Sep 10, 2024
1 parent 4262a02 commit 8cefc0b
Showing 1 changed file with 151 additions and 0 deletions.
151 changes: 151 additions & 0 deletions test/testdrive/wallclock-lag.td
Original file line number Diff line number Diff line change
@@ -0,0 +1,151 @@
# Copyright Materialize, Inc. and contributors. All rights reserved.
#
# Use of this software is governed by the Business Source License
# included in the LICENSE file at the root of this repository.
#
# As of the Change Date specified in that file, in accordance with
# the Business Source License, use of this software will be governed
# by the Apache License, Version 2.0.

# Test the contents of `mz_wallclock_lag_history`.
#
# These tests rely on testdrive's retry feature, as `mz_wallclock_lag_history`
# is only refreshed once per minute, so data is likely not immediately
# available.

> CREATE CLUSTER storage SIZE '1'
> CREATE CLUSTER compute SIZE '1', REPLICATION FACTOR 2

# Set up a bunch of frontiered objects and test that their wallclock lags get
# reported.

> CREATE SOURCE src IN CLUSTER storage FROM LOAD GENERATOR counter

> CREATE TABLE tbl (a int)

> CREATE VIEW src_plus_tbl AS SELECT counter + a AS a FROM src, tbl
> CREATE INDEX idx IN CLUSTER compute ON src_plus_tbl (a)
> CREATE MATERIALIZED VIEW mv IN CLUSTER compute AS SELECT * FROM src_plus_tbl

> CREATE MATERIALIZED VIEW mv_const IN CLUSTER compute AS SELECT 1
> CREATE DEFAULT INDEX idx_const IN CLUSTER compute ON mv_const

> CREATE CONNECTION kafka_conn
TO KAFKA (BROKER '${testdrive.kafka-addr}', SECURITY PROTOCOL PLAINTEXT)
> CREATE CONNECTION csr_conn
TO CONFLUENT SCHEMA REGISTRY (URL '${testdrive.schema-registry-url}')
> CREATE SINK snk
IN CLUSTER storage
FROM mv
INTO KAFKA CONNECTION kafka_conn (TOPIC 'testdrive-sink1-${testdrive.seed}')
FORMAT AVRO USING CONFLUENT SCHEMA REGISTRY CONNECTION csr_conn
ENVELOPE DEBEZIUM

> SELECT DISTINCT o.name, r.name
FROM mz_internal.mz_wallclock_lag_history l
JOIN mz_objects o ON o.id = l.object_id
LEFT JOIN mz_cluster_replicas r ON r.id = l.replica_id
WHERE l.object_id LIKE 'u%'
idx r1
idx r2
idx_const r1
idx_const r2
mv r1
mv r2
mv <null>
mv_const r1
mv_const r2
mv_const <null>
snk <null>
src <null>
src_progress <null>
tbl <null>

> SELECT DISTINCT o.name
FROM mz_internal.mz_wallclock_global_lag_history l
JOIN mz_objects o ON o.id = l.object_id
WHERE l.object_id LIKE 'u%'
idx
idx_const
mv
mv_const
snk
src
src_progress
tbl

> SELECT DISTINCT o.name
FROM mz_internal.mz_wallclock_global_lag_recent_history l
JOIN mz_objects o ON o.id = l.object_id
WHERE l.object_id LIKE 'u%'
idx
idx_const
mv
mv_const
snk
src
src_progress
tbl

# Verify that all lags are reasonable. This will likely require waiting another
# minute for the next refresh, since the first one includes lags from when the
# objects where not yet hydrated.

> SELECT DISTINCT ON(o.name, r.name)
o.name,
r.name,
l.lag_ms > 0,
l.lag_ms < 5000
FROM mz_internal.mz_wallclock_lag_history l
JOIN mz_objects o ON o.id = l.object_id
LEFT JOIN mz_cluster_replicas r ON r.id = l.replica_id
WHERE l.object_id LIKE 'u%'
ORDER BY o.name, r.name, l.occurred_at DESC
idx r1 true true
idx r2 true true
idx_const r1 false true
idx_const r2 false true
mv r1 true true
mv r2 true true
mv <null> true true
mv_const r1 false true
mv_const r2 false true
mv_const <null> false true
snk <null> true true
src <null> true true
src_progress <null> true true
tbl <null> true true

> SELECT DISTINCT ON(o.name)
o.name,
l.lag_ms > 0,
l.lag_ms < 5000
FROM mz_internal.mz_wallclock_global_lag_history l
JOIN mz_objects o ON o.id = l.object_id
WHERE l.object_id LIKE 'u%'
ORDER BY o.name, l.occurred_at DESC
idx true true
idx_const false true
mv true true
mv_const false true
snk true true
src true true
src_progress true true
tbl true true

> SELECT DISTINCT ON(o.name)
o.name,
l.lag_ms > 0,
l.lag_ms < 5000
FROM mz_internal.mz_wallclock_global_lag_recent_history l
JOIN mz_objects o ON o.id = l.object_id
WHERE l.object_id LIKE 'u%'
ORDER BY o.name, l.occurred_at DESC
idx true true
idx_const false true
mv true true
mv_const false true
snk true true
src true true
src_progress true true
tbl true true

0 comments on commit 8cefc0b

Please sign in to comment.