Skip to content

Commit 47ea469

Browse files
Add TokenAuthentication step for RayCluster oauth test
1 parent 415b938 commit 47ea469

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

Diff for: tests/e2e/mnist_raycluster_sdk_oauth_test.py

+8-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
from torchx.specs.api import AppState, is_terminal
66

7-
from codeflare_sdk.cluster.cluster import Cluster, ClusterConfiguration
7+
from codeflare_sdk import Cluster, ClusterConfiguration, TokenAuthentication
88
from codeflare_sdk.job.jobs import DDPJobDefinition
99

1010
import pytest
@@ -30,6 +30,13 @@ def test_mnist_ray_cluster_sdk_auth(self):
3030
def run_mnist_raycluster_sdk_oauth(self):
3131
ray_image = get_ray_image()
3232

33+
auth = TokenAuthentication(
34+
token=run_oc_command(["whoami", "--show-token=true"]),
35+
server=run_oc_command(["whoami", "--show-server=true"]),
36+
skip_tls=True,
37+
)
38+
auth.login()
39+
3340
cluster = Cluster(
3441
ClusterConfiguration(
3542
name="mnist",

Diff for: tests/e2e/support.py

+12
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import os
22
import random
33
import string
4+
import subprocess
45
from kubernetes import client, config
56
import kubernetes.client
67

@@ -33,3 +34,14 @@ def initialize_kubernetes_client(self):
3334
# Initialize Kubernetes client
3435
self.api_instance = client.CoreV1Api()
3536
self.custom_api = kubernetes.client.CustomObjectsApi(self.api_instance.api_client)
37+
38+
39+
def run_oc_command(args):
40+
try:
41+
result = subprocess.run(
42+
["oc"] + args, capture_output=True, text=True, check=True
43+
)
44+
return result.stdout.strip()
45+
except subprocess.CalledProcessError as e:
46+
print(f"Error executing 'oc {' '.join(args)}': {e}")
47+
return None

0 commit comments

Comments
 (0)