Skip to content

Commit df65a94

Browse files
authored
Merge pull request #15 from stalkerg/master
Add pgbench init and pgbench command for node.
2 parents da3b57a + 0ea2456 commit df65a94

File tree

2 files changed

+37
-1
lines changed

2 files changed

+37
-1
lines changed

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
setup(
33
name='testgres',
44
packages=['testgres'],
5-
version='0.1.16',
5+
version='0.1.17',
66
description='Testing utility for postgresql and its extensions',
77
author='Ildar Musin',
88
author_email='zildermann@gmail.com',

testgres/testgres.py

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -472,6 +472,42 @@ def backup(self, name):
472472

473473
return backup_path
474474

475+
def pgbench_init(self, dbname='postgres', scale=1, options=[]):
476+
"""Prepare pgbench database"""
477+
pgbench = self.get_bin_path("pgbench")
478+
params = [
479+
pgbench,
480+
"-i",
481+
"-s", "%i" % scale,
482+
"-p", "%i" % self.port
483+
] + options + [dbname]
484+
with open(self.output_filename, "a") as file_out, \
485+
open(self.error_filename, "a") as file_err:
486+
ret = subprocess.call(
487+
params,
488+
stdout=file_out,
489+
stderr=file_err
490+
)
491+
if ret:
492+
raise ClusterException("pgbench init failed")
493+
494+
return True
495+
496+
def pgbench(self, dbname='postgres', stdout=None, stderr=None, options=[]):
497+
"""Make pgbench process"""
498+
pgbench = self.get_bin_path("pgbench")
499+
params = [
500+
pgbench,
501+
"-p", "%i" % self.port
502+
] + options + [dbname]
503+
proc = subprocess.Popen(
504+
params,
505+
stdout=stdout,
506+
stderr=stderr
507+
)
508+
509+
return proc
510+
475511
def connect(self, dbname='postgres', username=None):
476512
return NodeConnection(parent_node=self, dbname=dbname, user=username)
477513

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy