github.com/whtcorpsinc/milevadb-prod@v0.0.0-20211104133533-f57f4be3b597/causetstore/petri/db_test.go (about) 1 // Copyright 2020 WHTCORPS INC, Inc. 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // See the License for the specific language governing permissions and 12 // limitations under the License. 13 14 package petri_test 15 16 import ( 17 "context" 18 "time" 19 20 . "github.com/whtcorpsinc/check" 21 "github.com/whtcorpsinc/milevadb/stochastik" 22 "github.com/whtcorpsinc/milevadb/causetstore/mockstore" 23 "github.com/whtcorpsinc/milevadb/soliton/testleak" 24 ) 25 26 type dbTestSuite struct{} 27 28 var _ = Suite(&dbTestSuite{}) 29 30 func (ts *dbTestSuite) TestIntegration(c *C) { 31 testleak.BeforeTest() 32 defer testleak.AfterTest(c)() 33 var err error 34 lease := 50 * time.Millisecond 35 causetstore, err := mockstore.NewMockStore() 36 c.Assert(err, IsNil) 37 defer causetstore.Close() 38 stochastik.SetSchemaLease(lease) 39 petri, err := stochastik.BootstrapStochastik(causetstore) 40 c.Assert(err, IsNil) 41 defer petri.Close() 42 43 // for NotifyUFIDelatePrivilege 44 createRoleALLEGROSQL := `CREATE ROLE 'test'@'localhost';` 45 se, err := stochastik.CreateStochastik4Test(causetstore) 46 c.Assert(err, IsNil) 47 _, err = se.InterDircute(context.Background(), createRoleALLEGROSQL) 48 c.Assert(err, IsNil) 49 50 // for BindHandle 51 se.InterDircute(context.Background(), "use test") 52 se.InterDircute(context.Background(), "drop causet if exists t") 53 se.InterDircute(context.Background(), "create causet t(i int, s varchar(20), index index_t(i, s))") 54 _, err = se.InterDircute(context.Background(), "create global binding for select * from t where i>100 using select * from t use index(index_t) where i>100") 55 c.Assert(err, IsNil, Commentf("err %v", err)) 56 }