-
Notifications
You must be signed in to change notification settings - Fork 442
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
[GCS FT] Redis e2e cleanup check #2773
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -81,7 +81,7 @@ func TestGcsFaultToleranceOptions(t *testing.T) { | |
g := NewWithT(t) | ||
namespace := test.NewTestNamespace() | ||
|
||
deployRedis(test, namespace.Name, tc.redisPassword) | ||
defer deployRedis(test, namespace.Name, tc.redisPassword)() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. what will the stack trace look like if the check in There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This trace is the defer approach: === RUN TestGcsFaultToleranceAnnotations/GCS_FT_without_redis_password
Modified Ray Image to: rayproject/ray:2.40.0-aarch64 for ARM chips
raycluster_gcsft_test.go:211: Created RayCluster test-ns-72s65/raycluster-gcsft successfully
raycluster_gcsft_test.go:213: Waiting for RayCluster test-ns-72s65/raycluster-gcsft to become ready
raycluster_gcsft_test.go:217: Verifying environment variables on Head Pod
support.go:253: failed cleanup redis expect 0 but got: 3
test.go:110: Retrieving Pod Container test-ns-72s65/redis/redis logs
test.go:98: Creating ephemeral output directory as KUBERAY_TEST_OUTPUT_DIR env variable is unset
test.go:101: Output directory has been created at: /var/folders/sw/cyfhnvns2hv82r3fj1sgwsb00000gn/T/TestGcsFaultToleranceAnnotationsGCS_FT_without_redis_password2730163886/001
--- FAIL: TestGcsFaultToleranceAnnotations/GCS_FT_without_redis_password (48.50s) This one is the trace for === RUN TestGcsFaultToleranceAnnotations/GCS_FT_without_redis_password
Modified Ray Image to: rayproject/ray:2.40.0-aarch64 for ARM chips
raycluster_gcsft_test.go:214: Created RayCluster test-ns-s257l/raycluster-gcsft successfully
raycluster_gcsft_test.go:216: Waiting for RayCluster test-ns-s257l/raycluster-gcsft to become ready
raycluster_gcsft_test.go:220: Verifying environment variables on Head Pod
core.go:88: Executing command: [redis-cli --no-auth-warning DBSIZE]
core.go:101: Command stdout: 3
core.go:102: Command stderr:
...
core.go:88: Executing command: [redis-cli --no-auth-warning DBSIZE]
core.go:101: Command stdout: 3
core.go:102: Command stderr:
core.go:88: Executing command: [redis-cli --no-auth-warning DBSIZE]
core.go:101: Command stdout: 3
core.go:102: Command stderr:
raycluster_gcsft_test.go:236:
Timed out after 30.072s.
Expected
<string>: 3
to be equivalent to
<string>: 0
test.go:110: Retrieving Pod Container test-ns-s257l/redis/redis logs
test.go:98: Creating ephemeral output directory as KUBERAY_TEST_OUTPUT_DIR env variable is unset
test.go:101: Output directory has been created at: /var/folders/sw/cyfhnvns2hv82r3fj1sgwsb00000gn/T/TestGcsFaultToleranceAnnotationsGCS_FT_without_redis_password315262234/001
--- FAIL: TestGcsFaultToleranceAnnotations/GCS_FT_without_redis_password (51.40s) |
||
|
||
if tc.createSecret { | ||
test.T().Logf("Creating Redis password secret") | ||
|
@@ -116,6 +116,9 @@ func TestGcsFaultToleranceOptions(t *testing.T) { | |
} else { | ||
g.Expect(utils.EnvVarExists(utils.REDIS_PASSWORD, headPod.Spec.Containers[utils.RayContainerIndex].Env)).Should(BeTrue()) | ||
} | ||
|
||
err = test.Client().Ray().RayV1().RayClusters(namespace.Name).Delete(test.Ctx(), rayCluster.Name, metav1.DeleteOptions{}) | ||
g.Expect(err).NotTo(HaveOccurred()) | ||
}) | ||
} | ||
} | ||
|
@@ -171,7 +174,7 @@ func TestGcsFaultToleranceAnnotations(t *testing.T) { | |
redisPassword = tc.redisPasswordInRayStartParams | ||
} | ||
|
||
deployRedis(test, namespace.Name, redisPassword) | ||
defer deployRedis(test, namespace.Name, redisPassword)() | ||
|
||
// Prepare RayCluster ApplyConfiguration | ||
podTemplateAC := headPodTemplateApplyConfiguration() | ||
|
@@ -224,6 +227,9 @@ func TestGcsFaultToleranceAnnotations(t *testing.T) { | |
} else { | ||
g.Expect(utils.EnvVarExists(utils.REDIS_PASSWORD, headPod.Spec.Containers[utils.RayContainerIndex].Env)).Should(BeTrue()) | ||
} | ||
|
||
err = test.Client().Ray().RayV1().RayClusters(namespace.Name).Delete(test.Ctx(), rayCluster.Name, metav1.DeleteOptions{}) | ||
g.Expect(err).NotTo(HaveOccurred()) | ||
}) | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,17 @@ | ||
package e2e | ||
|
||
import ( | ||
"bytes" | ||
"embed" | ||
"strings" | ||
"time" | ||
|
||
"github.com/stretchr/testify/assert" | ||
corev1 "k8s.io/api/core/v1" | ||
"k8s.io/apimachinery/pkg/api/resource" | ||
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/client-go/kubernetes/scheme" | ||
"k8s.io/client-go/tools/remotecommand" | ||
|
||
rayv1ac "github.com/ray-project/kuberay/ray-operator/pkg/client/applyconfiguration/ray/v1" | ||
. "github.com/ray-project/kuberay/ray-operator/test/support" | ||
|
@@ -177,26 +180,20 @@ func jobSubmitterPodTemplateApplyConfiguration() *corev1ac.PodTemplateSpecApplyC | |
})))) | ||
} | ||
|
||
func deployRedis(t Test, namespace string, password string) { | ||
func deployRedis(t Test, namespace string, password string) func() { | ||
redisContainer := corev1ac.Container().WithName("redis").WithImage("redis:7.4"). | ||
WithPorts(corev1ac.ContainerPort().WithContainerPort(6379)) | ||
dbSizeCmd := []string{"redis-cli", "--no-auth-warning", "DBSIZE"} | ||
if password != "" { | ||
redisContainer.WithCommand("redis-server", "--requirepass", password) | ||
dbSizeCmd = []string{"redis-cli", "--no-auth-warning", "-a", password, "DBSIZE"} | ||
} | ||
|
||
_, err := t.Client().Core().AppsV1().Deployments(namespace).Apply( | ||
_, err := t.Client().Core().CoreV1().Pods(namespace).Apply( | ||
t.Ctx(), | ||
appsv1ac.Deployment("redis", namespace). | ||
WithSpec(appsv1ac.DeploymentSpec(). | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. no need for us to use Deployment for Redis in tests. just use Pod instead. |
||
WithReplicas(1). | ||
WithSelector(metav1ac.LabelSelector().WithMatchLabels(map[string]string{"app": "redis"})). | ||
WithTemplate(corev1ac.PodTemplateSpec(). | ||
WithLabels(map[string]string{"app": "redis"}). | ||
WithSpec(corev1ac.PodSpec(). | ||
WithContainers(redisContainer), | ||
), | ||
), | ||
), | ||
corev1ac.Pod("redis", namespace). | ||
WithLabels(map[string]string{"app": "redis"}). | ||
WithSpec(corev1ac.PodSpec().WithContainers(redisContainer)), | ||
TestApplyOptions, | ||
) | ||
assert.NoError(t.T(), err) | ||
|
@@ -213,4 +210,46 @@ func deployRedis(t Test, namespace string, password string) { | |
TestApplyOptions, | ||
) | ||
assert.NoError(t.T(), err) | ||
|
||
checkDBSize := func() string { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 |
||
req := t.Client().Core().CoreV1().RESTClient().Post().Resource("pods"). | ||
Namespace(namespace).Name("redis").SubResource("exec"). | ||
VersionedParams(&corev1.PodExecOptions{ | ||
Container: "redis", | ||
Command: dbSizeCmd, | ||
Stdin: false, | ||
Stdout: true, | ||
Stderr: true, | ||
}, scheme.ParameterCodec) | ||
|
||
stdout := bytes.NewBuffer(nil) | ||
stderr := bytes.NewBuffer(nil) | ||
|
||
config := t.Client().Config() | ||
|
||
executor, err := remotecommand.NewSPDYExecutor(&config, "POST", req.URL()) | ||
if err != nil { | ||
t.T().Fatalf("failed to create executor: %v", err) | ||
} | ||
|
||
err = executor.StreamWithContext(t.Ctx(), remotecommand.StreamOptions{ | ||
Stdout: stdout, | ||
Stderr: stderr, | ||
}) | ||
if err != nil { | ||
t.T().Fatalf("failed to execute: %v", err) | ||
} | ||
|
||
return strings.TrimSpace(stdout.String() + stderr.String()) | ||
} | ||
return func() { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe only return There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 |
||
var output string | ||
for i := 0; i < 30; i++ { | ||
if output = checkDBSize(); output == "0" { | ||
return | ||
} | ||
time.Sleep(time.Second) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Wait for the cleanup job. |
||
} | ||
t.T().Fatalf("failed cleanup redis expect 0 but got: %s", output) | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
would you mind explaining the change?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Without the change, we could pass
None
to the password parameter and resulting in this error: