Skip to content

Commit

Permalink
fix timeout on install
Browse files Browse the repository at this point in the history
  • Loading branch information
MiaAltieri committed Dec 20, 2024
1 parent 62dd700 commit 4de4f4a
Show file tree
Hide file tree
Showing 15 changed files with 84 additions and 34 deletions.
10 changes: 8 additions & 2 deletions tests/integration/backup_tests/test_backups.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

from ..ha_tests import helpers as ha_helpers
from ..helpers import (
DEPLOYMENT_TIMEOUT,
destroy_cluster,
get_app_name,
is_relation_joined,
Expand Down Expand Up @@ -61,7 +62,7 @@ async def test_build_and_deploy(ops_test: OpsTest) -> None:
# deploy the s3 integrator charm
await ops_test.model.deploy(S3_APP_NAME, channel="edge")

await ops_test.model.wait_for_idle()
await ops_test.model.wait_for_idle(timeout=DEPLOYMENT_TIMEOUT)


@pytest.mark.runner(["self-hosted", "linux", "X64", "jammy", "large"])
Expand Down Expand Up @@ -347,7 +348,12 @@ async def test_restore_new_cluster(
db_charm = await ops_test.build_charm(".")
await ops_test.model.deploy(db_charm, num_units=3, application_name=new_cluster_app_name)
await asyncio.gather(
ops_test.model.wait_for_idle(apps=[new_cluster_app_name], status="active", idle_period=15),
ops_test.model.wait_for_idle(
apps=[new_cluster_app_name],
status="active",
idle_period=15,
timeout=DEPLOYMENT_TIMEOUT,
),
)

db_unit = await helpers.get_leader_unit(ops_test, db_app_name=new_cluster_app_name)
Expand Down
11 changes: 7 additions & 4 deletions tests/integration/ha_tests/test_ha.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
from tenacity import RetryError, Retrying, stop_after_delay, wait_fixed

from ..helpers import (
DEPLOYMENT_TIMEOUT,
check_or_scale_app,
get_app_name,
get_unit_ip,
Expand Down Expand Up @@ -81,7 +82,7 @@ async def test_build_and_deploy(ops_test: OpsTest) -> None:
storage = {"mongodb": {"pool": "lxd", "size": 2048}}

await ops_test.model.deploy(my_charm, num_units=required_units, storage=storage)
await ops_test.model.wait_for_idle()
await ops_test.model.wait_for_idle(timeout=DEPLOYMENT_TIMEOUT)


@pytest.mark.runner(["self-hosted", "linux", "X64", "jammy", "large"])
Expand Down Expand Up @@ -349,7 +350,9 @@ async def test_unique_cluster_dbs(ops_test: OpsTest, continuous_writes) -> None:
# deploy new cluster
my_charm = await ops_test.build_charm(".")
await ops_test.model.deploy(my_charm, num_units=1, application_name=ANOTHER_DATABASE_APP_NAME)
await ops_test.model.wait_for_idle(apps=[ANOTHER_DATABASE_APP_NAME], status="active")
await ops_test.model.wait_for_idle(
apps=[ANOTHER_DATABASE_APP_NAME], status="active", timeout=DEPLOYMENT_TIMEOUT
)

# write data to new cluster
ip_addresses = [
Expand Down Expand Up @@ -772,7 +775,7 @@ async def test_network_cut(ops_test, continuous_writes):
@pytest.mark.unstable
async def test_scale_up_down(ops_test: OpsTest, continuous_writes):
"""Scale up and down the application and verify the replica set is healthy."""
scales = [3, -3, 4, -4, 5, -5, 6, -6, 7, -7]
scales = [3, -3, 4, -4, 5, -5]
for count in scales:
await scale_and_verify(ops_test, count=count)
await verify_writes(ops_test)
Expand All @@ -784,7 +787,7 @@ async def test_scale_up_down(ops_test: OpsTest, continuous_writes):
@pytest.mark.unstable
async def test_scale_up_down_removing_leader(ops_test: OpsTest, continuous_writes):
"""Scale up and down the application and verify the replica set is healthy."""
scales = [3, -3, 4, -4, 5, -5, 6, -6, 7, -7]
scales = [3, -3, 4, -4, 5, -5]
for count in scales:
await scale_and_verify(ops_test, count=count, remove_leader=True)
await verify_writes(ops_test)
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
PORT = 27017
UNIT_IDS = [0, 1, 2]
SERIES = "jammy"

DEPLOYMENT_TIMEOUT = 2000
logger = logging.getLogger(__name__)

logger = logging.getLogger(__name__)
Expand Down
3 changes: 2 additions & 1 deletion tests/integration/metrics_tests/test_metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

from ..ha_tests import helpers as ha_helpers
from ..helpers import (
DEPLOYMENT_TIMEOUT,
UNIT_IDS,
check_or_scale_app,
find_unit,
Expand Down Expand Up @@ -40,7 +41,7 @@ async def test_build_and_deploy(ops_test: OpsTest) -> None:

my_charm = await ops_test.build_charm(".")
await ops_test.model.deploy(my_charm, num_units=3)
await ops_test.model.wait_for_idle()
await ops_test.model.wait_for_idle(timeout=DEPLOYMENT_TIMEOUT)


@pytest.mark.runner(["self-hosted", "linux", "X64", "jammy", "large"])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,12 @@
from tenacity import RetryError

from ...ha_tests.helpers import replica_set_primary
from ...helpers import check_or_scale_app, get_app_name, is_relation_joined
from ...helpers import (
DEPLOYMENT_TIMEOUT,
check_or_scale_app,
get_app_name,
is_relation_joined,
)
from .helpers import (
assert_created_user_can_connect,
get_application_relation_data,
Expand Down Expand Up @@ -89,7 +94,10 @@ async def test_deploy_charms(ops_test: OpsTest, application_charm, database_char
else:
APP_NAMES.append(DATABASE_APP_NAME)
await ops_test.model.wait_for_idle(
apps=APP_NAMES, status="active", wait_for_at_least_units=required_units
apps=APP_NAMES,
status="active",
wait_for_at_least_units=required_units,
timeout=DEPLOYMENT_TIMEOUT,
)


Expand Down Expand Up @@ -316,7 +324,9 @@ async def test_two_applications_doesnt_share_the_same_relation_data(
application_charm,
application_name=ANOTHER_APPLICATION_NAME,
)
await ops_test.model.wait_for_idle(apps=all_app_names, status="active")
await ops_test.model.wait_for_idle(
apps=all_app_names, status="active", timeout=DEPLOYMENT_TIMEOUT
)

db_app_name = (
await get_app_name(ops_test, test_deployments=[ANOTHER_DATABASE_APP_NAME])
Expand Down
3 changes: 2 additions & 1 deletion tests/integration/sharding_tests/test_mongos.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from pymongo.errors import OperationFailure
from pytest_operator.plugin import OpsTest

from ..helpers import DEPLOYMENT_TIMEOUT
from .helpers import count_users, generate_mongodb_client, get_username_password

MONGOS_HOST_APP_NAME = "application"
Expand Down Expand Up @@ -52,7 +53,7 @@ async def test_build_and_deploy(ops_test: OpsTest, mongos_host_application_charm
apps=[CONFIG_SERVER_APP_NAME, SHARD_ONE_APP_NAME, MONGOS_HOST_APP_NAME],
idle_period=20,
raise_on_blocked=False, # cluster components are blocked waiting for integration.
timeout=TIMEOUT,
timeout=DEPLOYMENT_TIMEOUT,
raise_on_error=False,
)

Expand Down
3 changes: 2 additions & 1 deletion tests/integration/sharding_tests/test_sharding.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from pytest_operator.plugin import OpsTest

from ..helpers import (
DEPLOYMENT_TIMEOUT,
get_leader_id,
get_password,
set_password,
Expand Down Expand Up @@ -71,7 +72,7 @@ async def test_build_and_deploy(ops_test: OpsTest) -> None:
],
idle_period=20,
raise_on_blocked=False,
timeout=TIMEOUT,
timeout=DEPLOYMENT_TIMEOUT,
raise_on_error=False,
)

Expand Down
10 changes: 8 additions & 2 deletions tests/integration/sharding_tests/test_sharding_backups.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,13 @@
from tenacity import Retrying, stop_after_delay, wait_fixed

from ..backup_tests import helpers as backup_helpers
from ..helpers import destroy_cluster, get_leader_id, get_password, set_password
from ..helpers import (
DEPLOYMENT_TIMEOUT,
destroy_cluster,
get_leader_id,
get_password,
set_password,
)
from . import writes_helpers
from .helpers import generate_mongodb_client, write_data_to_mongodb

Expand Down Expand Up @@ -406,7 +412,7 @@ async def deploy_cluster_backup_test(
apps=[S3_APP_NAME, config_server_name, shard_one_name, shard_two_name],
idle_period=20,
raise_on_blocked=False,
timeout=TIMEOUT,
timeout=DEPLOYMENT_TIMEOUT,
raise_on_error=False,
)

Expand Down
4 changes: 2 additions & 2 deletions tests/integration/sharding_tests/test_sharding_relations.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from juju.errors import JujuAPIError
from pytest_operator.plugin import OpsTest

from ..helpers import wait_for_mongodb_units_blocked
from ..helpers import DEPLOYMENT_TIMEOUT, wait_for_mongodb_units_blocked

S3_APP_NAME = "s3-integrator"
SHARD_ONE_APP_NAME = "shard"
Expand Down Expand Up @@ -75,7 +75,7 @@ async def test_build_and_deploy(
],
idle_period=20,
raise_on_blocked=False,
timeout=TIMEOUT,
timeout=DEPLOYMENT_TIMEOUT,
)

await ops_test.model.integrate(
Expand Down
8 changes: 6 additions & 2 deletions tests/integration/sharding_tests/test_sharding_tls.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,11 @@
import pytest
from pytest_operator.plugin import OpsTest

from ..helpers import destroy_cluster, wait_for_mongodb_units_blocked
from ..helpers import (
DEPLOYMENT_TIMEOUT,
destroy_cluster,
wait_for_mongodb_units_blocked,
)
from ..tls_tests import helpers as tls_helpers
from .helpers import deploy_cluster_components, integrate_cluster

Expand Down Expand Up @@ -38,7 +42,7 @@ async def test_build_and_deploy(ops_test: OpsTest) -> None:
apps=[CERTS_APP_NAME, CONFIG_SERVER_APP_NAME, SHARD_ONE_APP_NAME, SHARD_TWO_APP_NAME],
idle_period=20,
raise_on_blocked=False,
timeout=TIMEOUT,
timeout=DEPLOYMENT_TIMEOUT,
raise_on_error=False,
)

Expand Down
3 changes: 2 additions & 1 deletion tests/integration/test_charm.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
stop_continous_writes,
)
from .helpers import (
DEPLOYMENT_TIMEOUT,
PORT,
UNIT_IDS,
audit_log_line_sanity_check,
Expand Down Expand Up @@ -61,7 +62,7 @@ async def test_build_and_deploy(ops_test: OpsTest) -> None:

my_charm = await ops_test.build_charm(".")
await ops_test.model.deploy(my_charm, num_units=len(UNIT_IDS))
await ops_test.model.wait_for_idle()
await ops_test.model.wait_for_idle(timeout=DEPLOYMENT_TIMEOUT)


@pytest.mark.runner(["self-hosted", "linux", "X64", "jammy", "large"])
Expand Down
8 changes: 5 additions & 3 deletions tests/integration/tls_tests/test_tls.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import yaml
from pytest_operator.plugin import OpsTest

from ..helpers import UNIT_IDS, check_or_scale_app, get_app_name
from ..helpers import DEPLOYMENT_TIMEOUT, UNIT_IDS, check_or_scale_app, get_app_name
from .helpers import (
EXTERNAL_CERT_PATH,
INTERNAL_CERT_PATH,
Expand Down Expand Up @@ -47,12 +47,14 @@ async def test_build_and_deploy(ops_test: OpsTest) -> None:
async with ops_test.fast_forward():
my_charm = await ops_test.build_charm(".")
await ops_test.model.deploy(my_charm, num_units=3)
await ops_test.model.wait_for_idle(apps=[app_name], status="active")
await ops_test.model.wait_for_idle(
apps=[app_name], status="active", timeout=DEPLOYMENT_TIMEOUT
)

config = {"ca-common-name": "Test CA"}
await ops_test.model.deploy(TLS_CERTIFICATES_APP_NAME, channel="stable", config=config)
await ops_test.model.wait_for_idle(
apps=[TLS_CERTIFICATES_APP_NAME], status="active", timeout=1000
apps=[TLS_CERTIFICATES_APP_NAME], status="active", timeout=DEPLOYMENT_TIMEOUT
)


Expand Down
13 changes: 9 additions & 4 deletions tests/integration/upgrade/test_sharding_rollback.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import pytest
from pytest_operator.plugin import OpsTest

from ..helpers import find_unit, wait_for_mongodb_units_blocked
from ..helpers import DEPLOYMENT_TIMEOUT, find_unit, wait_for_mongodb_units_blocked
from ..sharding_tests.helpers import deploy_cluster_components, integrate_cluster
from ..sharding_tests.writes_helpers import (
SHARD_ONE_DB_NAME,
Expand All @@ -26,7 +26,6 @@
CLUSTER_COMPONENTS = [SHARD_ONE_APP_NAME, SHARD_TWO_APP_NAME, CONFIG_SERVER_APP_NAME]
SHARD_REL_NAME = "sharding"
CONFIG_SERVER_REL_NAME = "config-server"
TIMEOUT = 15 * 60
MEDIAN_REELECTION_TIME = 12


Expand All @@ -43,11 +42,17 @@ async def test_build_and_deploy(ops_test: OpsTest) -> None:
await deploy_cluster_components(ops_test, num_units_cluster_config, channel="6/edge")

await ops_test.model.wait_for_idle(
apps=CLUSTER_COMPONENTS, idle_period=20, timeout=TIMEOUT, raise_on_blocked=False
apps=CLUSTER_COMPONENTS,
idle_period=20,
timeout=DEPLOYMENT_TIMEOUT,
raise_on_blocked=False,
)
await integrate_cluster(ops_test)
await ops_test.model.wait_for_idle(
apps=CLUSTER_COMPONENTS, status="active", idle_period=20, timeout=TIMEOUT
apps=CLUSTER_COMPONENTS,
status="active",
idle_period=20,
timeout=DEPLOYMENT_TIMEOUT,
)


Expand Down
14 changes: 9 additions & 5 deletions tests/integration/upgrade/test_sharding_upgrade.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from pytest_operator.plugin import OpsTest

from ..ha_tests import helpers as ha_helpers
from ..helpers import find_unit, unit_hostname
from ..helpers import DEPLOYMENT_TIMEOUT, find_unit, unit_hostname
from ..sharding_tests.helpers import (
deploy_cluster_components,
generate_mongodb_client,
Expand All @@ -34,7 +34,6 @@
CLUSTER_COMPONENTS = [SHARD_ONE_APP_NAME, SHARD_TWO_APP_NAME, CONFIG_SERVER_APP_NAME]
SHARD_REL_NAME = "sharding"
CONFIG_SERVER_REL_NAME = "config-server"
TIMEOUT = 15 * 60
MEDIAN_REELECTION_TIME = 12


Expand All @@ -51,11 +50,17 @@ async def test_build_and_deploy(ops_test: OpsTest) -> None:
await deploy_cluster_components(ops_test, num_units_cluster_config, channel="6/edge")

await ops_test.model.wait_for_idle(
apps=CLUSTER_COMPONENTS, idle_period=20, timeout=TIMEOUT, raise_on_blocked=False
apps=CLUSTER_COMPONENTS,
idle_period=20,
timeout=DEPLOYMENT_TIMEOUT,
raise_on_blocked=False,
)
await integrate_cluster(ops_test)
await ops_test.model.wait_for_idle(
apps=CLUSTER_COMPONENTS, status="active", idle_period=20, timeout=TIMEOUT
apps=CLUSTER_COMPONENTS,
status="active",
idle_period=20,
timeout=DEPLOYMENT_TIMEOUT,
)


Expand Down Expand Up @@ -152,7 +157,6 @@ async def test_pre_upgrade_check_failure(ops_test: OpsTest) -> None:
apps=CLUSTER_COMPONENTS,
idle_period=20,
status="active",
timeout=TIMEOUT,
raise_on_blocked=False,
)

Expand Down
10 changes: 8 additions & 2 deletions tests/integration/upgrade/test_upgrade.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,13 @@
from pytest_operator.plugin import OpsTest

from ..ha_tests import helpers as ha_helpers
from ..helpers import check_or_scale_app, find_unit, get_app_name, unit_hostname
from ..helpers import (
DEPLOYMENT_TIMEOUT,
check_or_scale_app,
find_unit,
get_app_name,
unit_hostname,
)

logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -39,7 +45,7 @@ async def test_build_and_deploy(ops_test: OpsTest) -> None:
await ops_test.model.deploy(MONGODB_CHARM_NAME, channel="6/edge", num_units=3)

await ops_test.model.wait_for_idle(
apps=["mongodb"], status="active", timeout=1000, idle_period=120
apps=["mongodb"], status="active", timeout=DEPLOYMENT_TIMEOUT, idle_period=120
)


Expand Down

0 comments on commit 4de4f4a

Please sign in to comment.