From 9b8105a28ac673f92336a6c0517667466042fc04 Mon Sep 17 00:00:00 2001 From: stalkerg Date: Mon, 12 Dec 2016 18:47:46 +0300 Subject: [PATCH 1/2] Add pgbench init and pgbench command for node. Pgbench run as Popen for background tests. --- setup.py | 2 +- testgres/testgres.py | 36 ++++++++++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 83226c97..c43d8d98 100644 --- a/setup.py +++ b/setup.py @@ -2,7 +2,7 @@ setup( name='testgres', packages=['testgres'], - version='0.1.16', + version='0.1.17', description='Testing utility for postgresql and its extensions', author='Ildar Musin', author_email='zildermann@gmail.com', diff --git a/testgres/testgres.py b/testgres/testgres.py index c01e7a24..f06cc9ee 100644 --- a/testgres/testgres.py +++ b/testgres/testgres.py @@ -472,6 +472,42 @@ def backup(self, name): return backup_path + def pgbench_init(self, dbname='postgres', scale=1, options=[]): + """Prepare pgbench database""" + pgbench = self.get_bin_path("pgbench") + params = [ + pgbench, + "-i", + "-s", "%i" % scale, + "-p", "%i" % self.port, + ] + options + [dbname] + with open(self.output_filename, "a") as file_out, \ + open(self.error_filename, "a") as file_err: + ret = subprocess.call( + params, + stdout=file_out, + stderr=file_err + ) + if ret: + raise ClusterException("pgbench init failed") + + return True + + def pgbench(self, dbname='postgres', stdout=None, stderr=None, options=[]): + """Make pgbench process""" + pgbench = self.get_bin_path("pgbench") + params = [ + pgbench, + "-p", "%i" % self.port, + ] + options + [dbname] + proc = subprocess.Popen( + params, + stdout=stdout, + stderr=stderr + ) + + return proc + def connect(self, dbname='postgres', username=None): return NodeConnection(parent_node=self, dbname=dbname, user=username) From 0ea2456fe69f28ca5228f02583bea55be7829011 Mon Sep 17 00:00:00 2001 From: stalkerg Date: Mon, 12 Dec 2016 18:57:47 +0300 Subject: [PATCH 2/2] Fix spaces and comma pep8 warnings. --- testgres/testgres.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/testgres/testgres.py b/testgres/testgres.py index f06cc9ee..72af64b2 100644 --- a/testgres/testgres.py +++ b/testgres/testgres.py @@ -479,7 +479,7 @@ def pgbench_init(self, dbname='postgres', scale=1, options=[]): pgbench, "-i", "-s", "%i" % scale, - "-p", "%i" % self.port, + "-p", "%i" % self.port ] + options + [dbname] with open(self.output_filename, "a") as file_out, \ open(self.error_filename, "a") as file_err: @@ -498,7 +498,7 @@ def pgbench(self, dbname='postgres', stdout=None, stderr=None, options=[]): pgbench = self.get_bin_path("pgbench") params = [ pgbench, - "-p", "%i" % self.port, + "-p", "%i" % self.port ] + options + [dbname] proc = subprocess.Popen( params, 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