clientv3: do not reconnect on request context cancellation

This commit is contained in:
Anthony Romano
2016-03-03 12:57:38 -08:00
parent e3b755e9e0
commit 16c35167df
8 changed files with 56 additions and 15 deletions

View File

@ -15,9 +15,11 @@
package clientv3
import (
"fmt"
"testing"
"time"
"github.com/coreos/etcd/Godeps/_workspace/src/golang.org/x/net/context"
"github.com/coreos/etcd/Godeps/_workspace/src/google.golang.org/grpc"
)
@ -52,3 +54,17 @@ func TestDialTimeout(t *testing.T) {
}
}
}
func TestIsHalted(t *testing.T) {
if !isHalted(nil, fmt.Errorf("etcdserver: some etcdserver error")) {
t.Errorf(`error prefixed with "etcdserver: " should be Halted`)
}
ctx, cancel := context.WithCancel(context.TODO())
if isHalted(ctx, nil) {
t.Errorf("no error and active context should not be Halted")
}
cancel()
if !isHalted(ctx, nil) {
t.Errorf("cancel on context should be Halted")
}
}