Skip to content

Commit

Permalink
[MISC] Increase coverage (#505)
Browse files Browse the repository at this point in the history
* Bump libs

* Tweak asserts

* Bump topology coverage

* Increase charm coverage

* Increase coverage on charm

* Bump libs
  • Loading branch information
dragomirp authored Jun 26, 2024
1 parent 885ab0c commit 459f1f6
Show file tree
Hide file tree
Showing 11 changed files with 498 additions and 261 deletions.
11 changes: 5 additions & 6 deletions lib/charms/postgresql_k8s/v0/postgresql.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@

# Increment this PATCH version before using `charmcraft publish-lib` or reset
# to 0 if you are raising the major API version
LIBPATCH = 28
LIBPATCH = 29

INVALID_EXTRA_USER_ROLE_BLOCKING_MESSAGE = "invalid role(s) for extra user roles"

Expand Down Expand Up @@ -604,12 +604,11 @@ def build_postgresql_parameters(
# Use 25% of the available memory for shared_buffers.
# and the remaining as cache memory.
shared_buffers = int(available_memory * 0.25)
parameters["shared_buffers"] = f"{int(shared_buffers * 128 / 10**6)}"
effective_cache_size = int(available_memory - shared_buffers)
parameters.setdefault("shared_buffers", f"{int(shared_buffers / 10**6)}MB")
parameters.update({"effective_cache_size": f"{int(effective_cache_size / 10**6)}MB"})
else:
# Return default
parameters.setdefault("shared_buffers", "128MB")
parameters.update({
"effective_cache_size": f"{int(effective_cache_size / 10**6) * 128}"
})
return parameters

def validate_date_style(self, date_style: str) -> bool:
Expand Down
5 changes: 3 additions & 2 deletions lib/charms/postgresql_k8s/v0/postgresql_tls.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
from ops.charm import ActionEvent, RelationBrokenEvent
from ops.framework import Object
from ops.pebble import ConnectionError, PathError, ProtocolError
from tenacity import RetryError

# The unique Charmhub library identifier, never change it
LIBID = "c27af44a92df4ef38d7ae06418b2800f"
Expand All @@ -43,7 +44,7 @@

# Increment this PATCH version before using `charmcraft publish-lib` or reset
# to 0 if you are raising the major API version.
LIBPATCH = 8
LIBPATCH = 9

logger = logging.getLogger(__name__)
SCOPE = "unit"
Expand Down Expand Up @@ -142,7 +143,7 @@ def _on_certificate_available(self, event: CertificateAvailableEvent) -> None:
logger.debug("Cannot push TLS certificates at this moment")
event.defer()
return
except (ConnectionError, PathError, ProtocolError) as e:
except (ConnectionError, PathError, ProtocolError, RetryError) as e:
logger.error("Cannot push TLS certificates: %r", e)
event.defer()
return
Expand Down
Loading

0 comments on commit 459f1f6

Please sign in to comment.