Skip to content

Commit

Permalink
integration,proxy: Skip WatchRequestProgress test in grpc-proxy mode.
Browse files Browse the repository at this point in the history
Fixes:
  go test -tags cluster_proxy ./clientv3/integration -v -run TestWatchRequestProgress

Does not fail the grpc-server (completely) by a not implemented RPC.
Failing whole server by remote request is anti-pattern and security
risk.

Prior to the fix, the command line above was failing with:

```
=== RUN   TestWatchRequestProgress/0-watcher
panic: not implemented

goroutine 602 [running]:
go.etcd.io/etcd/v3/proxy/grpcproxy.(*watchProxyStream).recvLoop(0xc0004779d0, 0x0, 0x0)
	/home/ptab/corp/etcd/proxy/grpcproxy/watch.go:275 +0xac5
go.etcd.io/etcd/v3/proxy/grpcproxy.(*watchProxy).Watch.func1(0xc0034f94a0, 0xc0004779d0)
	/home/ptab/corp/etcd/proxy/grpcproxy/watch.go:129 +0x53
created by go.etcd.io/etcd/v3/proxy/grpcproxy.(*watchProxy).Watch
	/home/ptab/corp/etcd/proxy/grpcproxy/watch.go:127 +0x3c8
FAIL	go.etcd.io/etcd/v3/clientv3/integration	0.215s
FAIL
```
  • Loading branch information
ptabor committed Sep 19, 2020
1 parent 6d5b77b commit 5f9a139
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 5 deletions.
3 changes: 3 additions & 0 deletions clientv3/integration/watch_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -609,6 +609,9 @@ func TestConfigurableWatchProgressNotifyInterval(t *testing.T) {
}

func TestWatchRequestProgress(t *testing.T) {
if integration.ThroughProxy {
t.Skipf("grpc-proxy does not support WatchProgress yet")
}
testCases := []struct {
name string
watchers []string
Expand Down
2 changes: 1 addition & 1 deletion integration/cluster_direct.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import (
pb "go.etcd.io/etcd/v3/etcdserver/etcdserverpb"
)

const throughProxy = false
const ThroughProxy = false

func toGRPC(c *clientv3.Client) grpcAPI {
return grpcAPI{
Expand Down
2 changes: 1 addition & 1 deletion integration/cluster_proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import (
"go.uber.org/zap"
)

const throughProxy = true
const ThroughProxy = true

var (
pmu sync.Mutex
Expand Down
4 changes: 2 additions & 2 deletions integration/v3_watch_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1242,7 +1242,7 @@ func TestV3WatchCancellation(t *testing.T) {
}

var expected string
if throughProxy {
if ThroughProxy {
// grpc proxy has additional 2 watches open
expected = "3"
} else {
Expand Down Expand Up @@ -1279,7 +1279,7 @@ func TestV3WatchCloseCancelRace(t *testing.T) {
}

var expected string
if throughProxy {
if ThroughProxy {
// grpc proxy has additional 2 watches open
expected = "2"
} else {
Expand Down
3 changes: 2 additions & 1 deletion proxy/grpcproxy/watch.go
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,8 @@ func (wps *watchProxyStream) recvLoop() error {
wps.delete(uv.CancelRequest.WatchId)
wps.lg.Debug("cancel watcher", zap.Int64("watcherId", uv.CancelRequest.WatchId))
default:
panic("not implemented")
// Panic or Fatalf would allow to network clients to crash the serve remotely.
wps.lg.Error("not supported request type by gRPC proxy", zap.Stringer("request", req))
}
}
}
Expand Down

0 comments on commit 5f9a139

Please sign in to comment.