Skip to content

Commit 5753c36

Browse files
philip-stoevteskje
authored andcommitted
platform-checks: Add additional checks around replica_id migration
1 parent d8cf2c7 commit 5753c36

File tree

1 file changed

+35
-1
lines changed

1 file changed

+35
-1
lines changed

misc/python/materialize/checks/replica.py

+35-1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
from materialize.checks.actions import Testdrive
1313
from materialize.checks.checks import Check
14+
from materialize.util import MzVersion
1415

1516

1617
class CreateReplica(Check):
@@ -46,7 +47,40 @@ def validate(self) -> Testdrive:
4647
123
4748
> SELECT * FROM create_replica_view;
4849
123
49-
"""
50+
51+
# Confirm that all replica_ids have been migrated to the uXXX/sXXX format
52+
> SELECT COUNT(*)
53+
FROM mz_cluster_replicas
54+
WHERE id NOT LIKE 's%'
55+
AND id NOT LIKE 'u%';
56+
0
57+
58+
# Confirm that there are CREATE events for all replicas with new-format IDs
59+
# resultset should not contain any NULLs.
60+
# System and unmanaged replicas have no audit log entries, so we need to exclude
61+
# those.
62+
> SELECT DISTINCT event_type
63+
FROM mz_cluster_replicas
64+
LEFT JOIN mz_audit_events ON (
65+
mz_cluster_replicas.id = mz_audit_events.details->>'replica_id'
66+
AND mz_audit_events.event_type = 'create'
67+
)
68+
WHERE
69+
mz_cluster_replicas.id LIKE 'u%'
70+
AND mz_cluster_replicas.size IS NOT NULL;
71+
create
72+
"""
73+
+ """
74+
# Confirm that there are DROP events for replicas with old-format IDs
75+
> SELECT COUNT(*) >= 2 FROM mz_audit_events
76+
WHERE object_type = 'cluster-replica'
77+
AND event_type = 'drop'
78+
AND details->>'replica_id' NOT LIKE 's%'
79+
AND details->>'replica_id' NOT LIKE 'u%';
80+
true
81+
"""
82+
if self.base_version < MzVersion.parse("0.66.0-dev")
83+
else ""
5084
)
5185
)
5286

0 commit comments

Comments
 (0)