提交 bf45ff56 编写于 作者: wmmhello's avatar wmmhello

fix:modify fileContent for data compare

上级 20013b3f
...@@ -138,34 +138,6 @@ class TDTestCase: ...@@ -138,34 +138,6 @@ class TDTestCase:
else: else:
tdLog.exit("three mnodes is not ready in 10s ") 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): def tmqCase1(self):
tdLog.printNoPrefix("======== test case 1: ") tdLog.printNoPrefix("======== test case 1: ")
paraDict = {'dbName': 'db1', paraDict = {'dbName': 'db1',
...@@ -256,7 +228,7 @@ class TDTestCase: ...@@ -256,7 +228,7 @@ class TDTestCase:
tdLog.exit("0 tmq consume rows error!") tdLog.exit("0 tmq consume rows error!")
if expectRowsList[0] == resultList[0]: if expectRowsList[0] == resultList[0]:
self.checkFileContent(consumerId, queryString) tqCom.checkFileContent(consumerId, queryString)
time.sleep(10) time.sleep(10)
for i in range(len(topicNameList)): for i in range(len(topicNameList)):
......
...@@ -5,6 +5,7 @@ import time ...@@ -5,6 +5,7 @@ import time
import socket import socket
import os import os
import threading import threading
import math
from util.log import * from util.log import *
from util.sql import * from util.sql import *
...@@ -21,34 +22,6 @@ class TDTestCase: ...@@ -21,34 +22,6 @@ class TDTestCase:
tdSql.init(conn.cursor()) tdSql.init(conn.cursor())
#tdSql.init(conn.cursor(), logSql) # output sql.txt file #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): def tmqCase1(self):
tdLog.printNoPrefix("======== test case 1: ") tdLog.printNoPrefix("======== test case 1: ")
paraDict = {'dbName': 'db1', paraDict = {'dbName': 'db1',
...@@ -109,7 +82,7 @@ class TDTestCase: ...@@ -109,7 +82,7 @@ class TDTestCase:
tdLog.info("expect consume rows: %d, act consume rows: %d"%(expectRowsList[0], resultList[0])) tdLog.info("expect consume rows: %d, act consume rows: %d"%(expectRowsList[0], resultList[0]))
tdLog.exit("0 tmq consume rows error!") 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 # reinit consume info, and start tmq_sim, then check consume result
tmqCom.initConsumerTable() tmqCom.initConsumerTable()
...@@ -135,7 +108,7 @@ class TDTestCase: ...@@ -135,7 +108,7 @@ class TDTestCase:
tdLog.info("expect consume rows: %d, act consume rows: %d"%(expectRowsList[1], resultList[0])) tdLog.info("expect consume rows: %d, act consume rows: %d"%(expectRowsList[1], resultList[0]))
tdLog.exit("1 tmq consume rows error!") 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 # reinit consume info, and start tmq_sim, then check consume result
tmqCom.initConsumerTable() tmqCom.initConsumerTable()
......
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
################################################################### ###################################################################
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
import math
from asyncore import loop from asyncore import loop
from collections import defaultdict from collections import defaultdict
import subprocess import subprocess
...@@ -462,18 +462,22 @@ class TMQCom: ...@@ -462,18 +462,22 @@ class TMQCom:
for i in range(0,skipRowsOfCons): for i in range(0,skipRowsOfCons):
consumeFile.readline() consumeFile.readline()
lines = 0
while True: while True:
dst = queryFile.readline() dst = queryFile.readline()
src = consumeFile.readline() src = consumeFile.readline()
lines += 1 dstSplit = dst.split(',')
if dst: srcSplit = src.split(',')
if dst != src:
tdLog.info("src row: %s"%src) if len(dstSplit) != len(srcSplit):
tdLog.info("dst row: %s"%dst) tdLog.exit("consumerId %d consume rows len is not match the rows by direct query"%consumerId)
tdLog.exit("consumerId %d consume rows[%d] is not match the rows by direct query"%(consumerId, lines)) if not dst or not src:
else:
break break
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 return
def getResultFileByTaosShell(self, consumerId, queryString): def getResultFileByTaosShell(self, consumerId, queryString):
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册