Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Auto identify applications namespace and distribution #188

Merged
merged 59 commits into from
Mar 20, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
59 commits
Select commit Hold shift + click to select a range
b362382
Create size-labeler.yml
rnetser Dec 18, 2024
3c6a875
Delete .github/workflows/size-labeler.yml
rnetser Dec 18, 2024
ccb63af
Merge branch 'main' of github.com:rnetser/opendatahub-tests
rnetser Dec 24, 2024
da0c898
Merge branch 'main' of https://github.com/opendatahub-io/opendatahub-…
rnetser Dec 25, 2024
94a82ec
Merge branch 'main' of https://github.com/opendatahub-io/opendatahub-…
rnetser Dec 26, 2024
c0c82dd
Merge branch 'main' of https://github.com/opendatahub-io/opendatahub-…
rnetser Dec 27, 2024
5feb447
Merge branch 'main' of https://github.com/opendatahub-io/opendatahub-…
rnetser Dec 30, 2024
19b9c56
Merge branch 'main' of https://github.com/opendatahub-io/opendatahub-…
rnetser Dec 31, 2024
e22ac1a
Merge branch 'main' of https://github.com/opendatahub-io/opendatahub-…
rnetser Dec 31, 2024
56ab9c5
Merge branch 'main' of https://github.com/opendatahub-io/opendatahub-…
rnetser Dec 31, 2024
5a17f03
Merge branch 'main' of https://github.com/opendatahub-io/opendatahub-…
rnetser Dec 31, 2024
ef5fe65
Merge branch 'main' of https://github.com/opendatahub-io/opendatahub-…
rnetser Dec 31, 2024
1875a44
Merge branch 'main' of https://github.com/opendatahub-io/opendatahub-…
rnetser Jan 1, 2025
840d442
Merge branch 'main' of https://github.com/opendatahub-io/opendatahub-…
rnetser Jan 2, 2025
c0d4436
Merge branch 'main' of https://github.com/opendatahub-io/opendatahub-…
rnetser Jan 2, 2025
ba7971a
Merge branch 'main' of https://github.com/opendatahub-io/opendatahub-…
rnetser Jan 3, 2025
fd73a94
Merge branch 'main' of https://github.com/opendatahub-io/opendatahub-…
rnetser Jan 7, 2025
bde0493
Merge branch 'main' of https://github.com/opendatahub-io/opendatahub-…
rnetser Jan 8, 2025
d3cd799
Merge branch 'main' of https://github.com/opendatahub-io/opendatahub-…
rnetser Jan 9, 2025
710befa
Merge branch 'main' of https://github.com/opendatahub-io/opendatahub-…
rnetser Jan 12, 2025
a662364
Merge branch 'main' of https://github.com/opendatahub-io/opendatahub-…
rnetser Jan 16, 2025
579c283
Merge branch 'main' of https://github.com/opendatahub-io/opendatahub-…
rnetser Jan 16, 2025
927cbb0
Merge branch 'main' of https://github.com/opendatahub-io/opendatahub-…
rnetser Jan 19, 2025
99e242e
Merge branch 'main' of https://github.com/opendatahub-io/opendatahub-…
rnetser Jan 22, 2025
5b83bab
Merge branch 'main' of https://github.com/opendatahub-io/opendatahub-…
rnetser Jan 24, 2025
4b5b007
Merge branch 'main' of https://github.com/opendatahub-io/opendatahub-…
rnetser Jan 27, 2025
b8e5dee
Merge branch 'main' of https://github.com/opendatahub-io/opendatahub-…
rnetser Jan 30, 2025
0039df0
Merge branch 'main' of https://github.com/opendatahub-io/opendatahub-…
rnetser Jan 30, 2025
17938d6
model mesh - add auth tests
rnetser Feb 2, 2025
44a3120
xx
rnetser Feb 2, 2025
a418727
Merge branch 'main' of https://github.com/opendatahub-io/opendatahub-…
rnetser Feb 3, 2025
d291c32
Merge branch 'main' of https://github.com/opendatahub-io/opendatahub-…
rnetser Feb 4, 2025
b6650d8
Merge branch 'main' of https://github.com/opendatahub-io/opendatahub-…
rnetser Feb 5, 2025
8b9f838
Merge branch 'main' of https://github.com/opendatahub-io/opendatahub-…
rnetser Feb 7, 2025
d53a04c
Merge branch 'main' of https://github.com/opendatahub-io/opendatahub-…
rnetser Feb 10, 2025
db89111
Merge branch 'main' of https://github.com/opendatahub-io/opendatahub-…
rnetser Feb 10, 2025
773d81a
Merge branch 'main' of https://github.com/opendatahub-io/opendatahub-…
rnetser Feb 12, 2025
01be6e9
Merge branch 'main' of https://github.com/opendatahub-io/opendatahub-…
rnetser Feb 13, 2025
71df8d5
Merge branch 'main' of https://github.com/opendatahub-io/opendatahub-…
rnetser Feb 16, 2025
8896bd7
Merge branch 'main' of https://github.com/opendatahub-io/opendatahub-…
rnetser Feb 18, 2025
0eeb162
Merge branch 'main' of https://github.com/opendatahub-io/opendatahub-…
rnetser Feb 18, 2025
38e8a69
ci: on main upstream xxxxxxxxxxx
rnetser Feb 19, 2025
875f597
ci: reabsingxxxxxxxxxxxxxx
rnetser Feb 20, 2025
c90abf6
ci: reabsingxxxxxxxxxxxxxx
rnetser Feb 20, 2025
4a26346
ci: Merge branch 'main' of https://github.com/opendatahub-io/opendata…
rnetser Feb 24, 2025
8302ed1
ci: Merge branch 'main' of https://github.com/opendatahub-io/opendata…
rnetser Feb 25, 2025
ff1b155
ci: rebase on main
rnetser Mar 6, 2025
a04a3c4
ci: merge main branch
rnetser Mar 11, 2025
d1cb99b
ci: merge branch main
rnetser Mar 12, 2025
87faa7b
ci: merge branch main
rnetser Mar 17, 2025
dc8490d
ci: merge branch main
rnetser Mar 17, 2025
5856788
ci: merge main branch
rnetser Mar 18, 2025
a865aa8
ci: merge main branch
rnetser Mar 18, 2025
b899fc5
feat: get default application namespace from dsci
rnetser Mar 18, 2025
75c1e86
feat: add distribution
rnetser Mar 18, 2025
fb744fa
feat: add distribution
rnetser Mar 18, 2025
25da492
ci: merge main branch
rnetser Mar 18, 2025
8cc2a50
ci: merge main branch
rnetser Mar 18, 2025
d0a02bd
ci: resolve conflicts
rnetser Mar 20, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ def pytest_addoption(parser: Parser) -> None:
buckets_group = parser.getgroup(name="Buckets")
runtime_group = parser.getgroup(name="Runtime details")
upgrade_group = parser.getgroup(name="Upgrade options")
platform_group = parser.getgroup(name="Platform")

# AWS config and credentials options
aws_group.addoption(
Expand Down Expand Up @@ -113,6 +114,12 @@ def pytest_addoption(parser: Parser) -> None:
"If not set, all will be tested.",
)

# Platform options
platform_group.addoption(
"--applications-namespace",
help="RHOAI/ODH applications namespace",
)


def pytest_cmdline_main(config: Any) -> None:
config.option.basetemp = py_config["tmp_base_dir"] = f"{config.option.basetemp}-{shortuuid.uuid()}"
Expand Down Expand Up @@ -196,9 +203,6 @@ def pytest_sessionstart(session: Session) -> None:
log_level=session.config.getoption("log_cli_level") or logging.INFO,
)

if py_config.get("distribution") == "upstream":
py_config["applications_namespace"] = "opendatahub"


def pytest_fixture_setup(fixturedef: FixtureDef[Any], request: FixtureRequest) -> None:
LOGGER.info(f"Executing {fixturedef.scope} fixture: {fixturedef.argname}")
Expand Down
23 changes: 22 additions & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,13 @@
from simple_logger.logger import get_logger

from utilities.data_science_cluster_utils import update_components_in_dsc
from utilities.infra import create_ns, login_with_user_password, get_openshift_token
from utilities.infra import (
create_ns,
get_dsci_applications_namespace,
get_operator_distribution,
login_with_user_password,
get_openshift_token,
)
from utilities.constants import AcceleratorType, DscComponents
from utilities.infra import update_configmap_data

Expand All @@ -45,6 +51,21 @@ def tests_tmp_dir(request: FixtureRequest, tmp_path_factory: TempPathFactory) ->
shutil.rmtree(path=str(tests_tmp_path), ignore_errors=True)


@pytest.fixture(scope="session", autouse=True)
def updated_global_config(request: FixtureRequest, admin_client: DynamicClient) -> None:
if get_operator_distribution(client=admin_client) == "Open Data Hub":
py_config["distribution"] = "upstream"

else:
py_config["distribution"] = "downstream"

if applications_namespace := request.config.getoption("applications_namespace"):
py_config["applications_namespace"] = applications_namespace

else:
py_config["applications_namespace"] = get_dsci_applications_namespace(client=admin_client)


@pytest.fixture(scope="session")
def current_client_token(admin_client: DynamicClient) -> str:
return get_openshift_token()
Expand Down
4 changes: 4 additions & 0 deletions utilities/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,3 +80,7 @@ class InferenceCanaryTrafficError(Exception):

class PodLogMissMatchError(Exception):
pass


class ResourceMismatch(Exception):
pass
58 changes: 58 additions & 0 deletions utilities/infra.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@
from ocp_resources.catalog_source import CatalogSource
from ocp_resources.cluster_service_version import ClusterServiceVersion
from ocp_resources.config_map import ConfigMap
from ocp_resources.data_science_cluster import DataScienceCluster
from ocp_resources.deployment import Deployment
from ocp_resources.dsc_initialization import DSCInitialization
from ocp_resources.exceptions import MissingResourceError
from ocp_resources.inference_service import InferenceService
from ocp_resources.infrastructure import Infrastructure
Expand Down Expand Up @@ -616,3 +618,59 @@ def get_product_version(admin_client: DynamicClient) -> Version:
raise MissingResourceError("Operator ClusterServiceVersion not found")

return Version.parse(operator_version)


def get_dsci_applications_namespace(client: DynamicClient, dsci_name: str = "default-dsci") -> str:
"""
Get the namespace where DSCI applications are deployed.

Args:
client (DynamicClient): DynamicClient object
dsci_name (str): DSCI name

Returns:
str: Namespace where DSCI applications are deployed.

Raises:
ValueError: If DSCI applications namespace not found
MissingResourceError: If DSCI not found

"""
dsci = DSCInitialization(client=client, name=dsci_name)

if dsci.exists:
if app_namespace := dsci.instance.spec.get("applicationsNamespace"):
return app_namespace

else:
raise ValueError("DSCI applications namespace not found in {dsci_name}")

raise MissingResourceError(f"DSCI {dsci_name} not found")


def get_operator_distribution(client: DynamicClient, dsc_name: str = "default-dsc") -> str:
"""
Get the operator distribution.

Args:
client (DynamicClient): DynamicClient object
dsc_name (str): DSC name

Returns:
str: Operator distribution.

Raises:
ValueError: If DSC release name not found
MissingResourceError: If DSC not found

"""
dsc = DataScienceCluster(client=client, name=dsc_name)

if dsc.exists:
if dsc_release_name := dsc.instance.status.get("release", {}).get("name"):
return dsc_release_name

else:
raise ValueError("DSC release name not found in {dsc_name}")

raise MissingResourceError(f"DSC {dsc_name} not found")
Loading