fix/add-show-transaction-detail-case
This commit is contained in:
parent
ca8c1ea377
commit
8c14e3b12a
|
@ -369,6 +369,7 @@
|
||||||
,,y,system-test,./pytest.sh python3 ./test.py -f 0-others/test_hot_refresh_configurations.py
|
,,y,system-test,./pytest.sh python3 ./test.py -f 0-others/test_hot_refresh_configurations.py
|
||||||
,,y,system-test,./pytest.sh python3 ./test.py -f 0-others/subscribe_stream_privilege.py
|
,,y,system-test,./pytest.sh python3 ./test.py -f 0-others/subscribe_stream_privilege.py
|
||||||
,,y,system-test,./pytest.sh python3 ./test.py -f 0-others/empty_identifier.py
|
,,y,system-test,./pytest.sh python3 ./test.py -f 0-others/empty_identifier.py
|
||||||
|
,,y,system-test,./pytest.sh python3 ./test.py -f 0-others/show_transaction_detail.py -N 3
|
||||||
|
|
||||||
,,y,system-test,./pytest.sh python3 ./test.py -f 1-insert/composite_primary_key_create.py
|
,,y,system-test,./pytest.sh python3 ./test.py -f 1-insert/composite_primary_key_create.py
|
||||||
,,y,system-test,./pytest.sh python3 ./test.py -f 1-insert/composite_primary_key_insert.py
|
,,y,system-test,./pytest.sh python3 ./test.py -f 1-insert/composite_primary_key_insert.py
|
||||||
|
|
|
@ -0,0 +1,105 @@
|
||||||
|
###################################################################
|
||||||
|
# Copyright (c) 2016 by TAOS Technologies, Inc.
|
||||||
|
# All rights reserved.
|
||||||
|
#
|
||||||
|
# This file is proprietary and confidential to TAOS Technologies.
|
||||||
|
# No part of this file may be reproduced, stored, transmitted,
|
||||||
|
# disclosed or used in any form or by any means other than as
|
||||||
|
# expressly provided by the written permission from Jianhui Tao
|
||||||
|
#
|
||||||
|
###################################################################
|
||||||
|
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
from util.log import *
|
||||||
|
from util.cases import *
|
||||||
|
from util.dnodes import *
|
||||||
|
from util.sql import *
|
||||||
|
from util.cluster import *
|
||||||
|
import threading
|
||||||
|
|
||||||
|
class TDTestCase:
|
||||||
|
def init(self, conn, logSql, replicaVar=1):
|
||||||
|
tdLog.debug(f"start to init {__file__}")
|
||||||
|
self.replicaVar = int(replicaVar)
|
||||||
|
tdSql.init(conn.cursor(), logSql)
|
||||||
|
self.dnodes = cluster.dnodes
|
||||||
|
|
||||||
|
def stop(self):
|
||||||
|
tdSql.close()
|
||||||
|
tdLog.success(f"{__file__} successfully executed")
|
||||||
|
|
||||||
|
def run(self):
|
||||||
|
tdLog.debug(f"start to excute {__file__}")
|
||||||
|
|
||||||
|
tdLog.info("CREATE DATABASE db1 vgroups 16 replica 1;")
|
||||||
|
tdSql.execute('CREATE DATABASE db1 vgroups 16 replica 1;')
|
||||||
|
|
||||||
|
if self.waitTransactionZero() is False:
|
||||||
|
tdLog.exit(f"{sql} transaction not finished")
|
||||||
|
return False
|
||||||
|
|
||||||
|
newTdSql1=tdCom.newTdSql()
|
||||||
|
t1 = threading.Thread(target=self.alterDbThread, args=('', newTdSql1))
|
||||||
|
|
||||||
|
newTdSql2=tdCom.newTdSql()
|
||||||
|
t2 = threading.Thread(target=self.createDbThread, args=('', newTdSql2))
|
||||||
|
|
||||||
|
t1.start()
|
||||||
|
t2.start()
|
||||||
|
|
||||||
|
dnode = self.dnodes[1]
|
||||||
|
|
||||||
|
# stop dnode
|
||||||
|
tdLog.info(f"stop dnode 1")
|
||||||
|
dnode.stoptaosd()
|
||||||
|
|
||||||
|
rows = tdSql.query("show transactions;")
|
||||||
|
if rows > 0:
|
||||||
|
tranId = tdSql.getData(0, 0)
|
||||||
|
tdLog.info(f"show transaction {tranId}")
|
||||||
|
rows = tdSql.query(f"show transaction {tranId}", queryTimes=1)
|
||||||
|
|
||||||
|
if rows != 160:
|
||||||
|
tdLog.exit(f"restore transaction detial error, rows={rows}")
|
||||||
|
return False
|
||||||
|
|
||||||
|
rows = tdSql.query("show transactions;")
|
||||||
|
if rows > 0:
|
||||||
|
tranId = tdSql.getData(1, 0)
|
||||||
|
tdLog.info(f"show transaction {tranId}")
|
||||||
|
rows = tdSql.query(f"show transaction {tranId}", queryTimes=1)
|
||||||
|
|
||||||
|
if rows != 176:
|
||||||
|
tdLog.exit(f"restore transaction detial error, rows={rows}")
|
||||||
|
return False
|
||||||
|
|
||||||
|
tdLog.info(f"select * from ins_transaction_details")
|
||||||
|
rows = tdSql.query(f"select * from information_schema.ins_transaction_details", queryTimes=1)
|
||||||
|
|
||||||
|
if rows != 336:
|
||||||
|
tdLog.exit(f"restore transaction detial error, rows={rows}")
|
||||||
|
return False
|
||||||
|
|
||||||
|
def createDbThread(self, sql, newTdSql):
|
||||||
|
tdLog.info("CREATE DATABASE db2 vgroups 160 replica 1;")
|
||||||
|
newTdSql.execute('CREATE DATABASE db2 vgroups 160 replica 1;')
|
||||||
|
|
||||||
|
def alterDbThread(self, sql, newTdSql):
|
||||||
|
tdLog.info("alter DATABASE db1 replica 3;")
|
||||||
|
newTdSql.execute('alter DATABASE db1 replica 3;')
|
||||||
|
|
||||||
|
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
|
||||||
|
|
||||||
|
tdCases.addLinux(__file__, TDTestCase())
|
||||||
|
tdCases.addWindows(__file__, TDTestCase())
|
Loading…
Reference in New Issue