Skip to content

Commit

Permalink
Provide more context
Browse files Browse the repository at this point in the history
  • Loading branch information
sutaakar committed Jul 11, 2024
1 parent 677417b commit 52693db
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions test/e2e/mnist_pytorch_appwrapper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,11 @@ package e2e
import (
"testing"

"github.com/onsi/gomega"
. "github.com/onsi/gomega"
mcadv1beta2 "github.com/project-codeflare/appwrapper/api/v1beta2"
. "github.com/project-codeflare/codeflare-common/support"
"gopkg.in/yaml.v2"

batchv1 "k8s.io/api/batch/v1"
corev1 "k8s.io/api/core/v1"
Expand All @@ -44,6 +46,11 @@ func runMnistPyTorchAppWrapper(t *testing.T, accelerator string) {

// Create a namespace and localqueue in that namespace
namespace := test.NewTestNamespace()

test.T().Cleanup(func() {
storeLocalQueue(test, namespace)
})

localQueue := CreateKueueLocalQueue(test, namespace.Name, "e2e-cluster-queue")

// Test configuration
Expand Down Expand Up @@ -171,3 +178,36 @@ func runMnistPyTorchAppWrapper(t *testing.T, accelerator string) {
WithTransform(AppWrapperPhase, Equal(mcadv1beta2.AppWrapperFailed)),
))
}

func storeLocalQueue(t Test, namespace *corev1.Namespace) {
t.T().Helper()

lqs, err := t.Client().Kueue().KueueV1beta1().LocalQueues(namespace.Name).List(t.Ctx(), metav1.ListOptions{})
t.Expect(err).NotTo(gomega.HaveOccurred())

for _, lq := range lqs.Items {
var resource map[string]interface{}
resource, err = runtime.DefaultUnstructuredConverter.ToUnstructured(&lq)
t.Expect(err).NotTo(gomega.HaveOccurred())
lqByte, err := yaml.Marshal(resource)
t.Expect(err).NotTo(gomega.HaveOccurred())

WriteToOutputDir(t, lq.Name, Log, lqByte)
}
}

func storeWorkload(t Test, namespace *corev1.Namespace) {
t.T().Helper()

workloads := GetKueueWorkloads(t, namespace.Name)

for _, workload := range workloads {
var resource map[string]interface{}
resource, err := runtime.DefaultUnstructuredConverter.ToUnstructured(&workload)
t.Expect(err).NotTo(gomega.HaveOccurred())
workloadByte, err := yaml.Marshal(resource)
t.Expect(err).NotTo(gomega.HaveOccurred())

WriteToOutputDir(t, workload.Name, Log, workloadByte)
}
}

0 comments on commit 52693db

Please sign in to comment.