Skip to content

Add pgbench_with_wait function #122

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 20, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 26 additions & 1 deletion testgres/node.py
Original file line number Diff line number Diff line change
Expand Up @@ -1371,7 +1371,7 @@ def pgbench(self,
username=None,
stdout=None,
stderr=None,
options=[]):
options=None):
"""
Spawn a pgbench process.

Expand All @@ -1385,6 +1385,8 @@ def pgbench(self,
Returns:
Process created by subprocess.Popen.
"""
if options is None:
options = []

# Set default arguments
dbname = dbname or default_dbname()
Expand All @@ -1404,6 +1406,29 @@ def pgbench(self,

return proc

def pgbench_with_wait(self,
dbname=None,
username=None,
stdout=None,
stderr=None,
options=None):
"""
Do pgbench command and wait.

Args:
dbname: database name to connect to.
username: database user name.
stdout: stdout file to be used by Popen.
stderr: stderr file to be used by Popen.
options: additional options for pgbench (list).
"""
if options is None:
options = []

with self.pgbench(dbname, username, stdout, stderr, options) as pgbench:
pgbench.wait()
return

def pgbench_init(self, **kwargs):
"""
Small wrapper for pgbench_run().
Expand Down