Skip to content

Commit

Permalink
add test for ShutdownAfterJobFinishes and TTLSecondsAfterFinished
Browse files Browse the repository at this point in the history
Signed-off-by: Yicheng-Lu-llll <[email protected]>
  • Loading branch information
Yicheng-Lu-llll committed Dec 22, 2023
1 parent 695b3bc commit 76e422d
Showing 1 changed file with 16 additions and 8 deletions.
24 changes: 16 additions & 8 deletions flyteplugins/go/tasks/plugins/k8s/ray/ray_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,11 @@ func transformPodSpecToTaskTemplateTarget(podSpec *corev1.PodSpec) *core.TaskTem
func dummyRayCustomObj() *plugins.RayJob {
return &plugins.RayJob{
RayCluster: &plugins.RayCluster{
HeadGroupSpec: &plugins.HeadGroupSpec{RayStartParams: map[string]string{"num-cpus": "1"}},
WorkerGroupSpec: []*plugins.WorkerGroupSpec{{GroupName: workerGroupName, Replicas: 3, MinReplicas: 3, MaxReplicas: 3}},
EnableAutoscaling: false,
HeadGroupSpec: &plugins.HeadGroupSpec{RayStartParams: map[string]string{"num-cpus": "1"}},
WorkerGroupSpec: []*plugins.WorkerGroupSpec{{GroupName: workerGroupName, Replicas: 3, MinReplicas: 3, MaxReplicas: 3}},
EnableAutoscaling: true,
ShutdownAfterJobFinishes: true,
TtlSecondsAfterFinished: 120,
},
}
}
Expand Down Expand Up @@ -179,7 +181,9 @@ func TestBuildResourceRay(t *testing.T) {
ray, ok := RayResource.(*rayv1alpha1.RayJob)
assert.True(t, ok)

assert.Equal(t, *ray.Spec.RayClusterSpec.EnableInTreeAutoscaling, false)
assert.Equal(t, *ray.Spec.RayClusterSpec.EnableInTreeAutoscaling, true)
assert.Equal(t, *ray.Spec.RayClusterSpec.ShutdownAfterJobFinishes, true)
assert.Equal(t, *ray.Spec.RayClusterSpec.TTLSecondsAfterFinished, int32(120))

headReplica := int32(1)
assert.Equal(t, *ray.Spec.RayClusterSpec.HeadGroupSpec.Replicas, headReplica)
Expand Down Expand Up @@ -351,9 +355,11 @@ func TestDefaultStartParameters(t *testing.T) {
rayJobResourceHandler := rayJobResourceHandler{}
rayJob := &plugins.RayJob{
RayCluster: &plugins.RayCluster{
HeadGroupSpec: &plugins.HeadGroupSpec{},
WorkerGroupSpec: []*plugins.WorkerGroupSpec{{GroupName: workerGroupName, Replicas: 3, MinReplicas: 3, MaxReplicas: 3}},
EnableAutoscaling: false,
HeadGroupSpec: &plugins.HeadGroupSpec{},
WorkerGroupSpec: []*plugins.WorkerGroupSpec{{GroupName: workerGroupName, Replicas: 3, MinReplicas: 3, MaxReplicas: 3}},
EnableAutoscaling: true,
ShutdownAfterJobFinishes: true,
TtlSecondsAfterFinished: 120,
},
}

Expand All @@ -374,7 +380,9 @@ func TestDefaultStartParameters(t *testing.T) {
ray, ok := RayResource.(*rayv1alpha1.RayJob)
assert.True(t, ok)

assert.Equal(t, *ray.Spec.RayClusterSpec.EnableInTreeAutoscaling, false)
assert.Equal(t, *ray.Spec.RayClusterSpec.EnableInTreeAutoscaling, true)
assert.Equal(t, *ray.Spec.RayClusterSpec.ShutdownAfterJobFinishes, true)
assert.Equal(t, *ray.Spec.RayClusterSpec.TTLSecondsAfterFinished, int32(120))

headReplica := int32(1)
assert.Equal(t, *ray.Spec.RayClusterSpec.HeadGroupSpec.Replicas, headReplica)
Expand Down

0 comments on commit 76e422d

Please sign in to comment.