From f6aa9bcf172e2c12da9ff211624bf214baffd815 Mon Sep 17 00:00:00 2001 From: Ryan Leung Date: Mon, 5 Feb 2024 16:02:07 +0800 Subject: [PATCH] fix test Signed-off-by: Ryan Leung --- tests/integrations/client/global_config_test.go | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/tests/integrations/client/global_config_test.go b/tests/integrations/client/global_config_test.go index aeb704c3305..c52a35159b0 100644 --- a/tests/integrations/client/global_config_test.go +++ b/tests/integrations/client/global_config_test.go @@ -15,6 +15,7 @@ package client_test import ( + "context" "path" "strconv" "testing" @@ -37,7 +38,8 @@ import ( const globalConfigPath = "/global/config/" type testReceiver struct { - re *require.Assertions + re *require.Assertions + ctx context.Context grpc.ServerStream } @@ -49,6 +51,10 @@ func (s testReceiver) Send(m *pdpb.WatchGlobalConfigResponse) error { return nil } +func (s testReceiver) Context() context.Context { + return s.ctx +} + type globalConfigTestSuite struct { suite.Suite server *server.GrpcServer @@ -199,7 +205,9 @@ func (suite *globalConfigTestSuite) TestWatch() { re.NoError(err) } }() - server := testReceiver{re: suite.Require()} + ctx, cancel := context.WithCancel(suite.server.Context()) + defer cancel() + server := testReceiver{re: suite.Require(), ctx: ctx} go suite.server.WatchGlobalConfig(&pdpb.WatchGlobalConfigRequest{ ConfigPath: globalConfigPath, Revision: 0,