-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add integration test * Update library * Fix PostgreSQL library * Add relation broken test * Add jsonschema as a binary dependency * Change hostname to unit ip * Add unit test dependency * Add check for encrypted connections * Fix space and None check
- Loading branch information
1 parent
b9e15fe
commit 7ef75e5
Showing
6 changed files
with
173 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
#!/usr/bin/env python3 | ||
# Copyright 2022 Canonical Ltd. | ||
# See LICENSE file for licensing details. | ||
import pytest as pytest | ||
from pytest_operator.plugin import OpsTest | ||
|
||
from tests.helpers import METADATA | ||
from tests.integration.helpers import DATABASE_APP_NAME, check_tls | ||
|
||
APP_NAME = METADATA["name"] | ||
TLS_CERTIFICATES_APP_NAME = "tls-certificates-operator" | ||
|
||
|
||
@pytest.mark.abort_on_fail | ||
@pytest.mark.tls_tests | ||
@pytest.mark.skip_if_deployed | ||
async def test_deploy_active(ops_test: OpsTest): | ||
"""Build the charm and deploy it.""" | ||
charm = await ops_test.build_charm(".") | ||
async with ops_test.fast_forward(): | ||
await ops_test.model.deploy( | ||
charm, resources={"patroni": "patroni.tar.gz"}, application_name=APP_NAME, num_units=3 | ||
) | ||
await ops_test.juju("attach-resource", APP_NAME, "patroni=patroni.tar.gz") | ||
await ops_test.model.wait_for_idle(apps=[APP_NAME], status="active", timeout=1000) | ||
|
||
|
||
@pytest.mark.tls_tests | ||
async def test_tls_enabled(ops_test: OpsTest) -> None: | ||
"""Test that TLS is enabled when relating to the TLS Certificates Operator.""" | ||
async with ops_test.fast_forward(): | ||
# Deploy TLS Certificates operator. | ||
config = {"generate-self-signed-certificates": "true", "ca-common-name": "Test CA"} | ||
await ops_test.model.deploy(TLS_CERTIFICATES_APP_NAME, channel="edge", config=config) | ||
await ops_test.model.wait_for_idle( | ||
apps=[TLS_CERTIFICATES_APP_NAME], status="active", timeout=1000 | ||
) | ||
|
||
# Relate it to the PostgreSQL to enable TLS. | ||
await ops_test.model.relate(DATABASE_APP_NAME, TLS_CERTIFICATES_APP_NAME) | ||
await ops_test.model.wait_for_idle(status="active", timeout=1000) | ||
|
||
# Wait for all units enabling TLS. | ||
for unit in ops_test.model.applications[DATABASE_APP_NAME].units: | ||
assert await check_tls(ops_test, unit.name, enabled=True) | ||
|
||
# Remove the relation. | ||
await ops_test.model.applications[DATABASE_APP_NAME].remove_relation( | ||
f"{DATABASE_APP_NAME}:certificates", f"{TLS_CERTIFICATES_APP_NAME}:certificates" | ||
) | ||
await ops_test.model.wait_for_idle(apps=[DATABASE_APP_NAME], status="active", timeout=1000) | ||
|
||
# Wait for all units disabling TLS. | ||
for unit in ops_test.model.applications[DATABASE_APP_NAME].units: | ||
assert await check_tls(ops_test, unit.name, enabled=False) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters