Files
c737feb129 Go 1.26 and K8s 1.36 client-go updates (#4703)
* Updating client-go to v1.36.0-beta.0 (and updating golang to 1.26)

Signed-off-by: Mark Rossetti <[email protected]>

* Bump golangci-lint to v2.11.4 and fix lint issues for Go 1.26

Signed-off-by: Mark Rossetti <[email protected]>

* bump go to 1.26 in ray-operator docker file

Signed-off-by: Mark Rossetti <[email protected]>

* Migrate webhooks from deprecated CustomValidator to admission.Validation[T]

Signed-off-by: Mark Rossetti <[email protected]>

* Target K8s 1.36 GA deps

Signed-off-by: Mark Rossetti <[email protected]>

* Merge branch 'master' into go-client-go-updates

Signed-off-by: Rueian <[email protected]>

---------

Signed-off-by: Mark Rossetti <[email protected]>
Signed-off-by: Rueian <[email protected]>
Co-authored-by: Rueian <[email protected]>
2026-05-03 00:03:55 -07:00

58 lines
1.4 KiB
Go

package common
import (
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/util/intstr"
rayv1 "github.com/ray-project/kuberay/ray-operator/apis/ray/v1"
)
var instanceWithRouteEnabled = &rayv1.RayCluster{
ObjectMeta: metav1.ObjectMeta{
Name: "raycluster-sample",
Namespace: "default",
Annotations: map[string]string{
IngressClassAnnotationKey: "nginx",
},
},
Spec: rayv1.RayClusterSpec{
HeadGroupSpec: rayv1.HeadGroupSpec{
EnableIngress: new(true),
Template: corev1.PodTemplateSpec{
Spec: corev1.PodSpec{
Containers: []corev1.Container{
{
Name: "ray-head",
Image: "rayproject/autoscaler",
Command: []string{"python"},
Args: []string{"/opt/code.py"},
},
},
},
},
},
},
}
func TestBuildRouteForHeadService(t *testing.T) {
route, err := BuildRouteForHeadService(*instanceWithRouteEnabled)
require.NoError(t, err)
// Test name
assert.Equal(t, instanceWithIngressEnabled.ObjectMeta.Name+"-head-route", route.Name)
// Test To subject
assert.Equal(t, "Service", route.Spec.To.Kind)
// Test Service name
assert.Equal(t, instanceWithIngressEnabled.ObjectMeta.Name+"-head-svc", route.Spec.To.Name)
// Test Service port
assert.Equal(t, intstr.FromInt(8265), route.Spec.Port.TargetPort)
}