Skip to content

Commit

Permalink
Initial scaling test
Browse files Browse the repository at this point in the history
  • Loading branch information
dragomirp committed Sep 3, 2024
1 parent 538f721 commit 29aaf18
Showing 1 changed file with 65 additions and 0 deletions.
65 changes: 65 additions & 0 deletions tests/integration/ha_tests/test_scaling.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
#!/usr/bin/env python3
# Copyright 2023 Canonical Ltd.
# See LICENSE file for licensing details.
import logging
from asyncio import gather

import pytest
from pytest_operator.plugin import OpsTest

from .. import markers
from ..helpers import (
CHARM_SERIES,
)
from .conftest import APPLICATION_NAME
from .helpers import (
app_name,
are_writes_increasing,
get_primary,
start_continuous_writes,
)

logger = logging.getLogger(__name__)

charm = None


@pytest.mark.group(1)
@markers.juju3
@pytest.mark.abort_on_fail
async def test_build_and_deploy(ops_test: OpsTest) -> None:
"""Build and deploy two PostgreSQL clusters."""
# This is a potentially destructive test, so it shouldn't be run against existing clusters
charm = await ops_test.build_charm(".")
async with ops_test.fast_forward():
# Deploy the first cluster with reusable storage
await gather(
ops_test.model.deploy(
charm,
num_units=2,
series=CHARM_SERIES,
config={"profile": "testing"},
),
ops_test.model.deploy(
APPLICATION_NAME,
application_name=APPLICATION_NAME,
series=CHARM_SERIES,
channel="edge",
),
)

await ops_test.model.wait_for_idle(status="active", timeout=1500)


@pytest.mark.group(1)
@markers.juju3
async def test_removing_primary(ops_test: OpsTest, continuous_writes) -> None:
# Start an application that continuously writes data to the database.
app = await app_name(ops_test)
await start_continuous_writes(ops_test, app)
primary = await get_primary(ops_test, app)
await ops_test.model.destroy_unit(primary, force=True, destroy_storage=False, max_wait=1500)

await ops_test.model.wait_for_idle(status="active", timeout=600)

await are_writes_increasing(ops_test, primary)

0 comments on commit 29aaf18

Please sign in to comment.