8000 TestTestgresCommon.test_pgbench is added · postgrespro/testgres@4f49dde · GitHub
[go: up one dir, main page]

Skip to content

Commit 4f49dde

Browse files
TestTestgresCommon.test_pgbench is added
- [del] TestTestgresLocal.test_pgbench - [del] TestTestgresRemote.test_pgbench
1 parent 110947d commit 4f49dde

File tree

3 files changed

+21
-37
lines changed

3 files changed

+21
-37
lines changed

tests/test_testgres_common.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
import uuid
3939
import os
4040
import re
41+
import subprocess
4142

4243

4344
@contextmanager
@@ -1100,6 +1101,26 @@ def test_get_pg_config2(self, node_svc: PostgresNodeService):
11001101
b = get_pg_config2(node_svc.os_ops, None)
11011102
assert (id(a) != id(b))
11021103

1104+
def test_pgbench(self, node_svc: PostgresNodeService):
1105+
assert isinstance(node_svc, PostgresNodeService)
1106+
1107+
__class__.helper__skip_test_if_util_not_exist(node_svc.os_ops, "pgbench")
1108+
1109+
with __class__.helper__get_node(node_svc).init().start() as node:
1110+
# initialize pgbench DB and run benchmarks
1111+
node.pgbench_init(
1112+
scale=2,
1113+
foreign_keys=True,
1114+
options=['-q']
1115+
).pgbench_run(time=2)
1116+
1117+
# run TPC-B benchmark
1118+
proc = node.pgbench(stdout=subprocess.PIPE,
1119+
stderr=subprocess.STDOUT,
1120+
options=['-T3'])
1121+
out = proc.communicate()[0]
1122+
assert (b'tps = ' in out)
1123+
11031124
@staticmethod
11041125
def helper__get_node(node_svc: PostgresNodeService, name=None):
11051126
assert isinstance(node_svc, PostgresNodeService)

tests/test_testgres_local.py

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -100,27 +100,6 @@ def test_custom_init(self):
100100
# there should be no trust entries at all
101101
assert not (any('trust' in s for s in lines))
102102

103-
def test_pgbench(self):
104-
__class__.helper__skip_test_if_util_not_exist("pgbench")
105-
106-
with get_new_node().init().start() as node:
107-
108-
# initialize pgbench DB and run benchmarks
109-
node.pgbench_init(scale=2, foreign_keys=True,
110-
options=['-q']).pgbench_run(time=2)
111-
112-
# run TPC-B benchmark
113-
proc = node.pgbench(stdout=subprocess.PIPE,
114-
stderr=subprocess.STDOUT,
115-
options=['-T3'])
116-
117-
out, _ = proc.communicate()
118-
out = out.decode('utf-8')
119-
120-
proc.stdout.close()
121-
122-
assert ('tps' in out)
123-
124103
def test_pg_config(self):
125104
# check same instances
126105
a = get_pg_config()

tests/test_testgres_remote.py

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
# coding: utf-8
22
import os
33
import re
4-
import subprocess
54

65
import pytest
76
import logging
@@ -169,21 +168,6 @@ def test_init__unk_LANG_and_LC_CTYPE(self):
169168
__class__.helper__restore_envvar("LC_CTYPE", prev_LC_CTYPE)
170169
__class__.helper__restore_envvar("LC_COLLATE", prev_LC_COLLATE)
171170

172-
def test_pgbench(self):
173-
__class__.helper__skip_test_if_util_not_exist("pgbench")
174-
175-
with __class__.helper__get_node().init().start() as node:
176-
# initialize pgbench DB and run benchmarks
177-
node.pgbench_init(scale=2, foreign_keys=True,
178-
options=['-q']).pgbench_run(time=2)
179-
180-
# run TPC-B benchmark
181-
proc = node.pgbench(stdout=subprocess.PIPE,
182-
stderr=subprocess.STDOUT,
183-
options=['-T3'])
184-
out = proc.communicate()[0]
185-
assert (b'tps = ' in out)
186-
187171
def test_pg_config(self):
188172
# check same instances
189173
a = get_pg_config()

0 commit comments

Comments
 (0)
0