From 0c0d6b43e54338c8199f7e6ece2bac6cb32c7ff7 Mon Sep 17 00:00:00 2001 From: Ping Xiao Date: Mon, 20 Dec 2021 18:05:11 +0800 Subject: [PATCH] [TS-932]: add test case for client clientMerge option --- tests/pytest/fulltest.sh | 1 + tests/pytest/update/updateWithClientMerge.py | 50 ++++++++++++++++++++ tests/pytest/update/update_options.py | 4 +- tests/pytest/util/dnodes.py | 15 ++++-- 4 files changed, 65 insertions(+), 5 deletions(-) create mode 100644 tests/pytest/update/updateWithClientMerge.py diff --git a/tests/pytest/fulltest.sh b/tests/pytest/fulltest.sh index d712e04edf..443992cef6 100755 --- a/tests/pytest/fulltest.sh +++ b/tests/pytest/fulltest.sh @@ -156,6 +156,7 @@ python3 ./test.py -f import_merge/import_update_0.py python3 ./test.py -f import_merge/import_update_1.py python3 ./test.py -f import_merge/import_update_2.py python3 ./test.py -f update/merge_commit_data.py +python3 ./test.py -f update/updateWithClientMerge.py #======================p1-end=============== #======================p2-start=============== # tools diff --git a/tests/pytest/update/updateWithClientMerge.py b/tests/pytest/update/updateWithClientMerge.py new file mode 100644 index 0000000000..3632d77193 --- /dev/null +++ b/tests/pytest/update/updateWithClientMerge.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: + + updatecfgDict={'clientMerge':1} + + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor()) + + self.ts = 1606700000000 + + def run(self): + # TS-932 + tdSql.execute("create database db3 update 2") + tdSql.execute("use db3") + tdSql.execute("drop table if exists tb") + tdSql.execute("create table tb (ts timestamp, c1 int, c2 int, c3 int)") + tdSql.execute("insert into tb values(%d, 1, 2, 3)(%d, null, 4, 5)(%d, 6, null, null)" % (self.ts, self.ts, self.ts)) + + tdSql.query("select * from tb") + tdSql.checkData(0, 1, 6) + tdSql.checkData(0, 2, None) + tdSql.checkData(0, 3, None) + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/update/update_options.py b/tests/pytest/update/update_options.py index f70ac6cc1d..2635ee6784 100644 --- a/tests/pytest/update/update_options.py +++ b/tests/pytest/update/update_options.py @@ -20,6 +20,7 @@ from util.dnodes import * class TDTestCase: + def init(self, conn, logSql): tdLog.debug("start to execute %s" % __file__) tdSql.init(conn.cursor()) @@ -63,7 +64,7 @@ class TDTestCase: tdLog.sleep(3) # test case for https://jira.taosdata.com:18080/browse/TS-402 - tdLog.info("test case for update option 1") + tdLog.info("test case for update option 1") tdSql.execute("create database test update 1") tdSql.execute("use test") @@ -109,7 +110,6 @@ class TDTestCase: tdSql.checkData(0, 1, 6) tdSql.checkData(0, 2, 4) tdSql.checkData(0, 3, 7) - def stop(self): tdSql.close() diff --git a/tests/pytest/util/dnodes.py b/tests/pytest/util/dnodes.py index ff3c271cd8..05539a4e8f 100644 --- a/tests/pytest/util/dnodes.py +++ b/tests/pytest/util/dnodes.py @@ -64,10 +64,12 @@ class TDSimClient: cmd = "echo %s %s >> %s" % (option, value, self.cfgPath) if os.system(cmd) != 0: tdLog.exit(cmd) + def os_string(self,path): os_path = path.replace("/",os.sep) return os_path - def deploy(self): + + def deploy(self, *updatecfgDict): self.logDir = self.os_string("%s/sim/psim/log" % (self.path)) self.cfgDir = self.os_string("%s/sim/psim/cfg" % (self.path)) self.cfgPath = self.os_string("%s/sim/psim/cfg/taos.cfg" % (self.path)) @@ -107,6 +109,13 @@ class TDSimClient: self.cfg("masterIp", "192.168.0.1") self.cfg("secondIp", "192.168.0.2") self.cfg("logDir", self.logDir) + + # update extra client config + clientCfgkeys = ["clientMerge"] + if updatecfgDict[0] and updatecfgDict[0][0]: + for key, value in updatecfgDict[0][0].items(): + if key in clientCfgkeys: + self.cfg(key, value) for key, value in self.cfgDict.items(): self.cfg(key, value) @@ -240,7 +249,7 @@ class TDDnode: else: self.cfg(value,key) else: - self.addExtraCfg(key,value) + self.addExtraCfg(key,value) for key, value in self.cfgDict.items(): self.cfg(key, value) @@ -505,7 +514,7 @@ class TDDnodes: self.sim.setTestCluster(self.testCluster) if (self.simDeployed == False): - self.sim.deploy() + self.sim.deploy(updatecfgDict) self.simDeployed = True self.check(index) -- GitLab