Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Add Fail logs for Inference w/ Adapter test #516

Merged
merged 2 commits into from
Jul 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading