Skip to content

Add pg_probackup plugin #92

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 9 commits into from
Jan 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
readme = f.read()

setup(
version='1.9.3',
version='1.10.0',
name='testgres',
packages=['testgres', 'testgres.operations', 'testgres.helpers'],
description='Testing utility for PostgreSQL and its extensions',
Expand Down
9 changes: 9 additions & 0 deletions testgres/plugins/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
from pg_probackup2.gdb import GDBobj
from pg_probackup2.app import ProbackupApp, ProbackupException
from pg_probackup2.init_helpers import init_params
from pg_probackup2.storage.fs_backup import FSTestBackupDir
from pg_probackup2.storage.s3_backup import S3TestBackupDir

__all__ = [
"ProbackupApp", "ProbackupException", "init_params", "FSTestBackupDir", "S3TestBackupDir", "GDBobj"
]
65 changes: 65 additions & 0 deletions testgres/plugins/pg_probackup2/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
# testgres - pg_probackup2

Ccontrol and testing utility for [pg_probackup2](https://github.com/postgrespro/pg_probackup). Python 3.5+ is supported.


## Installation

To install `testgres`, run:

```
pip install testgres-pg_probackup
```

We encourage you to use `virtualenv` for your testing environment.
The package requires testgres~=1.9.3.

## Usage

### Environment

> Note: by default testgres runs `initdb`, `pg_ctl`, `psql` provided by `PATH`.

There are several ways to specify a custom postgres installation:

* export `PG_CONFIG` environment variable pointing to the `pg_config` executable;
* export `PG_BIN` environment variable pointing to the directory with executable files.

Example:

```bash
export PG_BIN=$HOME/pg/bin
python my_tests.py
```


### Examples

Here is an example of what you can do with `testgres-pg_probackup2`:

```python
# You can see full script here plugins/pg_probackup2/pg_probackup2/tests/basic_test.py
def test_full_backup(self):
# Setting up a simple test node
node = self.pg_node.make_simple('node', pg_options={"fsync": "off", "synchronous_commit": "off"})

# Initialize and configure Probackup
self.pb.init()
self.pb.add_instance('node', node)
self.pb.set_archiving('node', node)

# Start the node and initialize pgbench
node.slow_start()
node.pgbench_init(scale=100, no_vacuum=True)

# Perform backup and validation
backup_id = self.pb.backup_node('node', node)
out = self.pb.validate('node', backup_id)

# Check if the backup is valid
self.assertIn(f"INFO: Backup {backup_id} is valid", out)
```

## Authors

[Postgres Professional](https://postgrespro.ru/about)
Empty file.
Empty file.
Loading