Skip to content

Commit

Permalink
[MISC] Split topology script (#853)
Browse files Browse the repository at this point in the history
  • Loading branch information
sinclert-canonical authored Feb 11, 2025
1 parent 6b3c868 commit 297d181
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 5 deletions.
1 change: 1 addition & 0 deletions charmcraft.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ parts:
source: .
stage:
- LICENSE
- scripts
- templates
libpq:
build-packages:
Expand Down
4 changes: 4 additions & 0 deletions scripts/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Copyright 2025 Canonical Ltd.
# See LICENSE file for licensing details.

"""Charm script utilities."""
2 changes: 1 addition & 1 deletion src/rotate_logs.py → scripts/rotate_logs.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2024 Canonical Ltd.
# Copyright 2025 Canonical Ltd.
# See LICENSE file for licensing details.

"""Service for rotating logs."""
Expand Down
2 changes: 1 addition & 1 deletion src/backups.py
Original file line number Diff line number Diff line change
Expand Up @@ -1205,7 +1205,7 @@ def _render_pgbackrest_conf_file(self) -> bool:
with open("templates/pgbackrest.logrotate.j2") as file:
template = Template(file.read())
self.container.push(PGBACKREST_LOGROTATE_FILE, template.render())
with open("src/rotate_logs.py") as f:
with open("scripts/rotate_logs.py") as f:
self.container.push(
"/home/postgres/rotate_logs.py",
f.read(),
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/test_rotate_logs.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import contextlib
from unittest.mock import call, patch

from rotate_logs import main
from scripts.rotate_logs import main


def test_main():
Expand Down
5 changes: 3 additions & 2 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@ env_list = lint, unit

[vars]
src_path = "{tox_root}/src"
scripts_path = "{tox_root}/scripts"
tests_path = "{tox_root}/tests"
lib_path = "{tox_root}/lib/charms/postgresql_k8s"
all_path = {[vars]src_path} {[vars]tests_path} {[vars]lib_path}
all_path = {[vars]src_path} {[vars]scripts_path} {[vars]tests_path} {[vars]lib_path}

[testenv]
set_env =
Expand Down Expand Up @@ -48,7 +49,7 @@ set_env =
commands_pre =
poetry install --only main,charm-libs,unit --no-root
commands =
poetry run coverage run --source={[vars]src_path} \
poetry run coverage run --source={[vars]src_path},{[vars]scripts_path} \
-m pytest -v --tb native -s {posargs} {[vars]tests_path}/unit
poetry run coverage report
poetry run coverage xml
Expand Down

0 comments on commit 297d181

Please sign in to comment.