Skip to content

Commit

Permalink
Upgrade to jammy (#94)
Browse files Browse the repository at this point in the history
* Upgrade to jammy

* Fix formatting

* Fix merge

* Fix test after Discourse charm update
  • Loading branch information
marceloneppel authored Feb 28, 2023
1 parent e354f95 commit 79f99d1
Show file tree
Hide file tree
Showing 12 changed files with 49 additions and 21 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
name: Release to CharmHub
needs:
- ci-tests
runs-on: ubuntu-20.04
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ juju model-config logging-config="<root>=INFO;unit=DEBUG"
# enable Role-Based Access Control on microk8s
microk8s enable rbac
# Deploy the charm
juju deploy ./postgresql-k8s_ubuntu-20.04-amd64.charm \
juju deploy ./postgresql-k8s_ubuntu-22.04-amd64.charm \
--resource postgresql-image=dataplatformoci/postgres-patroni \
--trust
```
4 changes: 2 additions & 2 deletions charmcraft.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ type: "charm"
bases:
- build-on:
- name: "ubuntu"
channel: "20.04"
channel: "22.04"
run-on:
- name: "ubuntu"
channel: "20.04"
channel: "22.04"
parts:
charm:
build-packages:
Expand Down
4 changes: 2 additions & 2 deletions tests/integration/ha_tests/application-charm/charmcraft.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ type: charm
bases:
- build-on:
- name: "ubuntu"
channel: "20.04"
channel: "22.04"
run-on:
- name: "ubuntu"
channel: "20.04"
channel: "22.04"
parts:
charm:
charm-binary-python-packages: [psycopg2-binary==2.9.3]
5 changes: 4 additions & 1 deletion tests/integration/ha_tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
get_master_start_timeout,
stop_continuous_writes,
)
from tests.integration.helpers import CHARM_SERIES

APPLICATION_NAME = "application"

Expand All @@ -21,7 +22,9 @@ async def continuous_writes(ops_test: OpsTest) -> None:
async with ops_test.fast_forward():
if await app_name(ops_test, APPLICATION_NAME) is None:
charm = await ops_test.build_charm("tests/integration/ha_tests/application-charm")
await ops_test.model.deploy(charm, application_name=APPLICATION_NAME)
await ops_test.model.deploy(
charm, application_name=APPLICATION_NAME, series=CHARM_SERIES
)
await ops_test.model.wait_for_idle(status="active", timeout=1000)

# Start the continuous writes process by relating the application to the database or
Expand Down
2 changes: 2 additions & 0 deletions tests/integration/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
wait_exponential,
)

CHARM_SERIES = "jammy"
METADATA = yaml.safe_load(Path("./metadata.yaml").read_text())
DATABASE_APP_NAME = METADATA["name"]

Expand Down Expand Up @@ -73,6 +74,7 @@ async def build_and_deploy(
application_name=database_app_name,
trust=True,
num_units=num_units,
series=CHARM_SERIES,
),
if wait_for_idle:
# Wait until the PostgreSQL charm is successfully deployed.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ type: charm
bases:
- build-on:
- name: "ubuntu"
channel: "20.04"
channel: "22.04"
run-on:
- name: "ubuntu"
channel: "20.04"
channel: "22.04"
10 changes: 9 additions & 1 deletion tests/integration/new_relations/test_new_relations.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,11 @@
import yaml
from pytest_operator.plugin import OpsTest

from tests.integration.helpers import check_database_users_existence, scale_application
from tests.integration.helpers import (
CHARM_SERIES,
check_database_users_existence,
scale_application,
)
from tests.integration.new_relations.helpers import (
build_connection_string,
check_relation_data_existence,
Expand Down Expand Up @@ -44,6 +48,7 @@ async def test_database_relation_with_charm_libraries(
application_charm,
application_name=APPLICATION_APP_NAME,
num_units=2,
series=CHARM_SERIES,
),
ops_test.model.deploy(
database_charm,
Expand All @@ -54,6 +59,7 @@ async def test_database_relation_with_charm_libraries(
},
application_name=DATABASE_APP_NAME,
num_units=3,
series=CHARM_SERIES,
trust=True,
),
ops_test.model.deploy(
Expand All @@ -65,6 +71,7 @@ async def test_database_relation_with_charm_libraries(
},
application_name=ANOTHER_DATABASE_APP_NAME,
num_units=3,
series=CHARM_SERIES,
trust=True,
),
)
Expand Down Expand Up @@ -152,6 +159,7 @@ async def test_two_applications_doesnt_share_the_same_relation_data(
await ops_test.model.deploy(
application_charm,
application_name=another_application_app_name,
series=CHARM_SERIES,
)
await ops_test.model.wait_for_idle(apps=all_app_names, status="active")

Expand Down
2 changes: 2 additions & 0 deletions tests/integration/test_charm.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

from tests.helpers import METADATA, STORAGE_PATH
from tests.integration.helpers import (
CHARM_SERIES,
build_and_deploy,
convert_records_to_dict,
db_connect,
Expand Down Expand Up @@ -296,6 +297,7 @@ async def test_redeploy_charm_same_model(ops_test: OpsTest):
},
application_name=APP_NAME,
num_units=3,
series=CHARM_SERIES,
trust=True,
)

Expand Down
31 changes: 20 additions & 11 deletions tests/integration/test_db_admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,11 @@

from tests.helpers import METADATA
from tests.integration.helpers import (
CHARM_SERIES,
DATABASE_APP_NAME,
check_database_creation,
check_database_users_existence,
get_primary,
get_unit_address,
)

Expand Down Expand Up @@ -41,6 +43,7 @@ async def test_build_and_deploy(ops_test: OpsTest):
application_name=DATABASE_APP_NAME,
trust=True,
num_units=DATABASE_UNITS,
series=CHARM_SERIES,
),
ops_test.model.deploy(
FIRST_DISCOURSE_APP_NAME, application_name=FIRST_DISCOURSE_APP_NAME
Expand All @@ -50,34 +53,40 @@ async def test_build_and_deploy(ops_test: OpsTest):
await ops_test.model.wait_for_idle(
apps=[DATABASE_APP_NAME, REDIS_APP_NAME], status="active", timeout=1000
)
# Discourse becomes blocked waiting for relations.
# Discourse waits for relations.
await ops_test.model.wait_for_idle(
apps=[FIRST_DISCOURSE_APP_NAME], status="blocked", timeout=1000
apps=[FIRST_DISCOURSE_APP_NAME], status="waiting", timeout=1000
)


async def test_discourse(ops_test: OpsTest):
# Test the first Discourse charm.
# Add both relations to Discourse (PostgreSQL and Redis)
# and wait for it to be ready.
relation = await ops_test.model.add_relation(
await ops_test.model.add_relation(
f"{DATABASE_APP_NAME}:db-admin",
FIRST_DISCOURSE_APP_NAME,
)
await ops_test.model.add_relation(
REDIS_APP_NAME,
FIRST_DISCOURSE_APP_NAME,
)
await ops_test.model.wait_for_idle(
apps=[DATABASE_APP_NAME, FIRST_DISCOURSE_APP_NAME, REDIS_APP_NAME],
status="active",
timeout=2000, # Discourse takes a longer time to become active (a lot of setup).

# Discourse requests extensions through relation, so check that the PostgreSQL charm
# becomes blocked.
primary_name = await get_primary(ops_test)
await ops_test.model.block_until(
lambda: ops_test.model.units[primary_name].workload_status == "blocked", timeout=60
)
assert (
ops_test.model.units[primary_name].workload_status_message
== "extensions requested through relation"
)

# Check for the correct databases and users creation.
await check_database_creation(ops_test, "discourse-k8s")
discourse_users = [f"relation_id_{relation.id}"]
await check_database_users_existence(ops_test, discourse_users, [], admin=True)
# Destroy the relation to remove the blocked status.
await ops_test.model.applications[DATABASE_APP_NAME].destroy_relation(
f"{DATABASE_APP_NAME}:db-admin", FIRST_DISCOURSE_APP_NAME
)


async def test_discourse_from_discourse_charmers(ops_test: OpsTest):
Expand Down
2 changes: 2 additions & 0 deletions tests/integration/test_password_rotation.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

from tests.helpers import METADATA
from tests.integration.helpers import (
CHARM_SERIES,
check_patroni,
get_password,
restart_patroni,
Expand All @@ -30,6 +31,7 @@ async def test_deploy_active(ops_test: OpsTest):
},
application_name=APP_NAME,
num_units=3,
series=CHARM_SERIES,
trust=True,
)
await ops_test.model.wait_for_idle(apps=[APP_NAME], status="active", timeout=1000)
Expand Down
2 changes: 2 additions & 0 deletions tests/integration/test_tls.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

from tests.helpers import METADATA
from tests.integration.helpers import (
CHARM_SERIES,
DATABASE_APP_NAME,
check_database_creation,
check_database_users_existence,
Expand Down Expand Up @@ -44,6 +45,7 @@ async def test_mattermost_db(ops_test: OpsTest) -> None:
},
application_name=DATABASE_APP_NAME,
num_units=DATABASE_UNITS,
series=CHARM_SERIES,
trust=True,
)
# Deploy TLS Certificates operator.
Expand Down

0 comments on commit 79f99d1

Please sign in to comment.