Skip to content

Commit

Permalink
ddl: enable goleak for ingest package (pingcap#43765)
Browse files Browse the repository at this point in the history
  • Loading branch information
tangenta authored and ti-chi-bot committed May 15, 2023
1 parent baf73f1 commit 597d209
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 1 deletion.
4 changes: 3 additions & 1 deletion ddl/ingest/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,14 @@ go_test(
"checkpoint_test.go",
"env_test.go",
"integration_test.go",
"main_test.go",
"mem_root_test.go",
],
embed = [":ingest"],
flaky = True,
race = "on",
shard_count = 9,
deps = [
":ingest",
"//config",
"//ddl/internal/session",
"//kv",
Expand All @@ -69,5 +70,6 @@ go_test(
"@com_github_ngaut_pools//:pools",
"@com_github_pingcap_failpoint//:failpoint",
"@com_github_stretchr_testify//require",
"@org_uber_go_goleak//:goleak",
],
)
34 changes: 34 additions & 0 deletions ddl/ingest/main_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
// Copyright 2023 PingCAP, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package ingest

import (
"testing"

"go.uber.org/goleak"
)

func TestMain(m *testing.M) {
opts := []goleak.Option{
goleak.IgnoreTopFunction("github.com/golang/glog.(*loggingT).flushDaemon"),
goleak.IgnoreTopFunction("github.com/lestrrat-go/httprc.runFetchWorker"),
goleak.IgnoreTopFunction("go.etcd.io/etcd/client/pkg/v3/logutil.(*MergeLogger).outputLoop"),
goleak.IgnoreTopFunction("github.com/tikv/client-go/v2/txnkv/transaction.keepAlive"),
goleak.IgnoreTopFunction("go.opencensus.io/stats/view.(*worker).start"),
goleak.IgnoreTopFunction("internal/poll.runtime_pollWait"),
goleak.IgnoreTopFunction("net/http.(*persistConn).writeLoop"),
}
goleak.VerifyTestMain(m, opts...)
}
3 changes: 3 additions & 0 deletions ddl/ingest/mock.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,9 @@ func (m *MockBackendCtxMgr) Unregister(jobID int64) {
err := mCtx.sessCtx.CommitTxn(context.Background())
logutil.BgLogger().Info("mock backend mgr unregister", zap.Int64("jobID", jobID), zap.Error(err))
delete(m.runningJobs, jobID)
if mCtx.checkpointMgr != nil {
mCtx.checkpointMgr.Close()
}
}
}

Expand Down

0 comments on commit 597d209

Please sign in to comment.