提交 f2fc7760 编写于 作者: C cpwu

fix test.py , add restful flag

上级 b2933ea2
...@@ -29,6 +29,7 @@ from util.cases import * ...@@ -29,6 +29,7 @@ from util.cases import *
from util.cluster import * from util.cluster import *
import taos import taos
import taosrest
def checkRunTimeError(): def checkRunTimeError():
import win32gui import win32gui
...@@ -65,8 +66,9 @@ if __name__ == "__main__": ...@@ -65,8 +66,9 @@ if __name__ == "__main__":
execCmd = "" execCmd = ""
queryPolicy = 1 queryPolicy = 1
createDnodeNums = 1 createDnodeNums = 1
opts, args = getopt.gnu_getopt(sys.argv[1:], 'f:p:m:l:scghrd:k:e:N:M:Q:C:', [ restful = False
'file=', 'path=', 'master', 'logSql', 'stop', 'cluster', 'valgrind', 'help', 'restart', 'updateCfgDict', 'killv', 'execCmd','dnodeNums','mnodeNums','queryPolicy','createDnodeNums']) opts, args = getopt.gnu_getopt(sys.argv[1:], 'f:p:m:l:scghrd:k:e:N:M:Q:C:R', [
'file=', 'path=', 'master', 'logSql', 'stop', 'cluster', 'valgrind', 'help', 'restart', 'updateCfgDict', 'killv', 'execCmd','dnodeNums','mnodeNums','queryPolicy','createDnodeNums','restful'])
for key, value in opts: for key, value in opts:
if key in ['-h', '--help']: if key in ['-h', '--help']:
tdLog.printNoPrefix( tdLog.printNoPrefix(
...@@ -86,6 +88,7 @@ if __name__ == "__main__": ...@@ -86,6 +88,7 @@ if __name__ == "__main__":
tdLog.printNoPrefix('-M create mnode numbers in clusters') tdLog.printNoPrefix('-M create mnode numbers in clusters')
tdLog.printNoPrefix('-Q set queryPolicy in one dnode') tdLog.printNoPrefix('-Q set queryPolicy in one dnode')
tdLog.printNoPrefix('-C create Dnode Numbers in one cluster') tdLog.printNoPrefix('-C create Dnode Numbers in one cluster')
tdLog.printNoPrefix('-R restful realization form')
sys.exit(0) sys.exit(0)
...@@ -149,6 +152,9 @@ if __name__ == "__main__": ...@@ -149,6 +152,9 @@ if __name__ == "__main__":
if key in ['-C', '--createDnodeNums']: if key in ['-C', '--createDnodeNums']:
createDnodeNums = value createDnodeNums = value
if key in ['-R', '--restful']:
restful = True
if not execCmd == "": if not execCmd == "":
tdDnodes.init(deployPath) tdDnodes.init(deployPath)
print(execCmd) print(execCmd)
...@@ -241,9 +247,12 @@ if __name__ == "__main__": ...@@ -241,9 +247,12 @@ if __name__ == "__main__":
for dnode in tdDnodes.dnodes: for dnode in tdDnodes.dnodes:
tdDnodes.starttaosd(dnode.index) tdDnodes.starttaosd(dnode.index)
tdCases.logSql(logSql) tdCases.logSql(logSql)
if not restful:
conn = taos.connect( conn = taos.connect(
host, host,
config=tdDnodes.getSimCfgPath()) config=tdDnodes.getSimCfgPath())
else:
conn = taosrest.connect(url=f"http://{host}:6041")
print(tdDnodes.getSimCfgPath(),host) print(tdDnodes.getSimCfgPath(),host)
if createDnodeNums == 1: if createDnodeNums == 1:
createDnodeNums=dnodeNums createDnodeNums=dnodeNums
...@@ -258,9 +267,12 @@ if __name__ == "__main__": ...@@ -258,9 +267,12 @@ if __name__ == "__main__":
if ucase is not None and hasattr(ucase, 'noConn') and ucase.noConn == True: if ucase is not None and hasattr(ucase, 'noConn') and ucase.noConn == True:
conn = None conn = None
else: else:
if not restful:
conn = taos.connect( conn = taos.connect(
host="%s"%(host), host="%s"%(host),
config=tdDnodes.sim.getCfgDir()) config=tdDnodes.sim.getCfgDir())
else:
conn = taosrest.connect(url=f"http://{host}:6041")
if is_test_framework: if is_test_framework:
tdCases.runOneWindows(conn, fileName) tdCases.runOneWindows(conn, fileName)
else: else:
...@@ -293,20 +305,37 @@ if __name__ == "__main__": ...@@ -293,20 +305,37 @@ if __name__ == "__main__":
tdCases.logSql(logSql) tdCases.logSql(logSql)
if queryPolicy != 1: if queryPolicy != 1:
queryPolicy=int(queryPolicy) queryPolicy=int(queryPolicy)
if not restful:
conn = taos.connect( conn = taos.connect(
host, host,
config=tdDnodes.getSimCfgPath()) config=tdDnodes.getSimCfgPath())
tdSql.init(conn.cursor()) else:
tdSql.execute("create qnode on dnode 1") conn = taosrest.connect(url=f"http://{host}:6041")
tdSql.execute('alter local "queryPolicy" "%d"'%queryPolicy) # tdSql.init(conn.cursor())
tdSql.query("show local variables;") # tdSql.execute("create qnode on dnode 1")
for i in range(tdSql.queryRows): # tdSql.execute('alter local "queryPolicy" "%d"'%queryPolicy)
if tdSql.queryResult[i][0] == "queryPolicy" : # tdSql.query("show local variables;")
if int(tdSql.queryResult[i][1]) == int(queryPolicy): # for i in range(tdSql.queryRows):
tdLog.success('alter queryPolicy to %d successfully'%queryPolicy) # if tdSql.queryResult[i][0] == "queryPolicy" :
else : # if int(tdSql.queryResult[i][1]) == int(queryPolicy):
tdLog.debug(tdSql.queryResult) # tdLog.success('alter queryPolicy to %d successfully'%queryPolicy)
tdLog.exit("alter queryPolicy to %d failed"%queryPolicy) # else :
# tdLog.debug(tdSql.queryResult)
# tdLog.exit("alter queryPolicy to %d failed"%queryPolicy)
cursor = conn.cursor()
cursor.execute("create qnode on dnode 1")
cursor.execute(f'alter local "queryPolicy" "{queryPolicy}"')
cursor.execute("show local variables")
res = cursor.fetchall()
for i in range(cursor.rowcount):
if res[i][0] == "queryPolicy" :
if int(res[i][1]) == int(queryPolicy):
tdLog.success(f'alter queryPolicy to {queryPolicy} successfully')
else:
tdLog.debug(res)
tdLog.exit(f"alter queryPolicy to {queryPolicy} failed")
else : else :
tdLog.debug("create an cluster with %s nodes and make %s dnode as independent mnode"%(dnodeNums,mnodeNums)) tdLog.debug("create an cluster with %s nodes and make %s dnode as independent mnode"%(dnodeNums,mnodeNums))
dnodeslist = cluster.configure_cluster(dnodeNums=dnodeNums,mnodeNums=mnodeNums) dnodeslist = cluster.configure_cluster(dnodeNums=dnodeNums,mnodeNums=mnodeNums)
...@@ -320,9 +349,12 @@ if __name__ == "__main__": ...@@ -320,9 +349,12 @@ if __name__ == "__main__":
for dnode in tdDnodes.dnodes: for dnode in tdDnodes.dnodes:
tdDnodes.starttaosd(dnode.index) tdDnodes.starttaosd(dnode.index)
tdCases.logSql(logSql) tdCases.logSql(logSql)
if not restful:
conn = taos.connect( conn = taos.connect(
host, host,
config=tdDnodes.getSimCfgPath()) config=tdDnodes.getSimCfgPath())
else:
conn = taosrest.connect(url=f"http://{host}:6041")
print(tdDnodes.getSimCfgPath(),host) print(tdDnodes.getSimCfgPath(),host)
if createDnodeNums == 1: if createDnodeNums == 1:
createDnodeNums=dnodeNums createDnodeNums=dnodeNums
...@@ -344,9 +376,12 @@ if __name__ == "__main__": ...@@ -344,9 +376,12 @@ if __name__ == "__main__":
tdCases.runOneCluster(fileName) tdCases.runOneCluster(fileName)
else: else:
tdLog.info("Procedures for testing self-deployment") tdLog.info("Procedures for testing self-deployment")
if not restful:
conn = taos.connect( conn = taos.connect(
host, host,
config=tdDnodes.getSimCfgPath()) config=tdDnodes.getSimCfgPath())
else:
conn = taosrest.connect(url=f"http://{host}:6041")
if fileName == "all": if fileName == "all":
tdCases.runAllLinux(conn) tdCases.runAllLinux(conn)
...@@ -362,11 +397,15 @@ if __name__ == "__main__": ...@@ -362,11 +397,15 @@ if __name__ == "__main__":
tdDnodes.stopAll() tdDnodes.stopAll()
tdDnodes.start(1) tdDnodes.start(1)
time.sleep(1) time.sleep(1)
if not restful:
conn = taos.connect( host, config=tdDnodes.getSimCfgPath()) conn = taos.connect( host, config=tdDnodes.getSimCfgPath())
else:
conn = taosrest.connect(url=f"http://{host}:6041")
tdLog.info("Procedures for tdengine deployed in %s" % (host)) tdLog.info("Procedures for tdengine deployed in %s" % (host))
tdLog.info("query test after taosd restart") tdLog.info("query test after taosd restart")
tdCases.runOneLinux(conn, sp[0] + "_" + "restart.py") tdCases.runOneLinux(conn, sp[0] + "_" + "restart.py")
else: else:
tdLog.info("not need to query") tdLog.info("not need to query")
if conn is not None: if conn is not None:
conn.close() conn.close()
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册