From bef2ef7f3c12bde238ff2563825f97b9f4148acf Mon Sep 17 00:00:00 2001 From: Lynn Date: Thu, 5 Mar 2020 13:31:51 +0800 Subject: [PATCH] cmd/ddltest: using "RunWorker" to control if run worker --- cmd/ddltest/ddl_test.go | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/cmd/ddltest/ddl_test.go b/cmd/ddltest/ddl_test.go index d7e0751a92234..a6538376d9355 100644 --- a/cmd/ddltest/ddl_test.go +++ b/cmd/ddltest/ddl_test.go @@ -35,6 +35,7 @@ import ( zaplog "github.com/pingcap/log" "github.com/pingcap/parser/model" "github.com/pingcap/parser/terror" + "github.com/pingcap/tidb/ddl" "github.com/pingcap/tidb/domain" "github.com/pingcap/tidb/kv" "github.com/pingcap/tidb/session" @@ -103,9 +104,8 @@ func (s *TestDDLSuite) SetUpSuite(c *C) { // Make sure the schema lease of this session is equal to other TiDB servers'. session.SetSchemaLease(time.Duration(*lease) * time.Second) - dom, err := session.BootstrapSession(s.store) + s.dom, err = session.BootstrapSession(s.store) c.Assert(err, IsNil) - s.dom = dom s.s, err = session.CreateSession(s.store) c.Assert(err, IsNil) @@ -115,14 +115,20 @@ func (s *TestDDLSuite) SetUpSuite(c *C) { _, err = s.s.Execute(goCtx, "create database if not exists test_ddl") c.Assert(err, IsNil) - _, err = s.s.Execute(goCtx, "use test_ddl") - c.Assert(err, IsNil) - s.Bootstrap(c) // Stop current DDL worker, so that we can't be the owner now. err = domain.GetDomain(s.ctx).DDL().Stop() c.Assert(err, IsNil) + ddl.RunWorker = false + session.ResetStoreForWithTiKVTest(s.store) + s.s, err = session.CreateSession(s.store) + c.Assert(err, IsNil) + s.dom, err = session.BootstrapSession(s.store) + c.Assert(err, IsNil) + s.ctx = s.s.(sessionctx.Context) + _, err = s.s.Execute(goCtx, "use test_ddl") + c.Assert(err, IsNil) addEnvPath("..")