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

test:modify test frame that add multiple retries for sql execution and query

上级 e8a0cf5b
...@@ -283,16 +283,27 @@ class TDSql: ...@@ -283,16 +283,27 @@ class TDSql:
time.sleep(1) time.sleep(1)
continue continue
def execute(self, sql): def execute(self, sql,queyTimes=10):
self.sql = sql self.sql = sql
try: i=1
self.affectedRows = self.cursor.execute(sql) while i <= queyTimes:
except Exception as e: try:
caller = inspect.getframeinfo(inspect.stack()[1][0]) self.affectedRows = self.cursor.execute(sql)
args = (caller.filename, caller.lineno, sql, repr(e)) return self.affectedRows
tdLog.notice("%s(%d) failed: sql:%s, %s" % args) except Exception as e:
raise Exception(repr(e)) i+=1
return self.affectedRows tdLog.notice("Try to execute sql again, query times: %d "%i)
pass
else:
try:
tdLog.notice("Try the last execute sql ")
self.affectedRows = self.cursor.execute(sql)
return self.affectedRows
except Exception as e:
caller = inspect.getframeinfo(inspect.stack()[1][0])
args = (caller.filename, caller.lineno, sql, repr(e))
tdLog.notice("%s(%d) failed: sql:%s, %s" % args)
raise Exception(repr(e))
def checkAffectedRows(self, expectAffectedRows): def checkAffectedRows(self, expectAffectedRows):
if self.affectedRows != expectAffectedRows: if self.affectedRows != expectAffectedRows:
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册