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 8738874 commit 6d1c496
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions ray-operator/test/support/yaml.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,46 +28,46 @@ func DeserializeRayClusterYAML(t Test, filename string) *rayv1.RayCluster {
t.T().Helper()
rayCluster := &rayv1.RayCluster{}
err := deserializeYAML(filename, rayCluster)
require.NoError(t.T(), err)
require.NoError(t.T(), err, "Fail to deserialize yaml file %s", filename)
return rayCluster
}

func DeserializeRayJobYAML(t Test, filename string) *rayv1.RayJob {
t.T().Helper()
rayJob := &rayv1.RayJob{}
err := deserializeYAML(filename, rayJob)
require.NoError(t.T(), err)
require.NoError(t.T(), err, "Fail to deserialize yaml file %s", filename)
return rayJob
}

func DeserializeRayServiceYAML(t Test, filename string) *rayv1.RayService {
t.T().Helper()
rayService := &rayv1.RayService{}
err := deserializeYAML(filename, rayService)
require.NoError(t.T(), err)
require.NoError(t.T(), err, "Fail to deserialize yaml file %s", filename)
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()
require.NoError(t.T(), err)
require.NoError(t.T(), err, "Failed to apply %s to namespace %s", filename, namespace)
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()
require.NoError(t.T(), err)
require.NoError(t.T(), err, "Failed to apply quota %s in %s", quota, namespace)
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()
require.NoError(t.T(), err)
require.NoError(t.T(), err, "Failed to delete pods in %s", namespace)
t.T().Logf("Successfully delete pods in %s", namespace)
}

0 comments on commit 6d1c496

Please sign in to comment.