Skip to content

Commit

Permalink
adding version and active/idle checks
Browse files Browse the repository at this point in the history
  • Loading branch information
deusebio committed Jan 23, 2025
1 parent e93b6e3 commit f2d34fb
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
6 changes: 6 additions & 0 deletions driver/conftest.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Copyright 2023 Canonical Ltd.
# See LICENSE file for licensing details.

import pytest
from _pytest.config.argparsing import Parser


Expand All @@ -18,3 +19,8 @@ def pytest_addoption(parser: Parser):
" any test that doesn't contain 'kserve' in its name. Essentially, the option simulates"
" the behaviour of running `pytest -k '<filter>'` directly on the test suite.",
)
parser.addoption(
"--kubeflow-model",
default="kubeflow",
help="Provide the name of the namespace/juju model where kubeflow is deployed.",
)
30 changes: 30 additions & 0 deletions driver/test_kubeflow_workloads.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

import logging
import os
import re
import subprocess
import time
from pathlib import Path
Expand All @@ -15,6 +16,7 @@
load_in_cluster_generic_resources,
)
from lightkube.types import CascadeType
from pytest_operator.plugin import ops_test
from utils import (
assert_namespace_active,
assert_poddefault_created_in_namespace,
Expand Down Expand Up @@ -55,6 +57,8 @@

KFP_PODDEFAULT_NAME = "access-ml-pipeline"

CHARMS = {"kubeflow-dashboard": "1.8/.*"}


@pytest.fixture(scope="session")
def pytest_filter(request):
Expand All @@ -63,6 +67,13 @@ def pytest_filter(request):
return f"-k '{filter}'" if filter else ""


@pytest.fixture(scope="session")
def kubeflow_model(request, ops_test):
"""Retrieve name of the model where Kubeflow is deployed."""
model_name = request.config.getoption("--kubeflow-model")
return model_name if model_name else ops_test.model.name


@pytest.fixture(scope="session")
def tests_checked_out_commit(request):
"""Retrieve active git commit."""
Expand Down Expand Up @@ -105,6 +116,25 @@ def create_profile(lightkube_client):
assert_profile_deleted(lightkube_client, NAMESPACE, log)


async def test_bundle_correctness(ops_test, kubeflow_model):

model = await ops_test.track_model("kubeflow", model_name=kubeflow_model, use_existing=True)
status = await model.get_status()

# Check that the version is the one expected by this set of tests
for name, channel_regex in CHARMS.items():
assert re.compile(channel_regex).match(status["applications"][name]["charm-channel"])

# Check that everything is active/idle
await ops_test.model.wait_for_idle(
apps=list(status["applications"]),
timeout=3600,
idle_period=30,
status="active",
raise_on_error=True,
)


@pytest.mark.dependency()
async def test_create_profile(lightkube_client, create_profile):
"""Test Profile creation.
Expand Down

0 comments on commit f2d34fb

Please sign in to comment.