Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Ray cluster support in test support package #194

Merged
merged 1 commit into from
Jul 24, 2023
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
15 changes: 14 additions & 1 deletion test/support/conditions.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ limitations under the License.
package support

import (
appsv1 "k8s.io/api/apps/v1"
batchv1 "k8s.io/api/batch/v1"
corev1 "k8s.io/api/core/v1"
)
Expand All @@ -34,7 +35,10 @@ func ConditionStatus[T conditionType](conditionType T) func(any) corev1.Conditio
if c := getJobCondition(o.Status.Conditions, batchv1.JobConditionType(conditionType)); c != nil {
return c.Status
}

case *appsv1.Deployment:
if c := getDeploymentCondition(o.Status.Conditions, appsv1.DeploymentConditionType(conditionType)); c != nil {
return c.Status
}
}

return corev1.ConditionUnknown
Expand All @@ -51,3 +55,12 @@ func getJobCondition(conditions []batchv1.JobCondition, conditionType batchv1.Jo
}
return nil
}

func getDeploymentCondition(conditions []appsv1.DeploymentCondition, conditionType appsv1.DeploymentConditionType) *appsv1.DeploymentCondition {
for _, c := range conditions {
if c.Type == conditionType {
return &c
}
}
return nil
}
17 changes: 17 additions & 0 deletions test/support/ray.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,3 +68,20 @@ func WriteRayJobLogs(t Test, namespace, name string) {
t.T().Logf("Retrieving RayJob %s/%s logs", namespace, name)
WriteToOutputDir(t, name, Log, GetRayJobLogs(t, namespace, name))
}

func RayCluster(t Test, namespace, name string) func(g gomega.Gomega) *rayv1alpha1.RayCluster {
return func(g gomega.Gomega) *rayv1alpha1.RayCluster {
cluster, err := t.Client().Ray().RayV1alpha1().RayClusters(namespace).Get(t.Ctx(), name, metav1.GetOptions{})
g.Expect(err).NotTo(gomega.HaveOccurred())
return cluster
}
}

func GetRayCluster(t Test, namespace, name string) *rayv1alpha1.RayCluster {
t.T().Helper()
return RayCluster(t, namespace, name)(t)
}

func RayClusterState(cluster *rayv1alpha1.RayCluster) rayv1alpha1.ClusterState {
return cluster.Status.State
}