Skip to content

Commit

Permalink
ttl: Add some tools to build SQLs for TTL (#39359)
Browse files Browse the repository at this point in the history
close #39339
  • Loading branch information
lcwangchao authored Nov 27, 2022
1 parent 4019c2a commit 99dbc77
Show file tree
Hide file tree
Showing 5 changed files with 1,402 additions and 0 deletions.
44 changes: 44 additions & 0 deletions ttl/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")

go_library(
name = "ttl",
srcs = [
"sql.go",
"table.go",
],
importpath = "github.com/pingcap/tidb/ttl",
visibility = ["//visibility:public"],
deps = [
"//parser/ast",
"//parser/format",
"//parser/model",
"//parser/mysql",
"//types",
"//util/sqlexec",
"@com_github_pingcap_errors//:errors",
"@com_github_pkg_errors//:errors",
],
)

go_test(
name = "ttl_test",
srcs = [
"main_test.go",
"sql_test.go",
],
flaky = True,
deps = [
":ttl",
"//kv",
"//parser",
"//parser/ast",
"//parser/model",
"//parser/mysql",
"//testkit",
"//testkit/testsetup",
"//types",
"//util/sqlexec",
"@com_github_stretchr_testify//require",
"@org_uber_go_goleak//:goleak",
],
)
33 changes: 33 additions & 0 deletions ttl/main_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
// Copyright 2022 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 ttl_test

import (
"testing"

"github.com/pingcap/tidb/testkit/testsetup"
"go.uber.org/goleak"
)

func TestMain(m *testing.M) {
testsetup.SetupForCommonTest()
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("go.opencensus.io/stats/view.(*worker).start"),
}
goleak.VerifyTestMain(m, opts...)
}
Loading

0 comments on commit 99dbc77

Please sign in to comment.