From f5eb8bef89cd1229e01d527092e00d7b358dbfb2 Mon Sep 17 00:00:00 2001 From: Ivan Kozlovic Date: Thu, 6 May 2021 10:37:26 -0600 Subject: [PATCH] Fixed some tests to manually close account resolver Those tests don't really start the server, so the account resolver's internal expiration routine would be left running. Doing an explicit close solves this issue. Signed-off-by: Ivan Kozlovic --- server/jwt_test.go | 3 +++ server/leafnode_test.go | 3 +++ 2 files changed, 6 insertions(+) diff --git a/server/jwt_test.go b/server/jwt_test.go index bcc4cc73..3f18deaf 100644 --- a/server/jwt_test.go +++ b/server/jwt_test.go @@ -5755,6 +5755,9 @@ func TestJWTNoSystemAccountButNatsResolver(t *testing.T) { defer removeFile(t, conf) opts := LoadConfig(conf) s, err := NewServer(opts) + // Since the server cannot be stopped, since it did not start, + // let's manually close the account resolver to avoid leaking go routines. + opts.AccountResolver.Close() s.Shutdown() require_Error(t, err) require_Contains(t, err.Error(), "the system account needs to be specified in configuration or the operator jwt") diff --git a/server/leafnode_test.go b/server/leafnode_test.go index 7da76420..062a3548 100644 --- a/server/leafnode_test.go +++ b/server/leafnode_test.go @@ -2496,6 +2496,9 @@ func TestLeafNodeOperatorBadCfg(t *testing.T) { s.Shutdown() t.Fatal("Expected an error") } + // Since the server cannot be stopped, since it did not start, + // let's manually close the account resolver to avoid leaking go routines. + opts.AccountResolver.Close() if err.Error() != errorText { t.Fatalf("Expected error %s but got %s", errorText, err) }