test: enable telnet_tcp.py case

This commit is contained in:
Shuduo Sang 2022-11-09 14:39:13 +08:00
parent 9533ad4198
commit fd7d0f5928
6 changed files with 49 additions and 59 deletions

View File

@ -17,13 +17,7 @@
"databases": [{ "databases": [{
"dbinfo": { "dbinfo": {
"name": "db", "name": "db",
"drop": "yes", "drop": "yes"
"replica": 1,
"precision": "ms",
"keep": 36500,
"minRows": 100,
"maxRows": 4096,
"comp":2
}, },
"super_tables": [{ "super_tables": [{
"name": "stb1", "name": "stb1",

View File

@ -16,36 +16,40 @@ from util.log import *
from util.cases import * from util.cases import *
from util.sql import * from util.sql import *
from util.dnodes import * from util.dnodes import *
from util.taosadapter import *
class TDTestCase: class TDTestCase:
def caseDescription(self): def caseDescription(self):
''' """
[TD-11510] taosBenchmark test cases [TD-11510] taosBenchmark test cases
''' """
return
def init(self, conn, logSql, replicaVar=1): def init(self, conn, logSql, replicaVar=1):
self.replicaVar = int(replicaVar)
tdLog.debug("start to execute %s" % __file__) tdLog.debug("start to execute %s" % __file__)
tdSql.init(conn.cursor(), logSql) tdSql.init(conn.cursor(), logSql)
def getPath(self, tool="taosBenchmark"): def getPath(self, tool="taosBenchmark"):
selfPath = os.path.dirname(os.path.realpath(__file__)) selfPath = os.path.dirname(os.path.realpath(__file__))
if ("community" in selfPath): if "community" in selfPath:
projPath = selfPath[:selfPath.find("community")] projPath = selfPath[: selfPath.find("community")]
elif "src" in selfPath:
projPath = selfPath[: selfPath.find("src")]
elif "/tools/" in selfPath:
projPath = selfPath[: selfPath.find("/tools/")]
elif "/tests/" in selfPath:
projPath = selfPath[: selfPath.find("/tests/")]
else: else:
projPath = selfPath[:selfPath.find("tests")] tdLog.exit("cannot found %s in path: %s, use system's" % (tool, selfPath))
paths = [] paths = []
for root, dirs, files in os.walk(projPath): for root, dirs, files in os.walk(projPath):
if ((tool) in files): if (tool) in files:
rootRealPath = os.path.dirname(os.path.realpath(root)) rootRealPath = os.path.dirname(os.path.realpath(root))
if ("packaging" not in rootRealPath): if "packaging" not in rootRealPath:
paths.append(os.path.join(root, tool)) paths.append(os.path.join(root, tool))
break break
if (len(paths) == 0): if len(paths) == 0:
tdLog.exit("taosBenchmark not found!") tdLog.exit("taosBenchmark not found!")
return return
else: else:
@ -53,38 +57,30 @@ class TDTestCase:
return paths[0] return paths[0]
def run(self): def run(self):
tAdapter.init("")
adapter_cfg = {
"influxdb": {
"enable": True
},
"opentsdb": {
"enable": True
},
"opentsdb_telnet": {
"enable": True,
"maxTCPConnection": 250,
"tcpKeepAlive": True,
"dbs": ["opentsdb_telnet", "collectd", "icinga2", "tcollector"],
"ports": [6046, 6047, 6048, 6049],
"user": "root",
"password": "taosdata"
}
}
tAdapter.update_cfg(adapter_cfg)
tAdapter.deploy()
tAdapter.start()
binPath = self.getPath() binPath = self.getPath()
cmd = "%s -f ./5-taos-tools/taosbenchmark/json/sml_telnet_tcp.json" %binPath cmd = "%s -f ./5-taos-tools/taosbenchmark/json/sml_telnet_tcp.json" % binPath
tdLog.info("%s" % cmd) tdLog.info("%s" % cmd)
os.system("%s" % cmd) os.system("%s" % cmd)
time.sleep(5) time.sleep(5)
tdSql.execute("reset query cache") tdSql.execute("reset query cache")
tdSql.query("select count(*) from (select distinct(tbname) from opentsdb_telnet.stb1)") tdSql.query("select client_version()")
client_ver = "".join(tdSql.queryResult[0])
major_ver = client_ver.split(".")[0]
if major_ver == "3":
tdSql.query(
"select count(*) from (select distinct(tbname) from opentsdb_telnet.stb1)"
)
else:
tdSql.query("select count(tbname) from opentsdb_telnet.stb1")
tdSql.checkData(0, 0, 8) tdSql.checkData(0, 0, 8)
tdSql.query("select count(*) from opentsdb_telnet.stb1") tdSql.query("select count(*) from opentsdb_telnet.stb1")
tdSql.checkData(0, 0, 160) tdSql.checkData(0, 0, 160)
tdSql.query("select count(*) from (select distinct(tbname) from opentsdb_telnet.stb2)") if major_ver == "3":
tdSql.query(
"select count(*) from (select distinct(tbname) from opentsdb_telnet.stb2)"
)
else:
tdSql.query("select count(tbname) from opentsdb_telnet.stb2")
tdSql.checkData(0, 0, 8) tdSql.checkData(0, 0, 8)
tdSql.query("select count(*) from opentsdb_telnet.stb2") tdSql.query("select count(*) from opentsdb_telnet.stb2")
tdSql.checkData(0, 0, 160) tdSql.checkData(0, 0, 160)

View File

@ -17,5 +17,5 @@ python3 ./test.py -f 5-taos-tools/taosbenchmark/sample_csv_json.py
python3 ./test.py -f 5-taos-tools/taosbenchmark/sml_json_alltypes.py python3 ./test.py -f 5-taos-tools/taosbenchmark/sml_json_alltypes.py
#python3 ./test.py -f 5-taos-tools/taosbenchmark/sml_telnet_alltypes.py #python3 ./test.py -f 5-taos-tools/taosbenchmark/sml_telnet_alltypes.py
#python3 ./test.py -f 5-taos-tools/taosbenchmark/taosadapter_json.py #python3 ./test.py -f 5-taos-tools/taosbenchmark/taosadapter_json.py
#python3 ./test.py -f 5-taos-tools/taosbenchmark/telnet_tcp.py python3 ./test.py -f 5-taos-tools/taosbenchmark/telnet_tcp.py -R
python3 ./test.py -f 5-taos-tools/taosbenchmark/taosdemoTestQueryWithJson.py -R python3 ./test.py -f 5-taos-tools/taosbenchmark/taosdemoTestQueryWithJson.py -R

View File

@ -238,7 +238,7 @@ if __name__ == "__main__":
time.sleep(2) time.sleep(2)
if restful: if restful:
toBeKilled = "taosadapt" toBeKilled = "taosadapter"
# killCmd = "ps -ef|grep -w %s| grep -v grep | awk '{print $2}' | xargs kill -TERM > /dev/null 2>&1" % toBeKilled # killCmd = "ps -ef|grep -w %s| grep -v grep | awk '{print $2}' | xargs kill -TERM > /dev/null 2>&1" % toBeKilled
killCmd = f"pkill {toBeKilled}" killCmd = f"pkill {toBeKilled}"

View File

@ -13,7 +13,7 @@ class TAdapter:
"debug" : True, "debug" : True,
"taosConfigDir" : "", "taosConfigDir" : "",
"port" : 6041, "port" : 6041,
"logLevel" : "debug", "logLevel" : "error",
"cors" : { "cors" : {
"allowAllOrigins" : True, "allowAllOrigins" : True,
}, },
@ -49,25 +49,25 @@ class TAdapter:
"writeInterval" : "30s" "writeInterval" : "30s"
}, },
"opentsdb" : { "opentsdb" : {
"enable" : False "enable" : True
}, },
"influxdb" : { "influxdb" : {
"enable" : False "enable" : True
}, },
"statsd" : { "statsd" : {
"enable" : False "enable" : True
}, },
"collectd" : { "collectd" : {
"enable" : False "enable" : True
}, },
"opentsdb_telnet" : { "opentsdb_telnet" : {
"enable" : False "enable" : True
}, },
"node_exporter" : { "node_exporter" : {
"enable" : False "enable" : True
}, },
"prometheus" : { "prometheus" : {
"enable" : False "enable" : True
}, },
} }
# TODO: add taosadapter env: # TODO: add taosadapter env:
@ -164,7 +164,7 @@ class TAdapter:
if platform.system().lower() == 'windows': if platform.system().lower() == 'windows':
cmd = f"mintty -h never {bin_path} -c {self.cfg_dir}" cmd = f"mintty -h never {bin_path} -c {self.cfg_dir}"
else: else:
cmd = f"nohup {bin_path} -c {self.cfg_path} > /dev/null 2>&1 & " cmd = f"nohup {bin_path} -c {self.cfg_path} > /dev/null & "
if self.remoteIP: if self.remoteIP:
self.remote_exec(self.taosadapter_cfg_dict, f"tAdapter.deployed=1\ntAdapter.log_dir={self.log_dir}\ntAdapter.cfg_dir={self.cfg_dir}\ntAdapter.start()") self.remote_exec(self.taosadapter_cfg_dict, f"tAdapter.deployed=1\ntAdapter.log_dir={self.log_dir}\ntAdapter.cfg_dir={self.cfg_dir}\ntAdapter.start()")
@ -213,7 +213,7 @@ class TAdapter:
if platform.system().lower() == 'windows': if platform.system().lower() == 'windows':
cmd = f"mintty -h never {bin_path} -c {self.cfg_dir}" cmd = f"mintty -h never {bin_path} -c {self.cfg_dir}"
else: else:
cmd = f"nohup {bin_path} -c {self.cfg_path} > /dev/null 2>&1 & " cmd = f"nohup {bin_path} -c {self.cfg_path} > /dev/null & "
if self.remoteIP: if self.remoteIP:
self.remote_exec(self.taosadapter_cfg_dict, f"tAdapter.deployed=1\ntAdapter.log_dir={self.log_dir}\ntAdapter.cfg_dir={self.cfg_dir}\ntAdapter.start()") self.remote_exec(self.taosadapter_cfg_dict, f"tAdapter.deployed=1\ntAdapter.log_dir={self.log_dir}\ntAdapter.cfg_dir={self.cfg_dir}\ntAdapter.start()")
@ -243,7 +243,7 @@ class TAdapter:
psCmd, shell=True) psCmd, shell=True)
while(processID): while(processID):
killCmd = f"pkill {signal} {processID} > /dev/null 2>&1" killCmd = f"pkill {signal} {processID} > /dev/null "
os.system(killCmd) os.system(killCmd)
time.sleep(1) time.sleep(1)
processID = subprocess.check_output( processID = subprocess.check_output(

View File

@ -215,7 +215,7 @@ if __name__ == "__main__":
time.sleep(2) time.sleep(2)
if restful: if restful:
toBeKilled = "taosadapt" toBeKilled = "taosadapter"
# killCmd = "ps -ef|grep -w %s| grep -v grep | awk '{print $2}' | xargs kill -TERM > /dev/null 2>&1" % toBeKilled # killCmd = "ps -ef|grep -w %s| grep -v grep | awk '{print $2}' | xargs kill -TERM > /dev/null 2>&1" % toBeKilled
killCmd = f"pkill {toBeKilled}" killCmd = f"pkill {toBeKilled}"