Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit350ddf6

Browse files
authored
Merge pull requestsorintlab#763 from sgotti/tests_store_context_timeout
tests: use test store context timeout
2 parentsfc6e568 +79ea0fc commit350ddf6

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

‎tests/integration/utils.go

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@ const (
5353

5454
var (
5555
defaultPGParameters= cluster.PGParameters{"log_destination":"stderr","logging_collector":"false"}
56+
57+
defaultStoreTimeout=1*time.Second
5658
)
5759

5860
varcurPort=MinPort
@@ -806,7 +808,6 @@ func (tp *TestProxy) WaitListening(timeout time.Duration) error {
806808
iferr==nil {
807809
returnnil
808810
}
809-
tp.t.Logf("tp: %v, error: %v",tp.uid,err)
810811
time.Sleep(sleepInterval)
811812
}
812813
returnfmt.Errorf("timeout")
@@ -824,7 +825,6 @@ func (tp *TestProxy) WaitNotListening(timeout time.Duration) error {
824825
iferr!=nil {
825826
returnnil
826827
}
827-
tp.t.Logf("tp: %v, error: %v",tp.uid,err)
828828
time.Sleep(sleepInterval)
829829
}
830830
returnfmt.Errorf("timeout")
@@ -1073,7 +1073,9 @@ func NewTestConsul(t *testing.T, dir string, a ...string) (*TestStore, error) {
10731073
func (ts*TestStore)WaitUp(timeout time.Duration)error {
10741074
start:=time.Now()
10751075
fortime.Now().Add(-timeout).Before(start) {
1076-
_,err:=ts.store.Get(context.TODO(),"anykey")
1076+
ctx,cancel:=context.WithTimeout(context.Background(),defaultStoreTimeout)
1077+
_,err:=ts.store.Get(ctx,"anykey")
1078+
cancel()
10771079
ts.t.Logf("err: %v",err)
10781080
iferr!=nil&&err==store.ErrKeyNotFound {
10791081
returnnil
@@ -1090,7 +1092,9 @@ func (ts *TestStore) WaitUp(timeout time.Duration) error {
10901092
func (ts*TestStore)WaitDown(timeout time.Duration)error {
10911093
start:=time.Now()
10921094
fortime.Now().Add(-timeout).Before(start) {
1093-
_,err:=ts.store.Get(context.TODO(),"anykey")
1095+
ctx,cancel:=context.WithTimeout(context.Background(),defaultStoreTimeout)
1096+
_,err:=ts.store.Get(ctx,"anykey")
1097+
cancel()
10941098
iferr!=nil&&err!=store.ErrKeyNotFound {
10951099
returnnil
10961100
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp