Skip to content

Commit

Permalink
executor: unstable test TestFlushTables move to standalone sandbox (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
hawkingrei authored Jun 9, 2022
1 parent 6432975 commit 76e25d2
Show file tree
Hide file tree
Showing 4 changed files with 78 additions and 10 deletions.
10 changes: 0 additions & 10 deletions executor/simple_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -773,16 +773,6 @@ func TestDropStats(t *testing.T) {
h.SetLease(0)
}

func TestFlushTables(t *testing.T) {
store, clean := testkit.CreateMockStore(t)
defer clean()
tk := testkit.NewTestKit(t, store)

tk.MustExec("FLUSH TABLES")
err := tk.ExecToErr("FLUSH TABLES WITH READ LOCK")
require.Error(t, err)
}

func TestUseDB(t *testing.T) {
store, clean := testkit.CreateMockStore(t)
defer clean()
Expand Down
17 changes: 17 additions & 0 deletions executor/simpletest/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
load("@io_bazel_rules_go//go:def.bzl", "go_test")

go_test(
name = "simpletest_test",
srcs = [
"main_test.go",
"simple_test.go",
],
deps = [
"//config",
"//meta/autoid",
"//testkit",
"@com_github_stretchr_testify//require",
"@com_github_tikv_client_go_v2//tikv",
"@org_uber_go_goleak//:goleak",
],
)
29 changes: 29 additions & 0 deletions executor/simpletest/main_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// 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 simpletest

import (
"testing"

"go.uber.org/goleak"
)

func TestMain(m *testing.M) {
opts := []goleak.Option{
goleak.IgnoreTopFunction("github.com/golang/glog.(*loggingT).flushDaemon"),
goleak.IgnoreTopFunction("go.opencensus.io/stats/view.(*worker).start"),
}
goleak.VerifyTestMain(m, opts...)
}
32 changes: 32 additions & 0 deletions executor/simpletest/simple_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// 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 simpletest

import (
"testing"

"github.com/pingcap/tidb/testkit"
"github.com/stretchr/testify/require"
)

func TestFlushTables(t *testing.T) {
store, clean := testkit.CreateMockStore(t)
defer clean()
tk := testkit.NewTestKit(t, store)

tk.MustExec("FLUSH TABLES")
err := tk.ExecToErr("FLUSH TABLES WITH READ LOCK")
require.Error(t, err)
}

0 comments on commit 76e25d2

Please sign in to comment.