提交 8ba93cf9 编写于 作者: haoranc's avatar haoranc

test:add replica 3 for all testcases and frameworks

上级 5c759908
...@@ -72,8 +72,9 @@ if __name__ == "__main__": ...@@ -72,8 +72,9 @@ if __name__ == "__main__":
queryPolicy = 1 queryPolicy = 1
createDnodeNums = 1 createDnodeNums = 1
restful = False restful = False
opts, args = getopt.gnu_getopt(sys.argv[1:], 'f:p:m:l:scghrd:k:e:N:M:Q:C:RD:', [ replicaVar = 1
'file=', 'path=', 'master', 'logSql', 'stop', 'cluster', 'valgrind', 'help', 'restart', 'updateCfgDict', 'killv', 'execCmd','dnodeNums','mnodeNums','queryPolicy','createDnodeNums','restful','adaptercfgupdate']) opts, args = getopt.gnu_getopt(sys.argv[1:], 'f:p:m:l:scghrd:k:e:N:M:Q:C:RD:n:', [
'file=', 'path=', 'master', 'logSql', 'stop', 'cluster', 'valgrind', 'help', 'restart', 'updateCfgDict', 'killv', 'execCmd','dnodeNums','mnodeNums','queryPolicy','createDnodeNums','restful','adaptercfgupdate','replicaVar'])
for key, value in opts: for key, value in opts:
if key in ['-h', '--help']: if key in ['-h', '--help']:
tdLog.printNoPrefix( tdLog.printNoPrefix(
...@@ -95,8 +96,7 @@ if __name__ == "__main__": ...@@ -95,8 +96,7 @@ if __name__ == "__main__":
tdLog.printNoPrefix('-C create Dnode Numbers in one cluster') tdLog.printNoPrefix('-C create Dnode Numbers in one cluster')
tdLog.printNoPrefix('-R restful realization form') tdLog.printNoPrefix('-R restful realization form')
tdLog.printNoPrefix('-D taosadapter update cfg dict ') tdLog.printNoPrefix('-D taosadapter update cfg dict ')
tdLog.printNoPrefix('-n the number of replicas')
sys.exit(0) sys.exit(0)
if key in ['-r', '--restart']: if key in ['-r', '--restart']:
...@@ -168,6 +168,9 @@ if __name__ == "__main__": ...@@ -168,6 +168,9 @@ if __name__ == "__main__":
print('adapter cfg update convert fail.') print('adapter cfg update convert fail.')
sys.exit(0) sys.exit(0)
if key in ['-n', '--replicaVar']:
replicaVar = value
if not execCmd == "": if not execCmd == "":
if restful: if restful:
tAdapter.init(deployPath) tAdapter.init(deployPath)
...@@ -194,7 +197,7 @@ if __name__ == "__main__": ...@@ -194,7 +197,7 @@ if __name__ == "__main__":
processID = subprocess.check_output(psCmd, shell=True) processID = subprocess.check_output(psCmd, shell=True)
for port in range(6030, 6041): for port in range(6030, 6041):
usePortPID = "lsof -i tcp:%d | grep LISTEn | awk '{print $2}'" % port usePortPID = "lsof -i tcp:%d | grep LISTEN | awk '{print $2}'" % port
processID = subprocess.check_output(usePortPID, shell=True) processID = subprocess.check_output(usePortPID, shell=True)
if processID: if processID:
...@@ -206,11 +209,13 @@ if __name__ == "__main__": ...@@ -206,11 +209,13 @@ if __name__ == "__main__":
time.sleep(2) time.sleep(2)
if restful: if restful:
toBeKilled = "taosadapter" toBeKilled = "taosadapt"
killCmd = "ps -ef|grep -w %s| grep -v grep | awk '{print $2}' | xargs kill -TERM > /dev/null 2>&1" % toBeKilled # killCmd = "ps -ef|grep -w %s| grep -v grep | awk '{print $2}' | xargs kill -TERM > /dev/null 2>&1" % toBeKilled
killCmd = f"pkill {toBeKilled}"
psCmd = "ps -ef|grep -w %s| grep -v grep | awk '{print $2}'" % toBeKilled psCmd = "ps -ef|grep -w %s| grep -v grep | awk '{print $2}'" % toBeKilled
# psCmd = f"pgrep {toBeKilled}"
processID = subprocess.check_output(psCmd, shell=True) processID = subprocess.check_output(psCmd, shell=True)
while(processID): while(processID):
...@@ -218,15 +223,15 @@ if __name__ == "__main__": ...@@ -218,15 +223,15 @@ if __name__ == "__main__":
time.sleep(1) time.sleep(1)
processID = subprocess.check_output(psCmd, shell=True) processID = subprocess.check_output(psCmd, shell=True)
for port in range(6030, 6041): port = 6041
usePortPID = "lsof -i tcp:%d | grep LISTEn | awk '{print $2}'" % port usePortPID = f"lsof -i tcp:{port} | grep LISTEN | awk '{{print $2}}'"
processID = subprocess.check_output(usePortPID, shell=True) processID = subprocess.check_output(usePortPID, shell=True)
if processID: if processID:
killCmd = "kill -TERM %s" % processID killCmd = f"kill -TERM {processID}"
os.system(killCmd) os.system(killCmd)
fuserCmd = "fuser -k -n tcp %d" % port fuserCmd = f"fuser -k -n tcp {port}"
os.system(fuserCmd) os.system(fuserCmd)
tdLog.info('stop taosadapter') tdLog.info('stop taosadapter')
...@@ -319,7 +324,7 @@ if __name__ == "__main__": ...@@ -319,7 +324,7 @@ 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 restful: if restful:
tAdapter.deploy(adapter_cfg_dict) tAdapter.deploy(adapter_cfg_dict)
tAdapter.start() tAdapter.start()
...@@ -339,6 +344,26 @@ if __name__ == "__main__": ...@@ -339,6 +344,26 @@ if __name__ == "__main__":
print("check dnode ready") print("check dnode ready")
except Exception as r: except Exception as r:
print(r) print(r)
if queryPolicy != 1:
queryPolicy=int(queryPolicy)
if restful:
conn = taosrest.connect(url=f"http://{host}:6041")
else:
conn = taos.connect(host,config=tdDnodes.getSimCfgPath())
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")
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:
...@@ -453,6 +478,26 @@ if __name__ == "__main__": ...@@ -453,6 +478,26 @@ if __name__ == "__main__":
except Exception as r: except Exception as r:
print(r) print(r)
if queryPolicy != 1:
queryPolicy=int(queryPolicy)
if restful:
conn = taosrest.connect(url=f"http://{host}:6041")
else:
conn = taos.connect(host,config=tdDnodes.getSimCfgPath())
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")
if testCluster: if testCluster:
tdLog.info("Procedures for testing cluster") tdLog.info("Procedures for testing cluster")
...@@ -470,7 +515,7 @@ if __name__ == "__main__": ...@@ -470,7 +515,7 @@ if __name__ == "__main__":
if fileName == "all": if fileName == "all":
tdCases.runAllLinux(conn) tdCases.runAllLinux(conn)
else: else:
tdCases.runOneLinux(conn, fileName) tdCases.runOneLinux(conn, fileName, replicaVar)
if restart: if restart:
if fileName == "all": if fileName == "all":
...@@ -487,7 +532,7 @@ if __name__ == "__main__": ...@@ -487,7 +532,7 @@ if __name__ == "__main__":
conn = taosrest.connect(url=f"http://{host}:6041") 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", replicaVar)
else: else:
tdLog.info("not need to query") tdLog.info("not need to query")
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册