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

[TEST] testsuite's shell library doesn't parse command output correctly if it doesn't end with newline #4416

Open
1 task
rohanKanojia opened this issue Oct 25, 2024 · 0 comments · May be fixed by #4417
Open
1 task

Comments

@rohanKanojia
Copy link
Contributor

Component

E2E Test Utilities

Description

Related to #4397

I encountered this issue while working on #4397 . I had two statements in my test feature file where I just curl application endpoint and verify whether we received expected response:

Then executing "curl -s http://quarkus-jkube-quarkus-app-deploy-flow-test.apps-crc.testing" succeeds
And stdout should contain "{\"applicationName\":\"JKube\",\"message\":\"Subatomic JKube really whips the llama's ass!\"}"

However, I was getting the actual output string as '', hence causing the assertion to fail.

On closer look to shell.go , it looks like we append a token of the command's exit code to command stdout. We split the command output by \n and expect the last line containing the exit code token exitCodeOfLastCommandInShell= .

Here while parsing command output we either write command output or exit code:

if strings.Contains(str, exitCodeIdentifier) && !strings.Contains(str, shell.checkExitCodeCmd) {
exitCode := strings.Split(str, "=")[1]
shell.exitCodeChannel <- exitCode
} else {
buffer.WriteString(str + "\n")
}

This works for most cases, however the application I was testing E2E test with didn't had output ending with a newline. So we were getting a line like this:

{"applicationName":"JKube","message":"Subatomic JKube really whips the llama's ass!"}exitCodeOfLastCommandInShell=0

Due to this command output was being ignored.

We should refactor this code to also extract any prefix before exit code token and also write it to output buffer.

Expected Behavior

Shell command should be correctly parsed regardless of whether it ends with newline or not

Acceptance Criteria

  • abovementioned code is refactored also to consider any prefix while parsing exit code token
rohanKanojia added a commit to rohankanojia-forks/crc that referenced this issue Oct 25, 2024
…without newline (crc-org#4416)

ScanPipe should not assume entire line to contain only the exit code
token. It should extract exit code token and write remainder output to
output buffer.

Signed-off-by: Rohan Kumar <[email protected]>
rohanKanojia added a commit to rohankanojia-forks/crc that referenced this issue Oct 25, 2024
…without newline (crc-org#4416)

ScanPipe should not assume entire line to contain only the exit code
token. It should extract exit code token and write remainder output to
output buffer.

Signed-off-by: Rohan Kumar <[email protected]>
rohanKanojia added a commit to rohankanojia-forks/crc that referenced this issue Oct 28, 2024
…without newline (crc-org#4416)

ScanPipe should not assume entire line to contain only the exit code
token. It should extract exit code token and write remainder output to
output buffer.

Signed-off-by: Rohan Kumar <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant