From 5a6b922bdb320c81afc74a98afccca9acd66aba8 Mon Sep 17 00:00:00 2001 From: Tamir Duberstein Date: Wed, 23 Sep 2015 15:19:02 -0400 Subject: [PATCH] fix todo: clean up after tests --- rpc/client_test.go | 12 ------------ rpc/main_test.go | 13 +++++++++++++ 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/rpc/client_test.go b/rpc/client_test.go index 7f9e250d3be6..d8c2aef46d94 100644 --- a/rpc/client_test.go +++ b/rpc/client_test.go @@ -25,21 +25,9 @@ import ( "github.com/cockroachdb/cockroach/util" "github.com/cockroachdb/cockroach/util/hlc" "github.com/cockroachdb/cockroach/util/leaktest" - "github.com/cockroachdb/cockroach/util/retry" "github.com/cockroachdb/cockroach/util/stop" ) -func init() { - // Setting these in individual tests triggers the race detector, so - // this is better for now. - // TODO(tamird): stop doing this. - heartbeatInterval = 10 * time.Millisecond - clientRetryOptions = retry.Options{ - InitialBackoff: 1 * time.Millisecond, - MaxBackoff: 1 * time.Millisecond, - } -} - func TestClientHeartbeat(t *testing.T) { defer leaktest.AfterTest(t) diff --git a/rpc/main_test.go b/rpc/main_test.go index 75d7150ac325..6362f6bb5509 100644 --- a/rpc/main_test.go +++ b/rpc/main_test.go @@ -19,12 +19,14 @@ package rpc import ( "testing" + "time" "github.com/cockroachdb/cockroach/security" "github.com/cockroachdb/cockroach/security/securitytest" "github.com/cockroachdb/cockroach/testutils" "github.com/cockroachdb/cockroach/util/hlc" "github.com/cockroachdb/cockroach/util/leaktest" + "github.com/cockroachdb/cockroach/util/retry" "github.com/cockroachdb/cockroach/util/stop" ) @@ -44,5 +46,16 @@ func init() { //go:generate ../util/leaktest/add-leaktest.sh *_test.go func TestMain(m *testing.M) { + defer func(hbInterval time.Duration, retryOpts retry.Options) { + heartbeatInterval = hbInterval + clientRetryOptions = retryOpts + }(heartbeatInterval, clientRetryOptions) + + heartbeatInterval = 10 * time.Millisecond + clientRetryOptions = retry.Options{ + InitialBackoff: 1 * time.Millisecond, + MaxBackoff: 1 * time.Millisecond, + } + leaktest.TestMainWithLeakCheck(m) }