github.com/insionng/yougam@v0.0.0-20170714101924-2bc18d833463/libraries/pingcap/tidb/server/tidb_test.go (about) 1 // Copyright 2015 PingCAP, 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 server 15 16 import ( 17 "time" 18 19 "github.com/insionng/yougam/libraries/ngaut/log" 20 . "github.com/insionng/yougam/libraries/pingcap/check" 21 "github.com/insionng/yougam/libraries/pingcap/tidb" 22 ) 23 24 type TidbTestSuite struct { 25 tidbdrv *TiDBDriver 26 server *Server 27 } 28 29 var _ = Suite(new(TidbTestSuite)) 30 31 func (ts *TidbTestSuite) SetUpSuite(c *C) { 32 store, err := tidb.NewStore("memory:///tmp/tidb") 33 c.Assert(err, IsNil) 34 ts.tidbdrv = NewTiDBDriver(store) 35 cfg := &Config{ 36 Addr: ":4001", 37 LogLevel: "debug", 38 StatusAddr: ":10090", 39 } 40 server, err := NewServer(cfg, ts.tidbdrv) 41 c.Assert(err, IsNil) 42 ts.server = server 43 go ts.server.Run() 44 time.Sleep(time.Millisecond * 100) 45 46 log.SetLevelByString("error") 47 } 48 49 func (ts *TidbTestSuite) TearDownSuite(c *C) { 50 if ts.server != nil { 51 ts.server.Close() 52 } 53 } 54 55 func (ts *TidbTestSuite) TestRegression(c *C) { 56 if regression { 57 runTestRegression(c) 58 } 59 } 60 61 func (ts *TidbTestSuite) TestUint64(c *C) { 62 runTestPrepareResultFieldType(c) 63 } 64 65 func (ts *TidbTestSuite) TestSpecialType(c *C) { 66 runTestSpecialType(c) 67 } 68 69 func (ts *TidbTestSuite) TestPreparedString(c *C) { 70 runTestPreparedString(c) 71 } 72 73 func (ts *TidbTestSuite) TestConcurrentUpdate(c *C) { 74 runTestConcurrentUpdate(c) 75 } 76 77 func (ts *TidbTestSuite) TestErrorCode(c *C) { 78 runTestErrorCode(c) 79 } 80 81 func (ts *TidbTestSuite) TestAuth(c *C) { 82 runTestAuth(c) 83 } 84 85 func (ts *TidbTestSuite) TestIssues(c *C) { 86 runTestIssues(c) 87 } 88 89 func (ts *TidbTestSuite) TestResultFieldTableIsNull(c *C) { 90 runTestResultFieldTableIsNull(c) 91 } 92 93 func (ts *TidbTestSuite) TestStatusAPI(c *C) { 94 runTestStatusAPI(c) 95 } 96 97 func (ts *TidbTestSuite) TestSocket(c *C) { 98 cfg := &Config{ 99 LogLevel: "debug", 100 StatusAddr: ":10091", 101 Socket: "/tmp/tidbtest.sock", 102 } 103 server, err := NewServer(cfg, ts.tidbdrv) 104 c.Assert(err, IsNil) 105 go server.Run() 106 time.Sleep(time.Millisecond * 100) 107 tcpDsn := dsn 108 dsn = "root@unix(/tmp/tidbtest.sock)/test?strict=true" 109 runTestRegression(c) 110 dsn = tcpDsn 111 server.Close() 112 }