Skip to content

Commit

Permalink
Merge pull request #848 from EnterpriseDB/bar-115-fix-barman-cloud-ba…
Browse files Browse the repository at this point in the history
…ckup-compression-help

Fix help strings for barman-cloud-backup compression
  • Loading branch information
mikewallace1979 authored Sep 22, 2023
2 parents 0596f30 + 0091569 commit abef557
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 19 deletions.
6 changes: 3 additions & 3 deletions barman/clients/cloud_backup.py
Original file line number Diff line number Diff line change
Expand Up @@ -257,22 +257,22 @@ def parse_arguments(args=None):
compression.add_argument(
"-z",
"--gzip",
help="gzip-compress the WAL while uploading to the cloud",
help="gzip-compress the backup while uploading to the cloud",
action="store_const",
const="gz",
dest="compression",
)
compression.add_argument(
"-j",
"--bzip2",
help="bzip2-compress the WAL while uploading to the cloud",
help="bzip2-compress the backup while uploading to the cloud",
action="store_const",
const="bz2",
dest="compression",
)
compression.add_argument(
"--snappy",
help="snappy-compress the WAL while uploading to the cloud ",
help="snappy-compress the backup while uploading to the cloud ",
action="store_const",
const="snappy",
dest="compression",
Expand Down
4 changes: 3 additions & 1 deletion barman/postgres.py
Original file line number Diff line number Diff line change
Expand Up @@ -651,7 +651,9 @@ def has_checkpoint_privileges(self):
if self.is_superuser:
return True
else:
role_check_query = "select pg_has_role(CURRENT_USER ,'pg_checkpoint', 'MEMBER');"
role_check_query = (
"select pg_has_role(CURRENT_USER ,'pg_checkpoint', 'MEMBER');"
)
try:
cur = self._cursor()
cur.execute(role_check_query)
Expand Down
6 changes: 4 additions & 2 deletions barman/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -2913,8 +2913,10 @@ def switch_wal(self, force=False, archive=None, archive_timeout=None):
)
except PostgresCheckpointPrivilegesRequired:
# Superuser rights are required to perform the switch_wal
output.error("Barman switch-wal --force requires superuser rights or "
"the 'pg_checkpoint' role")
output.error(
"Barman switch-wal --force requires superuser rights or "
"the 'pg_checkpoint' role"
)
return

# If the user has asked to wait for a WAL file to be archived,
Expand Down
6 changes: 3 additions & 3 deletions doc/barman-cloud-backup.1
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,9 @@ optional\ arguments:
\ \ \-t,\ \-\-test\ \ \ \ \ \ \ \ \ \ \ \ Test\ cloud\ connectivity\ and\ exit
\ \ \-\-cloud\-provider\ {aws\-s3,azure\-blob\-storage,google\-cloud\-storage}
\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ The\ cloud\ provider\ to\ use\ as\ a\ storage\ backend
\ \ \-z,\ \-\-gzip\ \ \ \ \ \ \ \ \ \ \ \ gzip\-compress\ the\ WAL\ while\ uploading\ to\ the\ cloud
\ \ \-j,\ \-\-bzip2\ \ \ \ \ \ \ \ \ \ \ bzip2\-compress\ the\ WAL\ while\ uploading\ to\ the\ cloud
\ \ \-\-snappy\ \ \ \ \ \ \ \ \ \ \ \ \ \ snappy\-compress\ the\ WAL\ while\ uploading\ to\ the\ cloud
\ \ \-z,\ \-\-gzip\ \ \ \ \ \ \ \ \ \ \ \ gzip\-compress\ the\ backup\ while\ uploading\ to\ the\ cloud
\ \ \-j,\ \-\-bzip2\ \ \ \ \ \ \ \ \ \ \ bzip2\-compress\ the\ backup\ while\ uploading\ to\ the\ cloud
\ \ \-\-snappy\ \ \ \ \ \ \ \ \ \ \ \ \ \ snappy\-compress\ the\ backup\ while\ uploading\ to\ the\ cloud
\ \ \-h\ HOST,\ \-\-host\ HOST\ \ host\ or\ Unix\ socket\ for\ PostgreSQL\ connection
\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ (default:\ libpq\ settings)
\ \ \-p\ PORT,\ \-\-port\ PORT\ \ port\ for\ PostgreSQL\ connection\ (default:\ libpq
Expand Down
6 changes: 3 additions & 3 deletions doc/barman-cloud-backup.1.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,9 @@ optional arguments:
-t, --test Test cloud connectivity and exit
--cloud-provider {aws-s3,azure-blob-storage,google-cloud-storage}
The cloud provider to use as a storage backend
-z, --gzip gzip-compress the WAL while uploading to the cloud
-j, --bzip2 bzip2-compress the WAL while uploading to the cloud
--snappy snappy-compress the WAL while uploading to the cloud
-z, --gzip gzip-compress the backup while uploading to the cloud
-j, --bzip2 bzip2-compress the backup while uploading to the cloud
--snappy snappy-compress the backup while uploading to the cloud
-h HOST, --host HOST host or Unix socket for PostgreSQL connection
(default: libpq settings)
-p PORT, --port PORT port for PostgreSQL connection (default: libpq
Expand Down
15 changes: 8 additions & 7 deletions tests/test_postgres.py
Original file line number Diff line number Diff line change
Expand Up @@ -1065,10 +1065,7 @@ def test_get_remote_status(
"barman.postgres.PostgreSQLConnection.server_version", new_callable=PropertyMock
)
def test_has_checkpoint_privileges(
self,
server_version_mock,
is_su_mock,
conn_mock
self, server_version_mock, is_su_mock, conn_mock
):
server = build_real_server()
cursor_mock = conn_mock.return_value.cursor.return_value
Expand All @@ -1087,14 +1084,18 @@ def test_has_checkpoint_privileges(
is_su_mock.return_value = False
cursor_mock.fetchone.side_effect = [(False,)]
assert not server.postgres.has_checkpoint_privileges
cursor_mock.execute.assert_called_with("select pg_has_role(CURRENT_USER ,'pg_checkpoint', 'MEMBER');")
cursor_mock.execute.assert_called_with(
"select pg_has_role(CURRENT_USER ,'pg_checkpoint', 'MEMBER');"
)

# no superuser, pg_checkpoint -> True
cursor_mock.reset_mock()
is_su_mock.return_value = False
cursor_mock.fetchone.side_effect = [(True,)]
assert server.postgres.has_checkpoint_privileges
cursor_mock.execute.assert_called_with("select pg_has_role(CURRENT_USER ,'pg_checkpoint', 'MEMBER');")
cursor_mock.execute.assert_called_with(
"select pg_has_role(CURRENT_USER ,'pg_checkpoint', 'MEMBER');"
)

# superuser, no pg_checkpoint -> True
cursor_mock.reset_mock()
Expand All @@ -1114,7 +1115,7 @@ def test_has_checkpoint_privileges(
)
@patch(
"barman.postgres.PostgreSQLConnection.has_checkpoint_privileges",
new_callable=PropertyMock
new_callable=PropertyMock,
)
def test_checkpoint(self, has_cp_priv_mock, is_in_recovery_mock, conn_mock):
"""
Expand Down

0 comments on commit abef557

Please sign in to comment.