Skip to content

Commit

Permalink
test: use require.Eventually instead of sleep (#201)
Browse files Browse the repository at this point in the history
  • Loading branch information
Ehco1996 authored Jan 30, 2023
1 parent e9b628c commit 1af49c8
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ COMMIT ?= $(shell git describe --match=NeVeRmAtCh --always --abbrev=40 --dirty)
DEBUG ?=
DOCKERPREFIX ?=
BUILD_TAGS ?=
LDFLAGS ?=
LDFLAGS ?=
BUILDFLAGS ?= -gcflags '$(GCFLAGS)' -ldflags '$(LDFLAGS) -X main.Version=$(VERSION) -X main.Commit=$(COMMIT)' -tags '$(BUILD_TAGS)'
ifneq ("$(DEBUG)", "")
BUILDFLAGS += -race
Expand Down
5 changes: 3 additions & 2 deletions pkg/proxy/backend/backend_conn_mgr_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -646,8 +646,9 @@ func TestGracefulCloseWhenActive(t *testing.T) {
{
proxy: func(_, _ *pnet.PacketIO) error {
ts.mp.GracefulClose()
time.Sleep(300 * time.Millisecond)
require.Equal(t, statusNotifyClose, ts.mp.closeStatus.Load())
require.Eventually(t, func() bool {
return statusNotifyClose == ts.mp.closeStatus.Load()
}, 300*time.Millisecond, 100*time.Millisecond)
return nil
},
},
Expand Down

0 comments on commit 1af49c8

Please sign in to comment.