Skip to content

Commit

Permalink
Unit test to validate Cluster configuration parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
Ygnas authored and openshift-merge-bot[bot] committed Jul 18, 2024
1 parent 4dca262 commit 9c1e65d
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
6 changes: 6 additions & 0 deletions tests/unit_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@
from tests.unit_test_support import (
createClusterWithConfig,
createClusterConfig,
createClusterWrongType,
)

import codeflare_sdk.utils.kube_api_helpers
Expand Down Expand Up @@ -268,6 +269,11 @@ def test_config_creation():
assert config.appwrapper == True


def test_config_creation_wrong_type():
with pytest.raises(TypeError):
config = createClusterWrongType()


def test_cluster_creation(mocker):
# Create AppWrapper containing a Ray Cluster with no local queue specified
mocker.patch("kubernetes.client.ApisApi.get_api_versions")
Expand Down
20 changes: 20 additions & 0 deletions tests/unit_test_support.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,23 @@ def createClusterWithConfig(mocker):
)
cluster = Cluster(createClusterConfig())
return cluster


def createClusterWrongType():
config = ClusterConfiguration(
name="unit-test-cluster",
namespace="ns",
num_workers=2,
worker_cpu_requests=[],
worker_cpu_limits=4,
worker_memory_requests=5,
worker_memory_limits=6,
worker_extended_resource_requests={"nvidia.com/gpu": 7},
appwrapper=True,
machine_types=[True, False],
image_pull_secrets=["unit-test-pull-secret"],
image="quay.io/rhoai/ray:2.23.0-py39-cu121",
write_to_file=True,
labels={1: 1},
)
return config

0 comments on commit 9c1e65d

Please sign in to comment.