@@ -53,6 +53,8 @@ const (
53
53
54
54
var (
55
55
defaultPGParameters = cluster.PGParameters {"log_destination" : "stderr" , "logging_collector" : "false" }
56
+
57
+ defaultStoreTimeout = 1 * time .Second
56
58
)
57
59
58
60
var curPort = MinPort
@@ -806,7 +808,6 @@ func (tp *TestProxy) WaitListening(timeout time.Duration) error {
806
808
if err == nil {
807
809
return nil
808
810
}
809
- tp .t .Logf ("tp: %v, error: %v" , tp .uid , err )
810
811
time .Sleep (sleepInterval )
811
812
}
812
813
return fmt .Errorf ("timeout" )
@@ -824,7 +825,6 @@ func (tp *TestProxy) WaitNotListening(timeout time.Duration) error {
824
825
if err != nil {
825
826
return nil
826
827
}
827
- tp .t .Logf ("tp: %v, error: %v" , tp .uid , err )
828
828
time .Sleep (sleepInterval )
829
829
}
830
830
return fmt .Errorf ("timeout" )
@@ -1073,7 +1073,9 @@ func NewTestConsul(t *testing.T, dir string, a ...string) (*TestStore, error) {
1073
1073
func (ts * TestStore ) WaitUp (timeout time.Duration ) error {
1074
1074
start := time .Now ()
1075
1075
for time .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 ()
1077
1079
ts .t .Logf ("err: %v" , err )
1078
1080
if err != nil && err == store .ErrKeyNotFound {
1079
1081
return nil
@@ -1090,7 +1092,9 @@ func (ts *TestStore) WaitUp(timeout time.Duration) error {
1090
1092
func (ts * TestStore ) WaitDown (timeout time.Duration ) error {
1091
1093
start := time .Now ()
1092
1094
for time .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 ()
1094
1098
if err != nil && err != store .ErrKeyNotFound {
1095
1099
return nil
1096
1100
}
0 commit comments