Skip to content

Commit

Permalink
added TestRayClusterNetworkResourcesOptions
Browse files Browse the repository at this point in the history
Signed-off-by: owenowenisme <[email protected]>
  • Loading branch information
owenowenisme committed Jan 15, 2025
1 parent ed4aaa8 commit e570111
Showing 1 changed file with 40 additions and 2 deletions.
42 changes: 40 additions & 2 deletions ray-operator/controllers/ray/common/association_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"reflect"
"testing"

routev1 "github.com/openshift/api/route/v1"
"github.com/stretchr/testify/assert"
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
Expand Down Expand Up @@ -324,8 +325,45 @@ func TestRayClusterRedisPodsAssociationOptions(t *testing.T) {
utils.RayNodeTypeLabelKey: string(rayv1.RedisCleanupNode),
}),
}
for k, v := range expected {
t.Log(k, v)
}
result := RayClusterRedisCleanupJobAssociationOptions(instance).ToListOptions()

assert.Equal(t, expected, result)
}

func TestRayClusterNetworkResourcesOptions(t *testing.T) {
newScheme := runtime.NewScheme()
_ = rayv1.AddToScheme(newScheme)
_ = corev1.AddToScheme(newScheme)
_ = routev1.AddToScheme(newScheme)
instance := &rayv1.RayCluster{
ObjectMeta: metav1.ObjectMeta{
Name: "raycluster-example",
Namespace: "default",
Annotations: map[string]string{
IngressClassAnnotationKey: "nginx",
},
},
}
_ = &routev1.Route{
ObjectMeta: metav1.ObjectMeta{
Name: utils.GenerateRouteName(instance.Name),
Namespace: instance.Namespace,
Labels: map[string]string{
utils.RayClusterLabelKey: instance.Name,
},
},
}
expected := []client.ListOption{
client.InNamespace(instance.ObjectMeta.Namespace),
client.MatchingLabels(map[string]string{
utils.RayClusterLabelKey: instance.Name,
}),
}

listOpts := RayClusterRedisCleanupJobAssociationOptions(instance).ToListOptions()
result := RayClusterNetworkResourcesOptions(instance).ToListOptions()

assert.Equal(t, expected, listOpts)
assert.Equal(t, expected, result)
}

0 comments on commit e570111

Please sign in to comment.