Added limited data verification to crash_gen tool, with -v option
This commit is contained in:
parent
59b080f00d
commit
46b3204afb
|
@ -317,7 +317,7 @@ class ThreadCoordinator:
|
||||||
logger.debug("[TRD] Main thread waking up at step {}, tapping worker threads".format(
|
logger.debug("[TRD] Main thread waking up at step {}, tapping worker threads".format(
|
||||||
self._curStep)) # Now not all threads had time to go to sleep
|
self._curStep)) # Now not all threads had time to go to sleep
|
||||||
# Worker threads will wake up at this point, and each execute it's own task
|
# Worker threads will wake up at this point, and each execute it's own task
|
||||||
self.tapAllThreads() # release all worker thread from their "gate"
|
self.tapAllThreads() # release all worker thread from their "gates"
|
||||||
|
|
||||||
def _syncAtBarrier(self):
|
def _syncAtBarrier(self):
|
||||||
# Now main thread (that's us) is ready to enter a step
|
# Now main thread (that's us) is ready to enter a step
|
||||||
|
@ -818,7 +818,7 @@ class MyTDSql:
|
||||||
def _execInternal(self, sql):
|
def _execInternal(self, sql):
|
||||||
startTime = time.time()
|
startTime = time.time()
|
||||||
ret = self._cursor.execute(sql)
|
ret = self._cursor.execute(sql)
|
||||||
print("\nSQL success: {}".format(sql))
|
# print("\nSQL success: {}".format(sql))
|
||||||
queryTime = time.time() - startTime
|
queryTime = time.time() - startTime
|
||||||
# Record the query time
|
# Record the query time
|
||||||
cls = self.__class__
|
cls = self.__class__
|
||||||
|
@ -1339,7 +1339,6 @@ class StateMechine:
|
||||||
if rnd < 0:
|
if rnd < 0:
|
||||||
return i
|
return i
|
||||||
|
|
||||||
|
|
||||||
class Database:
|
class Database:
|
||||||
''' We use this to represent an actual TDengine database inside a service instance,
|
''' We use this to represent an actual TDengine database inside a service instance,
|
||||||
possibly in a cluster environment.
|
possibly in a cluster environment.
|
||||||
|
@ -1356,7 +1355,6 @@ class Database:
|
||||||
self._stateMachine = StateMechine(self)
|
self._stateMachine = StateMechine(self)
|
||||||
self._stateMachine.init(dbc)
|
self._stateMachine.init(dbc)
|
||||||
|
|
||||||
|
|
||||||
self._lock = threading.RLock()
|
self._lock = threading.RLock()
|
||||||
|
|
||||||
def getStateMachine(self) -> StateMechine:
|
def getStateMachine(self) -> StateMechine:
|
||||||
|
@ -1878,9 +1876,12 @@ class TaskCreateDb(StateTransitionTask):
|
||||||
# Actually creating the database(es)
|
# Actually creating the database(es)
|
||||||
def _executeInternal(self, te: TaskExecutor, wt: WorkerThread):
|
def _executeInternal(self, te: TaskExecutor, wt: WorkerThread):
|
||||||
# was: self.execWtSql(wt, "create database db")
|
# was: self.execWtSql(wt, "create database db")
|
||||||
numReplica = Dice.throw(3) + 1 # 1,2,3
|
repStr = ""
|
||||||
self.execWtSql(wt, "create database {} replica {}"
|
if gConfig.max_replicas != 1:
|
||||||
.format(self._db.getName(), numReplica) )
|
numReplica = Dice.throw(gConfig.max_replicas) + 1 # 1,2 ... N
|
||||||
|
repStr = "replica {}".format(numReplica)
|
||||||
|
self.execWtSql(wt, "create database {} {}"
|
||||||
|
.format(self._db.getName(), repStr) )
|
||||||
|
|
||||||
class TaskDropDb(StateTransitionTask):
|
class TaskDropDb(StateTransitionTask):
|
||||||
@classmethod
|
@classmethod
|
||||||
|
@ -2234,22 +2235,23 @@ class TaskAddData(StateTransitionTask):
|
||||||
os.fsync(self.fAddLogDone)
|
os.fsync(self.fAddLogDone)
|
||||||
|
|
||||||
# Now read it back and verify, we might encounter an error if table is dropped
|
# Now read it back and verify, we might encounter an error if table is dropped
|
||||||
try:
|
if gConfig.verify_data: # only if command line asks for it
|
||||||
readBack = dbc.queryScalar("SELECT speed from {}.{} WHERE ts= '{}'".
|
try:
|
||||||
format(db.getName(), regTableName, nextTick))
|
readBack = dbc.queryScalar("SELECT speed from {}.{} WHERE ts= '{}'".
|
||||||
if readBack != nextInt :
|
format(db.getName(), regTableName, nextTick))
|
||||||
raise taos.error.ProgrammingError(
|
if readBack != nextInt :
|
||||||
"Failed to read back same data, wrote: {}, read: {}"
|
raise taos.error.ProgrammingError(
|
||||||
.format(nextInt, readBack), 0x999)
|
"Failed to read back same data, wrote: {}, read: {}"
|
||||||
except taos.error.ProgrammingError as err:
|
.format(nextInt, readBack), 0x999)
|
||||||
errno = Helper.convertErrno(err.errno)
|
except taos.error.ProgrammingError as err:
|
||||||
if errno in [0x991, 0x992] : # not a single result
|
errno = Helper.convertErrno(err.errno)
|
||||||
raise taos.error.ProgrammingError(
|
if errno in [0x991, 0x992] : # not a single result
|
||||||
"Failed to read back same data for tick: {}, wrote: {}, read: {}"
|
raise taos.error.ProgrammingError(
|
||||||
.format(nextTick, nextInt, "Empty Result" if errno==0x991 else "Multiple Result"),
|
"Failed to read back same data for tick: {}, wrote: {}, read: {}"
|
||||||
errno)
|
.format(nextTick, nextInt, "Empty Result" if errno==0x991 else "Multiple Result"),
|
||||||
# Re-throw no matter what
|
errno)
|
||||||
raise
|
# Re-throw no matter what
|
||||||
|
raise
|
||||||
|
|
||||||
|
|
||||||
self.activeTable.discard(i) # not raising an error, unlike remove
|
self.activeTable.discard(i) # not raising an error, unlike remove
|
||||||
|
@ -3042,6 +3044,13 @@ def main():
|
||||||
'--run-tdengine',
|
'--run-tdengine',
|
||||||
action='store_true',
|
action='store_true',
|
||||||
help='Run TDengine service in foreground (default: false)')
|
help='Run TDengine service in foreground (default: false)')
|
||||||
|
parser.add_argument(
|
||||||
|
'-i',
|
||||||
|
'--max-replicas',
|
||||||
|
action='store',
|
||||||
|
default=1,
|
||||||
|
type=int,
|
||||||
|
help='Maximum number of replicas to use, when testing against clusters. (default: 1)')
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
'-l',
|
'-l',
|
||||||
'--larger-data',
|
'--larger-data',
|
||||||
|
@ -3071,6 +3080,11 @@ def main():
|
||||||
default=5,
|
default=5,
|
||||||
type=int,
|
type=int,
|
||||||
help='Number of threads to run (default: 10)')
|
help='Number of threads to run (default: 10)')
|
||||||
|
parser.add_argument(
|
||||||
|
'-v',
|
||||||
|
'--verify-data',
|
||||||
|
action='store_true',
|
||||||
|
help='Verify data written in a number of places by reading back (default: false)')
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
'-x',
|
'-x',
|
||||||
'--continue-on-exception',
|
'--continue-on-exception',
|
||||||
|
|
Loading…
Reference in New Issue