Skip to content

Commit bbc89f5

Browse files
committedOct 25, 2019
Try TPC-DS test
1 parent 957d83f commit bbc89f5

File tree

7 files changed

+4897
-17
lines changed

7 files changed

+4897
-17
lines changed
 

‎.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,5 @@ pg_query_state--*.sql
99
cscope.out
1010
tags
1111
Dockerfile
12+
tmp_stress
13+

‎.travis.yml

+1
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ env:
2626
- PG_VERSION=10
2727
- PG_VERSION=9.6 LEVEL=hardcore
2828
- PG_VERSION=9.6
29+
- PG_VERSION=12 LEVEL=stress
2930

3031
matrix:
3132
allow_failures:

‎Dockerfile.tmpl

+1-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ FROM postgres:${PG_VERSION}-alpine
22

33
# Install dependencies
44
RUN apk add --no-cache \
5-
openssl curl \
5+
openssl curl git \
66
perl perl-ipc-run \
77
make musl-dev gcc bison flex coreutils \
88
zlib-dev libedit-dev \
@@ -29,7 +29,6 @@ RUN chown postgres:postgres ${PGDATA} && \
2929
chmod a+rwx /usr/local/share/postgresql/extension
3030

3131
COPY run_tests.sh /run.sh
32-
COPY tests/requirements.txt /requirements.txt
3332
RUN chmod 755 /run.sh
3433

3534
ADD . /pg/testdir

‎run_tests.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ if [ -f regression.diffs ]; then cat regression.diffs; fi
144144
# run python tests
145145
set +x -e
146146
python3 -m venv /tmp/env && source /tmp/env/bin/activate &&
147-
pip install -r /requirements.txt
147+
pip install -r tests/requirements.txt
148148
set -e #exit virtualenv with error code
149149
python tests/pg_qs_test_runner.py --port $PGPORT
150150
deactivate

‎tests/prepare_stress.sh

100644100755
+4-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#!/usr/bin/env sh
2+
23
mkdir -p tmp_stress
34
cd tmp_stress
45
rm -rf ./*
@@ -8,10 +9,10 @@ cd tpcds-kit/tools
89
make -s
910

1011
#Generate data
11-
./dsdgen -FORCE -VERBOSE
12+
./dsdgen -FORCE -VERBOSE -SCALE 1
1213

1314
#Prepare data
14-
mkdir tables -p
15+
mkdir -p tables
1516
for i in `ls *.dat`; do
1617
echo "Preparing file " $i
1718
sed 's/|$//' $i > tables/$i
@@ -22,4 +23,5 @@ done
2223
-INPUT ../query_templates/templates.lst \
2324
-VERBOSE Y \
2425
-QUALIFY Y \
26+
-SCALE 1 \
2527
-DIALECT netezza

‎tests/query_tpcds.sql

+4,871
Large diffs are not rendered by default.

‎tests/test_cases.py

+17-12
Original file line numberDiff line numberDiff line change
@@ -471,7 +471,7 @@ def test_formats(config):
471471

472472
qs = query_state(config, acon, query, {'format': 'yaml'})
473473
try:
474-
yaml_doc = yaml.load(qs[0][3])
474+
yaml_doc = yaml.load(qs[0][3], Loader=yaml.FullLoader)
475475
except:
476476
assert False, 'Invalid yaml format'
477477
assert len(qs) == 1
@@ -508,26 +508,29 @@ class DataLoadException(Exception): pass
508508
class StressTestException(Exception): pass
509509

510510
def load_tpcds_data(config):
511-
print('Preparing TPC-DS...')
512-
subprocess.call(['./tests/prepare_stress.sh'])
511+
print('Loading TPC-DS data...')
512+
# subprocess.call(['./tests/prepare_stress.sh'])
513513

514514
try:
515515
conn = psycopg2.connect(**config)
516516
cur = conn.cursor()
517517

518518
# Create tables
519-
cur.execute(open('tmp_stress/tpcds-kit/tools/tpcds.sql', 'r').read())
519+
with open('tmp_stress/tpcds-kit/tools/tpcds.sql', 'r') as f:
520+
cur.execute(f.read())
520521

521522
# Copy table data from files
522523
for table_datafile in os.listdir('tmp_stress/tpcds-kit/tools/'):
523-
if table_datafile.endswith(".dat"):
524+
if table_datafile.endswith('.dat'):
524525
table_name = os.path.splitext(os.path.basename(table_datafile))[0]
525-
copy_cmd = "COPY %s FROM 'tmp_stress/tpcds-kit/tools/tables/%s' CSV DELIMITER '|'" % (table_name, table_datafile)
526+
copy_cmd = "COPY %s FROM '/pg/testdir/tmp_stress/tpcds-kit/tools/tables/%s' CSV DELIMITER '|'" % (table_name, table_datafile)
526527

527-
print("Loading table ", table_name)
528-
cur.execute("TRUNCATE %s" % table_name)
528+
print("Loading table", table_name)
529+
# cur.execute("TRUNCATE %s" % table_name)
529530
cur.execute(copy_cmd)
530531

532+
conn.commit()
533+
531534
except Exception as e:
532535
cur.close()
533536
conn.close()
@@ -538,10 +541,10 @@ def load_tpcds_data(config):
538541
def stress_test(config):
539542
"""TPC-DS stress test"""
540543
load_tpcds_data(config)
541-
print('Starting test...')
542544

545+
print('Preparing TPC-DS queries...')
543546
# Execute query in separate thread
544-
with open("tests/query_tpcds.sql",'r') as f:
547+
with open('tmp_stress/tpcds-kit/tools/query_0.sql', 'r') as f:
545548
sql = f.read()
546549

547550
queries = sql.split(';')
@@ -552,10 +555,14 @@ def stress_test(config):
552555

553556
acon, = n_async_connect(config)
554557

558+
print('Starting test...')
555559
timeout_list = []
560+
exclude_list = [2]
556561
bar = progressbar.ProgressBar(max_value=len(queries))
557562
for i, query in enumerate(queries):
558563
bar.update(i + 1)
564+
if i + 1 in exclude_list:
565+
continue
559566
try:
560567
# Set query timeout to 10 sec
561568
set_guc(acon, 'statement_timeout', 10000)
@@ -564,8 +571,6 @@ def stress_test(config):
564571
#TODO: Put here testgres exception when supported
565572
except psycopg2.extensions.QueryCanceledError:
566573
timeout_list.append(i)
567-
finally:
568-
pass
569574

570575
n_close((acon,))
571576

0 commit comments

Comments
 (0)
Please sign in to comment.