3030import yaml
3131from semver .version import Version
3232
33- from materialize import MZ_ROOT , ci_util , git , spawn , ui
34- from materialize .docker import MZ_GHCR_DEFAULT
33+ from materialize import MZ_ROOT , ci_util , git , spawn
3534from materialize .mz_version import MzVersion
3635from materialize .mzcompose .composition import (
3736 Composition ,
4140from materialize .mzcompose .services .balancerd import Balancerd
4241from materialize .mzcompose .services .clusterd import Clusterd
4342from materialize .mzcompose .services .environmentd import Environmentd
43+ from materialize .mzcompose .services .mz_debug import MzDebug
4444from materialize .mzcompose .services .orchestratord import Orchestratord
4545from materialize .mzcompose .services .testdrive import Testdrive
4646from materialize .util import all_subclasses
5555 Environmentd (),
5656 Clusterd (),
5757 Balancerd (),
58+ MzDebug (),
5859]
5960
6061
62+ def run_mz_debug () -> None :
63+ # Only using capture because it's too noisy
64+ spawn .capture (
65+ [
66+ "./mz-debug" ,
67+ "self-managed" ,
68+ "--k8s-namespace" ,
69+ "materialize-environment" ,
70+ "--mz-instance-name" ,
71+ "12345678-1234-1234-1234-123456789012" ,
72+ ]
73+ )
74+
75+
6176def get_tag (tag : str | None = None ) -> str :
6277 # We can't use the mzbuild tag because it has a different fingerprint for
6378 # environmentd/clusterd/balancerd and the orchestratord depends on them
@@ -498,14 +513,9 @@ def validate(self, mods: dict[type[Modification], Any]) -> None:
498513 def check () -> None :
499514 environmentd = get_environmentd_data ()
500515 image = environmentd ["items" ][0 ]["spec" ]["containers" ][0 ]["image" ]
501- image_registry = (
502- "ghcr.io/materializeinc/materialize"
503- if ui .env_is_truthy ("MZ_GHCR" , MZ_GHCR_DEFAULT )
504- else "materialize"
505- )
506- expected = f"{ image_registry } /environmentd:{ self .value } "
516+ expected = f"materialize/environmentd:{ self .value } "
507517 assert (
508- image == expected
518+ image == expected or f"ghcr.io/materializeinc/ { image } " == expected
509519 ), f"Expected environmentd image { expected } , but found { image } "
510520
511521 retry (check , 240 )
@@ -1070,11 +1080,11 @@ def check_pods() -> None:
10701080class AuthenticatorKind (Modification ):
10711081 @classmethod
10721082 def values (cls , version : MzVersion ) -> list [Any ]:
1073- # Test None, Password (v0.147.7+), and Sasl (v0.147.16+)
1083+ # Test None, Password (v0.147.7+), and Sasl
10741084 result = ["None" ]
10751085 if version >= MzVersion .parse_mz ("v0.147.7" ):
10761086 result .append ("Password" )
1077- if version >= MzVersion .parse_mz ("v0.147.16 " ):
1087+ if version >= MzVersion .parse_mz ("v26.0.0 " ):
10781088 result .append ("Sasl" )
10791089 return result
10801090
@@ -1100,13 +1110,13 @@ def validate(self, mods: dict[type[Modification], Any]) -> None:
11001110 if self .value == "Password" and version <= MzVersion .parse_mz ("v0.147.6" ):
11011111 return
11021112
1103- if self .value == "Sasl" and version < MzVersion .parse_mz ("v0.147.16 " ):
1113+ if self .value == "Sasl" and version < MzVersion .parse_mz ("v26.0.0 " ):
11041114 return
11051115
11061116 port = (
11071117 6875
11081118 if (version >= MzVersion .parse_mz ("v0.147.0" ) and self .value == "Password" )
1109- or (version >= MzVersion .parse_mz ("v0.147.16 " ) and self .value == "Sasl" )
1119+ or (version >= MzVersion .parse_mz ("v26.0.0 " ) and self .value == "Sasl" )
11101120 else 6877
11111121 )
11121122 for i in range (120 ):
@@ -1252,10 +1262,23 @@ def workflow_defaults(c: Composition, parser: WorkflowArgumentParser) -> None:
12521262 )
12531263 args = parser .parse_args ()
12541264
1255- current_version = get_tag (args .tag )
1265+ c .up (Service ("mz-debug" , idle = True ))
1266+ c .invoke ("cp" , "mz-debug:/usr/local/bin/mz-debug" , "." )
1267+
1268+ current_version = get_version (args .tag )
12561269
12571270 # Following https://materialize.com/docs/installation/install-on-local-kind/
1258- for version in reversed (get_self_managed_versions () + [get_version (args .tag )]):
1271+ # orchestratord test can't run against future versions, so ignore those
1272+ versions = reversed (
1273+ [
1274+ version
1275+ for version in get_self_managed_versions ()
1276+ if version < current_version
1277+ ]
1278+ + [current_version ]
1279+ )
1280+ for version in versions :
1281+ print (f"--- Running with defaults against { version } " )
12591282 dir = "my-local-mz"
12601283 if os .path .exists (dir ):
12611284 shutil .rmtree (dir )
@@ -1392,9 +1415,6 @@ def workflow_defaults(c: Composition, parser: WorkflowArgumentParser) -> None:
13921415 materialize_setup = list (yaml .load_all (f , Loader = yaml .Loader ))
13931416 assert len (materialize_setup ) == 3
13941417
1395- print (version )
1396- print (current_version )
1397- print (version == current_version )
13981418 if version == current_version :
13991419 materialize_setup [2 ]["spec" ][
14001420 "environmentdImageRef"
@@ -1493,6 +1513,7 @@ def workflow_defaults(c: Composition, parser: WorkflowArgumentParser) -> None:
14931513 ]
14941514 )
14951515 raise ValueError ("Never completed" )
1516+ run_mz_debug ()
14961517
14971518
14981519def workflow_default (c : Composition , parser : WorkflowArgumentParser ) -> None :
@@ -1534,7 +1555,8 @@ def workflow_default(c: Composition, parser: WorkflowArgumentParser) -> None:
15341555 "0.29.0"
15351556 ), f"kind >= v0.29.0 required, while you are on { kind_version } "
15361557
1537- c .up (Service ("testdrive" , idle = True ))
1558+ c .up (Service ("testdrive" , idle = True ), Service ("mz-debug" , idle = True ))
1559+ c .invoke ("cp" , "mz-debug:/usr/local/bin/mz-debug" , "." )
15381560
15391561 cluster = "kind"
15401562 clusters = spawn .capture (["kind" , "get" , "clusters" ]).strip ().split ("\n " )
@@ -1658,9 +1680,6 @@ def get_mods() -> Iterator[list[Modification]]:
16581680 mods .append (EnvironmentdImageRef (str (args .tag )))
16591681 run_scenario ([mods ], definition )
16601682 elif action == Action .Upgrade :
1661- assert not ui .env_is_truthy (
1662- "MZ_GHCR" , MZ_GHCR_DEFAULT
1663- ), "Manually set MZ_GHCR=0 as an environment variable for upgrade testing"
16641683 assert args .runtime
16651684 end_time = (
16661685 datetime .datetime .now () + datetime .timedelta (seconds = args .runtime )
@@ -1683,9 +1702,6 @@ def get_mods() -> Iterator[list[Modification]]:
16831702 ]
16841703 run_scenario (scenario , definition )
16851704 elif action == Action .UpgradeChain :
1686- assert not ui .env_is_truthy (
1687- "MZ_GHCR" , MZ_GHCR_DEFAULT
1688- ), "Manually set MZ_GHCR=0 as an environment variable for upgrade testing"
16891705 assert args .runtime
16901706 end_time = (
16911707 datetime .datetime .now () + datetime .timedelta (seconds = args .runtime )
@@ -1806,18 +1822,14 @@ def run_scenario(
18061822 mod .modify (definition )
18071823 if mod .value in mod .failed_reconciliation_values ():
18081824 expect_fail = True
1809- if not initialize :
1810- definition ["materialize" ]["spec" ][
1811- "rolloutStrategy"
1812- ] = "ImmediatelyPromoteCausingDowntime"
1813- definition ["materialize" ]["spec" ]["requestRollout" ] = str (uuid .uuid4 ())
1814- run (definition , expect_fail )
18151825 if initialize :
18161826 init (definition )
18171827 run (definition , expect_fail )
18181828 initialize = False # only initialize once
18191829 else :
18201830 upgrade (definition , expect_fail )
1831+ definition ["materialize" ]["spec" ]["requestRollout" ] = str (uuid .uuid4 ())
1832+ run (definition , expect_fail )
18211833 mod_dict = {mod .__class__ : mod .value for mod in mods }
18221834 for subclass in all_subclasses (Modification ):
18231835 if subclass not in mod_dict :
@@ -1831,6 +1843,9 @@ def run_scenario(
18311843 f"Reproduce with bin/mzcompose --find orchestratord run default --recreate-cluster --scenario='{ scenario_json } '"
18321844 )
18331845 raise
1846+ finally :
1847+ if not expect_fail :
1848+ run_mz_debug ()
18341849
18351850
18361851def init (definition : dict [str , Any ]) -> None :
@@ -2006,4 +2021,4 @@ def post_run_check(definition: dict[str, Any], expect_fail: bool) -> None:
20062021 )
20072022 raise ValueError ("Never completed" )
20082023 # Wait a bit for the status to stabilize
2009- time .sleep (60 )
2024+ time .sleep (180 )
0 commit comments