Skip to content

Commit 70098a0

Browse files
authored
test: make e2e tests compatible with byoidc and legacy auth (#995)
test: make e2e tests compatible with byoidc and legacy auth (#995)
1 parent 035e935 commit 70098a0

16 files changed

+3818
-422
lines changed

images/tests/run-tests.sh

Lines changed: 319 additions & 94 deletions
Large diffs are not rendered by default.

tests/e2e/gateway_api_resources_oauth_test.py

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
from codeflare_sdk import (
1919
Cluster,
2020
ClusterConfiguration,
21-
TokenAuthentication,
2221
)
2322

2423
from kubernetes import client
@@ -31,6 +30,8 @@
3130
delete_kueue_resources,
3231
get_ray_image,
3332
run_oc_command,
33+
authenticate_for_tests,
34+
cleanup_authentication,
3435
# Gateway API helpers
3536
get_reference_grant,
3637
list_reference_grants,
@@ -44,6 +45,7 @@
4445
verify_reference_grant_spec,
4546
verify_httproute_spec,
4647
verify_network_policy_spec,
48+
wait_ready_enhanced,
4749
)
4850

4951

@@ -61,6 +63,9 @@ def setup_method(self):
6163
self.networking_api = client.NetworkingV1Api(self.api_instance.api_client)
6264

6365
def teardown_method(self):
66+
# Clean up authentication if needed
67+
if hasattr(self, "auth_instance"):
68+
cleanup_authentication(self.auth_instance)
6469
# Only delete namespace if it was created
6570
if hasattr(self, "namespace"):
6671
delete_namespace(self)
@@ -80,13 +85,11 @@ def test_gateway_resources_created_with_raycluster(self):
8085
cluster_name = "gateway-test"
8186
ray_image = get_ray_image()
8287

83-
# Authenticate with current user token
84-
auth = TokenAuthentication(
85-
token=run_oc_command(["whoami", "--show-token=true"]),
86-
server=run_oc_command(["whoami", "--show-server=true"]),
87-
skip_tls=True,
88-
)
89-
auth.login()
88+
# Set up authentication based on detected method
89+
auth_instance = authenticate_for_tests()
90+
91+
# Store auth instance for cleanup
92+
self.auth_instance = auth_instance
9093

9194
cluster = Cluster(
9295
ClusterConfiguration(
@@ -116,7 +119,7 @@ def test_gateway_resources_created_with_raycluster(self):
116119
cluster.apply()
117120

118121
# Wait for cluster to be ready
119-
cluster.wait_ready()
122+
wait_ready_enhanced(cluster)
120123

121124
# Verify ReferenceGrant is created
122125
reference_grant_name = self.verify_reference_grant_created(cluster_name)

tests/e2e/heterogeneous_clusters_oauth_test.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
from codeflare_sdk import (
22
Cluster,
33
ClusterConfiguration,
4-
TokenAuthentication,
54
)
65

76
from codeflare_sdk.common.kueue.kueue import list_local_queues
@@ -19,6 +18,9 @@ def setup_method(self):
1918
initialize_kubernetes_client(self)
2019

2120
def teardown_method(self):
21+
# Clean up authentication if needed
22+
if hasattr(self, "auth_instance"):
23+
cleanup_authentication(self.auth_instance)
2224
delete_namespace(self)
2325
delete_kueue_resources(self)
2426

@@ -32,12 +34,11 @@ def run_heterogeneous_clusters(
3234
):
3335
ray_image = get_ray_image()
3436

35-
auth = TokenAuthentication(
36-
token=run_oc_command(["whoami", "--show-token=true"]),
37-
server=run_oc_command(["whoami", "--show-server=true"]),
38-
skip_tls=True,
39-
)
40-
auth.login()
37+
# Set up authentication based on detected method
38+
auth_instance = authenticate_for_tests()
39+
40+
# Store auth instance for cleanup
41+
self.auth_instance = auth_instance
4142

4243
for flavor in self.resource_flavors:
4344
node_labels = (
@@ -70,7 +71,7 @@ def run_heterogeneous_clusters(
7071
)
7172
cluster.apply()
7273
# Wait for the cluster to be scheduled and ready, we don't need the dashboard for this check
73-
cluster.wait_ready(dashboard_check=False)
74+
wait_ready_with_stuck_detection(cluster, dashboard_check=False)
7475
node_name = get_pod_node(self, self.namespace, cluster_name)
7576
print(f"Cluster {cluster_name}-{flavor} is running on node: {node_name}")
7677
assert (

tests/e2e/local_interactive_sdk_oauth_test.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
from codeflare_sdk import (
22
Cluster,
33
ClusterConfiguration,
4-
TokenAuthentication,
54
generate_cert,
65
)
76

@@ -20,6 +19,9 @@ def setup_method(self):
2019
initialize_kubernetes_client(self)
2120

2221
def teardown_method(self):
22+
# Clean up authentication if needed
23+
if hasattr(self, "auth_instance"):
24+
cleanup_authentication(self.auth_instance)
2325
delete_namespace(self)
2426
delete_kueue_resources(self)
2527

@@ -32,12 +34,11 @@ def test_local_interactives(self):
3234
def run_local_interactives(self):
3335
ray_image = get_ray_image()
3436

35-
auth = TokenAuthentication(
36-
token=run_oc_command(["whoami", "--show-token=true"]),
37-
server=run_oc_command(["whoami", "--show-server=true"]),
38-
skip_tls=True,
39-
)
40-
auth.login()
37+
# Set up authentication based on detected method
38+
auth_instance = authenticate_for_tests()
39+
40+
# Store auth instance for cleanup
41+
self.auth_instance = auth_instance
4142

4243
cluster_name = "test-ray-cluster-li"
4344

@@ -59,7 +60,7 @@ def run_local_interactives(self):
5960
)
6061
)
6162
cluster.apply()
62-
cluster.wait_ready()
63+
wait_ready_with_stuck_detection(cluster)
6364

6465
generate_cert.generate_tls_cert(cluster_name, self.namespace)
6566
generate_cert.export_env(cluster_name, self.namespace)

0 commit comments

Comments
 (0)