Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: add a memory usage test for real-tikv-test #37911

Merged
merged 2 commits into from
Sep 19, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 15 additions & 5 deletions tests/realtikvtest/addindextest/failpoints_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@ func initTestFailpoint(t *testing.T) *suiteContext {
}

func TestFailpointsCreateNonUniqueIndex(t *testing.T) {
t.Skip()
if !*FullMode {
t.Skip()
}
var colIDs = [][]int{
{1, 4, 7, 10, 13, 16, 19, 22, 25},
{2, 5, 8, 11, 14, 17, 20, 23, 26},
Expand All @@ -36,7 +38,9 @@ func TestFailpointsCreateNonUniqueIndex(t *testing.T) {
}

func TestFailpointsCreateUniqueIndex(t *testing.T) {
t.Skip()
if !*FullMode {
t.Skip()
}
var colIDs = [][]int{
{1, 6, 7, 8, 11, 13, 15, 16, 18, 19, 22, 26},
{2, 9, 11, 17},
Expand All @@ -47,19 +51,25 @@ func TestFailpointsCreateUniqueIndex(t *testing.T) {
}

func TestFailpointsCreatePrimaryKeyFailpoints(t *testing.T) {
t.Skip()
if !*FullMode {
t.Skip()
}
ctx := initTest(t)
testOneIndexFrame(ctx, 0, addIndexPK)
}

func TestFailpointsCreateGenColIndex(t *testing.T) {
t.Skip()
if !*FullMode {
t.Skip()
}
ctx := initTestFailpoint(t)
testOneIndexFrame(ctx, 29, addIndexGenCol)
}

func TestFailpointsCreateMultiColsIndex(t *testing.T) {
t.Skip()
if !*FullMode {
t.Skip()
}
var coliIDs = [][]int{
{1, 4, 7},
{2, 5, 8},
Expand Down
53 changes: 53 additions & 0 deletions tests/realtikvtest/addindextest/memory_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
// 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 addindextest

import (
"fmt"
"strings"
"testing"

"github.com/pingcap/tidb/ddl/ingest"
"github.com/pingcap/tidb/testkit"
"github.com/pingcap/tidb/tests/realtikvtest"
"github.com/stretchr/testify/require"
)

func TestLitAddIndexMemoryUsage(t *testing.T) {
store := realtikvtest.CreateMockStoreAndSetup(t)
tk := testkit.NewTestKit(t, store)
tk.MustExec("drop database if exists addindexlit;")
tk.MustExec("create database addindexlit;")
tk.MustExec("use addindexlit;")
tk.MustExec(`set global tidb_ddl_enable_fast_reorg=on;`)

tk.MustExec("create table t (a int, b int, c int);")
var sb strings.Builder
sb.WriteString("insert into t values ")
size := 100
for i := 0; i < size; i++ {
sb.WriteString(fmt.Sprintf("(%d, %d, %d)", i, i, i))
if i != size-1 {
sb.WriteString(",")
}
}
sb.WriteString(";")
tk.MustExec(sb.String())
require.Equal(t, int64(0), ingest.LitMemRoot.CurrentUsage())
tk.MustExec("alter table t add index idx(a);")
tk.MustExec("alter table t add unique index idx1(b);")
tk.MustExec("admin check table t;")
require.Equal(t, int64(0), ingest.LitMemRoot.CurrentUsage())
}