提交 1be46ac7 编写于 作者: S Steven Li

Now able to run without parameter, also refactored to run service binary

上级 23ed5e24
...@@ -686,7 +686,8 @@ class StateHasData(AnyState): ...@@ -686,7 +686,8 @@ class StateHasData(AnyState):
self.assertNoTask(tasks, TaskAddData) self.assertNoTask(tasks, TaskAddData)
# self.hasSuccess(tasks, DeleteDataTasks) # self.hasSuccess(tasks, DeleteDataTasks)
else: # should be STATE_HAS_DATA else: # should be STATE_HAS_DATA
self.assertNoTask(tasks, TaskDropDb) if (not self.hasTask(tasks, TaskCreateDb) ): # only if we didn't create one
self.assertNoTask(tasks, TaskDropDb) # we shouldn't have dropped it
if (not self.hasTask(tasks, TaskCreateSuperTable)) : # if we didn't create the table if (not self.hasTask(tasks, TaskCreateSuperTable)) : # if we didn't create the table
self.assertNoTask(tasks, TaskDropSuperTable) # we should not have a task that drops it self.assertNoTask(tasks, TaskDropSuperTable) # we should not have a task that drops it
# self.assertIfExistThenSuccess(tasks, ReadFixedDataTask) # self.assertIfExistThenSuccess(tasks, ReadFixedDataTask)
...@@ -1295,58 +1296,26 @@ class LoggingFilter(logging.Filter): ...@@ -1295,58 +1296,26 @@ class LoggingFilter(logging.Filter):
# return False # return False
return True return True
class MainExec:
@classmethod
def main(): def runClient(cls):
# Super cool Python argument library: https://docs.python.org/3/library/argparse.html
parser = argparse.ArgumentParser(
formatter_class=argparse.RawDescriptionHelpFormatter,
description=textwrap.dedent('''\
TDengine Auto Crash Generator (PLEASE NOTICE the Prerequisites Below)
---------------------------------------------------------------------
1. You build TDengine in the top level ./build directory, as described in offical docs
2. You run the server there before this script: ./build/bin/taosd -c test/cfg
'''))
parser.add_argument('-d', '--debug', action='store_true',
help='Turn on DEBUG mode for more logging (default: false)')
parser.add_argument('-l', '--larger-data', action='store_true',
help='Write larger amount of data during write operations (default: false)')
parser.add_argument('-p', '--per-thread-db-connection', action='store_true',
help='Use a single shared db connection (default: false)')
parser.add_argument('-r', '--record-ops', action='store_true',
help='Use a pair of always-fsynced fils to record operations performing + performed, for power-off tests (default: false)')
parser.add_argument('-s', '--max-steps', action='store', default=100, type=int,
help='Maximum number of steps to run (default: 100)')
parser.add_argument('-t', '--num-threads', action='store', default=10, type=int,
help='Number of threads to run (default: 10)')
global gConfig
gConfig = parser.parse_args()
if len(sys.argv) == 1:
parser.print_help()
sys.exit()
global logger
logger = logging.getLogger('CrashGen')
logger.addFilter(LoggingFilter())
if ( gConfig.debug ):
logger.setLevel(logging.DEBUG) # default seems to be INFO
else:
logger.setLevel(logging.INFO)
ch = logging.StreamHandler()
logger.addHandler(ch)
# resetDb = False # DEBUG only # resetDb = False # DEBUG only
# dbState = DbState(resetDb) # DBEUG only! # dbState = DbState(resetDb) # DBEUG only!
dbManager = DbManager() # Regular function dbManager = DbManager() # Regular function
Dice.seed(0) # initial seeding of dice Dice.seed(0) # initial seeding of dice
tc = ThreadCoordinator( thPool = ThreadPool(gConfig.num_threads, gConfig.max_steps)
ThreadPool(gConfig.num_threads, gConfig.max_steps), tc = ThreadCoordinator(thPool, dbManager)
# WorkDispatcher(dbState), # Obsolete?
dbManager tc.run()
) tc.logStats()
dbManager.cleanUp()
@classmethod
def runService(cls):
print("Running service...")
@classmethod
def runTemp(cls): # for debugging purposes
# # Hack to exercise reading from disk, imcreasing coverage. TODO: fix # # Hack to exercise reading from disk, imcreasing coverage. TODO: fix
# dbc = dbState.getDbConn() # dbc = dbState.getDbConn()
# sTbName = dbState.getFixedSuperTableName() # sTbName = dbState.getFixedSuperTableName()
...@@ -1382,17 +1351,61 @@ def main(): ...@@ -1382,17 +1351,61 @@ def main():
# except taos.error.ProgrammingError as err: # except taos.error.ProgrammingError as err:
# logger.info("Initial WRITE/READ error: {}".format(err)) # logger.info("Initial WRITE/READ error: {}".format(err))
# Sandbox testing code # Sandbox testing code
# dbc = dbState.getDbConn() # dbc = dbState.getDbConn()
# while True: # while True:
# rows = dbc.query("show databases") # rows = dbc.query("show databases")
# print("Rows: {}, time={}".format(rows, time.time())) # print("Rows: {}, time={}".format(rows, time.time()))
return
def main():
# Super cool Python argument library: https://docs.python.org/3/library/argparse.html
parser = argparse.ArgumentParser(
formatter_class=argparse.RawDescriptionHelpFormatter,
description=textwrap.dedent('''\
TDengine Auto Crash Generator (PLEASE NOTICE the Prerequisites Below)
---------------------------------------------------------------------
1. You build TDengine in the top level ./build directory, as described in offical docs
2. You run the server there before this script: ./build/bin/taosd -c test/cfg
'''))
parser.add_argument('-d', '--debug', action='store_true',
help='Turn on DEBUG mode for more logging (default: false)')
parser.add_argument('-e', '--run-tdengine', action='store_true',
help='Run TDengine service in foreground (default: false)')
parser.add_argument('-l', '--larger-data', action='store_true',
help='Write larger amount of data during write operations (default: false)')
parser.add_argument('-p', '--per-thread-db-connection', action='store_false',
help='Use a single shared db connection (default: false)')
parser.add_argument('-r', '--record-ops', action='store_true',
help='Use a pair of always-fsynced fils to record operations performing + performed, for power-off tests (default: false)')
parser.add_argument('-s', '--max-steps', action='store', default=1000, type=int,
help='Maximum number of steps to run (default: 100)')
parser.add_argument('-t', '--num-threads', action='store', default=5, type=int,
help='Number of threads to run (default: 10)')
global gConfig
gConfig = parser.parse_args()
# if len(sys.argv) == 1:
# parser.print_help()
# sys.exit()
global logger
logger = logging.getLogger('CrashGen')
logger.addFilter(LoggingFilter())
if ( gConfig.debug ):
logger.setLevel(logging.DEBUG) # default seems to be INFO
else:
logger.setLevel(logging.INFO)
ch = logging.StreamHandler()
logger.addHandler(ch)
if gConfig.run_tdengine : # run server
MainExec.runService()
else :
MainExec.runClient()
tc.run()
tc.logStats()
dbManager.cleanUp()
# logger.info("Crash_Gen execution finished") # logger.info("Crash_Gen execution finished")
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册