提交 3c81c340 编写于 作者: S Steven Li

Enhanced crash_gen tool to run multiple instances concurrently, by using...

Enhanced crash_gen tool to run multiple instances concurrently, by using dynamic names for tables and databases
上级 dc72a1a6
...@@ -484,8 +484,10 @@ class ThreadCoordinator: ...@@ -484,8 +484,10 @@ class ThreadCoordinator:
if gConfig.max_dbs == 0: if gConfig.max_dbs == 0:
self._dbs.append(Database(0, dbc)) self._dbs.append(Database(0, dbc))
else: else:
baseDbNumber = 0 if gConfig.dynamic_db_table_names else int(datetime.datetime.now(
).timestamp()) % 888 # Don't use Dice/random, as they are deterministic
for i in range(gConfig.max_dbs): for i in range(gConfig.max_dbs):
self._dbs.append(Database(i, dbc)) self._dbs.append(Database(baseDbNumber + i, dbc))
def pickDatabase(self): def pickDatabase(self):
idxDb = 0 idxDb = 0
...@@ -1793,7 +1795,7 @@ class ExecutionStats: ...@@ -1793,7 +1795,7 @@ class ExecutionStats:
"FAILED (reason: {})".format( "FAILED (reason: {})".format(
self._failureReason) if self._failed else "SUCCEEDED")) self._failureReason) if self._failed else "SUCCEEDED"))
Logging.info("| Task Execution Times (success/total):") Logging.info("| Task Execution Times (success/total):")
execTimesAny = 0.001 # avoid div by zero execTimesAny = 0.0
for k, n in self._execTimes.items(): for k, n in self._execTimes.items():
execTimesAny += n[0] execTimesAny += n[0]
errStr = None errStr = None
...@@ -1834,11 +1836,14 @@ class StateTransitionTask(Task): ...@@ -1834,11 +1836,14 @@ class StateTransitionTask(Task):
LARGE_NUMBER_OF_RECORDS = 50 LARGE_NUMBER_OF_RECORDS = 50
SMALL_NUMBER_OF_RECORDS = 3 SMALL_NUMBER_OF_RECORDS = 3
_baseTableNumber = None
_endState = None
@classmethod @classmethod
def getInfo(cls): # each sub class should supply their own information def getInfo(cls): # each sub class should supply their own information
raise RuntimeError("Overriding method expected") raise RuntimeError("Overriding method expected")
_endState = None
@classmethod @classmethod
def getEndState(cls): # TODO: optimize by calling it fewer times def getEndState(cls): # TODO: optimize by calling it fewer times
raise RuntimeError("Overriding method expected") raise RuntimeError("Overriding method expected")
...@@ -1858,7 +1863,9 @@ class StateTransitionTask(Task): ...@@ -1858,7 +1863,9 @@ class StateTransitionTask(Task):
@classmethod @classmethod
def getRegTableName(cls, i): def getRegTableName(cls, i):
return "reg_table_{}".format(i) if ( StateTransitionTask._baseTableNumber is None):
StateTransitionTask._baseTableNumber = 0 if gConfig.dynamic_db_table_names else Dice.throw(999)
return "reg_table_{}".format(StateTransitionTask._baseTableNumber + i)
def execute(self, wt: WorkerThread): def execute(self, wt: WorkerThread):
super().execute(wt) super().execute(wt)
...@@ -2477,6 +2484,9 @@ class MainExec: ...@@ -2477,6 +2484,9 @@ class MainExec:
global gContainer global gContainer
gContainer = Container() # micky-mouse DI gContainer = Container() # micky-mouse DI
global gSvcMgr # TODO: refactor away
gSvcMgr = None
# Super cool Python argument library: # Super cool Python argument library:
# https://docs.python.org/3/library/argparse.html # https://docs.python.org/3/library/argparse.html
parser = argparse.ArgumentParser( parser = argparse.ArgumentParser(
...@@ -2530,6 +2540,12 @@ class MainExec: ...@@ -2530,6 +2540,12 @@ class MainExec:
'--larger-data', '--larger-data',
action='store_true', action='store_true',
help='Write larger amount of data during write operations (default: false)') help='Write larger amount of data during write operations (default: false)')
parser.add_argument(
'-n',
'--dynamic-db-table-names',
action='store_true',
help='Use non-fixed names for dbs/tables, useful for multi-instance executions (default: false)')
parser.add_argument( parser.add_argument(
'-p', '-p',
'--per-thread-db-connection', '--per-thread-db-connection',
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册