Skip to content

Commit

Permalink
Merge pull request #2641 from tamird/fix-todos
Browse files Browse the repository at this point in the history
rpc: clean up after tests
  • Loading branch information
tamird committed Sep 23, 2015
2 parents e12714b + 5a6b922 commit 9714761
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 12 deletions.
12 changes: 0 additions & 12 deletions rpc/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
13 changes: 13 additions & 0 deletions rpc/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand All @@ -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)
}

0 comments on commit 9714761

Please sign in to comment.