Added limited data verification to crash_gen tool, with -v option

This commit is contained in:
Steven Li 2020-09-16 07:59:47 +00:00
parent 59b080f00d
commit 46b3204afb
1 changed files with 37 additions and 23 deletions

View File

@ -317,7 +317,7 @@ class ThreadCoordinator:
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
# 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):
# Now main thread (that's us) is ready to enter a step
@ -818,7 +818,7 @@ class MyTDSql:
def _execInternal(self, sql):
startTime = time.time()
ret = self._cursor.execute(sql)
print("\nSQL success: {}".format(sql))
# print("\nSQL success: {}".format(sql))
queryTime = time.time() - startTime
# Record the query time
cls = self.__class__
@ -1339,7 +1339,6 @@ class StateMechine:
if rnd < 0:
return i
class Database:
''' We use this to represent an actual TDengine database inside a service instance,
possibly in a cluster environment.
@ -1356,7 +1355,6 @@ class Database:
self._stateMachine = StateMechine(self)
self._stateMachine.init(dbc)
self._lock = threading.RLock()
def getStateMachine(self) -> StateMechine:
@ -1878,9 +1876,12 @@ class TaskCreateDb(StateTransitionTask):
# Actually creating the database(es)
def _executeInternal(self, te: TaskExecutor, wt: WorkerThread):
# was: self.execWtSql(wt, "create database db")
numReplica = Dice.throw(3) + 1 # 1,2,3
self.execWtSql(wt, "create database {} replica {}"
.format(self._db.getName(), numReplica) )
repStr = ""
if gConfig.max_replicas != 1:
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):
@classmethod
@ -2234,6 +2235,7 @@ class TaskAddData(StateTransitionTask):
os.fsync(self.fAddLogDone)
# Now read it back and verify, we might encounter an error if table is dropped
if gConfig.verify_data: # only if command line asks for it
try:
readBack = dbc.queryScalar("SELECT speed from {}.{} WHERE ts= '{}'".
format(db.getName(), regTableName, nextTick))
@ -3042,6 +3044,13 @@ def main():
'--run-tdengine',
action='store_true',
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(
'-l',
'--larger-data',
@ -3071,6 +3080,11 @@ def main():
default=5,
type=int,
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(
'-x',
'--continue-on-exception',