From d76f3894a216b5d18fc389acca4962db7b231f3f Mon Sep 17 00:00:00 2001 From: SimoTw Date: Fri, 29 Nov 2024 13:05:51 +0800 Subject: [PATCH] fix test isolation --- .../raycluster_autoscaler_test.go | 66 +++++++++---------- 1 file changed, 33 insertions(+), 33 deletions(-) diff --git a/ray-operator/test/e2eautoscaler/raycluster_autoscaler_test.go b/ray-operator/test/e2eautoscaler/raycluster_autoscaler_test.go index 2196285e22b..d244d2d7738 100644 --- a/ray-operator/test/e2eautoscaler/raycluster_autoscaler_test.go +++ b/ray-operator/test/e2eautoscaler/raycluster_autoscaler_test.go @@ -29,20 +29,20 @@ var tests = map[string]struct { } func TestRayClusterAutoscaler(t *testing.T) { - test := With(t) - g := NewWithT(t) + for name, tc := range tests { + test := With(t) + g := NewWithT(t) - // Create a namespace - namespace := test.NewTestNamespace() - test.StreamKubeRayOperatorLogs() + // Create a namespace + namespace := test.NewTestNamespace() + test.StreamKubeRayOperatorLogs() - // Scripts for creating and terminating detached actors to trigger autoscaling - scriptsAC := newConfigMap(namespace.Name, "scripts", files(test, "create_detached_actor.py", "terminate_detached_actor.py")) - scripts, err := test.Client().Core().CoreV1().ConfigMaps(namespace.Name).Apply(test.Ctx(), scriptsAC, TestApplyOptions) - g.Expect(err).NotTo(HaveOccurred()) - test.T().Logf("Created ConfigMap %s/%s successfully", scripts.Namespace, scripts.Name) + // Scripts for creating and terminating detached actors to trigger autoscaling + scriptsAC := newConfigMap(namespace.Name, "scripts", files(test, "create_detached_actor.py", "terminate_detached_actor.py")) + scripts, err := test.Client().Core().CoreV1().ConfigMaps(namespace.Name).Apply(test.Ctx(), scriptsAC, TestApplyOptions) + g.Expect(err).NotTo(HaveOccurred()) + test.T().Logf("Created ConfigMap %s/%s successfully", scripts.Namespace, scripts.Name) - for name, tc := range tests { test.T().Run(name, func(_ *testing.T) { rayClusterSpecAC := rayv1ac.RayClusterSpec(). WithEnableInTreeAutoscaling(true). @@ -98,20 +98,20 @@ func TestRayClusterAutoscaler(t *testing.T) { } func TestRayClusterAutoscalerWithFakeGPU(t *testing.T) { - test := With(t) - g := NewWithT(t) + for name, tc := range tests { - // Create a namespace - namespace := test.NewTestNamespace() - test.StreamKubeRayOperatorLogs() + test := With(t) + g := NewWithT(t) - // Scripts for creating and terminating detached actors to trigger autoscaling - scriptsAC := newConfigMap(namespace.Name, "scripts", files(test, "create_detached_actor.py", "terminate_detached_actor.py")) - scripts, err := test.Client().Core().CoreV1().ConfigMaps(namespace.Name).Apply(test.Ctx(), scriptsAC, TestApplyOptions) - g.Expect(err).NotTo(HaveOccurred()) - test.T().Logf("Created ConfigMap %s/%s successfully", scripts.Namespace, scripts.Name) + // Create a namespace + namespace := test.NewTestNamespace() + test.StreamKubeRayOperatorLogs() - for name, tc := range tests { + // Scripts for creating and terminating detached actors to trigger autoscaling + scriptsAC := newConfigMap(namespace.Name, "scripts", files(test, "create_detached_actor.py", "terminate_detached_actor.py")) + scripts, err := test.Client().Core().CoreV1().ConfigMaps(namespace.Name).Apply(test.Ctx(), scriptsAC, TestApplyOptions) + g.Expect(err).NotTo(HaveOccurred()) + test.T().Logf("Created ConfigMap %s/%s successfully", scripts.Namespace, scripts.Name) test.T().Run(name, func(_ *testing.T) { rayClusterSpecAC := rayv1ac.RayClusterSpec(). @@ -160,20 +160,20 @@ func TestRayClusterAutoscalerWithFakeGPU(t *testing.T) { } func TestRayClusterAutoscalerWithCustomResource(t *testing.T) { - test := With(t) - g := NewWithT(t) + for name, tc := range tests { - // Create a namespace - namespace := test.NewTestNamespace() - test.StreamKubeRayOperatorLogs() + test := With(t) + g := NewWithT(t) - // Scripts for creating and terminating detached actors to trigger autoscaling - scriptsAC := newConfigMap(namespace.Name, "scripts", files(test, "create_detached_actor.py", "terminate_detached_actor.py")) - scripts, err := test.Client().Core().CoreV1().ConfigMaps(namespace.Name).Apply(test.Ctx(), scriptsAC, TestApplyOptions) - g.Expect(err).NotTo(HaveOccurred()) - test.T().Logf("Created ConfigMap %s/%s successfully", scripts.Namespace, scripts.Name) + // Create a namespace + namespace := test.NewTestNamespace() + test.StreamKubeRayOperatorLogs() - for name, tc := range tests { + // Scripts for creating and terminating detached actors to trigger autoscaling + scriptsAC := newConfigMap(namespace.Name, "scripts", files(test, "create_detached_actor.py", "terminate_detached_actor.py")) + scripts, err := test.Client().Core().CoreV1().ConfigMaps(namespace.Name).Apply(test.Ctx(), scriptsAC, TestApplyOptions) + g.Expect(err).NotTo(HaveOccurred()) + test.T().Logf("Created ConfigMap %s/%s successfully", scripts.Namespace, scripts.Name) test.T().Run(name, func(_ *testing.T) { groupName := "custom-resource-group"