Skip to content

Commit

Permalink
Test gardener flavor
Browse files Browse the repository at this point in the history
  • Loading branch information
Gerrit91 committed Jan 16, 2025
2 parents 3bce134 + 1000e33 commit 53eb1ab
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 4 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/integration.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ jobs:
flavors:
- name: sonic
- name: cumulus
- name: gardener

steps:
- name: Gain back workspace permissions # https://github.com/actions/checkout/issues/211
Expand All @@ -34,7 +35,7 @@ jobs:
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# we can remove desired version again after this fix was released: https://github.com/srl-labs/containerlab/pull/2000
DESIRED_VERSION: v0.56.0
# DESIRED_VERSION:

- name: Checkout
uses: actions/checkout@v4
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ prep:

.PHONY: mini-lab
mini-lab:
make -C $(MINI_LAB_PATH)
cd $(MINI_LAB_PATH) && make

.PHONY: wait-for-images
wait-for-images:
Expand Down
2 changes: 1 addition & 1 deletion test/integration/deployment/integration.sh
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,4 @@ pip install --root-user-action=ignore --upgrade pip \
# if you want to develop tests from within here, comment in the following line:
# bash

pytest --junitxml=/output/results_$(date "+%Y.%m.%d-%H.%M.%S").xml
pytest -o cache_dir=/tmp/.pytest-cache --junitxml=/output/results_$(date "+%Y.%m.%d-%H.%M.%S").xml
46 changes: 45 additions & 1 deletion test/integration/deployment/test/deployment_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@
from metal_python.driver import Driver
import pytest
import testinfra

import yaml
import common
import base64


class MetalControlPlaneDeployment(unittest.TestCase):
Expand Down Expand Up @@ -97,3 +98,46 @@ def test_dhcpd_service(self):
self.service_enabled_and_running(self.hosts[0], "isc-dhcp-server")
else:
self.service_enabled_and_running(self.hosts[0], "dhcpd")


def garden_namespace_exists():
config.load_kube_config()
v1 = client.CoreV1Api()
res = v1.read_namespace("garden")
return True if res else False


@unittest.skipUnless(garden_namespace_exists(), "test only if gardener flavor was used")
class GardenerControlPlaneDeployment(unittest.TestCase):
def __init__(self, *args, **kwargs):
super(GardenerControlPlaneDeployment, self).__init__(*args, **kwargs)
config.load_kube_config()
self.maxDiff = None

def test_deployment(self):
v1 = client.AppsV1Api()
for ns in ["garden", "istio-ingress", "istio-system"]:
res = v1.list_namespaced_deployment(ns)
for i in res.items:
self.assertIsNone(i.status.unavailable_replicas, f"deployment {i.metadata.name} in namespace {ns} has unavailable replicas")

def test_stateful_sets(self):
v1 = client.AppsV1Api()
for ns in ["garden", "istio-ingress", "istio-system"]:
res = v1.list_namespaced_stateful_set(ns)
for i in res.items:
self.assertEqual(i.status.current_replicas, i.status.replicas, f"stateful set {i.metadata.name} in namespace {ns} has unready replicas")

@pytest.mark.flaky(reruns=36, reruns_delay=10)
def test_seed_ready(self):
v1 = client.CoreV1Api()
secret = v1.read_namespaced_secret("garden-kubeconfig-for-admin", "garden")
garden_client = config.new_client_from_config_dict(yaml.safe_load(base64.b64decode(secret.data["kubeconfig"])))

custom = client.CustomObjectsApi(api_client=garden_client)

seeds = custom.list_cluster_custom_object("core.gardener.cloud", "v1beta1", "seeds")

self.assertTrue(len(seeds["items"]) == 1, "no seed object found")
self.assertEqual(seeds["items"][0]["status"]["lastOperation"]["state"], "Succeeded")
self.assertEqual(seeds["items"][0]["status"]["lastOperation"]["progress"], 100)

0 comments on commit 53eb1ab

Please sign in to comment.