-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[DPE-5237] implement revision check for sharding components (#331)
* update deps for revision checker * copy over infra from vm * adding infra for local charm revision * update set status lib * add integration tests * fmt + lint * update unit tests * remove unused bits * Apply suggestions from code review Co-authored-by: Mehdi Bendriss <[email protected]> --------- Co-authored-by: Mehdi Bendriss <[email protected]>
- Loading branch information
1 parent
aa27779
commit b2aa4b2
Showing
13 changed files
with
299 additions
and
130 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,3 +17,4 @@ share/ | |
|
||
/requirements.txt | ||
/requirements-last-build.txt | ||
/charm_internal_version |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
#!/usr/bin/env python3 | ||
# Copyright 2024 Canonical Ltd. | ||
# See LICENSE file for licensing details. | ||
import pytest | ||
from pytest_operator.plugin import OpsTest | ||
|
||
from ..helpers import METADATA, wait_for_mongodb_units_blocked | ||
|
||
MONGODB_K8S_CHARM = "mongodb-k8s" | ||
SHARD_REL_NAME = "sharding" | ||
CONFIG_SERVER_REL_NAME = "config-server" | ||
|
||
LOCAL_SHARD_APP_NAME = "local-shard" | ||
REMOTE_SHARD_APP_NAME = "remote-shard" | ||
LOCAL_CONFIG_SERVER_APP_NAME = "local-config-server" | ||
REMOTE_CONFIG_SERVER_APP_NAME = "remote-config-server" | ||
|
||
CLUSTER_COMPONENTS = [ | ||
LOCAL_SHARD_APP_NAME, | ||
REMOTE_SHARD_APP_NAME, | ||
LOCAL_CONFIG_SERVER_APP_NAME, | ||
REMOTE_CONFIG_SERVER_APP_NAME, | ||
] | ||
|
||
|
||
@pytest.mark.group(1) | ||
@pytest.mark.abort_on_fail | ||
async def test_build_and_deploy(ops_test: OpsTest) -> None: | ||
my_charm = await ops_test.build_charm(".") | ||
resources = {"mongodb-image": METADATA["resources"]["mongodb-image"]["upstream-source"]} | ||
|
||
await ops_test.model.deploy( | ||
MONGODB_K8S_CHARM, | ||
application_name=REMOTE_SHARD_APP_NAME, | ||
config={"role": "shard"}, | ||
channel="edge", | ||
) | ||
|
||
await ops_test.model.deploy( | ||
MONGODB_K8S_CHARM, | ||
application_name=REMOTE_CONFIG_SERVER_APP_NAME, | ||
config={"role": "config-server"}, | ||
channel="edge", | ||
) | ||
await ops_test.model.deploy( | ||
my_charm, | ||
resources=resources, | ||
config={"role": "config-server"}, | ||
application_name=LOCAL_CONFIG_SERVER_APP_NAME, | ||
) | ||
await ops_test.model.deploy( | ||
my_charm, | ||
resources=resources, | ||
config={"role": "shard"}, | ||
application_name=LOCAL_SHARD_APP_NAME, | ||
) | ||
|
||
await ops_test.model.wait_for_idle(apps=CLUSTER_COMPONENTS, idle_period=20) | ||
|
||
|
||
@pytest.mark.group(1) | ||
@pytest.mark.abort_on_fail | ||
async def test_local_config_server_reports_remote_shard(ops_test: OpsTest) -> None: | ||
"""Tests that the local config server reports remote shard.""" | ||
await ops_test.model.integrate( | ||
f"{REMOTE_SHARD_APP_NAME}:{SHARD_REL_NAME}", | ||
f"{LOCAL_CONFIG_SERVER_APP_NAME}:{CONFIG_SERVER_REL_NAME}", | ||
) | ||
|
||
await ops_test.model.wait_for_idle( | ||
apps=[LOCAL_CONFIG_SERVER_APP_NAME], | ||
status="waiting", | ||
raise_on_blocked=False, | ||
idle_period=20, | ||
) | ||
|
||
config_server_unit = ops_test.model.applications[LOCAL_CONFIG_SERVER_APP_NAME].units[0] | ||
|
||
assert ( | ||
"Waiting for shards to upgrade/downgrade to revision" | ||
in config_server_unit.workload_status_message | ||
), "Config server does not correctly report mismatch in revision" | ||
|
||
|
||
@pytest.mark.group(1) | ||
@pytest.mark.abort_on_fail | ||
async def test_local_shard_reports_remote_config_server(ops_test: OpsTest) -> None: | ||
"""Tests that the local shard reports remote config-server.""" | ||
await ops_test.model.integrate( | ||
f"{LOCAL_SHARD_APP_NAME}:{SHARD_REL_NAME}", | ||
f"{REMOTE_CONFIG_SERVER_APP_NAME}:{CONFIG_SERVER_REL_NAME}", | ||
) | ||
|
||
await wait_for_mongodb_units_blocked( | ||
ops_test, | ||
LOCAL_SHARD_APP_NAME, | ||
timeout=300, | ||
) | ||
|
||
shard_unit = ops_test.model.applications[LOCAL_SHARD_APP_NAME].units[0] | ||
assert ( | ||
"is not up-to date with config-server." in shard_unit.workload_status_message | ||
), "Shard does not correctly report mismatch in revision" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.