Skip to content
Merged
Show file tree
Hide file tree
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
9 changes: 8 additions & 1 deletion tests/e2e/mnist_raycluster_sdk_oauth_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

from torchx.specs.api import AppState, is_terminal

from codeflare_sdk.cluster.cluster import Cluster, ClusterConfiguration
from codeflare_sdk import Cluster, ClusterConfiguration, TokenAuthentication
from codeflare_sdk.job.jobs import DDPJobDefinition

import pytest
Expand All @@ -30,6 +30,13 @@ def test_mnist_ray_cluster_sdk_auth(self):
def run_mnist_raycluster_sdk_oauth(self):
ray_image = get_ray_image()

auth = TokenAuthentication(
token=run_oc_command(["whoami", "--show-token=true"]),
server=run_oc_command(["whoami", "--show-server=true"]),
skip_tls=True,
)
auth.login()

cluster = Cluster(
ClusterConfiguration(
name="mnist",
Expand Down
12 changes: 12 additions & 0 deletions tests/e2e/support.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import os
import random
import string
import subprocess
from kubernetes import client, config
import kubernetes.client

Expand Down Expand Up @@ -33,3 +34,14 @@ def initialize_kubernetes_client(self):
# Initialize Kubernetes client
self.api_instance = client.CoreV1Api()
self.custom_api = kubernetes.client.CustomObjectsApi(self.api_instance.api_client)


def run_oc_command(args):
try:
result = subprocess.run(
["oc"] + args, capture_output=True, text=True, check=True
)
return result.stdout.strip()
except subprocess.CalledProcessError as e:
print(f"Error executing 'oc {' '.join(args)}': {e}")
return None