From 2d43a3157e36234fea1bfeadafe2be6f49daaf39 Mon Sep 17 00:00:00 2001 From: Piotr Tabor Date: Mon, 7 Sep 2020 20:08:29 +0200 Subject: [PATCH] integration: Fix 'go test --tags cluster_proxy --timeout=30m -v ./integration/...' grpc proxy opens additional 2 watching channels. The metric is shared between etcd-server & grpc_proxy, so all assertions on number of open watch channels need to take in consideration the additional "2" channels. --- integration/cluster_direct.go | 2 ++ integration/cluster_proxy.go | 2 ++ integration/v3_watch_test.go | 24 ++++++++++++++++++++---- 3 files changed, 24 insertions(+), 4 deletions(-) diff --git a/integration/cluster_direct.go b/integration/cluster_direct.go index 600cabe30..a3764d9ce 100644 --- a/integration/cluster_direct.go +++ b/integration/cluster_direct.go @@ -23,6 +23,8 @@ import ( pb "go.etcd.io/etcd/v3/etcdserver/etcdserverpb" ) +const throughProxy = false + func toGRPC(c *clientv3.Client) grpcAPI { return grpcAPI{ pb.NewClusterClient(c.ActiveConnection()), diff --git a/integration/cluster_proxy.go b/integration/cluster_proxy.go index 16587bf3c..0b024c719 100644 --- a/integration/cluster_proxy.go +++ b/integration/cluster_proxy.go @@ -27,6 +27,8 @@ import ( "go.uber.org/zap" ) +const throughProxy = true + var ( pmu sync.Mutex proxies map[*clientv3.Client]grpcClientProxy = make(map[*clientv3.Client]grpcClientProxy) diff --git a/integration/v3_watch_test.go b/integration/v3_watch_test.go index 4ae371973..1717c0537 100644 --- a/integration/v3_watch_test.go +++ b/integration/v3_watch_test.go @@ -1241,8 +1241,16 @@ func TestV3WatchCancellation(t *testing.T) { t.Fatal(err) } - if minWatches != "1" { - t.Fatalf("expected one watch, got %s", minWatches) + var expected string + if throughProxy { + // grpc proxy has additional 2 watches open + expected = "3" + } else { + expected = "1" + } + + if minWatches != expected { + t.Fatalf("expected %s watch, got %s", expected, minWatches) } } @@ -1270,7 +1278,15 @@ func TestV3WatchCloseCancelRace(t *testing.T) { t.Fatal(err) } - if minWatches != "0" { - t.Fatalf("expected zero watches, got %s", minWatches) + var expected string + if throughProxy { + // grpc proxy has additional 2 watches open + expected = "2" + } else { + expected = "0" + } + + if minWatches != expected { + t.Fatalf("expected %s watch, got %s", expected, minWatches) } }