Skip to content

Commit

Permalink
fix: enable pipefail mode for grpcproxy test
Browse files Browse the repository at this point in the history
By default, the pipefail is disabled. For instance, the commands should
return 1 as exit code, but we get zero. After pipefail enabled, it's
back to normal.

```bash
$ ( echo hello; exit 1 ) | tee 2>&1
hello
$ echo $?
0

$ set -o pipefail
$ ( echo hello; exit 122 ) | tee 2>&1
hello
$ echo $?
122
```

And the test.log is used to grep the error from a ton of messages. So
that we should `set +e` and set it back after egrep.

fixes: #15487

Signed-off-by: Wei Fu <fuweid89@gmail.com>
  • Loading branch information
fuweid committed Mar 18, 2023
1 parent 2eabc0b commit 9d7354f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
6 changes: 5 additions & 1 deletion .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,12 @@ jobs:
GO_BUILD_FLAGS='-v' GOARCH=s390x ./build
;;
linux-amd64-grpcproxy)
set -o pipefail; set +e;
PASSES='build grpcproxy' CPU='4' RACE='true' ./test 2>&1 | tee test.log
! egrep "(--- FAIL:|DATA RACE|panic: test timed out|appears to have leaked)" -B50 -A10 test.log
ecode=$?
egrep "(--- FAIL:|DATA RACE|panic: test timed out|appears to have leaked)" -B50 -A10 test.log
set -e
exit ${ecode}
;;
linux-386-unit)
GOARCH=386 PASSES='unit' ./test
Expand Down
1 change: 1 addition & 0 deletions integration/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
)

func TestMain(m *testing.M) {
panic("panic: test timed out")
v := m.Run()
if v == 0 && testutil.CheckLeakedGoroutine() {
os.Exit(1)
Expand Down

0 comments on commit 9d7354f

Please sign in to comment.