|
43 | 43 | KubeConfigFileAuthentication,
|
44 | 44 | config_check,
|
45 | 45 | )
|
46 |
| -from codeflare_sdk.utils.openshift_oauth import create_openshift_oauth_objects |
| 46 | +from codeflare_sdk.utils.openshift_oauth import ( |
| 47 | + create_openshift_oauth_objects, |
| 48 | + delete_openshift_oauth_objects, |
| 49 | +) |
47 | 50 | from codeflare_sdk.utils.pretty_print import (
|
48 | 51 | print_no_resources_found,
|
49 | 52 | print_app_wrappers_status,
|
@@ -489,13 +492,44 @@ def test_rc_status(mocker):
|
489 | 492 | assert rc == None
|
490 | 493 |
|
491 | 494 |
|
| 495 | +def test_delete_openshift_oauth_objects(mocker): |
| 496 | + mocker.patch.object(client.CoreV1Api, "delete_namespaced_service_account") |
| 497 | + mocker.patch.object(client.CoreV1Api, "delete_namespaced_service") |
| 498 | + mocker.patch.object(client.NetworkingV1Api, "delete_namespaced_ingress") |
| 499 | + mocker.patch.object(client.RbacAuthorizationV1Api, "delete_cluster_role_binding") |
| 500 | + delete_openshift_oauth_objects("test-cluster", "test-namespace") |
| 501 | + |
| 502 | + client.CoreV1Api.delete_namespaced_service_account.assert_called_with( |
| 503 | + name="test-cluster-oauth-proxy", namespace="test-namespace" |
| 504 | + ) |
| 505 | + client.CoreV1Api.delete_namespaced_service.assert_called_with( |
| 506 | + name="test-cluster-oauth", namespace="test-namespace" |
| 507 | + ) |
| 508 | + client.NetworkingV1Api.delete_namespaced_ingress.assert_called_with( |
| 509 | + name="test-cluster-ingress", namespace="test-namespace" |
| 510 | + ) |
| 511 | + client.RbacAuthorizationV1Api.delete_cluster_role_binding.assert_called_with( |
| 512 | + name="test-cluster-rb" |
| 513 | + ) |
| 514 | + |
| 515 | + |
492 | 516 | def test_cluster_uris(mocker):
|
493 | 517 | mocker.patch("kubernetes.config.load_kube_config", return_value="ignore")
|
494 | 518 | mocker.patch(
|
495 | 519 | "codeflare_sdk.cluster.cluster._get_ingress_domain",
|
496 | 520 | return_value="apps.cluster.awsroute.org",
|
497 | 521 | )
|
498 | 522 | cluster = cluster = createClusterWithConfig(mocker)
|
| 523 | + mocker.patch( |
| 524 | + "kubernetes.client.NetworkingV1Api.list_namespaced_ingress", |
| 525 | + return_value=ingress_retrieval( |
| 526 | + port=8265, annotations={"route.openshift.io/termination": "passthrough"} |
| 527 | + ), |
| 528 | + ) |
| 529 | + assert ( |
| 530 | + cluster.cluster_dashboard_uri() |
| 531 | + == "https://ray-dashboard-unit-test-cluster-ns.apps.cluster.awsroute.org" |
| 532 | + ) |
499 | 533 | mocker.patch(
|
500 | 534 | "kubernetes.client.NetworkingV1Api.list_namespaced_ingress",
|
501 | 535 | return_value=ingress_retrieval(port=8265),
|
@@ -543,13 +577,15 @@ def ray_addr(self, *args):
|
543 | 577 | return self._address
|
544 | 578 |
|
545 | 579 |
|
546 |
| -def ingress_retrieval(port): |
| 580 | +def ingress_retrieval(port, annotations=None): |
547 | 581 | if port == 10001:
|
548 | 582 | serviceName = "client"
|
549 | 583 | else:
|
550 | 584 | serviceName = "dashboard"
|
551 | 585 | mock_ingress = client.V1Ingress(
|
552 |
| - metadata=client.V1ObjectMeta(name=f"ray-{serviceName}-unit-test-cluster"), |
| 586 | + metadata=client.V1ObjectMeta( |
| 587 | + name=f"ray-{serviceName}-unit-test-cluster", annotations=annotations |
| 588 | + ), |
553 | 589 | spec=client.V1IngressSpec(
|
554 | 590 | rules=[
|
555 | 591 | client.V1IngressRule(
|
|
0 commit comments