mirror of
https://github.com/hanzo-ml/kuberay.git
synced 2026-10-30 19:48:47 +00:00
* bump ./proto deps * bump ./apiserver deps * bump ./ray-operator deps * bump ./cli deps * bump ./experimental deps * fixup! bump ./ray-operator deps * Doesn't seem to matter but also bump buildkite * Don't change the distro version just yet * Bump go version in gha jobs * Also bump sigs.k8s.io/controller-tools for build time * more bumps * Update package import paths for proto rename * Fix another deprecated API * s/corev1.ResourceRequirements/corev1.VolumeResourceRequirements/gci rename * Downgrade client-go * update-codegen.sh * Try bumping crd-ref-docs as well * make manifests * make sync * k8s.io/utils/pointer -> k8s.io/utils/ptr * lint: missing formatting directive * make generate * Try to bump version * Bump & standardize builder images * fixup! Bump & standardize builder images * Switch multi-arch Dockerfile to distrolss as well
73 lines
2.0 KiB
Go
73 lines
2.0 KiB
Go
package common
|
|
|
|
import (
|
|
"strings"
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
corev1 "k8s.io/api/core/v1"
|
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
|
"k8s.io/apimachinery/pkg/util/intstr"
|
|
"k8s.io/utils/ptr"
|
|
|
|
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: ptr.To(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)
|
|
assert.Nil(t, err)
|
|
|
|
// Test name
|
|
var builder strings.Builder
|
|
builder.WriteString(instanceWithIngressEnabled.ObjectMeta.Name)
|
|
builder.WriteString("-head-route")
|
|
if builder.String() != route.Name {
|
|
t.Fatalf("Error generating Route name. Expected `%v` but got `%v`", builder.String(), route.Name)
|
|
}
|
|
// Test To subject
|
|
expectedKind := "Service"
|
|
if expectedKind != route.Spec.To.Kind {
|
|
t.Fatalf("Error generating Route kind. Expected `%v` but got `%v`", expectedKind, route.Spec.To.Kind)
|
|
}
|
|
// Test Service name
|
|
builder.Reset()
|
|
builder.WriteString(instanceWithIngressEnabled.ObjectMeta.Name)
|
|
builder.WriteString("-head-svc")
|
|
if builder.String() != route.Spec.To.Name {
|
|
t.Fatalf("Error generating service name. Expected `%v` but got `%v`", builder.String(), route.Spec.To.Name)
|
|
}
|
|
|
|
// Test Service port
|
|
expectedPort := intstr.FromInt(8265)
|
|
if route.Spec.Port.TargetPort != expectedPort {
|
|
t.Fatalf("Error generating service port. Expected `%v` but got `%v`", expectedPort, route.Spec.Port.TargetPort)
|
|
}
|
|
}
|