Skip to content

Commit 13e7ec6

Browse files
authored
Merge pull request #34211 from def-/pr-orchestratord-upgrade-test
orchestratord tests: Adapt to v26.0 being released
2 parents 8858f4d + 073f6bc commit 13e7ec6

File tree

1 file changed

+59
-9
lines changed

1 file changed

+59
-9
lines changed

test/orchestratord/mzcompose.py

Lines changed: 59 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,42 @@ def get_image(image: str, tag: str | None) -> str:
7373
return f'{image.rsplit(":", 1)[0]}:{get_tag(tag)}'
7474

7575

76+
def get_upgrade_target(
77+
rng: random.Random, current_version: MzVersion, versions: list[MzVersion]
78+
) -> MzVersion:
79+
for version in rng.sample(versions, k=len(versions)):
80+
if version <= current_version:
81+
continue
82+
if (
83+
current_version.major == 0
84+
and current_version.minor == 130
85+
and version.major == 0
86+
and version.minor == 147
87+
):
88+
return version
89+
if (
90+
current_version.major == 0
91+
and current_version.minor == 147
92+
and current_version.patch < 20
93+
and version.major == 0
94+
and version.minor == 147
95+
):
96+
return version
97+
if (
98+
current_version.major == 0
99+
and current_version.minor == 147
100+
and current_version.patch >= 20
101+
and version.major == 26
102+
and version.minor == 0
103+
):
104+
return version
105+
if current_version.major >= 26 and current_version.major + 1 <= version.major:
106+
return version
107+
raise ValueError(
108+
f"No potential upgrade target for {current_version} found in {versions}"
109+
)
110+
111+
76112
def get_pod_data(
77113
labels: dict[str, str], namespace="materialize-environment"
78114
) -> dict[str, Any]:
@@ -1219,7 +1255,7 @@ def workflow_defaults(c: Composition, parser: WorkflowArgumentParser) -> None:
12191255
current_version = get_tag(args.tag)
12201256

12211257
# Following https://materialize.com/docs/installation/install-on-local-kind/
1222-
for version in reversed(get_self_managed_versions() + [current_version]):
1258+
for version in reversed(get_self_managed_versions() + [get_version(args.tag)]):
12231259
dir = "my-local-mz"
12241260
if os.path.exists(dir):
12251261
shutil.rmtree(dir)
@@ -1295,7 +1331,7 @@ def workflow_defaults(c: Composition, parser: WorkflowArgumentParser) -> None:
12951331
"--namespace=materialize",
12961332
"--create-namespace",
12971333
"--version",
1298-
"v25.3.0",
1334+
"v26.0.0",
12991335
"--set",
13001336
"observability.podMetrics.enabled=true",
13011337
"-f",
@@ -1356,10 +1392,14 @@ def workflow_defaults(c: Composition, parser: WorkflowArgumentParser) -> None:
13561392
materialize_setup = list(yaml.load_all(f, Loader=yaml.Loader))
13571393
assert len(materialize_setup) == 3
13581394

1395+
print(version)
1396+
print(current_version)
1397+
print(version == current_version)
13591398
if version == current_version:
13601399
materialize_setup[2]["spec"][
13611400
"environmentdImageRef"
13621401
] = f"materialize/environmentd:{version}"
1402+
if version >= MzVersion.parse_mz("v26.0.0"):
13631403
# Self-managed v25.1/2 don't require a license key yet
13641404
materialize_setup[1]["stringData"]["license_key"] = os.environ[
13651405
"MZ_CI_LICENSE_KEY"
@@ -1627,8 +1667,11 @@ def get_mods() -> Iterator[list[Modification]]:
16271667
).timestamp()
16281668
versions = get_all_self_managed_versions()
16291669
while time.time() < end_time:
1630-
selected_versions = sorted(list(rng.sample(versions, 2)))
1631-
current_version = selected_versions[0]
1670+
current_version = rng.choice(versions[:-1])
1671+
selected_versions = [
1672+
current_version,
1673+
get_upgrade_target(rng, current_version, versions),
1674+
]
16321675
try:
16331676
mod = next(mods_it)
16341677
except StopIteration:
@@ -1649,9 +1692,16 @@ def get_mods() -> Iterator[list[Modification]]:
16491692
).timestamp()
16501693
versions = get_all_self_managed_versions()
16511694
while time.time() < end_time:
1652-
random.randint(2, len(versions))
1653-
selected_versions = sorted(list(rng.sample(versions, 2)))
1654-
current_version = selected_versions[0]
1695+
current_version = rng.choice(versions)
1696+
selected_versions = [current_version]
1697+
next_version = current_version
1698+
try:
1699+
for i in range(len(versions)):
1700+
next_version = get_upgrade_target(rng, next_version, versions)
1701+
selected_versions.append(next_version)
1702+
except ValueError:
1703+
# We can't upgrade any further, just run the test as far as it goes now
1704+
pass
16551705
try:
16561706
mod = next(mods_it)
16571707
except StopIteration:
@@ -1807,7 +1857,7 @@ def init(definition: dict[str, Any]) -> None:
18071857
"--namespace=materialize",
18081858
"--create-namespace",
18091859
"--version",
1810-
"v25.3.0",
1860+
"v26.0.0",
18111861
"-f",
18121862
"-",
18131863
],
@@ -1849,7 +1899,7 @@ def upgrade(definition: dict[str, Any], expect_fail: bool) -> None:
18491899
MZ_ROOT / "misc" / "helm-charts" / "operator",
18501900
"--namespace=materialize",
18511901
"--version",
1852-
"v25.3.0",
1902+
"v26.0.0",
18531903
"-f",
18541904
"-",
18551905
],

0 commit comments

Comments
 (0)