Skip to content

Commit

Permalink
[RayCluster][CI] fail fast all support functions in test/support/yaml.go
Browse files Browse the repository at this point in the history
Signed-off-by: Rueian <[email protected]>
  • Loading branch information
rueian committed Dec 18, 2024
1 parent 013c1b2 commit 8738874
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions ray-operator/test/support/yaml.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"os"
"os/exec"

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"

"k8s.io/apimachinery/pkg/runtime"

Expand All @@ -28,48 +28,46 @@ func DeserializeRayClusterYAML(t Test, filename string) *rayv1.RayCluster {
t.T().Helper()
rayCluster := &rayv1.RayCluster{}
err := deserializeYAML(filename, rayCluster)
assert.NoError(t.T(), err)
require.NoError(t.T(), err)
return rayCluster
}

func DeserializeRayJobYAML(t Test, filename string) *rayv1.RayJob {
t.T().Helper()
rayJob := &rayv1.RayJob{}
err := deserializeYAML(filename, rayJob)
assert.NoError(t.T(), err)
require.NoError(t.T(), err)
return rayJob
}

func DeserializeRayServiceYAML(t Test, filename string) *rayv1.RayService {
t.T().Helper()
rayService := &rayv1.RayService{}
err := deserializeYAML(filename, rayService)
assert.NoError(t.T(), err)
require.NoError(t.T(), err)
return rayService
}

func KubectlApplyYAML(t Test, filename string, namespace string) {
t.T().Helper()
kubectlCmd := exec.CommandContext(t.Ctx(), "kubectl", "apply", "-f", filename, "-n", namespace)
err := kubectlCmd.Run()
if err != nil {
t.T().Fatalf("Failed to apply %s to namespace %s: %v", filename, namespace, err)
}
require.NoError(t.T(), err)
t.T().Logf("Successfully applied %s to namespace %s", filename, namespace)
}

func KubectlApplyQuota(t Test, namespace, quota string) {
t.T().Helper()
kubectlCmd := exec.CommandContext(t.Ctx(), "kubectl", "create", "quota", namespace, "-n", namespace, quota)
err := kubectlCmd.Run()
assert.NoError(t.T(), err)
require.NoError(t.T(), err)
t.T().Logf("Successfully applied quota %s in %s", quota, namespace)
}

func KubectlDeleteAllPods(t Test, namespace string) {
t.T().Helper()
kubectlCmd := exec.CommandContext(t.Ctx(), "kubectl", "delete", "--all", "pods", "-n", namespace)
err := kubectlCmd.Run()
assert.NoError(t.T(), err)
require.NoError(t.T(), err)
t.T().Logf("Successfully delete pods in %s", namespace)
}

0 comments on commit 8738874

Please sign in to comment.