diff --git a/src/relations/pgbouncer_provider.py b/src/relations/pgbouncer_provider.py index 5495fe5da..8e7455cf5 100644 --- a/src/relations/pgbouncer_provider.py +++ b/src/relations/pgbouncer_provider.py @@ -103,7 +103,7 @@ def _on_database_requested(self, event: DatabaseRequestedEvent) -> None: # Retrieve the database name and extra user roles using the charm library. databases = event.database - extra_user_roles = event.extra_user_roles + extra_user_roles = event.extra_user_roles or "" rel_id = event.relation.id # Creates the user and the database for this specific relation. diff --git a/tests/integration/relations/pgbouncer_provider/test_pgbouncer_provider.py b/tests/integration/relations/pgbouncer_provider/test_pgbouncer_provider.py index 60faf0418..52926f84a 100644 --- a/tests/integration/relations/pgbouncer_provider/test_pgbouncer_provider.py +++ b/tests/integration/relations/pgbouncer_provider/test_pgbouncer_provider.py @@ -29,6 +29,7 @@ logger = logging.getLogger(__name__) CLIENT_APP_NAME = "application" +DATA_INTEGRATOR_APP_NAME = "data-integrator" CLIENT_UNIT_NAME = f"{CLIENT_APP_NAME}/0" TEST_DBNAME = "application_first_database" ANOTHER_APPLICATION_APP_NAME = "another-application" @@ -424,3 +425,17 @@ async def test_relation_broken(ops_test: OpsTest): cfg = await get_cfg(ops_test, pgb_unit_name) assert "first-database" not in cfg["databases"].keys() assert "first-database_readonly" not in cfg["databases"].keys() + + +@pytest.mark.client_relation +async def test_relation_with_data_integrator(ops_test: OpsTest): + """Test that the charm can be related to the data integrator without extra user roles.""" + config = {"database-name": "test-database"} + await ops_test.model.deploy( + DATA_INTEGRATOR_APP_NAME, + channel="edge", + config=config, + ) + await ops_test.model.add_relation(f"{PGB}:database", DATA_INTEGRATOR_APP_NAME) + async with ops_test.fast_forward(): + await ops_test.model.wait_for_idle(status="active") diff --git a/tests/integration/relations/test_peers.py b/tests/integration/relations/test_peers.py index 1646a657b..4ab93063e 100644 --- a/tests/integration/relations/test_peers.py +++ b/tests/integration/relations/test_peers.py @@ -92,7 +92,6 @@ async def test_scaling(ops_test: OpsTest): # Ensure the initial number of units in the application. initial_scale = 4 async with ops_test.fast_forward(): - await scale_application(ops_test, PGB, initial_scale) await asyncio.gather( ops_test.model.wait_for_idle(apps=[MAILMAN], status="active", timeout=600),