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

test: Add TLS Requirer to integration tests #34

Merged
merged 1 commit into from
Feb 2, 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
43 changes: 0 additions & 43 deletions tests/integration/test_charm.py

This file was deleted.

70 changes: 70 additions & 0 deletions tests/integration/test_integration.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
#!/usr/bin/env python3
# Copyright 2024 Canonical Ltd.
# See LICENSE file for licensing details.


import logging
from pathlib import Path

import pytest
import yaml
from pytest_operator.plugin import OpsTest

logger = logging.getLogger(__name__)

METADATA = yaml.safe_load(Path("./metadata.yaml").read_text())
APP_NAME = METADATA["name"]

TLS_REQUIRER_CHARM_NAME = "tls-certificates-requirer"


@pytest.fixture(scope="module")
@pytest.mark.abort_on_fail
async def build_and_deploy(ops_test: OpsTest):
"""Build the charm-under-test and deploy it."""
charm = await ops_test.build_charm(".")
resources = {"lego-image": METADATA["resources"]["lego-image"]["upstream-source"]}
assert ops_test.model
await ops_test.model.deploy(
charm,
resources=resources,
application_name=APP_NAME,
series="jammy",
config={
"email": "example@email.com",
"httpreq_endpoint": "http://dummy.url.com",
},
)
await ops_test.model.deploy(
TLS_REQUIRER_CHARM_NAME,
application_name=TLS_REQUIRER_CHARM_NAME,
channel="edge",
)


@pytest.mark.abort_on_fail
async def test_given_charm_is_built_when_deployed_then_status_is_active(
ops_test: OpsTest,
build_and_deploy,
):
assert ops_test.model
await ops_test.model.wait_for_idle(
apps=[APP_NAME],
status="active",
timeout=1000,
)


async def test_given_tls_requirer_is_deployed_and_related_then_status_is_active(
ops_test: OpsTest,
build_and_deploy,
):
assert ops_test.model
await ops_test.model.add_relation(
relation1=f"{APP_NAME}:certificates", relation2=f"{TLS_REQUIRER_CHARM_NAME}"
)
await ops_test.model.wait_for_idle(
apps=[TLS_REQUIRER_CHARM_NAME],
status="active",
timeout=1000,
)
ghislainbourgeois marked this conversation as resolved.
Show resolved Hide resolved
2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ envlist = lint, static, unit
src_path = {toxinidir}/src/
unit_test_path = {toxinidir}/tests/unit/
integration_test_path = {toxinidir}/tests/integration/
all_path = {[vars]src_path} {[vars]unit_test_path}
all_path = {[vars]src_path} {[vars]unit_test_path} {[vars]integration_test_path}

[testenv]
setenv =
Expand Down
Loading