Skip to content

Commit cacafe9

Browse files
committed
upgrade tests: Fix upgrade tests on old versions
Seen failing in https://buildkite.com/materialize/nightly/builds/12016
1 parent 80e8aed commit cacafe9

File tree

4 files changed

+31
-11
lines changed

4 files changed

+31
-11
lines changed

misc/python/materialize/checks/scenarios_upgrade.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,7 @@ def get_minor_versions() -> list[MzVersion]:
3737
current_version = MzVersion.parse_cargo()
3838
_minor_versions = [
3939
v
40-
for v in get_published_minor_mz_versions(
41-
limit=4, exclude_current_minor_version=True
42-
)
40+
for v in get_published_minor_mz_versions(exclude_current_minor_version=True)
4341
if v < current_version
4442
]
4543
return _minor_versions

misc/python/materialize/git.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,14 +124,21 @@ def get_version_tags(
124124

125125

126126
def get_latest_version(
127-
version_type: type[VERSION_TYPE], excluded_versions: set[VERSION_TYPE] | None = None
127+
version_type: type[VERSION_TYPE],
128+
excluded_versions: set[VERSION_TYPE] | None = None,
129+
current_version: VERSION_TYPE | None = None,
128130
) -> VERSION_TYPE:
129131
all_version_tags: list[VERSION_TYPE] = get_version_tags(
130132
version_type=version_type, fetch=True
131133
)
132134

133135
if excluded_versions is not None:
134-
all_version_tags = [v for v in all_version_tags if v not in excluded_versions]
136+
all_version_tags = [
137+
v
138+
for v in all_version_tags
139+
if v not in excluded_versions
140+
and (not current_version or v < current_version)
141+
]
135142

136143
return max(all_version_tags)
137144

misc/python/materialize/version_list.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -245,12 +245,15 @@ def resolve_image_tag(self) -> tuple[str, str]:
245245

246246

247247
def get_latest_published_version() -> MzVersion:
248-
"""Get the latest mz version for which an image is published."""
248+
"""Get the latest mz version, older than current state, for which an image is published."""
249249
excluded_versions = set()
250+
current_version = MzVersion.parse_cargo()
250251

251252
while True:
252253
latest_published_version = git.get_latest_version(
253-
version_type=MzVersion, excluded_versions=excluded_versions
254+
version_type=MzVersion,
255+
excluded_versions=excluded_versions,
256+
current_version=current_version,
254257
)
255258

256259
if is_valid_release_image(latest_published_version):

test/legacy-upgrade/mzcompose.py

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -142,13 +142,20 @@ def workflow_default(c: Composition, parser: WorkflowArgumentParser) -> None:
142142
def get_all_and_latest_two_minor_mz_versions(
143143
use_versions_from_docs: bool,
144144
) -> tuple[list[MzVersion], list[MzVersion]]:
145+
current_version = MzVersion.parse_cargo()
145146
if use_versions_from_docs:
146147
version_list = VersionsFromDocs(respect_released_tag=False)
147-
all_versions = version_list.all_versions()
148+
all_versions = [v for v in version_list.all_versions() if v < current_version]
148149
tested_versions = version_list.minor_versions()[-2:]
149150
else:
150-
tested_versions = get_published_minor_mz_versions(limit=2)
151-
all_versions = get_all_published_mz_versions(newest_first=False)
151+
tested_versions = [
152+
v for v in get_published_minor_mz_versions() if v < current_version
153+
]
154+
all_versions = [
155+
v
156+
for v in get_all_published_mz_versions(newest_first=False)
157+
if v < current_version
158+
]
152159
return all_versions, tested_versions
153160

154161

@@ -249,8 +256,13 @@ def test_upgrade_from_version(
249256
c.rm(mz_service, "testdrive")
250257

251258
if from_version != "current_source" and not lts_upgrade:
259+
current_version = MzVersion.parse_cargo()
252260
# We can't skip in-between minor versions anymore, so go through all of them
253-
for version in get_published_minor_mz_versions(newest_first=False):
261+
for version in [
262+
v
263+
for v in get_published_minor_mz_versions(newest_first=False)
264+
if v < current_version
265+
]:
254266
if version <= from_version:
255267
continue
256268
if version >= MzVersion.parse_cargo():

0 commit comments

Comments
 (0)