add learner split vgroup case

This commit is contained in:
menshibin 2024-01-25 13:49:56 +08:00
parent 9d9306a03b
commit ce4583e38f
2 changed files with 174 additions and 0 deletions

View File

@ -0,0 +1,62 @@
{
"filetype": "insert",
"cfgdir": "/etc/taos",
"host": "127.0.0.1",
"port": 6030,
"user": "root",
"password": "taosdata",
"connection_pool_size": 8,
"num_of_records_per_req": 3000,
"prepared_rand": 3000,
"thread_count": 2,
"create_table_thread_count": 1,
"confirm_parameter_prompt": "no",
"continue_if_fail": "yes",
"databases": [
{
"dbinfo": {
"name": "db",
"drop": "yes",
"vgroups": 2,
"replica": 3,
"duration":"1d",
"wal_retention_period": 1,
"wal_retention_size": 1,
"keep": "3d,6d,30d"
},
"super_tables": [
{
"name": "stb",
"child_table_exists": "no",
"childtable_count": 10,
"insert_rows": 100000000,
"childtable_prefix": "d",
"insert_mode": "taosc",
"timestamp_step": 10000,
"start_timestamp":"now-12d",
"columns": [
{ "type": "bool", "name": "bc"},
{ "type": "float", "name": "fc" },
{ "type": "double", "name": "dc"},
{ "type": "tinyint", "name": "ti"},
{ "type": "smallint", "name": "si" },
{ "type": "int", "name": "ic" },
{ "type": "bigint", "name": "bi" },
{ "type": "utinyint", "name": "uti"},
{ "type": "usmallint", "name": "usi"},
{ "type": "uint", "name": "ui" },
{ "type": "ubigint", "name": "ubi"},
{ "type": "binary", "name": "bin", "len": 16},
{ "type": "nchar", "name": "nch", "len": 32}
],
"tags": [
{"type": "tinyint", "name": "groupid","max": 10,"min": 1},
{"name": "location","type": "binary", "len": 16, "values":
["San Francisco", "Los Angles", "San Diego", "San Jose", "Palo Alto", "Campbell", "Mountain View","Sunnyvale", "Santa Clara", "Cupertino"]
}
]
}
]
}
]
}

View File

@ -0,0 +1,112 @@
###################################################################
# 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 time
import random
import taos
import frame
import frame.etool
import json
import threading
from frame.log import *
from frame.cases import *
from frame.sql import *
from frame.caseBase import *
from frame import *
from frame.autogen import *
from frame.srvCtl import *
class TDTestCase(TBase):
def configJsonFile(self, fileName, dbName, vgroups, replica, newFileName='', insert_rows=10000000, timestamp_step=10000):
with open(fileName, 'r') as f:
data = json.load(f)
if len(newFileName) == 0:
newFileName = fileName
data['databases']['dbinfo']['name'] = dbName
data['databases']['dbinfo']['vgroups'] = vgroups
data['databases']['dbinfo']['replica'] = replica
data['databases']['dbinfo']['replica'] = replica
data['databases']['super_tables']['insert_rows'] = insert_rows
data['databases']['super_tables']['timestamp_step'] = timestamp_step
json_data = json.dumps(data)
with open(newFileName, "w") as file:
file.write(json_data)
def splitVgroupThread(self, configFile, event):
# self.insertData(configFile)
event.wait()
tdSql.execute('ALTER DATABASE db1 REPLICA 3')
time.sleep(5)
param_list = tdSql.query('show vgroups')
vgroupId = None
for param in param_list:
vgroupId = param[0]
tdSql.execute(f"split vgroup {vgroupId}")
# self.configJsonFile(configFile, 'db1', 1, 1, configFile, 100000000)
# self.insertData(configFile)
def dnodeNodeStopThread(self, event):
event.wait()
time.sleep(10)
on = 2
for i in range(5):
if i % 2 == 0:
on = 2
else:
on = 3
sc.dnodeStop(on)
time.sleep(5)
sc.dnodeStart(on)
time.sleep(5)
def dbInsertThread(self, configFile, event):
self.insertData(configFile)
event.set()
self.configJsonFile(configFile, 'db', 2, 3, configFile, 100000000)
self.insertData(configFile)
def init(self, conn, logSql, replicaVar=1):
self.replicaVar = int(replicaVar)
tdLog.debug(f"start to excute {__file__}")
tdSql.init(conn.cursor(), logSql) # output sql.txt file
self.configJsonFile('splitVgroupByLearner.json', 'db', 1, 1, 'splitVgroupByLearner.json', 1000000)
def insertData(self, configFile):
tdLog.info(f"insert data.")
# taosBenchmark run
jfile = etool.curFile(__file__, configFile)
etool.benchMark(json = jfile)
# run
def run(self):
tdLog.debug(f"start to excute {__file__}")
event = threading.Event
t1 = threading.Thread(target=self.splitVgroupThread, args=('splitVgroupByLearner1.json', event))
t2 = threading.Thread(target=self.dbInsertThread, args=('splitVgroupByLearner.json'))
t3 = threading.Thread(target=self.dnodeNodeStopThread, args=(event))
t1.join()
t2.join()
t3.join()
tdLog.success(f"{__file__} successfully executed")
def stop(self):
tdSql.close()
tdLog.success(f"{__file__} successfully executed")
tdCases.addLinux(__file__, TDTestCase())
tdCases.addWindows(__file__, TDTestCase())