You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+18-4Lines changed: 18 additions & 4 deletions
Original file line number
Diff line number
Diff line change
@@ -22,6 +22,9 @@ We encourage you to use `virtualenv` for your testing environment. Both Python 2
22
22
23
23
> Note: by default testgres runs `initdb`, `pg_ctl`, `psql` provided by `PATH`. To specify a custom postgres installation, set the environment variable `PG_CONFIG` pointing to the `pg_config` executable: `export PG_CONFIG=/path/to/pg_config`.
24
24
25
+
26
+
### Overview
27
+
25
28
Here is an example of what you can do with `testgres`:
26
29
27
30
```python
@@ -80,7 +83,7 @@ To stop the server, run:
80
83
node.stop()
81
84
```
82
85
83
-
It is essential to clean everything up, so make sure to call `node.cleanup()` once you've finished all of your tests.
86
+
### Logging
84
87
85
88
Nodes support python logging system, so if you have configured logging
86
89
in your tests you can use it to redirect postgres logs to yours.
@@ -90,11 +93,22 @@ To do that just use `use_logging` argument like here:
Also you can find working configuration sample for logging in tests.
96
+
You can find working configuration example for logging in `tests/test_simple.py`.
94
97
95
-
Please see `testgres/tests` directory for replication configuration example.
96
-
> Note: you could take a look at [`pg_pathman`](https://github.com/postgrespro/pg_pathman) to get an idea of `testgres`' capabilities.
97
98
99
+
### Backup & replication
100
+
101
+
It's quite easy to create a backup and start a new replica:
102
+
103
+
```python
104
+
with testgres.get_new_node('master') as master:
105
+
master.init().start()
106
+
with master.backup() as backup:
107
+
replica = backup.spawn_replica('replica').start()
108
+
print(replica.execute('postgres', 'select 1'))
109
+
```
110
+
111
+
> Note: you could take a look at [`pg_pathman`](https://github.com/postgrespro/pg_pathman) to get an idea of `testgres`' capabilities.
0 commit comments