未验证 提交 f8981e55 编写于 作者: H huili 提交者: GitHub

Merge pull request #4516 from taosdata/test/jenkins

modify jenkinsfile
properties([pipelineTriggers([githubPush()])])
node {
git url: 'https://github.com/taosdata/TDengine'
}
// execute this before anything else, including requesting any time on an agent // execute this before anything else, including requesting any time on an agent
if (currentBuild.rawBuild.getCauses().toString().contains('BranchIndexingCause')) { if (currentBuild.rawBuild.getCauses().toString().contains('BranchIndexingCause')) {
print "INFO: Build skipped due to trigger being Branch Indexing" print "INFO: Build skipped due to trigger being Branch Indexing"
currentBuild.result = 'ABORTED' // optional, gives a better hint to the user that it's been skipped, rather than the default which shows it's successful currentBuild.result = 'ABORTED' // optional, gives a better hint to the user that it's been skipped, rather than the default which shows it's successful
return return
} }
properties([pipelineTriggers([githubPush()])])
node {
git url: 'https://github.com/taosdata/TDengine.git'
}
def pre_test(){ def pre_test(){
catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE') { catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE') {
......
...@@ -43,7 +43,8 @@ class ConcurrentInquiry: ...@@ -43,7 +43,8 @@ class ConcurrentInquiry:
self.subtb_stru_list=[] self.subtb_stru_list=[]
self.stb_tag_list=[] self.stb_tag_list=[]
self.subtb_tag_list=[] self.subtb_tag_list=[]
self.probabilities = [0.95,0.05]
self.ifjoin = [0,1]
def SetThreadsNum(self,num): def SetThreadsNum(self,num):
self.numOfTherads=num self.numOfTherads=num
...@@ -105,7 +106,7 @@ class ConcurrentInquiry: ...@@ -105,7 +106,7 @@ class ConcurrentInquiry:
conn.close() conn.close()
#query condition #query condition
def con_where(self,tlist): def con_where(self,tlist,col_list,tag_list):
l=[] l=[]
for i in range(random.randint(0,len(tlist))): for i in range(random.randint(0,len(tlist))):
c = random.choice(where_list) c = random.choice(where_list)
...@@ -115,19 +116,26 @@ class ConcurrentInquiry: ...@@ -115,19 +116,26 @@ class ConcurrentInquiry:
l.append(random.choice(tlist)+c) l.append(random.choice(tlist)+c)
return 'where '+random.choice([' and ',' or ']).join(l) return 'where '+random.choice([' and ',' or ']).join(l)
def con_interval(self,tlist): def con_interval(self,tlist,col_list,tag_list):
return random.choice(['interval(10s)','interval(10d)','interval(1n)']) interval = 'interval' + str(random.randint(0,100)) + random.choice(['a','s','d','w','n','y'])
return interval
def con_limit(self,tlist): def con_limit(self,tlist,col_list,tag_list):
return random.choice(['limit 10','limit 10 offset 10','slimit 10','slimit 10 offset 10','limit 10 slimit 10','limit 10 offset 5 slimit 5 soffset 10']) rand1 = str(random.randint(0,1000))
rand2 = str(random.randint(0,1000))
return random.choice(['limit ' + rand1,'limit ' + rand1 + 'offset '+rand2,
'slimit ' + rand1,'slimit ' + rand1 + 'offset ' + rand2,'limit '+rand1 + 'slimit '+ rand2,
'limit '+ rand1 + 'offset' + rand2 + 'slimit '+ rand1 + 'soffset ' + rand2 ])
def con_fill(self,tlist): def con_fill(self,tlist,col_list,tag_list):
return random.choice(['fill(null)','fill(prev)','fill(none)','fill(LINEAR)']) return random.choice(['fill(null)','fill(prev)','fill(none)','fill(LINEAR)'])
def con_group(self,tlist): def con_group(self,tlist,col_list,tag_list):
return 'group by '+random.choice(tlist) rand_tag = random.randint(0,5)
rand_col = random.randint(0,1)
return 'group by '+','.join(random.sample(col_list,rand_col))+','.join(random.sample(tag_list,rand_tag))
def con_order(self,tlist): def con_order(self,tlist,col_list,tag_list):
return 'order by '+random.choice(tlist) return 'order by '+random.choice(tlist)
def gen_query_sql(self): #生成查询语句 def gen_query_sql(self): #生成查询语句
...@@ -158,22 +166,87 @@ class ConcurrentInquiry: ...@@ -158,22 +166,87 @@ class ConcurrentInquiry:
sel_col_list=[] sel_col_list=[]
col_rand=random.randint(0,len(col_list)) col_rand=random.randint(0,len(col_list))
for i,j in zip(col_list[0:col_rand],func_list): #决定每个被查询col的函数 for i,j in zip(col_list[0:col_rand],func_list): #决定每个被查询col的函数
alias = 'as '+ str(i)
pick_func = ''
if j == 'leastsquares': if j == 'leastsquares':
sel_col_list.append(j+'('+i+',1,1)') pick_func=j+'('+i+',1,1)'
elif j == 'top' or j == 'bottom' or j == 'percentile' or j == 'apercentile': elif j == 'top' or j == 'bottom' or j == 'percentile' or j == 'apercentile':
sel_col_list.append(j+'('+i+',1)') pick_func=j+'('+i+',1)'
else: else:
sel_col_list.append(j+'('+i+')') pick_func=j+'('+i+')'
if bool(random.getrandbits(1)):
pick_func+=alias
sel_col_list.append(pick_func)
sql=sql+','.join(sel_col_list)+' from '+random.choice(self.stb_list+self.subtb_list)+' ' #select col & func sql=sql+','.join(sel_col_list)+' from '+random.choice(self.stb_list+self.subtb_list)+' ' #select col & func
con_func=[self.con_where,self.con_interval,self.con_limit,self.con_group,self.con_order,self.con_fill] con_func=[self.con_where,self.con_interval,self.con_limit,self.con_group,self.con_order,self.con_fill]
sel_con=random.sample(con_func,random.randint(0,len(con_func))) sel_con=random.sample(con_func,random.randint(0,len(con_func)))
sel_con_list=[] sel_con_list=[]
for i in sel_con: for i in sel_con:
sel_con_list.append(i(tlist)) #获取对应的条件函数 sel_con_list.append(i(tlist,col_list,tag_list)) #获取对应的条件函数
sql+=' '.join(sel_con_list) # condition sql+=' '.join(sel_con_list) # condition
print(sql) print(sql)
return sql return sql
def gen_query_join(self): #生成join查询语句
tbi=random.randint(0,len(self.subtb_list)+len(self.stb_list)) #随机决定查询哪张表
tbname=''
col_list=[]
tag_list=[]
is_stb=0
if tbi>len(self.stb_list) :
tbi=tbi-len(self.stb_list)
tbname=self.subtb_list[tbi-1]
col_list=self.subtb_stru_list[tbi-1]
tag_list=self.subtb_tag_list[tbi-1]
else:
tbname=self.stb_list[tbi-1]
col_list=self.stb_stru_list[tbi-1]
tag_list=self.stb_tag_list[tbi-1]
is_stb=1
tlist=col_list+tag_list+['abc'] #增加不存在的域'abc',是否会引起新bug
con_rand=random.randint(0,len(condition_list))
func_rand=random.randint(0,len(func_list))
col_rand=random.randint(0,len(col_list))
tag_rand=random.randint(0,len(tag_list))
t_rand=random.randint(0,len(tlist))
sql='select ' #select
random.shuffle(col_list)
random.shuffle(func_list)
sel_col_list=[]
col_rand=random.randint(0,len(col_list))
for i,j in zip(col_list[0:col_rand],func_list): #决定每个被查询col的函数
alias = 'as '+ str(i)
pick_func = ''
if j == 'leastsquares':
pick_func=j+'('+i+',1,1)'
elif j == 'top' or j == 'bottom' or j == 'percentile' or j == 'apercentile':
pick_func=j+'('+i+',1)'
else:
pick_func=j+'('+i+')'
if bool(random.getrandbits(1)):
pick_func+=alias
sel_col_list.append(pick_func)
sql=sql+','.join(sel_col_list)+' from '+random.choice(self.stb_list+self.subtb_list)+' ' #select col & func
con_func=[self.con_where,self.con_interval,self.con_limit,self.con_group,self.con_order,self.con_fill]
sel_con=random.sample(con_func,random.randint(0,len(con_func)))
sel_con_list=[]
for i in sel_con:
sel_con_list.append(i(tlist,col_list,tag_list)) #获取对应的条件函数
sql+=' '.join(sel_con_list) # condition
print(sql)
return sql
def random_pick(self):
x = random.uniform(0,1)
cumulative_probability = 0.0
for item, item_probability in zip(self.ifjoin, self.probabilities):
cumulative_probability += item_probability
if x < cumulative_probability:break
return item
def rest_query(self,sql): #rest 接口 def rest_query(self,sql): #rest 接口
host = "127.0.0.1" host = "127.0.0.1"
user = "root" user = "root"
...@@ -210,6 +283,7 @@ class ConcurrentInquiry: ...@@ -210,6 +283,7 @@ class ConcurrentInquiry:
nRows = rj['rows'] if ('rows' in rj) else 0 nRows = rj['rows'] if ('rows' in rj) else 0
return nRows return nRows
def query_thread_n(self,threadID): #使用原生python接口查询 def query_thread_n(self,threadID): #使用原生python接口查询
host = "127.0.0.1" host = "127.0.0.1"
user = "root" user = "root"
...@@ -227,7 +301,10 @@ class ConcurrentInquiry: ...@@ -227,7 +301,10 @@ class ConcurrentInquiry:
while True: while True:
try: try:
sql=self.gen_query_sql() if self.random_pick():
sql=self.gen_query_sql()
else:
sql=self.gen_query_join()
print("sql is ",sql) print("sql is ",sql)
start = time.time() start = time.time()
cl.execute(sql) cl.execute(sql)
...@@ -247,7 +324,10 @@ class ConcurrentInquiry: ...@@ -247,7 +324,10 @@ class ConcurrentInquiry:
print("Thread %d: starting" % threadID) print("Thread %d: starting" % threadID)
while True: while True:
try: try:
sql=self.gen_query_sql() if self.random_pick():
sql=self.gen_query_sql()
else:
sql=self.gen_query_join()
print("sql is ",sql) print("sql is ",sql)
start = time.time() start = time.time()
self.rest_query(sql) self.rest_query(sql)
...@@ -270,7 +350,6 @@ class ConcurrentInquiry: ...@@ -270,7 +350,6 @@ class ConcurrentInquiry:
threads.append(thread) threads.append(thread)
thread.start() thread.start()
for i in range(self.r_numOfTherads): for i in range(self.r_numOfTherads):
# for i in range(1):
thread = threading.Thread(target=self.query_thread_r, args=(i,)) thread = threading.Thread(target=self.query_thread_r, args=(i,))
threads.append(thread) threads.append(thread)
thread.start() thread.start()
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册