Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[RayService] Use Ready condition in e2e tests #2849

Merged
merged 1 commit into from
Jan 28, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 10 additions & 19 deletions ray-operator/test/e2erayservice/rayservice_redeploy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import (
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"

rayv1 "github.com/ray-project/kuberay/ray-operator/apis/ray/v1"
"github.com/ray-project/kuberay/ray-operator/controllers/ray/utils"
rayv1ac "github.com/ray-project/kuberay/ray-operator/pkg/client/applyconfiguration/ray/v1"
"github.com/ray-project/kuberay/ray-operator/test/sampleyaml"
Expand All @@ -30,7 +29,7 @@ func TestRedeployRayServe(t *testing.T) {

test.T().Logf("Waiting for RayService %s/%s to running", rayService.Namespace, rayService.Name)
g.Eventually(RayService(test, rayService.Namespace, rayService.Name), TestTimeoutMedium).
Should(WithTransform(RayServiceStatus, Equal(rayv1.Running)))
Should(WithTransform(IsRayServiceReady, BeTrue()))

// Get the latest RayService
rayService, err = GetRayService(test, namespace.Name, rayServiceName)
Expand All @@ -52,14 +51,10 @@ func TestRedeployRayServe(t *testing.T) {
test.T().Logf("Curl pod %s/%s is running and ready", namespace.Name, curlPodName)

test.T().Logf("Sending requests to the RayService to make sure it is ready to serve requests")
g.Eventually(func(g Gomega) {
// curl /fruit
stdout, _ := curlRayServicePod(test, rayService, curlPod, curlContainerName, "/fruit", `["MANGO", 2]`)
g.Expect(stdout.String()).To(Equal("6"))
// curl /calc
stdout, _ = curlRayServicePod(test, rayService, curlPod, curlContainerName, "/calc", `["MUL", 3]`)
g.Expect(stdout.String()).To(Equal("15 pizzas please!"))
}, TestTimeoutShort).Should(Succeed())
stdout, _ := curlRayServicePod(test, rayService, curlPod, curlContainerName, "/fruit", `["MANGO", 2]`)
g.Expect(stdout.String()).To(Equal("6"))
stdout, _ = curlRayServicePod(test, rayService, curlPod, curlContainerName, "/calc", `["MUL", 3]`)
g.Expect(stdout.String()).To(Equal("15 pizzas please!"))

test.T().Logf("Deleting the current Head for recreating a new one")
rayServiceUnderlyingRayCluster, err := GetRayCluster(test, namespace.Name, rayService.Status.ActiveServiceStatus.RayClusterName)
Expand All @@ -81,15 +76,11 @@ func TestRedeployRayServe(t *testing.T) {

test.T().Logf("Waiting for RayService %s/%s to running", rayService.Namespace, rayService.Name)
g.Eventually(RayService(test, rayService.Namespace, rayService.Name), TestTimeoutMedium).
Should(WithTransform(RayServiceStatus, Equal(rayv1.Running)))
Should(WithTransform(IsRayServiceReady, BeTrue()))

test.T().Logf("Sending requests to the RayService to make sure it is ready to serve requests")
g.Eventually(func(g Gomega) {
// curl /fruit
stdout, _ := curlRayServicePod(test, rayService, curlPod, curlContainerName, "/fruit", `["MANGO", 2]`)
g.Expect(stdout.String()).To(Equal("6"))
// curl /calc
stdout, _ = curlRayServicePod(test, rayService, curlPod, curlContainerName, "/calc", `["MUL", 3]`)
g.Expect(stdout.String()).To(Equal("15 pizzas please!"))
}, TestTimeoutShort).Should(Succeed())
stdout, _ = curlRayServicePod(test, rayService, curlPod, curlContainerName, "/fruit", `["MANGO", 2]`)
g.Expect(stdout.String()).To(Equal("6"))
stdout, _ = curlRayServicePod(test, rayService, curlPod, curlContainerName, "/calc", `["MUL", 3]`)
g.Expect(stdout.String()).To(Equal("15 pizzas please!"))
}
5 changes: 5 additions & 0 deletions ray-operator/test/support/ray.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"github.com/stretchr/testify/assert"

corev1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/meta"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"

rayv1 "github.com/ray-project/kuberay/ray-operator/apis/ray/v1"
Expand Down Expand Up @@ -194,6 +195,10 @@ func RayServiceStatus(service *rayv1.RayService) rayv1.ServiceStatus {
return service.Status.ServiceStatus
}

func IsRayServiceReady(service *rayv1.RayService) bool {
return meta.IsStatusConditionTrue(service.Status.Conditions, string(rayv1.RayServiceReady))
}

func RayServicesNumEndPoints(service *rayv1.RayService) int32 {
return service.Status.NumServeEndpoints
}
Expand Down
Loading