github.com/pingcap/ticdc@v0.0.0-20220526033649-485a10ef2652/tests/dailytest/dailytest.go (about)

     1  // Copyright 2020 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 dailytest
    15  
    16  import (
    17  	"database/sql"
    18  
    19  	"github.com/pingcap/log"
    20  )
    21  
    22  // Run runs the daily test
    23  func Run(sourceDB *sql.DB, targetDB *sql.DB, schema string, workerCount int, jobCount int, batch int) {
    24  	TableSQLs := []string{
    25  		`
    26  		create table ptest(
    27  			a int primary key,
    28  			b double NOT NULL DEFAULT 2.0,
    29  			c varchar(10) NOT NULL,
    30  			d time unique
    31  		);
    32  		`,
    33  		`create table itest(
    34  			a int,
    35  			b double NOT NULL DEFAULT 2.0,
    36  			c varchar(10) NOT NULL,
    37  			d time unique,
    38  			PRIMARY KEY(a, b)
    39  		);
    40  		`,
    41  		`create table ntest(
    42  			a int,
    43  			b double NOT NULL DEFAULT 2.0,
    44  			c varchar(10) NOT NULL,
    45  			d time unique not null
    46  		);
    47  		`,
    48  	}
    49  
    50  	// run the simple test case
    51  	RunCase(sourceDB, targetDB, schema)
    52  
    53  	RunTest(sourceDB, targetDB, schema, func(src *sql.DB) {
    54  		// generate insert/update/delete sqls and execute
    55  		RunDailyTest(sourceDB, TableSQLs, workerCount, jobCount, batch)
    56  	})
    57  
    58  	RunTest(sourceDB, targetDB, schema, func(src *sql.DB) {
    59  		// truncate test data
    60  		TruncateTestTable(sourceDB, TableSQLs)
    61  	})
    62  
    63  	RunTest(sourceDB, targetDB, schema, func(src *sql.DB) {
    64  		// drop test table
    65  		DropTestTable(sourceDB, TableSQLs)
    66  	})
    67  
    68  	log.S().Info("test pass!!!")
    69  }