From 4baa315e05698f54e716f19d569913a5546db287 Mon Sep 17 00:00:00 2001 From: Claudiu Belu Date: Fri, 19 Jul 2024 09:48:48 +0000 Subject: [PATCH] Adds 1.27.2 rock Adds a rock for the mentioned version. Updated the rockcraft.yaml file paths. Updated sanity tests to include both rock versions. --- rockcraft.yaml => 1.24.0/rockcraft.yaml | 0 1.27.2/rockcraft.yaml | 37 +++++++++++++++++++++++++ tests/requirements-test.txt | 1 + tests/sanity/test_rock.py | 21 ++++++++++---- 4 files changed, 54 insertions(+), 5 deletions(-) rename rockcraft.yaml => 1.24.0/rockcraft.yaml (100%) create mode 100644 1.27.2/rockcraft.yaml diff --git a/rockcraft.yaml b/1.24.0/rockcraft.yaml similarity index 100% rename from rockcraft.yaml rename to 1.24.0/rockcraft.yaml diff --git a/1.27.2/rockcraft.yaml b/1.27.2/rockcraft.yaml new file mode 100644 index 0000000..26b2643 --- /dev/null +++ b/1.27.2/rockcraft.yaml @@ -0,0 +1,37 @@ +name: cluster-autoscaler +summary: ROCK for the cluster-autoscaler Project. +description: This ROCK is a drop-in replacement for the autoscaling/cluster-autoscaler image. +version: "1.27.2" +license: Apache-2.0 + +base: bare +build-base: ubuntu@22.04 +platforms: + amd64: + arm64: + +entrypoint-service: cluster-autoscaler +services: + cluster-autoscaler: + override: replace + summary: "cluster-autoscaler service" + startup: enabled + command: "/cluster-autoscaler [ --help ]" + on-failure: shutdown + +parts: + cluster-autoscaler: + plugin: nil + source: https://github.com/kubernetes/autoscaler.git + source-type: git + source-tag: cluster-autoscaler-${CRAFT_PROJECT_VERSION} + source-depth: 1 + build-snaps: + - go/1.20/stable + override-build: | + cd cluster-autoscaler + make build-arch-${CRAFT_PLATFORM} + cp cluster-autoscaler-${CRAFT_PLATFORM} ${CRAFT_PART_INSTALL}/cluster-autoscaler + prime: + - cluster-autoscaler + diff --git a/tests/requirements-test.txt b/tests/requirements-test.txt index e267307..ff57d6b 100644 --- a/tests/requirements-test.txt +++ b/tests/requirements-test.txt @@ -2,3 +2,4 @@ coverage[toml]==7.2.5 pytest==7.3.1 PyYAML==6.0.1 tenacity==8.2.3 +git+https://github.com/canonical/k8s-test-harness.git@main diff --git a/tests/sanity/test_rock.py b/tests/sanity/test_rock.py index 4bb2846..bf14a51 100644 --- a/tests/sanity/test_rock.py +++ b/tests/sanity/test_rock.py @@ -2,15 +2,18 @@ # Copyright 2024 Canonical, Ltd. # -import os import subprocess +from k8s_test_harness.util import env_util + + +def _test_sanity(image_version): + rock = env_util.get_build_meta_info_for_rock_version( + "cluster-autoscaler", image_version, "amd64" + ) + image = rock.image -def test_sanity(): - image_variable = "ROCK_CLUSTER_AUTOSCALER" entrypoint = "/cluster-autoscaler" - image = os.getenv(image_variable) - assert image is not None, f"${image_variable} is not set" # assert we have the expected files docker_run = subprocess.run( ["docker", "run", "--rm", "--entrypoint", entrypoint, image, "--help"], @@ -18,3 +21,11 @@ def test_sanity(): text=True, ) assert "Usage of /cluster-autoscaler:" in docker_run.stderr + + +def test_cluster_autoscaler_1_24_0(): + _test_sanity("1.24.0") + + +def test_cluster_autoscaler_1_27_2(): + _test_sanity("1.27.2")