fix/TS-5251-ad-conflict-check-fix-case
This commit is contained in:
parent
73d19520de
commit
8e45332228
|
@ -1,62 +0,0 @@
|
||||||
{
|
|
||||||
"filetype": "insert",
|
|
||||||
"cfgdir": "/etc/taos",
|
|
||||||
"host": "127.0.0.1",
|
|
||||||
"port": 6030,
|
|
||||||
"user": "root",
|
|
||||||
"password": "taosdata",
|
|
||||||
"connection_pool_size": 8,
|
|
||||||
"num_of_records_per_req": 3000,
|
|
||||||
"prepared_rand": 3000,
|
|
||||||
"thread_count": 2,
|
|
||||||
"create_table_thread_count": 1,
|
|
||||||
"confirm_parameter_prompt": "no",
|
|
||||||
"continue_if_fail": "yes",
|
|
||||||
"databases": [
|
|
||||||
{
|
|
||||||
"dbinfo": {
|
|
||||||
"name": "db",
|
|
||||||
"drop": "yes",
|
|
||||||
"vgroups": 2,
|
|
||||||
"replica": 3,
|
|
||||||
"duration":"1d",
|
|
||||||
"wal_retention_period": 1,
|
|
||||||
"wal_retention_size": 1,
|
|
||||||
"keep": "3d,6d,30d"
|
|
||||||
},
|
|
||||||
"super_tables": [
|
|
||||||
{
|
|
||||||
"name": "stb",
|
|
||||||
"child_table_exists": "no",
|
|
||||||
"childtable_count": 10,
|
|
||||||
"insert_rows": 100000000,
|
|
||||||
"childtable_prefix": "d",
|
|
||||||
"insert_mode": "taosc",
|
|
||||||
"timestamp_step": 10000,
|
|
||||||
"start_timestamp":"now-12d",
|
|
||||||
"columns": [
|
|
||||||
{ "type": "bool", "name": "bc"},
|
|
||||||
{ "type": "float", "name": "fc" },
|
|
||||||
{ "type": "double", "name": "dc"},
|
|
||||||
{ "type": "tinyint", "name": "ti"},
|
|
||||||
{ "type": "smallint", "name": "si" },
|
|
||||||
{ "type": "int", "name": "ic" },
|
|
||||||
{ "type": "bigint", "name": "bi" },
|
|
||||||
{ "type": "utinyint", "name": "uti"},
|
|
||||||
{ "type": "usmallint", "name": "usi"},
|
|
||||||
{ "type": "uint", "name": "ui" },
|
|
||||||
{ "type": "ubigint", "name": "ubi"},
|
|
||||||
{ "type": "binary", "name": "bin", "len": 16},
|
|
||||||
{ "type": "nchar", "name": "nch", "len": 32}
|
|
||||||
],
|
|
||||||
"tags": [
|
|
||||||
{"type": "tinyint", "name": "groupid","max": 10,"min": 1},
|
|
||||||
{"name": "location","type": "binary", "len": 16, "values":
|
|
||||||
["San Francisco", "Los Angles", "San Diego", "San Jose", "Palo Alto", "Campbell", "Mountain View","Sunnyvale", "Santa Clara", "Cupertino"]
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
|
@ -10,116 +10,97 @@
|
||||||
###################################################################
|
###################################################################
|
||||||
|
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
import frame.etool
|
from util.log import *
|
||||||
from frame.caseBase import *
|
from util.cases import *
|
||||||
from frame.cases import *
|
from util.dnodes import *
|
||||||
from frame import *
|
from util.sql import *
|
||||||
import json
|
|
||||||
import threading
|
import threading
|
||||||
|
|
||||||
|
|
||||||
class TDTestCase(TBase):
|
class TDTestCase:
|
||||||
def init(self, conn, logSql, replicaVar=1):
|
def init(self, conn, logSql, replicaVar=1):
|
||||||
tdLog.debug(f"start to init {__file__}")
|
tdLog.debug(f"start to init {__file__}")
|
||||||
self.replicaVar = int(replicaVar)
|
self.replicaVar = int(replicaVar)
|
||||||
tdSql.init(conn.cursor(), logSql) # output sql.txt file
|
tdSql.init(conn.cursor(), logSql) # output sql.txt file
|
||||||
self.configJsonFile('compactDBConflict.json', 'db', 4, 1, 'compactDBConflict.json', 100000)
|
|
||||||
|
|
||||||
def configJsonFile(self, fileName, dbName, vgroups, replica, newFileName='', insert_rows=100000,
|
|
||||||
timestamp_step=10000):
|
|
||||||
tdLog.debug(f"configJsonFile {fileName}")
|
|
||||||
filePath = etool.curFile(__file__, fileName)
|
|
||||||
with open(filePath, 'r') as f:
|
|
||||||
data = json.load(f)
|
|
||||||
|
|
||||||
if len(newFileName) == 0:
|
|
||||||
newFileName = fileName
|
|
||||||
|
|
||||||
data['databases'][0]['dbinfo']['name'] = dbName
|
|
||||||
data['databases'][0]['dbinfo']['vgroups'] = vgroups
|
|
||||||
data['databases'][0]['dbinfo']['replica'] = replica
|
|
||||||
data['databases'][0]['super_tables'][0]['insert_rows'] = insert_rows
|
|
||||||
data['databases'][0]['super_tables'][0]['timestamp_step'] = timestamp_step
|
|
||||||
json_data = json.dumps(data)
|
|
||||||
filePath = etool.curFile(__file__, newFileName)
|
|
||||||
with open(filePath, "w") as file:
|
|
||||||
file.write(json_data)
|
|
||||||
|
|
||||||
tdLog.debug(f"configJsonFile {json_data}")
|
|
||||||
|
|
||||||
def insertData(self, configFile):
|
|
||||||
tdLog.info(f"insert data.")
|
|
||||||
# taosBenchmark run
|
|
||||||
jfile = etool.curFile(__file__, configFile)
|
|
||||||
etool.benchMark(json=jfile)
|
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
tdLog.debug(f"start to excute {__file__}")
|
tdLog.debug(f"start to excute {__file__}")
|
||||||
|
|
||||||
self.insertData('compactDBConflict.json')
|
tdSql.execute('CREATE DATABASE db vgroups 4 replica 1;')
|
||||||
|
|
||||||
tdSql.execute('use db')
|
tdSql.execute('use db;')
|
||||||
|
|
||||||
|
tdLog.debug("start test1")
|
||||||
event = threading.Event()
|
event = threading.Event()
|
||||||
t0 = threading.Thread(target=self.compactDBThread, args=('', event))
|
t0 = threading.Thread(target=self.compactDBThread, args=('', event))
|
||||||
t0.start()
|
t0.start()
|
||||||
tdLog.debug("t0 threading started!!!!!")
|
tdLog.info("t0 threading started,wait compact db tran finish")
|
||||||
event.wait()
|
event.wait()
|
||||||
tdSql.error('ALTER DATABASE db REPLICA 3;', expectErrInfo="Transaction not completed due to conflict with compact")
|
tdSql.error('ALTER DATABASE db REPLICA 3;', expectErrInfo="Transaction not completed due to conflict with compact")
|
||||||
|
tdLog.info("wait compact db finish")
|
||||||
t0.join()
|
t0.join()
|
||||||
|
|
||||||
|
tdLog.debug("start test2")
|
||||||
event1 = threading.Event()
|
event1 = threading.Event()
|
||||||
t1 = threading.Thread(target=self.compactDBThread, args=('', event1))
|
t1 = threading.Thread(target=self.compactDBThread, args=('', event1))
|
||||||
t1.start()
|
t1.start()
|
||||||
tdLog.debug("t1 threading started!!!!!")
|
tdLog.info("t1 threading started,wait compact db tran finish")
|
||||||
event1.wait()
|
event1.wait()
|
||||||
tdSql.error('REDISTRIBUTE VGROUP 5 DNODE 1;', expectErrInfo="Transaction not completed due to conflict with compact")
|
tdSql.error('REDISTRIBUTE VGROUP 5 DNODE 1;', expectErrInfo="Transaction not completed due to conflict with compact")
|
||||||
|
tdLog.info("wait compact db finish")
|
||||||
t1.join()
|
t1.join()
|
||||||
|
|
||||||
|
tdLog.debug("start test3")
|
||||||
event2 = threading.Event()
|
event2 = threading.Event()
|
||||||
t2 = threading.Thread(target=self.compactDBThread, args=('', event2))
|
t2 = threading.Thread(target=self.compactDBThread, args=('', event2))
|
||||||
t2.start()
|
t2.start()
|
||||||
tdLog.debug("t2 threading started!!!!!")
|
tdLog.info("t2 threading started,wait compact db tran finish")
|
||||||
event2.wait()
|
event2.wait()
|
||||||
rowLen = tdSql.query('show vgroups')
|
rowLen = tdSql.query('show vgroups')
|
||||||
if rowLen > 0:
|
if rowLen > 0:
|
||||||
vgroupId = tdSql.getData(0, 0)
|
vgroupId = tdSql.getData(0, 0)
|
||||||
tdLog.debug(f"splitVgroupThread vgroupId:{vgroupId}")
|
tdLog.info(f"splitVgroupThread vgroupId:{vgroupId}")
|
||||||
tdSql.error('REDISTRIBUTE VGROUP 5 DNODE 1;', expectErrInfo="Transaction not completed due to conflict with compact")
|
tdSql.error('REDISTRIBUTE VGROUP 5 DNODE 1;', expectErrInfo="Transaction not completed due to conflict with compact")
|
||||||
|
tdLog.info("wait compact db finish")
|
||||||
t2.join()
|
t2.join()
|
||||||
|
|
||||||
|
tdLog.debug("start test4")
|
||||||
event3 = threading.Event()
|
event3 = threading.Event()
|
||||||
t3 = threading.Thread(target=self.compactDBThread, args=('', event3))
|
t3 = threading.Thread(target=self.compactDBThread, args=('', event3))
|
||||||
t3.start()
|
t3.start()
|
||||||
tdLog.debug("t3 threading started!!!!!")
|
tdLog.info("t3 threading started!!!!!")
|
||||||
event3.wait()
|
event3.wait()
|
||||||
tdSql.error('BALANCE VGROUP;', expectErrInfo="Transaction not completed due to conflict with compact")
|
tdSql.error('BALANCE VGROUP;', expectErrInfo="Transaction not completed due to conflict with compact")
|
||||||
t3.join()
|
t3.join()
|
||||||
|
|
||||||
|
tdLog.debug("start test5")
|
||||||
t4 = threading.Thread(target=self.splitVgroupThread)
|
t4 = threading.Thread(target=self.splitVgroupThread)
|
||||||
t4.start()
|
t4.start()
|
||||||
tdLog.debug("t4 threading started!!!!!")
|
tdLog.info("t4 threading started!!!!!")
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
tdSql.error('compact database db;', expectErrInfo="Conflict transaction not completed")
|
tdSql.error('compact database db;', expectErrInfo="Conflict transaction not completed")
|
||||||
t4.join()
|
t4.join()
|
||||||
|
|
||||||
|
tdLog.debug("start test6")
|
||||||
t5 = threading.Thread(target=self.RedistributeVGroups)
|
t5 = threading.Thread(target=self.RedistributeVGroups)
|
||||||
t5.start()
|
t5.start()
|
||||||
tdLog.debug("t5 threading started!!!!!")
|
tdLog.info("t5 threading started!!!!!")
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
tdSql.error('compact database db;', expectErrInfo="Conflict transaction not completed")
|
tdSql.error('compact database db;', expectErrInfo="Conflict transaction not completed")
|
||||||
t5.join()
|
t5.join()
|
||||||
|
|
||||||
|
tdLog.debug("start test7")
|
||||||
t6 = threading.Thread(target=self.balanceVGROUPThread)
|
t6 = threading.Thread(target=self.balanceVGROUPThread)
|
||||||
t6.start()
|
t6.start()
|
||||||
tdLog.debug("t6 threading started!!!!!")
|
tdLog.info("t6 threading started!!!!!")
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
tdSql.error('compact database db;', expectErrInfo="Conflict transaction not completed")
|
tdSql.error('compact database db;', expectErrInfo="Conflict transaction not completed")
|
||||||
t6.join()
|
t6.join()
|
||||||
|
|
||||||
|
tdLog.debug("start test8")
|
||||||
t7 = threading.Thread(target=self.alterDBThread)
|
t7 = threading.Thread(target=self.alterDBThread)
|
||||||
t7.start()
|
t7.start()
|
||||||
tdLog.debug("t7 threading started!!!!!")
|
tdLog.info("t7 threading started!!!!!")
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
tdSql.error('compact database db;', expectErrInfo="Conflict transaction not completed")
|
tdSql.error('compact database db;', expectErrInfo="Conflict transaction not completed")
|
||||||
t7.join()
|
t7.join()
|
||||||
|
@ -175,7 +156,32 @@ class TDTestCase(TBase):
|
||||||
tdLog.exit("get vgroupId fail!")
|
tdLog.exit("get vgroupId fail!")
|
||||||
if self.waitTransactionZero() is False:
|
if self.waitTransactionZero() is False:
|
||||||
tdLog.info(f"transaction not finished")
|
tdLog.info(f"transaction not finished")
|
||||||
|
|
||||||
|
def waitTransactionZero(self, seconds = 300, interval = 1):
|
||||||
|
# wait end
|
||||||
|
for i in range(seconds):
|
||||||
|
sql ="show transactions;"
|
||||||
|
rows = tdSql.query(sql)
|
||||||
|
if rows == 0:
|
||||||
|
tdLog.info("transaction count became zero.")
|
||||||
|
return True
|
||||||
|
#tdLog.info(f"i={i} wait ...")
|
||||||
|
time.sleep(interval)
|
||||||
|
|
||||||
|
return False
|
||||||
|
def waitCompactsZero(self, seconds = 300, interval = 1):
|
||||||
|
# wait end
|
||||||
|
for i in range(seconds):
|
||||||
|
sql ="show compacts;"
|
||||||
|
rows = tdSql.query(sql)
|
||||||
|
if rows == 0:
|
||||||
|
tdLog.info("compacts count became zero.")
|
||||||
|
return True
|
||||||
|
#tdLog.info(f"i={i} wait ...")
|
||||||
|
time.sleep(interval)
|
||||||
|
|
||||||
|
return False
|
||||||
|
|
||||||
def stop(self):
|
def stop(self):
|
||||||
tdSql.close()
|
tdSql.close()
|
||||||
tdLog.success(f"{__file__} successfully executed")
|
tdLog.success(f"{__file__} successfully executed")
|
Loading…
Reference in New Issue