Skip to content

e2e test enhancement#141

Open
gshikhar2021 wants to merge 1 commit intoredhat-data-and-ai:mainfrom
gshikhar2021:enhance-e2e
Open

e2e test enhancement#141
gshikhar2021 wants to merge 1 commit intoredhat-data-and-ai:mainfrom
gshikhar2021:enhance-e2e

Conversation

@gshikhar2021
Copy link
Copy Markdown
Contributor

  • removed using grep command on logs
  • Using exec command with timeout

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request refactors the Ollama embedding service setup in the E2E tests by splitting model operations into separate commands with 10-minute timeouts. Feedback points out a compilation error involving io.ReadAll on a string type, recommends removing the unused io import, and suggests quoting a jsonpath expression for shell safety.

Comment on lines +252 to +256
outBytes, err := io.ReadAll(p.Out())
if err != nil {
return fmt.Errorf("failed to read pod name output: %v", err)
}
ollamaPod := podNameOutput.Out()
podName := strings.TrimSpace(string(outBytes))
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

critical

The utils.RunCommand function from sigs.k8s.io/e2e-framework/pkg/utils returns a *CmdResult where Out() returns a string. Passing a string to io.ReadAll will cause a compilation error. Since the output is already a string, you can directly trim it.

Suggested change
outBytes, err := io.ReadAll(p.Out())
if err != nil {
return fmt.Errorf("failed to read pod name output: %v", err)
}
ollamaPod := podNameOutput.Out()
podName := strings.TrimSpace(string(outBytes))
podName := strings.TrimSpace(p.Out())

import (
"context"
"fmt"
"io"
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The io package is no longer needed if the io.ReadAll call is removed as suggested below.

log.Printf("Failed to get Ollama pod name: %s", podNameOutput.Err())
return podNameOutput.Err()
cmd := fmt.Sprintf(
"kubectl get pods -n %s -l app=ollama-embedding -o jsonpath={.items[0].metadata.name}",
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

It is recommended to wrap the jsonpath expression in single quotes to prevent potential shell expansion of the curly braces, especially since utils.RunCommand executes the command via a shell.

Suggested change
"kubectl get pods -n %s -l app=ollama-embedding -o jsonpath={.items[0].metadata.name}",
"kubectl get pods -n %s -l app=ollama-embedding -o jsonpath='{.items[0].metadata.name}'",

- removed using grep command on logs
- Using exec command with timeout
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Minute)
defer cancel()

pullCmd := exec.CommandContext(ctx, "kubectl", "exec", "-n", testNamespace, podName, "--", "ollama", "pull", "nomic-embed-text:latest")
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

whats the difference between previous implementation and this implementation

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants