Skip to content

Commit

Permalink
lxd(remotes): add support for interim Ubuntu releases
Browse files Browse the repository at this point in the history
Signed-off-by: Callahan Kovacs <[email protected]>
  • Loading branch information
mr-cal committed Feb 22, 2023
1 parent 9159e0d commit 827dfff
Show file tree
Hide file tree
Showing 7 changed files with 41 additions and 2 deletions.
4 changes: 3 additions & 1 deletion craft_providers/bases/buildd.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# Copyright 2021-2022 Canonical Ltd.
# Copyright 2021-2023 Canonical Ltd.
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
Expand Down Expand Up @@ -144,6 +144,8 @@ class BuilddBaseAlias(enum.Enum):
BIONIC = "18.04"
FOCAL = "20.04"
JAMMY = "22.04"
KINETIC = "22.10"
LUNAR = "23.04"


class Snap(pydantic.BaseModel, extra=pydantic.Extra.forbid):
Expand Down
22 changes: 22 additions & 0 deletions craft_providers/lxd/remotes.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,14 @@
BUILDD_RELEASES_REMOTE_NAME = "craft-com.ubuntu.cloud-buildd"
BUILDD_RELEASES_REMOTE_ADDRESS = "https://cloud-images.ubuntu.com/buildd/releases"

# XXX: lunar and kinetic buildd daily images are not working (LP #2007419)
BUILDD_DAILY_REMOTE_NAME = "craft-com.ubuntu.cloud-buildd-daily"
BUILDD_DAILY_REMOTE_ADDRESS = "https://cloud-images.ubuntu.com/buildd/daily"

# temporarily use the cloud release images until daily buildd images are fixed
DAILY_REMOTE_NAME = "ubuntu-daily"
DAILY_REMOTE_ADDRESS = "https://cloud-images.ubuntu.com/daily"


class ProtocolType(Enum):
"""Enumeration of protocols for LXD remotes."""
Expand Down Expand Up @@ -116,6 +124,20 @@ def add_remote(self, lxc: LXC = LXC()) -> None:
remote_protocol=ProtocolType.SIMPLESTREAMS,
is_stable=True,
),
BuilddBaseAlias.KINETIC.value: RemoteImage(
image_name="kinetic",
remote_name=DAILY_REMOTE_NAME,
remote_address=DAILY_REMOTE_ADDRESS,
remote_protocol=ProtocolType.SIMPLESTREAMS,
is_stable=False,
),
BuilddBaseAlias.LUNAR.value: RemoteImage(
image_name="lunar",
remote_name=DAILY_REMOTE_NAME,
remote_address=DAILY_REMOTE_ADDRESS,
remote_protocol=ProtocolType.SIMPLESTREAMS,
is_stable=False,
),
}


Expand Down
3 changes: 2 additions & 1 deletion craft_providers/multipass/multipass_provider.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# -*- Mode:Python; indent-tabs-mode:nil; tab-width:4 -*-
#
# Copyright 2022 Canonical Ltd.
# Copyright 2022-2023 Canonical Ltd.
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
Expand Down Expand Up @@ -33,6 +33,7 @@
logger = logging.getLogger(__name__)


# TODO: support KINETIC and LUNAR
PROVIDER_BASE_TO_MULTIPASS_BASE = {
bases.BuilddBaseAlias.BIONIC.value: "snapcraft:18.04",
bases.BuilddBaseAlias.FOCAL.value: "snapcraft:20.04",
Expand Down
2 changes: 2 additions & 0 deletions tests/integration/lxd/test_lxd_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ def test_create_environment(installed_lxd, instance_name):
BuilddBaseAlias.BIONIC,
BuilddBaseAlias.FOCAL,
BuilddBaseAlias.JAMMY,
BuilddBaseAlias.KINETIC,
BuilddBaseAlias.LUNAR,
],
)
def test_launched_environment(alias, installed_lxd, instance_name, tmp_path):
Expand Down
2 changes: 2 additions & 0 deletions tests/integration/lxd/test_remotes.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
bases.BuilddBaseAlias.BIONIC,
bases.BuilddBaseAlias.FOCAL,
bases.BuilddBaseAlias.JAMMY,
bases.BuilddBaseAlias.KINETIC,
bases.BuilddBaseAlias.LUNAR,
],
)
def test_configure_and_launch_remote(instance_name, alias):
Expand Down
8 changes: 8 additions & 0 deletions tests/unit/bases/test_buildd.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ def mock_inject_from_host(mocker):
(buildd.BuilddBaseAlias.BIONIC, "test-bionic-host"),
(buildd.BuilddBaseAlias.FOCAL, "test-focal-host"),
(buildd.BuilddBaseAlias.JAMMY, "test-jammy-host"),
(buildd.BuilddBaseAlias.KINETIC, "test-kinetic-host"),
(buildd.BuilddBaseAlias.LUNAR, "test-lunar-host"),
],
)
@pytest.mark.parametrize(
Expand Down Expand Up @@ -846,6 +848,8 @@ def test_setup_snapd_failures(fake_process, fake_executor, fail_index):
buildd.BuilddBaseAlias.BIONIC,
buildd.BuilddBaseAlias.FOCAL,
buildd.BuilddBaseAlias.JAMMY,
buildd.BuilddBaseAlias.KINETIC,
buildd.BuilddBaseAlias.LUNAR,
],
)
@pytest.mark.parametrize("system_running_ready_stdout", ["degraded", "running"])
Expand Down Expand Up @@ -918,6 +922,8 @@ def test_wait_for_system_ready(
buildd.BuilddBaseAlias.BIONIC,
buildd.BuilddBaseAlias.FOCAL,
buildd.BuilddBaseAlias.JAMMY,
buildd.BuilddBaseAlias.KINETIC,
buildd.BuilddBaseAlias.LUNAR,
],
)
def test_wait_for_system_ready_timeout(fake_executor, fake_process, alias):
Expand Down Expand Up @@ -950,6 +956,8 @@ def test_wait_for_system_ready_timeout(fake_executor, fake_process, alias):
buildd.BuilddBaseAlias.BIONIC,
buildd.BuilddBaseAlias.FOCAL,
buildd.BuilddBaseAlias.JAMMY,
buildd.BuilddBaseAlias.KINETIC,
buildd.BuilddBaseAlias.LUNAR,
],
)
def test_wait_for_system_ready_timeout_in_network(
Expand Down
2 changes: 2 additions & 0 deletions tests/unit/lxd/test_remotes.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,8 @@ def test_add_remote_race_condition_error(fake_remote_image, mock_lxc, logs):
(BuilddBaseAlias.BIONIC.value, "core18"),
(BuilddBaseAlias.FOCAL.value, "core20"),
(BuilddBaseAlias.JAMMY.value, "core22"),
(BuilddBaseAlias.KINETIC.value, "kinetic"),
(BuilddBaseAlias.LUNAR.value, "lunar"),
],
)
def test_get_image_remote(provider_base, image_name):
Expand Down

0 comments on commit 827dfff

Please sign in to comment.