TDengine/tests/army/tools/benchmark/basic/connMode.py
Linhe Huo e273a943ea
fix: add show connMode string (#30323)
* fix: add show connMode string

* fix: add stdbool.h to pub.h

* fix: remove trash file army/output.txt

* fix: caseBase.py modify syntax error

* fix: restore -R option for taosdump

* fix: taosdumpCommandline.py case

* fix: native stmt write normal table failed

* fix: taosdumpCommandline.py case passed

* fix: restore test.py from main branch

* fix: taosCli.py check default conn mode

* fix: commandline-sml.py case pass

* fix: websiteCase.py case passed

* fix: connMode.py case

* fix: modify default port is 0

* fix: taos_options with config dir not work

* fix: websocket.py delete -D timeout options

* fix: default_tmq_json.py context move to default_json.py, so delete

* fix python kafka bug

* chore: improve taos_init in wrapper

* chore: add installation path preparation in build workflow

* fix connMode bug

* fix: fix tmq conf/consumer new error in wrapperFunc.c

* fix: correct the spelling toss -> taosGetInstall...

* chore: fix compile error in wrapperFunc.c

* fix: createConnect fix memory leak

* fix: tsim forbid CHECK  ODR

* modify userOperTest uuse static lib

* reverse userOperTest use static lib

---------

Co-authored-by: Alex Duan <417921451@qq.com>
Co-authored-by: taos-support <it@taosdata.com>
Co-authored-by: “chris <“zk662144@163.com”>
Co-authored-by: t_max <1172915550@qq.com>
Co-authored-by: sheyanjie-qq <249478495@qq.com>
2025-03-22 20:44:07 +08:00

161 lines
4.6 KiB
Python

###################################################################
# 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 os, signal
import os
from time import sleep
import frame
import frame.etool
from frame.log import *
from frame.cases import *
from frame.sql import *
from frame.caseBase import *
from frame import *
class TDTestCase(TBase):
def caseDescription(self):
"""
taosBenchmark public->connMode test cases
"""
# expect cmd > evn > json
def checkPriority(self):
#
# cmd & json
#
# cmd first 6041 - valid
options = "-X http://127.0.0.1:6041"
# json 6042 - invalid
json = "tools/benchmark/basic/json/connModePriorityErrDsn.json"
self.insertBenchJson(json, options, True)
#
# env > json
#
# env 6041 - valid
os.environ['TDENGINE_CLOUD_DSN'] = "http://127.0.0.1:6041"
# json 6042 - invalid
json = "tools/benchmark/basic/json/connModePriorityErrDsn.json"
self.insertBenchJson(json, "", True)
#
# cmd & json & evn
#
# cmd 6041 - valid
options = "-X http://127.0.0.1:6041"
# env 6043 - invalid
os.environ['TDENGINE_CLOUD_DSN'] = "http://127.0.0.1:6043"
# json 6042 - invalid
json = "tools/benchmark/basic/json/connModePriorityErrDsn.json"
self.insertBenchJson(json, options, True)
# clear env
os.environ['TDENGINE_CLOUD_DSN'] = ""
def checkCommandLine(self):
# default CONN_MODE
DEFAULT_CONN_MODE = "Native"
# modes
modes = ["", "-Z 1 -B 1", "-Z websocket", "-Z 0", "-Z native -B 2"]
# result
Rows = "insert rows: 9990"
results1 = [
[f"Connect mode is : {DEFAULT_CONN_MODE}", Rows],
["Connect mode is : WebSocket", Rows],
["Connect mode is : WebSocket", Rows],
["Connect mode is : Native", Rows],
["Connect mode is : Native", Rows],
]
# iface todo add sml
iface = ["taosc", "stmt", "stmt2"]
# do check
for face in iface:
for i in range(len(modes)):
self.benchmarkCmd(f"{modes[i]} -I {face}", 10, 999, 1000, results1[i])
def checkExceptCmd(self):
# exe
bench = frame.etool.benchMarkFile()
# option
options = [
"-Z native -X http://127.0.0.1:6041",
"-Z 100",
"-Z abcdefg",
"-X",
"-X 127.0.0.1:6041",
"-X https://gw.cloud.taosdata.com?token617ffdf...",
"-Z 1 -X https://gw.cloud.taosdata.com?token=617ffdf...",
"-X http://127.0.0.1:6042"
]
# do check
for option in options:
self.checkExcept(bench + " -y " + option)
def checkHostPort(self):
#
# ommand
#
self.benchmarkCmd("-h 127.0.0.1", 5, 100, 10, ["insert rows: 500"])
self.benchmarkCmd("-h 127.0.0.1 -uroot -ptaosdata", 5, 100, 10, ["insert rows: 500"])
self.benchmarkCmd("-Z 0 -h 127.0.0.1 -P 6030 -uroot -ptaosdata", 5, 100, 10, ["insert rows: 500"])
#
# command & json
#
# 6041 is default
options = "-Z 1 -h 127.0.0.1 -P 6041 -uroot -ptaosdata"
json = "tools/benchmark/basic/json/connModePriorityErrHost.json"
self.insertBenchJson(json, options, True)
# cmd port first json port
options = "-Z native -P 6030"
json = "tools/benchmark/basic/json/connModePriority.json"
self.insertBenchJson(json, options, True)
options = "-Z websocket -P 6041"
json = "tools/benchmark/basic/json/connModePriority.json"
self.insertBenchJson(json, options, True)
def run(self):
# init
self.db = "test"
self.stb = "meters"
# command line test
self.checkCommandLine()
# except
self.checkExceptCmd()
# cmd > json > env
self.checkPriority()
# host and port
self.checkHostPort()
def stop(self):
tdSql.close()
tdLog.success("%s successfully executed" % __file__)
tdCases.addWindows(__file__, TDTestCase())
tdCases.addLinux(__file__, TDTestCase())