Skip to content

Commit

Permalink
Merge pull request #20864 from taosdata/fix/display_taos
Browse files Browse the repository at this point in the history
fix(shell): update the double display.
  • Loading branch information
hjxilinx committed Apr 12, 2023
2 parents 24c9495 + 985a238 commit 3f5f76a
Show file tree
Hide file tree
Showing 12 changed files with 46 additions and 301 deletions.
4 changes: 2 additions & 2 deletions tests/system-test/2-query/sml.py
Expand Up @@ -24,7 +24,7 @@ def init(self, conn, logSql, replicaVar=1):
tdSql.init(conn.cursor(), True)
#tdSql.init(conn.cursor(), logSql) # output sql.txt file

def checkFileContent(self, dbname="sml_db"):
def checkContent(self, dbname="sml_db"):
simClientCfg="%s/taos.cfg"%tdDnodes.getSimCfgPath()
buildPath = tdCom.getBuildPath()
cmdStr = '%s/build/bin/sml_test %s'%(buildPath, simClientCfg)
Expand Down Expand Up @@ -102,7 +102,7 @@ def checkFileContent(self, dbname="sml_db"):

def run(self):
tdSql.prepare()
self.checkFileContent()
self.checkContent()

def stop(self):
tdSql.close()
Expand Down
28 changes: 0 additions & 28 deletions tests/system-test/7-tmq/dropDbR3ConflictTransaction.py
Expand Up @@ -32,34 +32,6 @@ def init(self, conn, logSql, replicaVar=1):
tdSql.init(conn.cursor())
#tdSql.init(conn.cursor(), logSql) # output sql.txt file

def checkFileContent(self, consumerId, queryString):
buildPath = tdCom.getBuildPath()
cfgPath = tdCom.getClientCfgPath()
dstFile = '%s/../log/dstrows_%d.txt'%(cfgPath, consumerId)
cmdStr = '%s/build/bin/taos -c %s -s "%s >> %s"'%(buildPath, cfgPath, queryString, dstFile)
tdLog.info(cmdStr)
os.system(cmdStr)

consumeRowsFile = '%s/../log/consumerid_%d.txt'%(cfgPath, consumerId)
tdLog.info("rows file: %s, %s"%(consumeRowsFile, dstFile))

consumeFile = open(consumeRowsFile, mode='r')
queryFile = open(dstFile, mode='r')

# skip first line for it is schema
queryFile.readline()

while True:
dst = queryFile.readline()
src = consumeFile.readline()

if dst:
if dst != src:
tdLog.exit("consumerId %d consume rows is not match the rows by direct query"%consumerId)
else:
break
return

def prepareTestEnv(self):
tdLog.printNoPrefix("======== prepare test env include database, stable, ctables, and insert data: ")
paraDict = {'dbName': 'dbt',
Expand Down
30 changes: 1 addition & 29 deletions tests/system-test/7-tmq/tmq3mnodeSwitch.py
Expand Up @@ -138,34 +138,6 @@ def check3mnode1off(self):
else:
tdLog.exit("three mnodes is not ready in 10s ")

def checkFileContent(self, consumerId, queryString):
buildPath = tdCom.getBuildPath()
cfgPath = tdCom.getClientCfgPath()
dstFile = '%s/../log/dstrows_%d.txt'%(cfgPath, consumerId)
cmdStr = '%s/build/bin/taos -c %s -s "%s >> %s"'%(buildPath, cfgPath, queryString, dstFile)
tdLog.info(cmdStr)
os.system(cmdStr)

consumeRowsFile = '%s/../log/consumerid_%d.txt'%(cfgPath, consumerId)
tdLog.info("rows file: %s, %s"%(consumeRowsFile, dstFile))

consumeFile = open(consumeRowsFile, mode='r')
queryFile = open(dstFile, mode='r')

# skip first line for it is schema
queryFile.readline()

while True:
dst = queryFile.readline()
src = consumeFile.readline()

if dst:
if dst != src:
tdLog.exit("consumerId %d consume rows is not match the rows by direct query"%consumerId)
else:
break
return

def tmqCase1(self):
tdLog.printNoPrefix("======== test case 1: ")
paraDict = {'dbName': 'db1',
Expand Down Expand Up @@ -256,7 +228,7 @@ def tmqCase1(self):
tdLog.exit("0 tmq consume rows error!")

if expectRowsList[0] == resultList[0]:
self.checkFileContent(consumerId, queryString)
tmqCom.checkFileContent(consumerId, queryString)

time.sleep(10)
for i in range(len(topicNameList)):
Expand Down
35 changes: 4 additions & 31 deletions tests/system-test/7-tmq/tmqCheckData.py
Expand Up @@ -5,6 +5,7 @@
import socket
import os
import threading
import math

from util.log import *
from util.sql import *
Expand All @@ -21,34 +22,6 @@ def init(self, conn, logSql, replicaVar=1):
tdSql.init(conn.cursor())
#tdSql.init(conn.cursor(), logSql) # output sql.txt file

def checkFileContent(self, consumerId, queryString):
buildPath = tdCom.getBuildPath()
cfgPath = tdCom.getClientCfgPath()
dstFile = '%s/../log/dstrows_%d.txt'%(cfgPath, consumerId)
cmdStr = '%s/build/bin/taos -c %s -s "%s >> %s"'%(buildPath, cfgPath, queryString, dstFile)
tdLog.info(cmdStr)
os.system(cmdStr)

consumeRowsFile = '%s/../log/consumerid_%d.txt'%(cfgPath, consumerId)
tdLog.info("rows file: %s, %s"%(consumeRowsFile, dstFile))

consumeFile = open(consumeRowsFile, mode='r')
queryFile = open(dstFile, mode='r')

# skip first line for it is schema
queryFile.readline()

while True:
dst = queryFile.readline()
src = consumeFile.readline()

if dst:
if dst != src:
tdLog.exit("consumerId %d consume rows is not match the rows by direct query"%consumerId)
else:
break
return

def tmqCase1(self):
tdLog.printNoPrefix("======== test case 1: ")
paraDict = {'dbName': 'db1',
Expand Down Expand Up @@ -109,7 +82,7 @@ def tmqCase1(self):
tdLog.info("expect consume rows: %d, act consume rows: %d"%(expectRowsList[0], resultList[0]))
tdLog.exit("0 tmq consume rows error!")

self.checkFileContent(consumerId, queryString)
tmqCom.checkFileContent(consumerId, queryString)

# reinit consume info, and start tmq_sim, then check consume result
tmqCom.initConsumerTable()
Expand All @@ -135,7 +108,7 @@ def tmqCase1(self):
tdLog.info("expect consume rows: %d, act consume rows: %d"%(expectRowsList[1], resultList[0]))
tdLog.exit("1 tmq consume rows error!")

self.checkFileContent(consumerId, queryString)
tmqCom.checkFileContent(consumerId, queryString)

# reinit consume info, and start tmq_sim, then check consume result
tmqCom.initConsumerTable()
Expand All @@ -161,7 +134,7 @@ def tmqCase1(self):
# tdLog.info("expect consume rows: %d, act consume rows: %d"%(expectRowsList[2], resultList[0]))
# tdLog.exit("2 tmq consume rows error!")

# self.checkFileContent(consumerId, queryString)
# tmqCom.checkFileContent(consumerId, queryString)

time.sleep(10)
for i in range(len(topicNameList)):
Expand Down
34 changes: 3 additions & 31 deletions tests/system-test/7-tmq/tmqCheckData1.py
Expand Up @@ -21,34 +21,6 @@ def init(self, conn, logSql, replicaVar=1):
tdSql.init(conn.cursor())
#tdSql.init(conn.cursor(), logSql) # output sql.txt file

def checkFileContent(self, consumerId, queryString):
buildPath = tdCom.getBuildPath()
cfgPath = tdCom.getClientCfgPath()
dstFile = '%s/../log/dstrows_%d.txt'%(cfgPath, consumerId)
cmdStr = '%s/build/bin/taos -c %s -s "%s >> %s"'%(buildPath, cfgPath, queryString, dstFile)
tdLog.info(cmdStr)
os.system(cmdStr)

consumeRowsFile = '%s/../log/consumerid_%d.txt'%(cfgPath, consumerId)
tdLog.info("rows file: %s, %s"%(consumeRowsFile, dstFile))

consumeFile = open(consumeRowsFile, mode='r')
queryFile = open(dstFile, mode='r')

# skip first line for it is schema
queryFile.readline()

while True:
dst = queryFile.readline()
src = consumeFile.readline()

if dst:
if dst != src:
tdLog.exit("consumerId %d consume rows is not match the rows by direct query"%consumerId)
else:
break
return

def tmqCase1(self):
tdLog.printNoPrefix("======== test case 1: ")
paraDict = {'dbName': 'db1',
Expand Down Expand Up @@ -109,7 +81,7 @@ def tmqCase1(self):
tdLog.info("expect consume rows: %d, act consume rows: %d"%(expectRowsList[0], resultList[0]))
tdLog.exit("0 tmq consume rows error!")

self.checkFileContent(consumerId, queryString)
tmqCom.checkFileContent(consumerId, queryString)

# reinit consume info, and start tmq_sim, then check consume result
tmqCom.initConsumerTable()
Expand All @@ -134,7 +106,7 @@ def tmqCase1(self):
tdLog.info("expect consume rows: %d, act consume rows: %d"%(expectRowsList[1], resultList[0]))
tdLog.exit("1 tmq consume rows error!")

self.checkFileContent(consumerId, queryString)
tmqCom.checkFileContent(consumerId, queryString)

# reinit consume info, and start tmq_sim, then check consume result
tmqCom.initConsumerTable()
Expand All @@ -159,7 +131,7 @@ def tmqCase1(self):
tdLog.info("expect consume rows: %d, act consume rows: %d"%(expectRowsList[2], resultList[0]))
tdLog.exit("2 tmq consume rows error!")

self.checkFileContent(consumerId, queryString)
tmqCom.checkFileContent(consumerId, queryString)

time.sleep(10)
for i in range(len(topicNameList)):
Expand Down
24 changes: 15 additions & 9 deletions tests/system-test/7-tmq/tmqCommon.py
Expand Up @@ -10,7 +10,7 @@
###################################################################

# -*- coding: utf-8 -*-

import math
from asyncore import loop
from collections import defaultdict
import subprocess
Expand Down Expand Up @@ -462,18 +462,24 @@ def checkFileContent(self, consumerId, queryString, skipRowsOfCons=0):
for i in range(0,skipRowsOfCons):
consumeFile.readline()

lines = 0
while True:
dst = queryFile.readline()
src = consumeFile.readline()
lines += 1
if dst:
if dst != src:
tdLog.info("src row: %s"%src)
tdLog.info("dst row: %s"%dst)
tdLog.exit("consumerId %d consume rows[%d] is not match the rows by direct query"%(consumerId, lines))
else:
dstSplit = dst.split(',')
srcSplit = src.split(',')

if not dst or not src:
break
if len(dstSplit) != len(srcSplit):
tdLog.exit("consumerId %d consume rows len is not match the rows by direct query,len(dstSplit):%d != len(srcSplit):%d, dst:%s, src:%s"
%(consumerId, len(dstSplit), len(srcSplit), dst, src))

for i in range(len(dstSplit)):
if srcSplit[i] != dstSplit[i]:
srcFloat = float(srcSplit[i])
dstFloat = float(dstSplit[i])
if not math.isclose(srcFloat, dstFloat, abs_tol=1e-9):
tdLog.exit("consumerId %d consume rows is not match the rows by direct query"%consumerId)
return

def getResultFileByTaosShell(self, consumerId, queryString):
Expand Down
28 changes: 0 additions & 28 deletions tests/system-test/7-tmq/tmqConsumerGroup.py
Expand Up @@ -21,34 +21,6 @@ def init(self, conn, logSql, replicaVar=1):
tdSql.init(conn.cursor())
#tdSql.init(conn.cursor(), logSql) # output sql.txt file

def checkFileContent(self, consumerId, queryString):
buildPath = tdCom.getBuildPath()
cfgPath = tdCom.getClientCfgPath()
dstFile = '%s/../log/dstrows_%d.txt'%(cfgPath, consumerId)
cmdStr = '%s/build/bin/taos -c %s -s "%s >> %s"'%(buildPath, cfgPath, queryString, dstFile)
tdLog.info(cmdStr)
os.system(cmdStr)

consumeRowsFile = '%s/../log/consumerid_%d.txt'%(cfgPath, consumerId)
tdLog.info("rows file: %s, %s"%(consumeRowsFile, dstFile))

consumeFile = open(consumeRowsFile, mode='r')
queryFile = open(dstFile, mode='r')

# skip first line for it is schema
queryFile.readline()

while True:
dst = queryFile.readline()
src = consumeFile.readline()

if dst:
if dst != src:
tdLog.exit("consumerId %d consume rows is not match the rows by direct query"%consumerId)
else:
break
return

def tmqCase1(self):
tdLog.printNoPrefix("======== test case 1: ")
paraDict = {'dbName': 'db1',
Expand Down
36 changes: 4 additions & 32 deletions tests/system-test/7-tmq/tmqUdf-multCtb-snapshot0.py
Expand Up @@ -60,34 +60,6 @@ def create_udf_function(self):
tdLog.exit("create udf functions fail")
return

def checkFileContent(self, consumerId, queryString):
buildPath = tdCom.getBuildPath()
cfgPath = tdCom.getClientCfgPath()
dstFile = '%s/../log/dstrows_%d.txt'%(cfgPath, consumerId)
cmdStr = '%s/build/bin/taos -c %s -s "%s >> %s"'%(buildPath, cfgPath, queryString, dstFile)
tdLog.info(cmdStr)
os.system(cmdStr)

consumeRowsFile = '%s/../log/consumerid_%d.txt'%(cfgPath, consumerId)
tdLog.info("rows file: %s, %s"%(consumeRowsFile, dstFile))

consumeFile = open(consumeRowsFile, mode='r')
queryFile = open(dstFile, mode='r')

# skip first line for it is schema
queryFile.readline()

while True:
dst = queryFile.readline()
src = consumeFile.readline()

if dst:
if dst != src:
tdLog.exit("consumerId %d consume rows is not match the rows by direct query"%consumerId)
else:
break
return

def prepareTestEnv(self):
tdLog.printNoPrefix("======== prepare test env include database, stable, ctables, and insert data: ")
paraDict = {'dbName': 'dbt',
Expand Down Expand Up @@ -199,7 +171,7 @@ def tmqCase1(self):
tdLog.info("expect consume rows: %d, act consume rows: %d"%(expectRowsList[0], resultList[0]))
tdLog.exit("0 tmq consume rows error!")

# self.checkFileContent(consumerId, queryString)
# tmqCom.checkFileContent(consumerId, queryString)
# tdLog.printNoPrefix("consumerId %d check data ok!"%(consumerId))

# reinit consume info, and start tmq_sim, then check consume result
Expand All @@ -226,7 +198,7 @@ def tmqCase1(self):
tdLog.info("expect consume rows: %d, act consume rows: %d"%(expectRowsList[1], resultList[0]))
tdLog.exit("1 tmq consume rows error!")

# self.checkFileContent(consumerId, queryString)
# tmqCom.checkFileContent(consumerId, queryString)
# tdLog.printNoPrefix("consumerId %d check data ok!"%(consumerId))

time.sleep(10)
Expand Down Expand Up @@ -309,7 +281,7 @@ def tmqCase2(self):
tdLog.info("expect consume rows: %d, act consume rows: %d"%(expectRowsList[0], resultList[0]))
tdLog.exit("2 tmq consume rows error!")

# self.checkFileContent(consumerId, queryString)
# tmqCom.checkFileContent(consumerId, queryString)
# tdLog.printNoPrefix("consumerId %d check data ok!"%(consumerId))

# reinit consume info, and start tmq_sim, then check consume result
Expand All @@ -336,7 +308,7 @@ def tmqCase2(self):
tdLog.info("expect consume rows: %d, act consume rows: %d"%(expectRowsList[1], resultList[0]))
tdLog.exit("3 tmq consume rows error!")

# self.checkFileContent(consumerId, queryString)
# tmqCom.checkFileContent(consumerId, queryString)
# tdLog.printNoPrefix("consumerId %d check data ok!"%(consumerId))

time.sleep(10)
Expand Down

0 comments on commit 3f5f76a

Please sign in to comment.