Skip to content
This repository has been archived by the owner on Oct 16, 2024. It is now read-only.

Bump paas-app-charmer version to 1.1.0 #43

Merged
merged 8 commits into from
Sep 17, 2024
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
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# See LICENSE file for licensing details.
[project]
name = "paas-app-charmer"
version = "1.0.4"
version = "1.1.0"
description = "Companion library for PaaS app charmer."
readme = "README.md"
authors = [
Expand Down
11 changes: 11 additions & 0 deletions tests/integration/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,17 @@ async def deploy_prometheus_fixture(
return app


@pytest_asyncio.fixture(scope="module", name="postgresql_k8s")
async def deploy_postgres_fixture(ops_test: OpsTest, model: Model):
"""Deploy postgres k8s charm."""
_, status, _ = await ops_test.juju("status", "--format", "json")
version = json.loads(status)["model"]["version"]
if tuple(map(int, (version.split(".")))) >= (3, 4, 0):
return await model.deploy("postgresql-k8s", channel="14/stable", trust=True)
else:
return await model.deploy("postgresql-k8s", channel="14/stable", revision=300, trust=True)


@pytest_asyncio.fixture
def run_action(ops_test: OpsTest):
async def _run_action(application_name, action_name, **params):
Expand Down
19 changes: 8 additions & 11 deletions tests/integration/django/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,26 +55,23 @@ async def charm_file_fixture(


@pytest_asyncio.fixture(scope="module", name="django_app")
async def django_app_fixture(charm_file: str, model: Model, django_app_image: str):
async def django_app_fixture(charm_file: str, model: Model, django_app_image: str, postgresql_k8s):
"""Build and deploy the django charm."""
app_name = "django-k8s"

resources = {
"django-app-image": django_app_image,
}
apps = await asyncio.gather(
model.deploy(
charm_file,
application_name=app_name,
config={"django-allowed-hosts": "*"},
resources=resources,
series="jammy",
),
model.deploy("postgresql-k8s", channel="14/stable", trust=True),
app = await model.deploy(
charm_file,
application_name=app_name,
config={"django-allowed-hosts": "*"},
resources=resources,
series="jammy",
)
await model.integrate(app_name, "postgresql-k8s")
await model.wait_for_idle(status="active")
return apps[0]
return app


@pytest_asyncio.fixture
Expand Down
17 changes: 8 additions & 9 deletions tests/integration/fastapi/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,21 +48,20 @@ async def charm_file_fixture(


@pytest_asyncio.fixture(scope="module", name="fastapi_app")
async def fastapi_app_fixture(charm_file: str, model: Model, fastapi_app_image: str):
async def fastapi_app_fixture(
charm_file: str, model: Model, fastapi_app_image: str, postgresql_k8s
):
"""Build and deploy the fastapi charm."""
app_name = "fastapi-k8s"

resources = {
"app-image": fastapi_app_image,
}
apps = await asyncio.gather(
model.deploy(
charm_file,
application_name=app_name,
resources=resources,
),
model.deploy("postgresql-k8s", channel="14/stable", trust=True),
app = await model.deploy(
charm_file,
application_name=app_name,
resources=resources,
)
await model.integrate(app_name, "postgresql-k8s")
await model.wait_for_idle(status="active")
return apps[0]
return app
2 changes: 1 addition & 1 deletion tests/integration/flask/test_database.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
[
("redis/status", "redis-k8s", "latest/edge", None, True),
("mysql/status", "mysql-k8s", "8.0/stable", "140", True),
("postgresql/status", "postgresql-k8s", "14/stable", None, True),
("postgresql/status", "postgresql-k8s", "14/stable", "300", True),
("mongodb/status", "mongodb-k8s", "6/beta", None, True),
],
)
Expand Down
7 changes: 2 additions & 5 deletions tests/integration/flask/test_db_migration.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,16 @@


async def test_db_migration(
flask_db_app: Application,
model: juju.model.Model,
get_unit_ips,
flask_db_app: Application, model: juju.model.Model, get_unit_ips, postgresql_k8s
):
"""
arrange: build and deploy the flask charm.
act: deploy the database and relate it to the charm.
assert: requesting the charm should return a correct response indicate
the database migration script has been executed and only executed once.
"""
db_app = await model.deploy("postgresql-k8s", channel="14/stable", trust=True)
await model.wait_for_idle()
await model.add_relation(flask_db_app.name, db_app.name)
await model.add_relation(flask_db_app.name, postgresql_k8s.name)
await model.wait_for_idle(status="active", timeout=20 * 60)

for unit_ip in await get_unit_ips(flask_db_app.name):
Expand Down
15 changes: 6 additions & 9 deletions tests/integration/go/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,21 +46,18 @@ async def charm_file_fixture(


@pytest_asyncio.fixture(scope="module", name="go_app")
async def go_app_fixture(charm_file: str, model: Model, go_app_image: str):
async def go_app_fixture(charm_file: str, model: Model, go_app_image: str, postgresql_k8s):
"""Build and deploy the go charm."""
app_name = "go-k8s"

resources = {
"app-image": go_app_image,
}
apps = await asyncio.gather(
model.deploy(
charm_file,
application_name=app_name,
resources=resources,
),
model.deploy("postgresql-k8s", channel="14/stable", trust=True),
app = await model.deploy(
charm_file,
application_name=app_name,
resources=resources,
)
await model.integrate(app_name, "postgresql-k8s")
await model.wait_for_idle(status="active")
return apps[0]
return app
2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ description = Run integration tests
deps =
cosl
boto3
juju==3.1.2.0
juju==3.5.2.0
git+https://github.com/canonical/saml-test-idp.git
-r{toxinidir}/requirements.txt
-r{toxinidir}/tests/integration/flask/requirements.txt
Expand Down
Loading