Skip to content

Commit

Permalink
Test cdk-addons is in the correct track (#1524)
Browse files Browse the repository at this point in the history
  • Loading branch information
addyess committed Jul 3, 2024
1 parent 34c0234 commit bb5691e
Showing 1 changed file with 17 additions and 17 deletions.
34 changes: 17 additions & 17 deletions jobs/integration/validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
from asyncio_extras import async_contextmanager
from async_generator import yield_
from base64 import b64encode
from cilib.enums import K8S_STABLE_VERSION

from datetime import datetime
from pathlib import Path
Expand Down Expand Up @@ -271,13 +272,6 @@ async def test_snap_versions(model, tools):
"kubernetes-worker": ["kubectl", "kubelet", "kube-proxy"],
}

# cdk-addons snap track follows the charm track starting in 1.29 charms
addons_track = tools.charm_channel.split("/")[0]
if addons_track in ["stable", "candidate", "beta", "edge"]:
addons_track = "latest"
if addons_track != "latest" and tuple(map(int, addons_track.split("."))) < (1, 29):
addons_track = None

for app_name, snaps in snaps_to_validate.items():
app = model.applications[app_name]
config = await app.get_config()
Expand All @@ -287,15 +281,7 @@ async def test_snap_versions(model, tools):
message = message % (app_name, channel)
click.echo(message)
continue
track, risk = channel.split("/", 1)
if app_name.endswith("control-plane") and addons_track == "latest":
stdout, *_ = await tools.run("snap", "info", "cdk-addons")
info = {
i["name"]: i["channels"][f"latest/{risk}"].split(".", 2)[:2]
for i in yaml.safe_load_all(stdout)
}
expected, *_ = info.values()
addons_track = ".".join(expected)
track, _ = channel.split("/", 1)
if track == "latest":
# Use snap info to determine the versions of the latest/{risk}
stdout, *_ = await tools.run("snap", "info", *snaps)
Expand All @@ -319,7 +305,21 @@ async def test_snap_versions(model, tools):
snap_versions = dict(line.split()[:2] for line in lines)
for snap in snaps:
snap_version = snap_versions[snap]
if snap == "cdk-addons" and addons_track:
if snap == "cdk-addons":
# cdk-addons is a special case, it may have a charm_branch file which defines the snap track
charm_branch = await juju_run(
unit, "tail -n1 templates/charm_branch", check=False
)
if not charm_branch.success:
# follows the same track as the other snaps
addons_track = track
elif (branch := charm_branch.stdout.strip()).startswith("release_"):
# follows the track defined in the charm_branch file
addons_track = branch.replace("release_", "")
else:
# cdk-addons follows the stable track in other cases.
addons_track = K8S_STABLE_VERSION

msg = f"Snap {snap} is version {snap_version} and not {addons_track}.*"
assert snap_version.startswith(addons_track + "."), msg
else:
Expand Down

0 comments on commit bb5691e

Please sign in to comment.