close grpc server in test file to avoid goroutine leak

Signed-off-by: cyclinder <kuocyclinder@gmail.com>
This commit is contained in:
cyclinder 2023-02-08 21:40:21 +08:00
parent b0171f77f6
commit 1bdcd18bf6

View File

@ -198,6 +198,9 @@ func Test_Run_Positive_Register(t *testing.T) {
pluginName := fmt.Sprintf("example-plugin") pluginName := fmt.Sprintf("example-plugin")
p := pluginwatcher.NewTestExamplePlugin(pluginName, registerapi.DevicePlugin, socketPath, supportedVersions...) p := pluginwatcher.NewTestExamplePlugin(pluginName, registerapi.DevicePlugin, socketPath, supportedVersions...)
require.NoError(t, p.Serve("v1beta1", "v1beta2")) require.NoError(t, p.Serve("v1beta1", "v1beta2"))
defer func() {
require.NoError(t, p.Stop())
}()
timestampBeforeRegistration := time.Now() timestampBeforeRegistration := time.Now()
dsw.AddOrUpdatePlugin(socketPath) dsw.AddOrUpdatePlugin(socketPath)
waitForRegistration(t, socketPath, timestampBeforeRegistration, asw) waitForRegistration(t, socketPath, timestampBeforeRegistration, asw)