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

RHOAIENG-16055: new(tests): test to start a Workbench, by creating the Notebook CR directly #94

Open
wants to merge 9 commits into
base: main
Choose a base branch
from

Conversation

jiridanek
Copy link
Member

@jiridanek jiridanek commented Jan 15, 2025

Description

This is a port of

How Has This Been Tested?

  • figure out when/how to use unprivileged k8s client

Merge criteria:

  • The commits are squashed in a cohesive manner and have meaningful messages.
  • Testing instructions have been added in the PR body (for PRs involving changes that are not immediately obvious).
  • The developer has manually tested the changes and verified that the changes work

@jiridanek jiridanek marked this pull request as draft January 15, 2025 17:04
Copy link

The following are automatically added/executed:

Available user actions:

  • To mark a PR as WIP, add /wip in a comment. To remove it from the PR comment /wip cancel to the PR.
  • To block merging of a PR, add /hold in a comment. To un-block merging of PR comment /hold cancel.
  • To mark a PR as approved, add /lgtm in a comment. To remove, add /lgtm cancel.
    lgtm label removed on each new commit push.
  • To mark PR as verified comment /verified to the PR, to un-verify comment /verified cancel to the PR.
    verified label removed on each new commit push.
Supported labels

{'/hold', '/verified', '/lgtm', '/wip'}

@jiridanek jiridanek marked this pull request as ready for review January 17, 2025 09:27
@@ -0,0 +1,309 @@
from __future__ import annotations

import logging
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please use simple_logger

resource_manager.destroy()


class KubeResourceManager:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please use ocpenshift python wrapper to CRUD resources

Comment on lines +46 to +47
OPENSHIFT_DOMAIN = "openshift.io/"
ODH_DOMAIN = "opendatahub.io/"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

used in other places as well, please place under https://github.com/opendatahub-io/opendatahub-tests/blob/main/utilities/constants.py and re-use


LABEL_DASHBOARD = ODH_DOMAIN + "dashboard"
LABEL_ODH_MANAGED = ODH_DOMAIN + "odh-managed"
LABEL_SIDECAR_ISTIO_INJECT = "sidecar.istio.io/inject"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto

self.privileged_client = privileged_client
self.resources: list[ocp_resources.resource.Resource] = []

def createResourceWithoutWait(self, client: DynamicClient, resource: ocp_resources.resource.Resource):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please use python naming conventions

import kubernetes.client
from kubernetes.dynamic import DynamicClient

from tests.workbenches.conftest import OdhAnnotationsLabels, OdhConstants, PodUtils
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

under conftest place fixtures; functions and classes should be under utils.py in the relevant dir

@classmethod
@property
@functools.cache
def logger(cls):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please use simple_logger

),
},
)
def testCreateSimpleNotebook(self, function_resource_manager, admin_client, unprivileged_client):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

all setup steps (e.g namespace, pvc) should be done in fixtures
please check existing fixtures and re-use

# }


def loadDefaultNotebook(client: DynamicClient, namespace: str, name: str, image: str) -> Notebook:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

functions should go under utils.py in the relevant dir

@@ -0,0 +1,146 @@
apiVersion: kubeflow.org/v1
kind: Notebook
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is there a template for this in the cluster?


with allure.step("Create Notebook CR"):
# notebookImage: str = NotebookType.getNotebookImage(NotebookType.JUPYTER_MINIMAL_IMAGE, NotebookType.JUPYTER_MINIMAL_2023_2_TAG);
notebookImage: str = "quay.io/modh/odh-minimal-notebook-container@sha256:615af25cfd4f3f2981b173e1a5ab24cb79f268ee72dabbddb6867ee1082eb902"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can this be fetched dinamically from the cluster?

Comment on lines +170 to +172
notebookString = pathlib.Path(
"/Users/jdanek/IdeaProjects/opendatahub-tests/tests/workbenches/notebook-controller/test_data/notebook.yaml"
).read_text()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pretty sure this won't work :)

Comment on lines +45 to +50
afterTestSteps={
Step(
value="Delete ODH operator and all created resources",
expected="Operator is removed and all other resources as well",
)
},
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this has been functionally implemented but FWIW we don't plan to remove the operator after the test run

@@ -0,0 +1,39 @@
from typing import Callable
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is this used for? does it just provide additional documentation for tests in e.g. https://github.com/opendatahub-io/opendatahub-tests/pull/94/files#diff-358f1122838e1ac22415822c5a85d419e2d111c64285e488695af1cf6f03d490R35 ?
IMHO if this is implemented we should use it across the repo to keep consistency, so this should go under a higher level directory, but it should probably be discussed beforehand. Can you attend the shift left wg meeting to do so?

@@ -0,0 +1,309 @@
from __future__ import annotations
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the majority of these classes could be avoided if you instead used the wrapper library https://github.com/RedHatQE/openshift-python-wrapper

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants