goss-org / goss

Quick and Easy server testing/validation
https://goss.rocks
Apache License 2.0
5.5k stars 470 forks source link

Syntax error: redirection unexpected #797

Closed kmonticolo closed 1 year ago

kmonticolo commented 1 year ago

Describe the bug Rarely I got a syntax error from goss: "./goss: 1: Syntax error: redirection unexpected" and I got non-zero exit code.

How To Reproduce it's hard to reproduce, I got it 2-3 times during thousand runs. I ran it like this: "./goss -g test-dir/country/goss.yaml v"

Expected Behavior No "Syntax error", goss should working normally.

Actual Behavior Rarely I got a syntax error from goss: "./goss: 1: Syntax error: redirection unexpected" It's very rarely hapen so it's not easy to reproduce.

Environment:

ripienaar commented 1 year ago

We'd need to see the yaml file causing it.

aelsabbahy commented 1 year ago

Is your ./goss a shell script wrapping goss by any chance?

What do these say on good vs bad runs?

file ./goss
md5sum ./goss

Possibly, if you're downloading goss prior to every run, perhaps the download is an HTML error file with <...> type symbols confusing sh/bash?

Hard to tell without understanding your flow a bit better. If it is in fact being downloaded on every execution, perhaps add a call to md5sum ./goss and see if the error cases have the same checksum.

We'd need to see the yaml file causing it.

This also would be helpful.

kmonticolo commented 1 year ago

No, it was not a shell script, I just ran it like that because I did not add it to PATH. Previously I downloaded it from github site, but now I copied it to local repo to avoid downloading it from github for each time.

$ md5sum $(which goss)
315bfaa776f502fb2ecafb1bd93ff56f  goss
$ goss -v
goss version v0.3.20

yaml file consists of multiple command invokes, here is an example:

command:
  mysql --login-path=shared -u mysql_ro -h 10.1.10.230 -P 3306 db1 -e 'describe table1':
    exit-status: 0
    stdout:
    - "Field\tType\tNull\tKey\tDefault\tExtra"
    - "created\tdatetime\tNO\tPRI\tNULL"
    - "something\tint(10) unsigned\tNO\t\tNULL"
    - "<redacted>"
    stderr: []
    timeout: 10000
  mysql --login-path=shared -u mysql_ro -h 10.1.10.230 -P 3306 db1 -e 'describe table2':
    exit-status: 0
    stdout:
    - "Field\tType\tNull\tKey\tDefault\tExtra"
    - "id\tint(10) unsigned\tNO\tPRI\tNULL\tauto_increment"
    - "<redacted>"
    stderr: []
    timeout: 10000

and I run it:

 goss -g path/to/goss.yaml v
kmonticolo commented 1 year ago

I leaved just one test in yaml file and simulated execution for few thousand times in a loop and could not replicate this. Assuming that downloading the binary from github may causing this kind of problem.

aelsabbahy commented 1 year ago

Might not be a bad idea to add, the following to whatever it is that's running Goss.

md5sum $(which goss)

That could help identify if the failed ones are corrupted downloads. That's my gut feeling, but can't say for sure.

If you're fairly confident at this point that it's the download, I can close out this ticket and you're always welcome to reopen if it ends up being Goss that's the culprit.

kmonticolo commented 1 year ago

Okay, I'm going to close it. Thank you for the great job Ahmed.