From e5b0b962d7e4f7a72a19375f5a79e23f6c3e94e4 Mon Sep 17 00:00:00 2001 From: Shuduo Sang Date: Wed, 13 Apr 2022 17:00:41 +0800 Subject: [PATCH] test: adjust test case for show databases result on 3.0 (#11454) * [TD-13558]: taos shell refactor add taosTools as submodule * add tools/taos-tools * add more client interface for taosTools compile * update taos-tools * update taos-tools * refactor shell * [TD-13558]: taos shell test speed * [TD-13558]: taos -n startup works * taos -n rpc works * taos -n server works * cleanup code since no endPort in 3.0 * update taos-tools * [TD-13558]: taos -C works * improve taos shell -c WIP * update taos-tools * add demoapi.c * adjust show databases result for 3.0 --- tests/pytest/insert/binary.py | 41 +++++++++++++++++++++++++++++++---- 1 file changed, 37 insertions(+), 4 deletions(-) diff --git a/tests/pytest/insert/binary.py b/tests/pytest/insert/binary.py index 0cbb7876c6..567a2eaad5 100644 --- a/tests/pytest/insert/binary.py +++ b/tests/pytest/insert/binary.py @@ -13,6 +13,23 @@ class TDTestCase: tdLog.debug("start to execute %s" % __file__) tdSql.init(conn.cursor(), logSql) + def getPath(self, tool="taos"): + selfPath = os.path.dirname(os.path.realpath(__file__)) + + if ("community" in selfPath): + projPath = selfPath[:selfPath.find("community")] + else: + projPath = selfPath[:selfPath.find("tests")] + + paths = [] + for root, dirs, files in os.walk(projPath): + if ((tool) in files): + rootRealPath = os.path.dirname(os.path.realpath(root)) + if ("packaging" not in rootRealPath): + paths.append(os.path.join(root, tool)) + break + return paths[0] + def run(self): tdSql.prepare() @@ -53,15 +70,31 @@ class TDTestCase: tdLog.info("tdSql.checkData(0, 0, '34567')") tdSql.checkData(0, 0, '34567') tdLog.info("insert into tb values (now+4a, \"'';\")") - config_dir = subprocess.check_output(str("ps -ef |grep dnode1|grep -v grep |awk '{print $NF}'"), stderr=subprocess.STDOUT, shell=True).decode('utf-8').replace('\n', '') - result = ''.join(os.popen(r"""taos -s "insert into db.tb values (now+4a, \"'';\")" -c %s"""%(config_dir)).readlines()) - if "Query OK" not in result: tdLog.exit("err:insert '';") + config_dir = subprocess.check_output( + str("ps -ef |grep dnode1|grep -v grep |awk '{print $NF}'"), + stderr=subprocess.STDOUT, + shell=True).decode('utf-8').replace( + '\n', + '') + + binPath = self.getPath("taos") + if (binPath == ""): + tdLog.exit("taos not found!") + else: + tdLog.info("taos found: %s" % binPath) + + result = ''.join( + os.popen( + r"""%s -s "insert into db.tb values (now+4a, \"'';\")" -c %s""" % + (binPath, (config_dir))).readlines()) + if "Query OK" not in result: + tdLog.exit("err:insert '';") tdLog.info('drop database db') tdSql.execute('drop database db') tdLog.info('show databases') tdSql.query('show databases') tdLog.info('tdSql.checkRow(0)') - tdSql.checkRows(0) + tdSql.checkRows(1) # convert end def stop(self): -- GitLab