Skip to content

Commit

Permalink
fix: Add Fail logs for Inference w/ Adapter test (#516)
Browse files Browse the repository at this point in the history
**Reason for Change**:
Add fail logs for inference with adapter test
  • Loading branch information
ishaansehgal99 authored Jul 15, 2024
1 parent 7d1dc82 commit 78544e1
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 28 deletions.
9 changes: 9 additions & 0 deletions test/e2e/inference_with_adapters.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,15 @@ var _ = Describe("Workspace Preset", func() {
loadModelVersions()
})

AfterEach(func() {
if CurrentSpecReport().Failed() {
utils.PrintPodLogsOnFailure(namespaceName, "") // The Preset Pod
utils.PrintPodLogsOnFailure("kaito-workspace", "") // The Kaito Workspace Pod
utils.PrintPodLogsOnFailure("gpu-provisioner", "") // The gpu-provisioner Pod
Fail("Fail threshold reached")
}
})

It("should create a falcon workspace with adapter", func() {
numOfNode := 1
workspaceObj := createCustomWorkspaceWithAdapter(numOfNode)
Expand Down
31 changes: 3 additions & 28 deletions test/e2e/preset_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -533,31 +533,6 @@ func deleteWorkspace(workspaceObj *kaitov1alpha1.Workspace) error {
return nil
}

func printPodLogsOnFailure(namespace, labelSelector string) {
coreClient, err := utils.GetK8sConfig()
if err != nil {
log.Printf("Failed to create core client: %v", err)
}
pods, err := coreClient.CoreV1().Pods(namespace).List(ctx, metav1.ListOptions{
LabelSelector: labelSelector,
})
if err != nil {
log.Printf("Failed to list pods: %v", err)
return
}

for _, pod := range pods.Items {
for _, container := range pod.Spec.Containers {
logs, err := utils.GetPodLogs(coreClient, namespace, pod.Name, container.Name)
if err != nil {
log.Printf("Failed to get logs from pod %s, container %s: %v", pod.Name, container.Name, err)
} else {
fmt.Printf("Logs from pod %s, container %s:\n%s\n", pod.Name, container.Name, string(logs))
}
}
}
}

var runLlama13B bool
var aiModelsRegistry string
var aiModelsRegistrySecret string
Expand All @@ -574,9 +549,9 @@ var _ = Describe("Workspace Preset", func() {

AfterEach(func() {
if CurrentSpecReport().Failed() {
printPodLogsOnFailure(namespaceName, "") // The Preset Pod
printPodLogsOnFailure("kaito-workspace", "") // The Kaito Workspace Pod
printPodLogsOnFailure("gpu-provisioner", "") // The gpu-provisioner Pod
utils.PrintPodLogsOnFailure(namespaceName, "") // The Preset Pod
utils.PrintPodLogsOnFailure("kaito-workspace", "") // The Kaito Workspace Pod
utils.PrintPodLogsOnFailure("gpu-provisioner", "") // The gpu-provisioner Pod
Fail("Fail threshold reached")
}
})
Expand Down
25 changes: 25 additions & 0 deletions test/e2e/utils/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,31 @@ func GetPodLogs(coreClient *kubernetes.Clientset, namespace, podName, containerN
return buf.String(), nil
}

func PrintPodLogsOnFailure(namespace, labelSelector string) {
coreClient, err := GetK8sConfig()
if err != nil {
log.Printf("Failed to create core client: %v", err)
}
pods, err := coreClient.CoreV1().Pods(namespace).List(context.Background(), metav1.ListOptions{
LabelSelector: labelSelector,
})
if err != nil {
log.Printf("Failed to list pods: %v", err)
return
}

for _, pod := range pods.Items {
for _, container := range pod.Spec.Containers {
logs, err := GetPodLogs(coreClient, namespace, pod.Name, container.Name)
if err != nil {
log.Printf("Failed to get logs from pod %s, container %s: %v", pod.Name, container.Name, err)
} else {
fmt.Printf("Logs from pod %s, container %s:\n%s\n", pod.Name, container.Name, string(logs))
}
}
}
}

func CopySecret(original *corev1.Secret, targetNamespace string) *corev1.Secret {
newSecret := &corev1.Secret{
ObjectMeta: metav1.ObjectMeta{
Expand Down

0 comments on commit 78544e1

Please sign in to comment.