Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitc28bcee

Browse files
committed
New tests refactoring
1 parent37bedbe commitc28bcee

File tree

2 files changed

+21
-15
lines changed

2 files changed

+21
-15
lines changed

‎tests/prepare_stress.sh‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ mkdir -p tmp_stress
44
cd tmp_stress
55
rm -rf ./*
66

7-
git clone https://github.com/gregrahn/tpcds-kit.git
7+
git clone--depth 1 --single-branch --branch masterhttps://github.com/gregrahn/tpcds-kit.git
88
cd tpcds-kit/tools
99
make -s
1010

‎tests/test_cases.py‎

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,11 @@
1414

1515
fromtimeimportsleep
1616

17+
MAX_PG_QS_RETRIES=50
18+
TPC_DS_EXCLUDE_LIST= []# actual numbers of TPC-DS tests to exclude
19+
TPC_DS_STATEMENT_TIMEOUT=20000# statement_timeout in ms
20+
stress_in_progress=False
21+
1722
defwait(conn):
1823
"""wait for some event on connection to postgres"""
1924
while1:
@@ -98,18 +103,21 @@ def pg_query_state(config, pid, verbose=False, costs=False, timing=False, \
98103

99104
conn=psycopg2.connect(**config)
100105
curs=conn.cursor()
101-
set_guc(conn,'statement_timeout',10000)
106+
107+
ifstress_in_progress:
108+
set_guc(conn,'statement_timeout',TPC_DS_STATEMENT_TIMEOUT)
109+
n_retries=0
102110

103111
result= []
104-
n_retries=0
105112
whilenotresult:
106113
curs.callproc('pg_query_state', (pid,verbose,costs,timing,buffers,triggers,format))
107114
result=curs.fetchall()
108-
n_retries+=1
109115

110-
ifn_retries==25:
111-
print('pg_query_state tried 25 times with no effect')
112-
break
116+
ifstress_in_progress:
117+
n_retries+=1
118+
ifn_retries>=MAX_PG_QS_RETRIES:
119+
print('\npg_query_state tried %s times with no effect, giving up'%MAX_PG_QS_RETRIES)
120+
break
113121

114122
notices=conn.notices[:]
115123
conn.close()
@@ -565,24 +573,22 @@ def stress_test(config):
565573

566574
acon,=n_async_connect(config)
567575

568-
print('Startingtest...')
576+
print('StartingTPC-DS queries...')
569577
timeout_list= []
570-
exclude_list= []
571578
bar=progressbar.ProgressBar(max_value=len(queries))
572579
fori,queryinenumerate(queries):
573580
bar.update(i+1)
574-
ifi+1inexclude_list:
581+
ifi+1inTPC_DS_EXCLUDE_LIST:
575582
continue
576583
try:
577-
# Set query timeout to10 sec
578-
set_guc(acon,'statement_timeout',10000)
584+
# Set query timeout toTPC_DS_STATEMENT_TIMEOUT / 1000 seconds
585+
set_guc(acon,'statement_timeout',TPC_DS_STATEMENT_TIMEOUT)
579586
qs=query_state(config,acon,query)
580587

581-
#TODO: Put here testgres exception when supported
582588
exceptpsycopg2.extensions.QueryCanceledError:
583-
timeout_list.append(i)
589+
timeout_list.append(i+1)
584590

585591
n_close((acon,))
586592

587593
iflen(timeout_list)>0:
588-
print('There were pg_query_state timeouts (10s) on queries: ',timeout_list)
594+
print('There were pg_query_state timeouts (%s s) on queries:'%TPC_DS_STATEMENT_TIMEOUT,timeout_list)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp