mirror of
https://github.com/hanzo-ml/kuberay.git
synced 2026-10-30 19:48:47 +00:00
Rename msft-operator to ray-operator. See https://github.com/ray-project/ray-contrib/issues/17 for more details Signed-off-by: Jiaxin Shan <[email protected]>
71 lines
1.2 KiB
Go
71 lines
1.2 KiB
Go
package utils
|
|
|
|
import (
|
|
"testing"
|
|
|
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
|
|
|
corev1 "k8s.io/api/core/v1"
|
|
v1 "k8s.io/api/core/v1"
|
|
)
|
|
|
|
func TestBefore(t *testing.T) {
|
|
if Before("a", "b") != "" {
|
|
t.Fail()
|
|
}
|
|
|
|
if Before("aaa", "a") != "" {
|
|
t.Fail()
|
|
}
|
|
|
|
if Before("aab", "b") != "aa" {
|
|
t.Fail()
|
|
}
|
|
}
|
|
|
|
func TestStatus(t *testing.T) {
|
|
pod := createSomePod()
|
|
pod.Status.Phase = v1.PodPending
|
|
if !IsCreated(pod) {
|
|
t.Fail()
|
|
}
|
|
|
|
}
|
|
|
|
func TestCheckName(t *testing.T) {
|
|
|
|
// test 1 -> change
|
|
str := "72fbcc7e-a661-4b18e-ca41-e903-fc3ae634b18e-lazer090scholar-director-s"
|
|
str = CheckName(str)
|
|
if str != "rca41-e903-fc3ae634b18e-lazer090scholar-director-s" {
|
|
t.Fail()
|
|
}
|
|
// test 2 -> change
|
|
str = "--------566666--------444433-----------222222----------4444"
|
|
str = CheckName(str)
|
|
if str != "r6666--------444433-----------222222----------4444" {
|
|
t.Fail()
|
|
}
|
|
|
|
// test 3 -> keep
|
|
str = "acceptable-name-head-12345"
|
|
str = CheckName(str)
|
|
if str != "acceptable-name-head-12345" {
|
|
t.Fail()
|
|
}
|
|
}
|
|
|
|
func createSomePod() (pod *corev1.Pod) {
|
|
|
|
return &corev1.Pod{
|
|
TypeMeta: metav1.TypeMeta{
|
|
APIVersion: "v1",
|
|
Kind: "Pod",
|
|
},
|
|
ObjectMeta: metav1.ObjectMeta{
|
|
Name: "raycluster-sample-small-group-worker-0",
|
|
Namespace: "default",
|
|
},
|
|
}
|
|
}
|