Skip to content

Commit 1ff1120

Browse files
sutaakaropenshift-merge-robot
authored andcommitted
Add Ray cluster support in test support package
1 parent 0a84b1d commit 1ff1120

File tree

2 files changed

+31
-1
lines changed

2 files changed

+31
-1
lines changed

test/support/conditions.go

+14-1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ limitations under the License.
1818
package support
1919

2020
import (
21+
appsv1 "k8s.io/api/apps/v1"
2122
batchv1 "k8s.io/api/batch/v1"
2223
corev1 "k8s.io/api/core/v1"
2324
)
@@ -34,7 +35,10 @@ func ConditionStatus[T conditionType](conditionType T) func(any) corev1.Conditio
3435
if c := getJobCondition(o.Status.Conditions, batchv1.JobConditionType(conditionType)); c != nil {
3536
return c.Status
3637
}
37-
38+
case *appsv1.Deployment:
39+
if c := getDeploymentCondition(o.Status.Conditions, appsv1.DeploymentConditionType(conditionType)); c != nil {
40+
return c.Status
41+
}
3842
}
3943

4044
return corev1.ConditionUnknown
@@ -51,3 +55,12 @@ func getJobCondition(conditions []batchv1.JobCondition, conditionType batchv1.Jo
5155
}
5256
return nil
5357
}
58+
59+
func getDeploymentCondition(conditions []appsv1.DeploymentCondition, conditionType appsv1.DeploymentConditionType) *appsv1.DeploymentCondition {
60+
for _, c := range conditions {
61+
if c.Type == conditionType {
62+
return &c
63+
}
64+
}
65+
return nil
66+
}

test/support/ray.go

+17
Original file line numberDiff line numberDiff line change
@@ -68,3 +68,20 @@ func WriteRayJobLogs(t Test, namespace, name string) {
6868
t.T().Logf("Retrieving RayJob %s/%s logs", namespace, name)
6969
WriteToOutputDir(t, name, Log, GetRayJobLogs(t, namespace, name))
7070
}
71+
72+
func RayCluster(t Test, namespace, name string) func(g gomega.Gomega) *rayv1alpha1.RayCluster {
73+
return func(g gomega.Gomega) *rayv1alpha1.RayCluster {
74+
cluster, err := t.Client().Ray().RayV1alpha1().RayClusters(namespace).Get(t.Ctx(), name, metav1.GetOptions{})
75+
g.Expect(err).NotTo(gomega.HaveOccurred())
76+
return cluster
77+
}
78+
}
79+
80+
func GetRayCluster(t Test, namespace, name string) *rayv1alpha1.RayCluster {
81+
t.T().Helper()
82+
return RayCluster(t, namespace, name)(t)
83+
}
84+
85+
func RayClusterState(cluster *rayv1alpha1.RayCluster) rayv1alpha1.ClusterState {
86+
return cluster.Status.State
87+
}

0 commit comments

Comments
 (0)