Skip to content

Commit

Permalink
Openserch tests
Browse files Browse the repository at this point in the history
  • Loading branch information
juditnovak committed Aug 28, 2023
1 parent 73df7c4 commit e4f3544
Showing 1 changed file with 38 additions and 1 deletion.
39 changes: 38 additions & 1 deletion tests/integration/test_opensearch_charm.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import pytest
from pytest_operator.plugin import OpsTest

from .helpers import get_application_relation_data
from .helpers import get_application_relation_data, get_juju_secret

logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -41,6 +41,7 @@ async def test_deploy_charms(ops_test: OpsTest, application_charm, opensearch_ch


@pytest.mark.abort_on_fail
@pytest.mark.usefixtures("only_without_juju_secrets")
async def test_opensearch_relation_with_charm_libraries(ops_test: OpsTest):
"""Test basic functionality of opensearch relation interface."""
# Relate the charms and wait for them exchanging some connection data.
Expand Down Expand Up @@ -71,3 +72,39 @@ async def test_opensearch_relation_with_charm_libraries(ops_test: OpsTest):
assert password == "password"
assert endpoints == "host1:port,host2:port"
assert index == "test-index"


@pytest.mark.abort_on_fail
@pytest.mark.usefixtures("only_with_juju_secrets")
async def test_opensearch_relation_with_charm_libraries_secrets(ops_test: OpsTest):
"""Test basic functionality of opensearch relation interface."""
# Relate the charms and wait for them exchanging some connection data.
await ops_test.model.add_relation(OPENSEARCH_APP_NAME, APPLICATION_APP_NAME)
await ops_test.model.wait_for_idle(apps=APP_NAMES, status="active")

# check unit messagge to check if the index_created_event is triggered
for unit in ops_test.model.applications[APPLICATION_APP_NAME].units:
assert unit.workload_status_message == "opensearch_index_created"
# check if index access is granted
for unit in ops_test.model.applications[OPENSEARCH_APP_NAME].units:
assert "granted" in unit.workload_status_message

secret_uri = await get_application_relation_data(
ops_test, APPLICATION_APP_NAME, RELATION_NAME, "secret"
)

secret_content = await get_juju_secret(ops_test, secret_uri)
username = secret_content["username"]
password = secret_content["password"]

endpoints = await get_application_relation_data(
ops_test, APPLICATION_APP_NAME, RELATION_NAME, "endpoints"
)
index = await get_application_relation_data(
ops_test, APPLICATION_APP_NAME, RELATION_NAME, "index"
)

assert username == "admin"
assert password == "password"
assert endpoints == "host1:port,host2:port"
assert index == "test-index"

0 comments on commit e4f3544

Please sign in to comment.