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

change to using create-user and promote-user #253

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
55 changes: 31 additions & 24 deletions tests/integration/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,36 +33,43 @@ def model_fixture(ops_test: OpsTest) -> Model:


@pytest_asyncio.fixture(scope="module")
async def discourse(model: Model) -> Application:
async def discourse(model: Model, ops_test: OpsTest) -> Application:
"""Deploy discourse."""
postgres_charm_name = "postgresql-k8s"
redis_charm_name = "redis-k8s"
discourse_charm_name = "discourse-k8s"
await asyncio.gather(
model.deploy(
postgres_charm_name,
channel="14/edge",
series="jammy",
trust=True,
config={
"profile": "testing",
"plugin_hstore_enable": "true",
"plugin_pg_trgm_enable": "true",
},
),
model.deploy(redis_charm_name, channel="latest/edge", series="jammy"),
)
await model.wait_for_idle(
apps=[postgres_charm_name, redis_charm_name], status="active", raise_on_error=False

postgres_app = await model.deploy(
postgres_charm_name,
channel="14/stable",
series="jammy",
trust=True,
config={"profile": "testing"},
)
async with ops_test.fast_forward():
await model.wait_for_idle(apps=[postgres_app.name], status="active")

discourse_app: Application = await model.deploy(discourse_charm_name, channel="edge")
await model.wait_for_idle(apps=[discourse_charm_name], status="waiting", raise_on_error=False)
redis_app = await model.deploy(redis_charm_name, series="jammy", channel="latest/edge")
await model.wait_for_idle(apps=[redis_app.name], status="active")

await model.integrate(discourse_charm_name, f"{postgres_charm_name}:database")
discourse_app: Application = await model.deploy(
discourse_charm_name, channel="edge", series="focal"
)
await model.wait_for_idle(apps=[discourse_app.name], status="waiting")

# configure postgres
await postgres_app.set_config(
{
"plugin_hstore_enable": "true",
"plugin_pg_trgm_enable": "true",
}
)
await model.wait_for_idle(apps=[postgres_app.name], status="active")

await model.integrate(discourse_charm_name, postgres_charm_name)
await model.integrate(discourse_charm_name, redis_charm_name)
await model.wait_for_idle(
apps=[discourse_charm_name], status="active", timeout=60 * 60, raise_on_error=False
apps=[discourse_app.name], status="active", timeout=60 * 60, raise_on_error=False
)

status: FullStatus = await model.get_status()
Expand Down Expand Up @@ -106,9 +113,9 @@ async def create_discourse_admin_account(discourse: Application, email: str):
"""
password = secrets.token_urlsafe(16)
discourse_unit: Unit = discourse.units[0]
action: Action = await discourse_unit.run_action(
"add-admin-user", email=email, password=password
)
action: Action = await discourse_unit.run_action("create-user", email=email, password=password)
await action.wait()
action = await discourse_unit.run_action("promote-user", email=email)
await action.wait()
return types.Credentials(email=email, username=email.split("@")[0], password=password)

Expand Down
Loading