Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use integrate() instead of add_relation() #23

Merged
merged 2 commits into from
Oct 20, 2023
Merged
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
58 changes: 33 additions & 25 deletions tests/integration/test_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@

async def _deploy_database(ops_test: OpsTest):
"""Deploy a MongoDB."""
await ops_test.model.deploy( # type: ignore[union-attr]
assert ops_test.model
await ops_test.model.deploy(
DATABASE_APP_NAME,
application_name=DATABASE_APP_NAME,
channel="5/edge",
Expand All @@ -31,7 +32,8 @@ async def _deploy_database(ops_test: OpsTest):

async def _deploy_nrf(ops_test: OpsTest):
"""Deploy a NRF."""
await ops_test.model.deploy( # type: ignore[union-attr]
assert ops_test.model
await ops_test.model.deploy(
NRF_APP_NAME,
application_name=NRF_APP_NAME,
channel="edge",
Expand All @@ -41,7 +43,8 @@ async def _deploy_nrf(ops_test: OpsTest):

async def _deploy_tls_provider(ops_test: OpsTest):
"""Deploy a TLS provider."""
await ops_test.model.deploy( # type: ignore[union-attr]
assert ops_test.model
await ops_test.model.deploy(
TLS_PROVIDER_APP_NAME,
application_name=TLS_PROVIDER_APP_NAME,
channel="beta",
Expand All @@ -52,11 +55,12 @@ async def _deploy_tls_provider(ops_test: OpsTest):
@pytest.mark.abort_on_fail
async def build_and_deploy(ops_test: OpsTest):
"""Build the charm-under-test and deploy it."""
assert ops_test.model
charm = await ops_test.build_charm(".")
resources = {
"smf-image": METADATA["resources"]["smf-image"]["upstream-source"],
}
await ops_test.model.deploy( # type: ignore[union-attr]
await ops_test.model.deploy(
charm,
resources=resources,
application_name=APP_NAME,
Expand All @@ -71,7 +75,8 @@ async def build_and_deploy(ops_test: OpsTest):
async def test_given_charm_is_built_when_deployed_then_status_is_blocked(
ops_test: OpsTest, build_and_deploy
):
await ops_test.model.wait_for_idle( # type: ignore[union-attr]
assert ops_test.model
await ops_test.model.wait_for_idle(
apps=[APP_NAME],
status="blocked",
timeout=1000,
Expand All @@ -80,16 +85,17 @@ async def test_given_charm_is_built_when_deployed_then_status_is_blocked(

@pytest.mark.abort_on_fail
async def test_relate_and_wait_for_active_status(ops_test: OpsTest, build_and_deploy):
await ops_test.model.add_relation( # type: ignore[union-attr]
assert ops_test.model
await ops_test.model.integrate(
relation1=f"{NRF_APP_NAME}:database", relation2=f"{DATABASE_APP_NAME}"
)
await ops_test.model.add_relation( # type: ignore[union-attr]
await ops_test.model.integrate(
relation1=f"{APP_NAME}:database", relation2=f"{DATABASE_APP_NAME}"
)
await ops_test.model.add_relation(relation1=NRF_APP_NAME, relation2=TLS_PROVIDER_APP_NAME) # type: ignore[union-attr] # noqa: E501
await ops_test.model.add_relation(relation1=APP_NAME, relation2=NRF_APP_NAME) # type: ignore[union-attr] # noqa: E501
await ops_test.model.add_relation(relation1=APP_NAME, relation2=TLS_PROVIDER_APP_NAME) # type: ignore[union-attr] # noqa: E501
await ops_test.model.wait_for_idle( # type: ignore[union-attr]
await ops_test.model.integrate(relation1=NRF_APP_NAME, relation2=TLS_PROVIDER_APP_NAME)
await ops_test.model.integrate(relation1=APP_NAME, relation2=NRF_APP_NAME)
await ops_test.model.integrate(relation1=APP_NAME, relation2=TLS_PROVIDER_APP_NAME)
await ops_test.model.wait_for_idle(
apps=[APP_NAME],
status="active",
timeout=1000,
Expand All @@ -98,41 +104,43 @@ async def test_relate_and_wait_for_active_status(ops_test: OpsTest, build_and_de

@pytest.mark.abort_on_fail
async def test_remove_nrf_and_wait_for_blocked_status(ops_test: OpsTest, build_and_deploy):
await ops_test.model.remove_application(NRF_APP_NAME, block_until_done=True) # type: ignore[union-attr] # noqa: E501
await ops_test.model.wait_for_idle(apps=[APP_NAME], status="blocked", timeout=60) # type: ignore[union-attr] # noqa: E501
assert ops_test.model
await ops_test.model.remove_application(NRF_APP_NAME, block_until_done=True)
await ops_test.model.wait_for_idle(apps=[APP_NAME], status="blocked", timeout=60)


@pytest.mark.abort_on_fail
async def test_restore_nrf_and_wait_for_active_status(ops_test: OpsTest, build_and_deploy):
await ops_test.model.deploy( # type: ignore[union-attr]
assert ops_test.model
await ops_test.model.deploy(
NRF_APP_NAME,
application_name=NRF_APP_NAME,
channel="edge",
trust=True,
)
await ops_test.model.add_relation( # type: ignore[union-attr]
await ops_test.model.integrate(
relation1=f"{NRF_APP_NAME}:database", relation2=DATABASE_APP_NAME
)
await ops_test.model.add_relation(relation1=NRF_APP_NAME, relation2=TLS_PROVIDER_APP_NAME) # type: ignore[union-attr] # noqa: E501
await ops_test.model.add_relation(relation1=APP_NAME, relation2=NRF_APP_NAME) # type: ignore[union-attr] # noqa: E501
await ops_test.model.wait_for_idle(apps=[APP_NAME], status="active", timeout=1000) # type: ignore[union-attr] # noqa: E501
await ops_test.model.integrate(relation1=NRF_APP_NAME, relation2=TLS_PROVIDER_APP_NAME)
await ops_test.model.integrate(relation1=APP_NAME, relation2=NRF_APP_NAME)
await ops_test.model.wait_for_idle(apps=[APP_NAME], status="active", timeout=1000)


@pytest.mark.abort_on_fail
async def test_remove_tls_and_wait_for_blocked_status(ops_test: OpsTest, build_and_deploy):
await ops_test.model.remove_application(TLS_PROVIDER_APP_NAME, block_until_done=True) # type: ignore[union-attr] # noqa: E501
await ops_test.model.wait_for_idle(apps=[APP_NAME], status="blocked", timeout=60) # type: ignore[union-attr] # noqa: E501
assert ops_test.model
await ops_test.model.remove_application(TLS_PROVIDER_APP_NAME, block_until_done=True)
await ops_test.model.wait_for_idle(apps=[APP_NAME], status="blocked", timeout=60)


@pytest.mark.abort_on_fail
async def test_restore_tls_and_wait_for_active_status(ops_test: OpsTest, build_and_deploy):
await ops_test.model.deploy( # type: ignore[union-attr]
assert ops_test.model
await ops_test.model.deploy(
TLS_PROVIDER_APP_NAME,
application_name=TLS_PROVIDER_APP_NAME,
channel="beta",
trust=True,
)
await ops_test.model.add_relation( # type: ignore[union-attr]
relation1=APP_NAME, relation2=TLS_PROVIDER_APP_NAME
)
await ops_test.model.wait_for_idle(apps=[APP_NAME], status="active", timeout=1000) # type: ignore[union-attr] # noqa: E501
await ops_test.model.integrate(relation1=APP_NAME, relation2=TLS_PROVIDER_APP_NAME)
await ops_test.model.wait_for_idle(apps=[APP_NAME], status="active", timeout=1000)
Loading