diff --git a/tests/perftest-scripts/taosadapter_perftest/opentsdb_json_createStb.jmx b/tests/perftest-scripts/taosadapter_perftest/opentsdb_json_createStb.jmx new file mode 100644 index 0000000000000000000000000000000000000000..11f0ed8f64a51aee50be99cc4ee8f1b7450b34e8 --- /dev/null +++ b/tests/perftest-scripts/taosadapter_perftest/opentsdb_json_createStb.jmx @@ -0,0 +1,191 @@ + + + + + + false + true + false + + + + + + + + continue + + false + 1 + + 1 + 1 + false + + + true + + + + true + + + + false + create database if not exists test precision 'ms' + = + + + + + + + + http://192.168.1.85:6041/rest/sql + POST + true + false + true + false + + + + + + + false + + saveConfig + + + true + true + true + + true + true + true + true + false + true + true + false + false + false + true + false + false + false + true + 0 + true + true + true + true + true + true + + + + + + + + + Authorization + Basic cm9vdDp0YW9zZGF0YQ== + + + + + + + continue + + false + looptimes + + 100 + + false + + + true + + + + true + + + + false + {"metric": "cpu.usage_user_${__Random(1,100000,)}_${__Random(1,100000,)}_${__Random(1,100000,)}", "timestamp":1626006833640, "value":32.261068286779754, "tags":{"arch":"x64","datacenter":"us-west-1b","hostname":"host_5","os":"Ubuntu16","rack":"13","region":"us-west-1","service":"10","service_environment":"staging","service_version":"0","team":"NYC"}} + = + + + + + + + + http://192.168.1.85:6041/opentsdb/v1/put/json/test + POST + true + false + true + false + + + + + + + false + + saveConfig + + + true + true + true + + true + true + true + true + false + true + true + false + false + false + true + false + false + false + true + 0 + true + true + true + true + true + true + + + + + + + + + Authorization + Basic cm9vdDp0YW9zZGF0YQ== + + + + + + + + diff --git a/tests/perftest-scripts/taosadapter_perftest/opentsdb_json_createTb.jmx b/tests/perftest-scripts/taosadapter_perftest/opentsdb_json_createTb.jmx new file mode 100644 index 0000000000000000000000000000000000000000..053480dc47a9c26cd5faf0b0fb277c3fa060b87d --- /dev/null +++ b/tests/perftest-scripts/taosadapter_perftest/opentsdb_json_createTb.jmx @@ -0,0 +1,191 @@ + + + + + + false + true + false + + + + + + + + continue + + false + 1 + + 1 + 1 + false + + + true + + + + true + + + + false + create database if not exists test precision 'ms' + = + + + + + + + + http://192.168.1.85:6041/rest/sql + POST + true + false + true + false + + + + + + + false + + saveConfig + + + true + true + true + + true + true + true + true + false + true + true + false + false + false + true + false + false + false + true + 0 + true + true + true + true + true + true + + + + + + + + + Authorization + Basic cm9vdDp0YW9zZGF0YQ== + + + + + + + continue + + false + looptimes + + 100 + + false + + + true + + + + true + + + + false + {"metric": "cpu.usage_user", "timestamp":1626006833640, "value":32.261068286779754, "tags":{"arch":"x64","datacenter":"us-west-1b","hostname":"host_5","os":"Ubuntu16","rack":"${__Random(1,100000,)}","region":"us-west-1","service":"${__Random(1,100000,)}","service_environment":"staging","service_version":"${__Random(1,100000,)}","team":"NYC"}} + = + + + + + + + + http://192.168.1.85:6041/opentsdb/v1/put/json/test + POST + true + false + true + false + + + + + + + false + + saveConfig + + + true + true + true + + true + true + true + true + false + true + true + false + false + false + true + false + false + false + true + 0 + true + true + true + true + true + true + + + + + + + + + Authorization + Basic cm9vdDp0YW9zZGF0YQ== + + + + + + + + diff --git a/tests/perftest-scripts/taosadapter_perftest/opentsdb_json_insertRows.jmx b/tests/perftest-scripts/taosadapter_perftest/opentsdb_json_insertRows.jmx new file mode 100644 index 0000000000000000000000000000000000000000..be8b8bdc2b8491b6f1689ad45b31e026dcae6f23 --- /dev/null +++ b/tests/perftest-scripts/taosadapter_perftest/opentsdb_json_insertRows.jmx @@ -0,0 +1,200 @@ + + + + + + false + true + false + + + + + + + + continue + + false + 1 + + 1 + 1 + false + + + true + + + + true + + + + false + create database if not exists test precision 'ms' + = + + + + + + + + http://192.168.1.85:6041/rest/sql + POST + true + false + true + false + + + + + + + false + + saveConfig + + + true + true + true + + true + true + true + true + false + true + true + false + false + false + true + false + false + false + true + 0 + true + true + true + true + true + true + + + + + + + + + Authorization + Basic cm9vdDp0YW9zZGF0YQ== + + + + + + + continue + + false + looptimes + + 24 + + false + + + true + + + + true + + + + false + {"metric": "cpu.usage_user.rows", "timestamp":${ts_counter}, "value":32.261068286779754, "tags":{"arch":"x64","datacenter":"us-west-1b","hostname":"host_5","os":"Ubuntu16","rack":"13","region":"us-west-1","service":"10","service_environment":"staging","service_version":"0","team":"NYC"}} + = + + + + + + + + http://192.168.1.85:6041/opentsdb/v1/put/json/test + POST + true + false + true + false + + + + + + + false + + saveConfig + + + true + true + true + + true + true + true + true + false + true + true + false + false + false + true + false + false + false + true + 0 + true + true + true + true + true + true + + + + + + + + + Authorization + Basic cm9vdDp0YW9zZGF0YQ== + + + + + + 1614530008000 + + 1 + ts_counter + + false + + + + + + diff --git a/tests/perftest-scripts/taosadapter_perftest/opentsdb_telnet_createStb.jmx b/tests/perftest-scripts/taosadapter_perftest/opentsdb_telnet_createStb.jmx new file mode 100644 index 0000000000000000000000000000000000000000..0a7a6aad4790bb0e8dca56f58eb8ef447ebe1f89 --- /dev/null +++ b/tests/perftest-scripts/taosadapter_perftest/opentsdb_telnet_createStb.jmx @@ -0,0 +1,191 @@ + + + + + + false + true + false + + + + + + + + continue + + false + 1 + + 1 + 1 + false + + + true + + + + true + + + + false + create database if not exists test precision 'ms' + = + + + + + + + + http://192.168.1.85:6041/rest/sql + POST + true + false + true + false + + + + + + + false + + saveConfig + + + true + true + true + + true + true + true + true + false + true + true + false + false + false + true + false + false + false + true + 0 + true + true + true + true + true + true + + + + + + + + + Authorization + Basic cm9vdDp0YW9zZGF0YQ== + + + + + + + continue + + false + looptimes + + 100 + + false + + + true + + + + true + + + + false + cpu.usage_user_${__Random(1,100000,)}_${__Random(1,100000,)}_${__Random(1,100000,)} 1626006833640 32.261068286779754 arch=x64 datacenter=us-west-1b hostname=host_5 os=Ubuntu16 rack=13 region=us-west-1 service=10 service_environment=staging service_version=0 team=NYC + = + + + + + + + + http://192.168.1.85:6041/opentsdb/v1/put/telnet/test + POST + true + false + true + false + + + + + + + false + + saveConfig + + + true + true + true + + true + true + true + true + false + true + true + false + false + false + true + false + false + false + true + 0 + true + true + true + true + true + true + + + + + + + + + Authorization + Basic cm9vdDp0YW9zZGF0YQ== + + + + + + + + diff --git a/tests/perftest-scripts/taosadapter_perftest/opentsdb_telnet_createTb.jmx b/tests/perftest-scripts/taosadapter_perftest/opentsdb_telnet_createTb.jmx new file mode 100644 index 0000000000000000000000000000000000000000..6e7a8268f092c13ddf3e1896702aa23fe94221d0 --- /dev/null +++ b/tests/perftest-scripts/taosadapter_perftest/opentsdb_telnet_createTb.jmx @@ -0,0 +1,191 @@ + + + + + + false + true + false + + + + + + + + continue + + false + 1 + + 1 + 1 + false + + + true + + + + true + + + + false + create database if not exists test precision 'ms' + = + + + + + + + + http://192.168.1.85:6041/rest/sql + POST + true + false + true + false + + + + + + + false + + saveConfig + + + true + true + true + + true + true + true + true + false + true + true + false + false + false + true + false + false + false + true + 0 + true + true + true + true + true + true + + + + + + + + + Authorization + Basic cm9vdDp0YW9zZGF0YQ== + + + + + + + continue + + false + looptimes + + 100 + + false + + + true + + + + true + + + + false + cpu.usage_user 1626006833640 32.261068286779754 arch=x64 datacenter=us-west-1b hostname=host_5 os=Ubuntu16 rack=${__Random(1,100000,)} region=us-west-1 service=${__Random(1,100000,)} service_environment=staging service_version=${__Random(1,100000,)} team=NYC + = + + + + + + + + http://192.168.1.85:6041/opentsdb/v1/put/telnet/test + POST + true + false + true + false + + + + + + + false + + saveConfig + + + true + true + true + + true + true + true + true + false + true + true + false + false + false + true + false + false + false + true + 0 + true + true + true + true + true + true + + + + + + + + + Authorization + Basic cm9vdDp0YW9zZGF0YQ== + + + + + + + + diff --git a/tests/perftest-scripts/taosadapter_perftest/opentsdb_telnet_insertRows.jmx b/tests/perftest-scripts/taosadapter_perftest/opentsdb_telnet_insertRows.jmx new file mode 100644 index 0000000000000000000000000000000000000000..eb86c0b2fc1b307fae1881f278fde9c5f0ed27b8 --- /dev/null +++ b/tests/perftest-scripts/taosadapter_perftest/opentsdb_telnet_insertRows.jmx @@ -0,0 +1,200 @@ + + + + + + false + true + false + + + + + + + + continue + + false + 1 + + 1 + 1 + false + + + true + + + + true + + + + false + create database if not exists test precision 'ms' + = + + + + + + + + http://192.168.1.85:6041/rest/sql + POST + true + false + true + false + + + + + + + false + + saveConfig + + + true + true + true + + true + true + true + true + false + true + true + false + false + false + true + false + false + false + true + 0 + true + true + true + true + true + true + + + + + + + + + Authorization + Basic cm9vdDp0YW9zZGF0YQ== + + + + + + + continue + + false + looptimes + + 24 + + false + + + true + + + + true + + + + false + cpu.usage_user.rows ${ts_counter} 22.345567 arch=x64 datacenter=us-west-1b hostname=host_5 os=Ubuntu16 rack=13 region=us-west-1 service=10 service_environment=staging service_version=0 team=NYC + = + + + + + + + + http://192.168.1.85:6041/opentsdb/v1/put/telnet/test + POST + true + false + true + false + + + + + + + false + + saveConfig + + + true + true + true + + true + true + true + true + false + true + true + false + false + false + true + false + false + false + true + 0 + true + true + true + true + true + true + + + + + + + + + Authorization + Basic cm9vdDp0YW9zZGF0YQ== + + + + + + 1614530008000 + + 1 + ts_counter + + false + + + + + + diff --git a/tests/perftest-scripts/taosadapter_perftest/taosadapter_perftest.py b/tests/perftest-scripts/taosadapter_perftest/taosadapter_perftest.py new file mode 100644 index 0000000000000000000000000000000000000000..5094c0d3d9ec31433400b384d5cb4ada78fd5889 --- /dev/null +++ b/tests/perftest-scripts/taosadapter_perftest/taosadapter_perftest.py @@ -0,0 +1,171 @@ +from fabric import Connection +from loguru import logger +import shutil +import os +import time + +class TaosadapterPerftest(): + def __init__(self): + self.ip = "192.168.1.85" + self.port = "22" + self.user = "root" + self.passwd = "tbase125!" + self.telnetCreateStbJmxFile = "opentsdb_telnet_createStb.jmx" + self.telnetCreateTbJmxFile = "opentsdb_telnet_createTb.jmx" + self.telnetInsertRowsFile = "opentsdb_telnet_insertRows.jmx" + self.jsonCreateStbJmxFile = "opentsdb_json_createStb.jmx" + self.jsonCreateTbJmxFile = "opentsdb_json_createTb.jmx" + self.jsonInsertRowsFile = "opentsdb_json_insertRows.jmx" + self.logfile = "taosadapter_perftest.log" + self.createStbThreads = 100 + self.createTbThreads = 100 + self.insertRowsThreads = 24 + + logger.add(self.logfile) + + def exec_remote_cmd(self, cmd): + """ + remote exec shell cmd + """ + try: + c = Connection(self.ip, user=self.user, port=self.port, connect_timeout=120, connect_kwargs={"password": self.passwd}) + result = c.run(cmd, pty=False, warn=True, hide=True).stdout + c.close() + return result + except Exception as e: + logger.error(f"exec cmd {cmd} failed:{e}"); + + def exec_local_cmd(self, shell_cmd): + ''' + exec local shell cmd + ''' + result = os.popen(shell_cmd).read().strip() + return result + + def modifyJxmLooptimes(self, filename, looptimes): + ''' + modify looptimes + ''' + with open(filename, "r", encoding="utf-8") as f: + lines = f.readlines() + with open(filename, "w", encoding="utf-8") as f_w: + for line in lines: + if "looptimes" in line: + line = line.replace("looptimes", looptimes) + f_w.write(line) + + def cleanAndRestartTaosd(self): + ''' + restart taosd and clean env + ''' + logger.info("restarting taosd and taosadapter") + self.exec_remote_cmd("systemctl stop taosd") + self.exec_remote_cmd("rm -rf /var/lib/taos/* /var/log/taos/*") + self.exec_remote_cmd("systemctl start taosd") + time.sleep(60) + + def recreateReportDir(self, path): + ''' + recreate jmeter report path + ''' + if os.path.exists(path): + self.exec_local_cmd(f'rm -rf {path}/*') + else: + os.makedirs(path) + + def cleanLog(self): + ''' + clean log + ''' + with open(self.logfile, 'w') as f: + f.seek(0) + f.truncate() + + def outputParams(self, protocol, create_type): + ''' + procotol is "telnet" or "json" + create_type is "stb" or "tb" or "rows" + ''' + if protocol == "telnet": + if create_type == "stb": + return self.telnetCreateStbJmxFile, self.createStbThreads + elif create_type == "tb": + return self.telnetCreateTbJmxFile, self.createTbThreads + elif create_type == "rows": + return self.telnetInsertRowsFile, self.insertRowsThreads + else: + logger.error("create type error!") + else: + if create_type == "stb": + return self.jsonCreateStbJmxFile, self.createStbThreads + elif create_type == "tb": + return self.jsonCreateTbJmxFile, self.createTbThreads + elif create_type == "rows": + return self.jsonInsertRowsFile, self.insertRowsThreads + else: + logger.error("create type error!") + + def insertTDengine(self, procotol, create_type, count): + ''' + create stb/tb or insert rows + ''' + jmxfile, threads = self.outputParams(procotol, create_type) + handle_file = str(count) + jmxfile + report_dir = f'testreport/{handle_file}' + self.recreateReportDir(report_dir) + shutil.copyfile(jmxfile, handle_file) + replace_count = int(count/threads) + self.modifyJxmLooptimes(handle_file, str(replace_count)) + result = self.exec_local_cmd(f"jmeter -n -t {handle_file} -l {report_dir}/{handle_file}.txt -e -o {report_dir}") + logger.info(result) + +if __name__ == '__main__': + taosadapterPerftest = TaosadapterPerftest() + taosadapterPerftest.cleanLog() + + logger.info('------------ Start testing the scenarios in the report chapter 3.4.1 ------------') + for procotol in ["telnet", "json"]: + taosadapterPerftest.cleanAndRestartTaosd() + logger.info(f'----- {procotol} protocol ------- Creating 30W stable ------------') + taosadapterPerftest.insertTDengine(procotol, "stb", 300000) + time.sleep(120) + logger.info(f'----- {procotol} protocol ------- Creating 100W table with stb "cpu.usage_user" ------------') + taosadapterPerftest.insertTDengine(procotol, "tb", 1000000) + time.sleep(120) + logger.info(f'----- {procotol} protocol ------- inserting 100W rows ------------') + taosadapterPerftest.insertTDengine(procotol, "rows", 1000000) + time.sleep(120) + + taosadapterPerftest.cleanAndRestartTaosd() + logger.info(f'----- {procotol} protocol ------- Creating 50W stable ------------') + taosadapterPerftest.insertTDengine(procotol, "stb", 500000) + time.sleep(120) + logger.info(f'----- {procotol} protocol ------- Creating 500W table with stb "cpu.usage_user" ------------') + taosadapterPerftest.insertTDengine(procotol, "tb", 5000000) + time.sleep(120) + logger.info(f'----- {procotol} protocol ------- inserting 500W rows ------------') + taosadapterPerftest.insertTDengine(procotol, "rows", 5000000) + time.sleep(120) + + taosadapterPerftest.cleanAndRestartTaosd() + logger.info(f'----- {procotol} protocol ------- Creating 100W stable ------------') + taosadapterPerftest.insertTDengine(procotol, "stb", 1000000) + time.sleep(120) + logger.info(f'----- {procotol} protocol ------- Creating 1000W table with stb "cpu.usage_user" ------------') + taosadapterPerftest.insertTDengine(procotol, "tb", 10000000) + time.sleep(120) + logger.info(f'----- {procotol} protocol ------- inserting 1000W rows ------------') + taosadapterPerftest.insertTDengine(procotol, "rows", 10000000) + time.sleep(120) + + + + + + + + + + + +