Skip to content

Commit bfaa00b

Browse files
authored
Merge pull request #22155 from philip-stoev/mzcompose_skip_sanity
mzcompose: Allow tests to opt out of the mz_sanity_restart check
2 parents 45ca8f6 + a72419b commit bfaa00b

File tree

4 files changed

+17
-4
lines changed

4 files changed

+17
-4
lines changed

misc/python/materialize/mzcompose/composition.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -701,13 +701,13 @@ def validate_sources_sinks_clusters(self) -> str | None:
701701
def sanity_restart_mz(self) -> None:
702702
"""Restart Materialized if it is part of the composition to find
703703
problems with persisted objects, functions as a sanity check."""
704-
# Exclude environmentd image, which is used in cloud-canary, and doesn't start up fully without clusterd images
705704
if (
706705
"materialized" in self.compose["services"]
707-
and "materialize/environmentd"
708-
not in self.compose["services"]["materialized"]["image"]
706+
and "sanity_restart" in self.compose["services"]["materialized"]["labels"]
709707
):
710-
ui.header("Sanity Check: Restart Mz, verify source/sink/replica health")
708+
ui.header(
709+
"Sanity Restart: Restart Mz and verify source/sink/replica health"
710+
)
711711
self.kill("materialized")
712712
# TODO(def-): Better way to detect when kill has finished
713713
time.sleep(3)
@@ -724,6 +724,10 @@ def sanity_restart_mz(self) -> None:
724724
# Sources and cluster replicas need a few seconds to start up
725725
print(f"Retrying ({i+1}/{NUM_RETRIES})...")
726726
time.sleep(1)
727+
else:
728+
ui.header(
729+
"Sanity Restart skipped because Mz not in services or `sanity_restart` label not set"
730+
)
727731

728732
def down(
729733
self,

misc/python/materialize/mzcompose/service.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,9 @@ class ServiceConfig(TypedDict, total=False):
159159
restart: str
160160
"""Restart policy."""
161161

162+
labels: list[str]
163+
"""Container labels."""
164+
162165

163166
class Service:
164167
"""A Docker Compose service in a `Composition`.

misc/python/materialize/mzcompose/services/materialized.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ def __init__(
4848
system_parameter_defaults: dict[str, str] | None = None,
4949
additional_system_parameter_defaults: dict[str, str] | None = None,
5050
soft_assertions: bool = True,
51+
sanity_restart: bool = True,
5152
) -> None:
5253
depends_graph: dict[str, ServiceDependency] = {
5354
s: {"condition": "service_started"} for s in depends_on
@@ -164,6 +165,9 @@ def __init__(
164165
if memory:
165166
config["deploy"] = {"resources": {"limits": {"memory": memory}}}
166167

168+
if sanity_restart:
169+
config.setdefault("labels", []).append("sanity_restart")
170+
167171
volumes = []
168172
if use_default_volumes:
169173
volumes += DEFAULT_MZ_VOLUMES

test/cloud-canary/mzcompose.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,8 @@
5454
"--orchestrator-process-secrets-directory=/mzdata/secrets",
5555
"--orchestrator-process-scratch-directory=/scratch",
5656
],
57+
# We can not restart this container at will, as it does not have clusterd
58+
sanity_restart=False,
5759
),
5860
Testdrive(), # Overriden below
5961
Mz(

0 commit comments

Comments
 (0)