From 5746eb5c655b6600284b70245b0c4deb46435576 Mon Sep 17 00:00:00 2001 From: liuyq-617 Date: Mon, 11 Jan 2021 18:42:31 +0800 Subject: [PATCH] fix dict error --- tests/pytest/multilevel/basic.py | 7 +- tests/pytest/multilevel/dirNotExist.py | 49 ++++++++++++ tests/pytest/multilevel/moreThan16disks.py | 80 +++++++++++++++++++ .../pytest/multilevel/multiMainMountPoint.py | 50 ++++++++++++ tests/pytest/multilevel/noneMainMountPoint.py | 50 ++++++++++++ tests/pytest/multilevel/tt.py | 20 +++++ tests/pytest/util/dnodes.py | 18 ++++- tests/pytest/util/sql.py | 20 ++--- 8 files changed, 278 insertions(+), 16 deletions(-) create mode 100644 tests/pytest/multilevel/dirNotExist.py create mode 100644 tests/pytest/multilevel/moreThan16disks.py create mode 100644 tests/pytest/multilevel/multiMainMountPoint.py create mode 100644 tests/pytest/multilevel/noneMainMountPoint.py create mode 100644 tests/pytest/multilevel/tt.py diff --git a/tests/pytest/multilevel/basic.py b/tests/pytest/multilevel/basic.py index 8ae8d9868a..b3e38cb6ce 100644 --- a/tests/pytest/multilevel/basic.py +++ b/tests/pytest/multilevel/basic.py @@ -30,12 +30,15 @@ class TDTestCase: self.startTime = 1520000010000 tdDnodes.stop(1) + print('-'*40) cfg={ - 'dataDir': '/mnt/data1', - 'dataDir': '/mnt/data2 0 0' + '/mnt/data1' : 'dataDir', + '/mnt/data2 0 0' : 'dataDir' } + print('*'*40) tdSql.createDir('/mnt/data1') tdSql.createDir('/mnt/data2') + print('+'*40) tdDnodes.deploy(1,cfg) tdDnodes.startWithoutSleep(1) diff --git a/tests/pytest/multilevel/dirNotExist.py b/tests/pytest/multilevel/dirNotExist.py new file mode 100644 index 0000000000..a0d9d4c5bf --- /dev/null +++ b/tests/pytest/multilevel/dirNotExist.py @@ -0,0 +1,49 @@ +################################################################### +# 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 +import taos +from util.log import * +from util.cases import * +from util.sql import * +from util.dnodes import * + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def run(self): + self.ntables = 10 + self.rowsPerTable = 10 + self.startTime = 1520000010000 + + tdDnodes.stop(1) + cfg={ + 'dataDir': '/mnt/data1 0 0 ', + 'dataDir': '/mnt/data2 0 0' + } + tdSql.createDir('/mnt/data1') + tdDnodes.deploy(1,cfg) + tdDnodes.startWithoutSleep(1) + + tdSql.taosdStatus(0) + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/multilevel/moreThan16disks.py b/tests/pytest/multilevel/moreThan16disks.py new file mode 100644 index 0000000000..09af90f160 --- /dev/null +++ b/tests/pytest/multilevel/moreThan16disks.py @@ -0,0 +1,80 @@ +################################################################### +# 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 +import taos +from util.log import * +from util.cases import * +from util.sql import * +from util.dnodes import * + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def run(self): + self.ntables = 10 + self.rowsPerTable = 10 + self.startTime = 1520000010000 + + tdDnodes.stop(1) + cfg={ + 'dataDir': '/mnt/data1 0 0', + 'dataDir': '/mnt/data2 0 0', + 'dataDir': '/mnt/data3 0 0', + 'dataDir': '/mnt/data4 0 0', + 'dataDir': '/mnt/data5 0 0', + 'dataDir': '/mnt/data6 0 0', + 'dataDir': '/mnt/data7 0 0', + 'dataDir': '/mnt/data8 0 0', + 'dataDir': '/mnt/data9 0 0', + 'dataDir': '/mnt/data10 0 0', + 'dataDir': '/mnt/data11 0 0', + 'dataDir': '/mnt/data12 0 0', + 'dataDir': '/mnt/data13 0 0', + 'dataDir': '/mnt/data14 0 0', + 'dataDir': '/mnt/data15 0 0', + 'dataDir': '/mnt/data16 0 0', + 'dataDir': '/mnt/data17 0 0' + } + tdSql.createDir('/mnt/data1') + tdSql.createDir('/mnt/data2') + tdSql.createDir('/mnt/data3') + tdSql.createDir('/mnt/data4') + tdSql.createDir('/mnt/data5') + tdSql.createDir('/mnt/data6') + tdSql.createDir('/mnt/data7') + tdSql.createDir('/mnt/data8') + tdSql.createDir('/mnt/data9') + tdSql.createDir('/mnt/data10') + tdSql.createDir('/mnt/data11') + tdSql.createDir('/mnt/data12') + tdSql.createDir('/mnt/data13') + tdSql.createDir('/mnt/data14') + tdSql.createDir('/mnt/data15') + tdSql.createDir('/mnt/data16') + tdSql.createDir('/mnt/data17') + tdDnodes.deploy(1,cfg) + tdDnodes.startWithoutSleep(1) + + tdSql.taosdStatus(0) + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/multilevel/multiMainMountPoint.py b/tests/pytest/multilevel/multiMainMountPoint.py new file mode 100644 index 0000000000..4a0a913b23 --- /dev/null +++ b/tests/pytest/multilevel/multiMainMountPoint.py @@ -0,0 +1,50 @@ +################################################################### +# 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 +import taos +from util.log import * +from util.cases import * +from util.sql import * +from util.dnodes import * + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def run(self): + self.ntables = 10 + self.rowsPerTable = 10 + self.startTime = 1520000010000 + + tdDnodes.stop(1) + cfg={ + 'dataDir': '/mnt/data1', + 'dataDir': '/mnt/data2' + } + tdSql.createDir('/mnt/data1') + tdSql.createDir('/mnt/data2') + tdDnodes.deploy(1,cfg) + tdDnodes.startWithoutSleep(1) + + tdSql.taosdStatus(0) + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/multilevel/noneMainMountPoint.py b/tests/pytest/multilevel/noneMainMountPoint.py new file mode 100644 index 0000000000..2a6e092bf7 --- /dev/null +++ b/tests/pytest/multilevel/noneMainMountPoint.py @@ -0,0 +1,50 @@ +################################################################### +# 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 +import taos +from util.log import * +from util.cases import * +from util.sql import * +from util.dnodes import * + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def run(self): + self.ntables = 10 + self.rowsPerTable = 10 + self.startTime = 1520000010000 + + tdDnodes.stop(1) + cfg={ + 'dataDir': '/mnt/data1 0 0', + 'dataDir': '/mnt/data2 0 0' + } + tdSql.createDir('/mnt/data1') + tdSql.createDir('/mnt/data2') + tdDnodes.deploy(1,cfg) + tdDnodes.startWithoutSleep(1) + + tdSql.taosdStatus(0) + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/multilevel/tt.py b/tests/pytest/multilevel/tt.py new file mode 100644 index 0000000000..a84e3f80c9 --- /dev/null +++ b/tests/pytest/multilevel/tt.py @@ -0,0 +1,20 @@ +cfg={ + '/mnt/data1 0 0': 'dataDir' , + 'dataDir': '/mnt/data2 0 0', + 'dataDir': '/mnt/data3 0 0', + 'dataDir': '/mnt/data4 0 0', + 'dataDir': '/mnt/data5 0 0', + 'dataDir': '/mnt/data6 0 0', + 'dataDir': '/mnt/data7 0 0', + 'dataDir': '/mnt/data8 0 0', + 'dataDir': '/mnt/data9 0 0', + 'dataDir': '/mnt/data10 0 0', + 'dataDir': '/mnt/data11 0 0', + 'dataDir': '/mnt/data12 0 0', + 'dataDir': '/mnt/data13 0 0', + 'dataDir': '/mnt/data14 0 0', + 'dataDir': '/mnt/data15 0 0', + 'dataDir': '/mnt/data16 0 0', + 'dataDir': '/mnt/data17 0 0' + } +print(cfg) \ No newline at end of file diff --git a/tests/pytest/util/dnodes.py b/tests/pytest/util/dnodes.py index afea23372f..117dfe5f07 100644 --- a/tests/pytest/util/dnodes.py +++ b/tests/pytest/util/dnodes.py @@ -208,14 +208,24 @@ class TDDnode: self.cfg("publicIp", "192.168.0.%d" % (self.index)) self.cfg("internalIp", "192.168.0.%d" % (self.index)) self.cfg("privateIp", "192.168.0.%d" % (self.index)) - - self.cfg("dataDir",self.dataDir) - self.cfg("logDir",self.logDir) + self.cfgDict["dataDir"] = self.dataDir + self.cfgDict["logDir"] = self.logDir + # self.cfg("dataDir",self.dataDir) + # self.cfg("logDir",self.logDir) print(updatecfgDict) + isFirstDir = 1 if updatecfgDict[0] and updatecfgDict[0][0]: print(updatecfgDict[0][0]) for key,value in updatecfgDict[0][0].items(): - self.addExtraCfg(key,value) + if value == 'dataDir' : + if isFirstDir: + self.cfgDict.pop('dataDir') + self.cfg(value,key) + isFirstDir = 0 + else: + self.cfg(value,key) + else: + self.addExtraCfg(key,value) for key, value in self.cfgDict.items(): self.cfg(key, value) diff --git a/tests/pytest/util/sql.py b/tests/pytest/util/sql.py index 6deeae2d0b..904a647b7f 100644 --- a/tests/pytest/util/sql.py +++ b/tests/pytest/util/sql.py @@ -199,33 +199,33 @@ class TDSql: break if loop:break time.sleep(5) - + args=(pstate,state) if pstate == state: - tdLog.info("taosd state is %d == expect:%d",pstate,state) + tdLog.info("taosd state is %d == expect:%d" %args) else: - tdLog.exit("taosd state is %d != expect:%d" ,pstate,state) + tdLog.exit("taosd state is %d != expect:%d" %args) pass def haveFile(self, dir, state): if os.path.exists(dir) and os.path.isdir(dir): if not os.listdir(dir): if state : - tdLog.exit("dir: %s is empty, expect: not empty" ,dir) + tdLog.exit("dir: %s is empty, expect: not empty" %dir) else: - tdLog.info("dir: %s is empty, expect: empty" ,dir) + tdLog.info("dir: %s is empty, expect: empty" %dir) else: if state : - tdLog.info("dir: %s is empty, expect: not empty" ,dir) + tdLog.info("dir: %s is empty, expect: not empty" %dir) else: - tdLog.exit("dir: %s is empty, expect: empty" ,dir) + tdLog.exit("dir: %s is empty, expect: empty" %dir) else: - tdLog.exit("dir: %s doesn't exist" ,dir) + tdLog.exit("dir: %s doesn't exist" %dir) def createDir(self, dir): if os.path.exists(dir): shutil.rmtree(dir) - tdLog.info("dir: %s is removed" ,dir) + tdLog.info("dir: %s is removed" %dir) os.makedirs( dir, 755 ) - tdLog.info("dir: %s is created" ,dir) + tdLog.info("dir: %s is created" %dir) pass tdSql = TDSql() -- GitLab