Skip to content

Commit

Permalink
fast_forward postgresql and ranger integration
Browse files Browse the repository at this point in the history
  • Loading branch information
AmberCharitos committed Mar 25, 2024
1 parent ab98f4a commit 517ec0c
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 45 deletions.
60 changes: 24 additions & 36 deletions tests/integration/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,11 @@
# See LICENSE file for licensing details.

"""Trino charm integration test config."""
import asyncio
import logging

import pytest
import pytest_asyncio
from helpers import APP_NAME, METADATA, NGINX_NAME, WORKER_NAME, POSTGRES_NAME
from helpers import APP_NAME, METADATA, NGINX_NAME, WORKER_NAME
from pytest_operator.plugin import OpsTest

logger = logging.getLogger(__name__)
Expand All @@ -17,16 +16,6 @@
@pytest_asyncio.fixture(name="deploy", scope="module")
async def deploy(ops_test: OpsTest):
"""Deploy the app."""
asyncio.gather(
ops_test.model.deploy(POSTGRES_NAME, channel="14", trust=True),
)
async with ops_test.fast_forward():
await ops_test.model.wait_for_idle(
apps=[POSTGRES_NAME],
status="active",
raise_on_blocked=False,
timeout=2000,
)
charm = await ops_test.build_charm(".")
resources = {
"trino-image": METADATA["resources"]["trino-image"]["upstream-source"]
Expand All @@ -52,29 +41,28 @@ async def deploy(ops_test: OpsTest):

await ops_test.model.deploy(NGINX_NAME, trust=True)

async with ops_test.fast_forward():
await ops_test.model.wait_for_idle(
apps=[APP_NAME, WORKER_NAME],
status="active",
raise_on_blocked=False,
timeout=600,
)
await ops_test.model.wait_for_idle(
apps=[NGINX_NAME],
status="waiting",
raise_on_blocked=False,
timeout=600,
)
await ops_test.model.wait_for_idle(
apps=[APP_NAME, WORKER_NAME],
status="active",
raise_on_blocked=False,
timeout=600,
)
await ops_test.model.wait_for_idle(
apps=[NGINX_NAME],
status="waiting",
raise_on_blocked=False,
timeout=600,
)

await ops_test.model.integrate(APP_NAME, NGINX_NAME)
await ops_test.model.integrate(APP_NAME, NGINX_NAME)

await ops_test.model.wait_for_idle(
apps=[APP_NAME],
status="active",
raise_on_blocked=False,
timeout=300,
)
assert (
ops_test.model.applications[APP_NAME].units[0].workload_status
== "active"
)
await ops_test.model.wait_for_idle(
apps=[APP_NAME],
status="active",
raise_on_blocked=False,
timeout=300,
)
assert (
ops_test.model.applications[APP_NAME].units[0].workload_status
== "active"
)
26 changes: 17 additions & 9 deletions tests/integration/test_policy.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,17 +34,26 @@ class TestPolicyManager:
async def test_policy_enforcement(self, ops_test: OpsTest):
"""Add Ranger relation and apply group configuration."""
# Deploy and prepare Ranger admin.
await ps_test.model.deploy(POSTGRES_NAME, channel="14", trust=True)
await ops_test.model.deploy(RANGER_NAME, channel="edge")
await ops_test.model.deploy(LDAP_NAME, channel="edge")
await ops_test.model.integrate(RANGER_NAME, POSTGRES_NAME)

await ops_test.model.wait_for_idle(
apps=[POSTGRES_NAME, RANGER_NAME],
status="active",
raise_on_blocked=False,
raise_on_error=False,
timeout=2000,
)
async with ops_test.fast_forward():
await ops_test.model.wait_for_idle(
apps=[POSTGRES_NAME, RANGER_NAME, LDAP_NAME],
status="active",
raise_on_blocked=False,
timeout=2000,
)
await ops_test.model.integrate(RANGER_NAME, POSTGRES_NAME)

await ops_test.model.wait_for_idle(
apps=[POSTGRES_NAME, RANGER_NAME],
status="active",
raise_on_blocked=False,
raise_on_error=False,
timeout=2000,
)

# Deploy and prepare Ranger usersync.
await ops_test.model.wait_for_idle(
Expand All @@ -70,7 +79,6 @@ async def test_policy_enforcement(self, ops_test: OpsTest):
await ops_test.model.integrate(USERSYNC_NAME, LDAP_NAME)

# Integrate Trino and Ranger.
logging.info("integrating trino and ranger")
await ops_test.model.integrate(RANGER_NAME, APP_NAME)
await ops_test.model.wait_for_idle(
apps=[APP_NAME, RANGER_NAME, USERSYNC_NAME, LDAP_NAME],
Expand Down

0 comments on commit 517ec0c

Please sign in to comment.