Skip to content

Commit

Permalink
[RayCluster][Feature] add an e2e test for GcsFaultToleranceOptions
Browse files Browse the repository at this point in the history
Signed-off-by: Rueian <[email protected]>
  • Loading branch information
rueian committed Jan 4, 2025
1 parent 976a090 commit 8e3f506
Showing 1 changed file with 60 additions and 0 deletions.
60 changes: 60 additions & 0 deletions ray-operator/test/e2e/raycluster_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ import (
. "github.com/onsi/gomega"
"k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
appsv1ac "k8s.io/client-go/applyconfigurations/apps/v1"
corev1ac "k8s.io/client-go/applyconfigurations/core/v1"
metav1ac "k8s.io/client-go/applyconfigurations/meta/v1"
"k8s.io/utils/ptr"

rayv1 "github.com/ray-project/kuberay/ray-operator/apis/ray/v1"
Expand Down Expand Up @@ -121,3 +124,60 @@ func TestRayClusterSuspend(t *testing.T) {
g.Eventually(RayCluster(test, namespace.Name, rayCluster.Name), TestTimeoutMedium).
Should(WithTransform(StatusCondition(rayv1.RayClusterProvisioned), MatchCondition(metav1.ConditionTrue, rayv1.AllPodRunningAndReadyFirstTime)))
}

func TestRayClusterGCSFT(t *testing.T) {
test := With(t)
g := NewWithT(t)
// Create a namespace
namespace := test.NewTestNamespace()

_, err := test.Client().Core().AppsV1().Deployments(namespace.Name).Apply(
test.Ctx(),
appsv1ac.Deployment("redis", namespace.Name).
WithSpec(appsv1ac.DeploymentSpec().
WithReplicas(1).
WithSelector(metav1ac.LabelSelector().WithMatchLabels(map[string]string{"app": "redis"})).
WithTemplate(corev1ac.PodTemplateSpec().
WithLabels(map[string]string{"app": "redis"}).
WithSpec(corev1ac.PodSpec().
WithContainers(corev1ac.Container().
WithName("redis").
WithImage("redis:7.4").
WithPorts(corev1ac.ContainerPort().WithContainerPort(6379)).
WithCommand("redis-server", "--requirepass", "5241590000000000"),
),
),
),
),
TestApplyOptions,
)
g.Expect(err).NotTo(HaveOccurred())

_, err = test.Client().Core().CoreV1().Services(namespace.Name).Apply(
test.Ctx(),
corev1ac.Service("redis", namespace.Name).
WithSpec(corev1ac.ServiceSpec().
WithSelector(map[string]string{"app": "redis"}).
WithPorts(corev1ac.ServicePort().
WithPort(6379),
),
),
TestApplyOptions,
)
g.Expect(err).NotTo(HaveOccurred())

rayClusterAC := rayv1ac.RayCluster("raycluster-gcsft", namespace.Name).WithSpec(
newRayClusterSpec().WithGcsFaultToleranceOptions(
rayv1ac.GcsFaultToleranceOptions().WithRedisAddress("redis:6379").WithRedisPassword(
rayv1ac.RedisCredential().WithValue("5241590000000000")),
),
)

rayCluster, err := test.Client().Ray().RayV1().RayClusters(namespace.Name).Apply(test.Ctx(), rayClusterAC, TestApplyOptions)
g.Expect(err).NotTo(HaveOccurred())
test.T().Logf("Created RayCluster %s/%s successfully", rayCluster.Namespace, rayCluster.Name)

test.T().Logf("Waiting for RayCluster %s/%s to become ready", rayCluster.Namespace, rayCluster.Name)
g.Eventually(RayCluster(test, namespace.Name, rayCluster.Name), TestTimeoutMedium).
Should(WithTransform(StatusCondition(rayv1.RayClusterProvisioned), MatchCondition(metav1.ConditionTrue, rayv1.AllPodRunningAndReadyFirstTime)))
}

0 comments on commit 8e3f506

Please sign in to comment.