homework-jianmu/tests/system-test/7-tmq/tmq_ts6115.py

117 lines
3.4 KiB
Python

import taos
import sys
import time
import socket
import os
import threading
from util.log import *
from util.sql import *
from util.cases import *
from util.dnodes import *
from util.common import *
sys.path.append("./7-tmq")
insertJson = '''{
"filetype": "insert",
"cfgdir": "/etc/taos",
"host": "localhost",
"port": 6030,
"user": "root",
"password": "taosdata",
"connection_pool_size": 10,
"thread_count": 10,
"create_table_thread_count": 10,
"result_file": "./insert-2-2-1.txt",
"confirm_parameter_prompt": "no",
"num_of_records_per_req": 3600,
"prepared_rand": 3600,
"chinese": "no",
"escape_character": "yes",
"continue_if_fail": "no",
"databases": [
{
"dbinfo": {
"name": "ts6115",
"drop": "yes",
"vgroups": 10,
"precision": "ms",
"buffer": 512,
"cachemodel":"'both'",
"stt_trigger": 1
},
"super_tables": [
{
"name": "stb",
"child_table_exists": "no",
"childtable_count": 10000,
"childtable_prefix": "d_",
"auto_create_table": "yes",
"batch_create_tbl_num": 10,
"data_source": "csv",
"insert_mode": "stmt",
"non_stop_mode": "no",
"line_protocol": "line",
"insert_rows": 1000,
"childtable_limit": 0,
"childtable_offset": 0,
"interlace_rows": 0,
"insert_interval": 0,
"partial_col_num": 0,
"timestamp_step": 1000,
"start_timestamp": "2024-11-01 00:00:00.000",
"sample_format": "csv",
"sample_file": "./td_double10000_juchi.csv",
"use_sample_ts": "no",
"tags_file": "",
"columns": [
{"type": "DOUBLE", "name": "val"},
{ "type": "INT", "name": "quality"}
],
"tags": [
{"type": "INT", "name": "id", "max": 100, "min": 1}
]
}
]
}
]
}'''
class TDTestCase:
updatecfgDict = {'debugFlag': 135, 'asynclog': 0}
clientCfgDict = {'debugFlag': 135, 'asynclog': 0}
updatecfgDict["clientCfg"] = clientCfgDict
def init(self, conn, logSql, replicaVar=1):
self.replicaVar = int(replicaVar)
tdLog.debug(f"start to excute {__file__}")
tdSql.init(conn.cursor())
#tdSql.init(conn.cursor(), logSql) # output sql.txt file
def run(self):
with open('ts-6115.json', 'w') as file:
file.write(insertJson)
tdLog.info("start to insert data: taosBenchmark -f ts-6115.json")
if os.system("taosBenchmark -f ts-6115.json") != 0:
tdLog.exit("taosBenchmark -f ts-6115.json")
tdLog.info("test ts-6115 ......")
buildPath = tdCom.getBuildPath()
cmdStr = '%s/build/bin/tmq_ts6115'%(buildPath)
tdLog.info(cmdStr)
if os.system(cmdStr) != 0:
tdLog.exit(cmdStr)
return
def stop(self):
tdSql.close()
tdLog.success(f"{__file__} successfully executed")
tdCases.addLinux(__file__, TDTestCase())
tdCases.addWindows(__file__, TDTestCase())