Skip to content

Commit

Permalink
Restore same tests with SAML integration test
Browse files Browse the repository at this point in the history
  • Loading branch information
amandahla committed Aug 16, 2023
1 parent f75594c commit 81ea1ee
Show file tree
Hide file tree
Showing 2 changed files with 128 additions and 119 deletions.
44 changes: 30 additions & 14 deletions tests/integration/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,14 +65,16 @@ def synapse_app_name_fixture() -> str:

@pytest_asyncio.fixture(scope="module", name="synapse_app")
async def synapse_app_fixture(
ops_test: OpsTest,
synapse_app_name: str,
synapse_image: str,
model: Model,
server_name: str,
synapse_charm: str,
postgresql_app: Application,
postgresql_app_name: str,
):
"""Build and deploy the Synapse and PostgreSQL charms."""
"""Build and deploy the Synapse charm."""
resources = {
"synapse-image": synapse_image,
}
Expand All @@ -82,13 +84,12 @@ async def synapse_app_fixture(
application_name=synapse_app_name,
series="jammy",
config={"server_name": server_name},
trust=True,
)
await model.deploy(postgresql_app_name, channel="14/stable", trust=True)
await model.wait_for_idle(raise_on_blocked=True, status=ACTIVE_STATUS_NAME)
await model.relate(f"{synapse_app_name}:database", f"{postgresql_app_name}")
await model.wait_for_idle(wait_for_active=True, status=ACTIVE_STATUS_NAME)
yield app
async with ops_test.fast_forward():
await model.wait_for_idle(raise_on_blocked=True, status=ACTIVE_STATUS_NAME)
await model.relate(f"{synapse_app_name}:database", f"{postgresql_app_name}")
await model.wait_for_idle(wait_for_active=True, status=ACTIVE_STATUS_NAME)
return app


@pytest_asyncio.fixture(scope="module", name="get_unit_ips")
Expand Down Expand Up @@ -131,6 +132,7 @@ def traefik_app_name_fixture() -> str:
async def traefik_app_fixture(
ops_test: OpsTest,
model: Model,
synapse_app,
traefik_app_name: str,
external_hostname: str,
):
Expand All @@ -146,7 +148,7 @@ async def traefik_app_fixture(
},
)
await model.wait_for_idle(raise_on_blocked=True, status=ACTIVE_STATUS_NAME)
yield app
return app


@pytest.fixture(scope="module", name="nginx_integrator_app_name")
Expand All @@ -159,6 +161,7 @@ def nginx_integrator_app_name_fixture() -> str:
async def nginx_integrator_app_fixture(
ops_test: OpsTest,
model: Model,
synapse_app,
nginx_integrator_app_name: str,
):
"""Deploy nginx-ingress-integrator."""
Expand All @@ -169,10 +172,10 @@ async def nginx_integrator_app_fixture(
trust=True,
)
await model.wait_for_idle(raise_on_blocked=True, status=ACTIVE_STATUS_NAME)
yield app
return app


@pytest.fixture(scope="module", name="another_synapse_app")
@pytest_asyncio.fixture(scope="function", name="another_synapse_app")
async def another_synapse_app_fixture(
model: Model, synapse_app: Application, server_name: str, another_server_name: str
):
Expand All @@ -196,6 +199,18 @@ def postgresql_app_name_app_name_fixture() -> str:
return "postgresql-k8s"


@pytest_asyncio.fixture(scope="module", name="postgresql_app")
async def postgresql_app_fixture(
ops_test: OpsTest,
model: Model,
postgresql_app_name: str,
):
"""Deploy postgresql."""
async with ops_test.fast_forward():
await model.deploy(postgresql_app_name, channel="14/stable", trust=True)
await model.wait_for_idle(status=ACTIVE_STATUS_NAME)


@pytest.fixture(scope="module", name="grafana_app_name")
def grafana_app_name_fixture() -> str:
"""Return the name of the grafana application deployed for tests."""
Expand All @@ -218,7 +233,7 @@ async def grafana_app_fixture(
)
await model.wait_for_idle(raise_on_blocked=True, status=ACTIVE_STATUS_NAME)

yield app
return app


@pytest.fixture(scope="module", name="prometheus_app_name")
Expand All @@ -228,7 +243,7 @@ def prometheus_app_name_fixture() -> str:


@pytest_asyncio.fixture(scope="module", name="prometheus_app")
async def prometheus_app_fixture(
async def deploy_prometheus_fixture(
ops_test: OpsTest,
model: Model,
prometheus_app_name: str,
Expand All @@ -243,7 +258,7 @@ async def prometheus_app_fixture(
)
await model.wait_for_idle(raise_on_blocked=True, status=ACTIVE_STATUS_NAME)

yield app
return app


@pytest.fixture(scope="module", name="saml_integrator_app_name")
Expand All @@ -266,7 +281,7 @@ async def saml_integrator_app_fixture(
channel="latest/edge",
trust=True,
)
await model.wait_for_idle(raise_on_blocked=True, status=ACTIVE_STATUS_NAME)
await model.wait_for_idle()
entity_id = "https://login.staging.ubuntu.com"
metadata_url = "https://login.staging.ubuntu.com/saml/metadata"
await app.set_config( # type: ignore[attr-defined]
Expand All @@ -275,4 +290,5 @@ async def saml_integrator_app_fixture(
"metadata_url": metadata_url,
}
)
await model.wait_for_idle()
yield app
Loading

0 comments on commit 81ea1ee

Please sign in to comment.