Skip to content
Merged
Changes from all commits
Commits
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
32 changes: 14 additions & 18 deletions tests/workbenches/notebook-controller/test_spawning.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
import pytest

from timeout_sampler import TimeoutExpiredError
from kubernetes.dynamic.client import DynamicClient

from ocp_resources.pod import Pod
from ocp_resources.namespace import Namespace
from ocp_resources.notebook import Notebook
from ocp_resources.persistent_volume_claim import PersistentVolumeClaim


class TestNotebook:
Expand All @@ -26,25 +29,18 @@ class TestNotebook:
)
def test_create_simple_notebook(
self,
unprivileged_client,
unprivileged_model_namespace,
users_persistent_volume_claim,
default_notebook,
unprivileged_client: DynamicClient,
unprivileged_model_namespace: Namespace,
users_persistent_volume_claim: PersistentVolumeClaim,
default_notebook: Notebook,
):
"""
Create a simple Notebook CR with all necessary resources and see if the Notebook Operator creates it properly
"""
pods = Pod.get(
dyn_client=unprivileged_client,
namespace=unprivileged_model_namespace.name,
label_selector=f"app={unprivileged_model_namespace.name}",
notebook_pod = Pod(
client=unprivileged_client,
namespace=default_notebook.namespace,
name=f"{default_notebook.name}-0",
)
assert pods, "The expected notebook pods were not found"

failed_pods = []
for pod in pods:
try:
pod.wait_for_condition(condition=pod.Condition.READY, status=pod.Condition.Status.TRUE)
except TimeoutExpiredError:
failed_pods.append(pod)
assert not failed_pods, f"The following pods failed to get READY when starting the notebook: {failed_pods}"
notebook_pod.wait()
notebook_pod.wait_for_condition(condition=Pod.Condition.READY, status=Pod.Condition.Status.TRUE)