|
11 | 11 |
|
12 | 12 | from materialize.checks.actions import Testdrive
|
13 | 13 | from materialize.checks.checks import Check
|
| 14 | +from materialize.util import MzVersion |
14 | 15 |
|
15 | 16 |
|
16 | 17 | class CreateReplica(Check):
|
@@ -46,7 +47,40 @@ def validate(self) -> Testdrive:
|
46 | 47 | 123
|
47 | 48 | > SELECT * FROM create_replica_view;
|
48 | 49 | 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 "" |
50 | 84 | )
|
51 | 85 | )
|
52 | 86 |
|
|
0 commit comments