Skip to content
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
20 changes: 10 additions & 10 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v3
- name: Install dependencies
run: python3 -m pip install tox
- name: Run linters
Expand All @@ -20,13 +20,13 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v3
- name: Install dependencies
run: python -m pip install tox
- name: Run tests
run: tox -e unit
- name: Upload Coverage to Codecov
uses: codecov/codecov-action@v2
uses: codecov/codecov-action@v3

integration-test-lxd-charm:
name: Integration tests for charm deployment (lxd)
Expand All @@ -36,7 +36,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v3
- name: Setup operator environment
uses: charmed-kubernetes/actions-operator@main
with:
Expand All @@ -52,7 +52,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v3
- name: Setup operator environment
uses: charmed-kubernetes/actions-operator@main
with:
Expand All @@ -70,7 +70,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v3
- name: Setup operator environment
uses: charmed-kubernetes/actions-operator@main
with:
Expand All @@ -86,7 +86,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v3
- name: Setup operator environment
uses: charmed-kubernetes/actions-operator@main
with:
Expand All @@ -102,7 +102,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v3
- name: Setup operator environment
uses: charmed-kubernetes/actions-operator@main
with:
Expand All @@ -120,7 +120,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v3
- name: Setup operator environment
uses: charmed-kubernetes/actions-operator@main
with:
Expand All @@ -136,7 +136,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v3
- name: Setup operator environment
uses: charmed-kubernetes/actions-operator@main
with:
Expand Down
4 changes: 3 additions & 1 deletion src/relations/db.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,9 @@ def _on_relation_changed(self, event: RelationChangedEvent) -> None:
application_relation_databag = event.relation.data[self.charm.app]

# Do not allow apps requesting extensions to be installed.
if "extensions" in unit_relation_databag or "extensions" in application_relation_databag:
if "extensions" in event.relation.data[
event.app
] or "extensions" in event.relation.data.get(event.unit, {}):
logger.error(
"ERROR - `extensions` cannot be requested through relations"
" - they should be installed through a database charm config in the future"
Expand Down
38 changes: 38 additions & 0 deletions tests/integration/test_db.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

import psycopg2 as psycopg2
import pytest as pytest
from juju.errors import JujuUnitError
from mailmanclient import Client
from pytest_operator.plugin import OpsTest

Expand All @@ -14,6 +15,7 @@
check_database_users_existence,
check_databases_creation,
deploy_and_relate_application_with_postgresql,
find_unit,
)

logger = logging.getLogger(__name__)
Expand Down Expand Up @@ -156,3 +158,39 @@ async def test_relation_data_is_updated_correctly_when_scaling(ops_test: OpsTest
await ops_test.model.wait_for_idle(apps=[DATABASE_APP_NAME], status="active", timeout=1000)
with pytest.raises(psycopg2.OperationalError):
psycopg2.connect(primary_connection_string)


@pytest.mark.db_relation_tests
async def test_nextcloud_db_blocked(ops_test: OpsTest, charm: str) -> None:
async with ops_test.fast_forward():
# Deploy Nextcloud.
await ops_test.model.deploy(
"nextcloud",
channel="edge",
application_name="nextcloud",
num_units=APPLICATION_UNITS,
)
await ops_test.model.wait_for_idle(
apps=["nextcloud"],
status="blocked",
raise_on_blocked=False,
timeout=1000,
)
Comment on lines +167 to +178
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a third party charm requesting extensions.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome finding!


await ops_test.model.relate("nextcloud:db", f"{DATABASE_APP_NAME}:db")

# Only the leader will block
leader_unit = await find_unit(ops_test, DATABASE_APP_NAME, True)

try:
await ops_test.model.wait_for_idle(
apps=[DATABASE_APP_NAME],
status="blocked",
raise_on_blocked=True,
timeout=1000,
)
assert False, "Leader didn't block"
except JujuUnitError:
pass

leader_unit.workload_status_message == "extensions requested through relation"