From 88d56bcd4ec0ce8741906f7065115bed11afa2de Mon Sep 17 00:00:00 2001 From: Alex Duan <417921451@qq.com> Date: Wed, 17 May 2023 14:29:36 +0800 Subject: [PATCH] test: splite one case to four cases --- .../{restore_basic.py => restoreBasic.py} | 45 +++++-------------- .../3-enterprise/restore/restoreDnode.py | 41 +++++++++++++++++ .../3-enterprise/restore/restoreMnode.py | 42 +++++++++++++++++ .../3-enterprise/restore/restoreQnode.py | 41 +++++++++++++++++ .../3-enterprise/restore/restoreVnode.py | 41 +++++++++++++++++ 5 files changed, 175 insertions(+), 35 deletions(-) rename tests/system-test/3-enterprise/restore/{restore_basic.py => restoreBasic.py} (88%) create mode 100644 tests/system-test/3-enterprise/restore/restoreDnode.py create mode 100644 tests/system-test/3-enterprise/restore/restoreMnode.py create mode 100644 tests/system-test/3-enterprise/restore/restoreQnode.py create mode 100644 tests/system-test/3-enterprise/restore/restoreVnode.py diff --git a/tests/system-test/3-enterprise/restore/restore_basic.py b/tests/system-test/3-enterprise/restore/restoreBasic.py similarity index 88% rename from tests/system-test/3-enterprise/restore/restore_basic.py rename to tests/system-test/3-enterprise/restore/restoreBasic.py index 1a2cdef7fb..0f91916a34 100644 --- a/tests/system-test/3-enterprise/restore/restore_basic.py +++ b/tests/system-test/3-enterprise/restore/restoreBasic.py @@ -28,11 +28,10 @@ import shutil import time -class TDTestCase: +class RestoreBasic: # init def init(self, conn, logSql, replicaVar=1): self.replicaVar = int(replicaVar) - tdLog.debug("start to execute %s" % __file__) tdSql.init(conn.cursor()) self.dnodes_num = 5 @@ -41,17 +40,15 @@ class TDTestCase: self.dnodes = cluster.dnodes num = len(self.dnodes) - if num != self.dnodes_num : - tdLog.exit(f" cluster dnode is not equal 5. num={num}") - return - - print(f" start dnode num={num} !") - for i in range(num): - dnode = self.dnodes[i] - print(f" dnode{i} dataDir={dnode.dataDir} ip={dnode.remoteIP} path={dnode.path}") - - print(" end !") + if num < self.dnodes_num : + tdLog.exit(f" cluster dnode is less than {self.dnodes_num}. num={num}") + # create data + self.dbname = "db" + self.stable = "st" + self.child_count = 100 + self.insert_rows = 10000 + self.create_data() # create data def create_data(self): @@ -97,8 +94,6 @@ class TDTestCase: tdLog.info("check vgroups status successfully.") return True - - # check data corrent def check_corrent(self): # check status @@ -226,29 +221,9 @@ class TDTestCase: tdLog.exit(f"qnode restore failed. qnode.json is not exist. {qfile}") else: tdLog.info(f"check qnode.json restore ok. {qfile}") - - # run - def run(self): - - # create data - self.dbname = "db" - self.stable = "st" - self.child_count = 10 - self.insert_rows = 1000 - self.create_data() - - # remove dnode - index = 1 - self.restore_dnode(2) - self.restore_mnode(3) - self.restore_vnode(4) - self.restore_qnode(5) - # stop def stop(self): tdSql.close() - tdLog.success("%s successfully executed" % __file__) -tdCases.addWindows(__file__, TDTestCase()) -tdCases.addLinux(__file__, TDTestCase()) + diff --git a/tests/system-test/3-enterprise/restore/restoreDnode.py b/tests/system-test/3-enterprise/restore/restoreDnode.py new file mode 100644 index 0000000000..b92c823764 --- /dev/null +++ b/tests/system-test/3-enterprise/restore/restoreDnode.py @@ -0,0 +1,41 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys + +from util.log import * +from util.cases import * +from util.sql import * +from util.common import * +sys.path.append("./3-enterprise/restore") +from restoreBasic import * + + +class TDTestCase: + # init + def init(self, conn, logSql, replicaVar=1): + tdLog.debug("start to execute %s" % __file__) + self.basic = RestoreBasic() + self.basic.init(conn, logSql, replicaVar) + + # run + def run(self): + self.basic.restore_dnode(2) + + # stop + def stop(self): + self.basic.stop() + tdLog.success("%s successfully executed" % __file__) + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/system-test/3-enterprise/restore/restoreMnode.py b/tests/system-test/3-enterprise/restore/restoreMnode.py new file mode 100644 index 0000000000..3f3ccb8a5f --- /dev/null +++ b/tests/system-test/3-enterprise/restore/restoreMnode.py @@ -0,0 +1,42 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys + +from util.log import * +from util.cases import * +from util.sql import * +from util.common import * +sys.path.append("./3-enterprise/restore") +from restoreBasic import * + + + +class TDTestCase: + # init + def init(self, conn, logSql, replicaVar=1): + tdLog.debug("start to execute %s" % __file__) + self.basic = RestoreBasic() + self.basic.init(conn, logSql, replicaVar) + + # run + def run(self): + self.basic.restore_mnode(3) + + # stop + def stop(self): + self.basic.stop() + tdLog.success("%s successfully executed" % __file__) + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/system-test/3-enterprise/restore/restoreQnode.py b/tests/system-test/3-enterprise/restore/restoreQnode.py new file mode 100644 index 0000000000..d2136523e8 --- /dev/null +++ b/tests/system-test/3-enterprise/restore/restoreQnode.py @@ -0,0 +1,41 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys + +from util.log import * +from util.cases import * +from util.sql import * +from util.common import * +sys.path.append("./3-enterprise/restore") +from restoreBasic import * + + +class TDTestCase: + # init + def init(self, conn, logSql, replicaVar=1): + tdLog.debug("start to execute %s" % __file__) + self.basic = RestoreBasic() + self.basic.init(conn, logSql, replicaVar) + + # run + def run(self): + self.basic.restore_qnode(5) + + # stop + def stop(self): + self.basic.stop() + tdLog.success("%s successfully executed" % __file__) + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/system-test/3-enterprise/restore/restoreVnode.py b/tests/system-test/3-enterprise/restore/restoreVnode.py new file mode 100644 index 0000000000..57e95e34c3 --- /dev/null +++ b/tests/system-test/3-enterprise/restore/restoreVnode.py @@ -0,0 +1,41 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys + +from util.log import * +from util.cases import * +from util.sql import * +from util.common import * +sys.path.append("./3-enterprise/restore") +from restoreBasic import * + + +class TDTestCase: + # init + def init(self, conn, logSql, replicaVar=1): + tdLog.debug("start to execute %s" % __file__) + self.basic = RestoreBasic() + self.basic.init(conn, logSql, replicaVar) + + # run + def run(self): + self.basic.restore_dnode(4) + + # stop + def stop(self): + self.basic.stop() + tdLog.success("%s successfully executed" % __file__) + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) -- GitLab