diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 0d2810354..008b4434d 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -70,7 +70,7 @@ juju add-model dev # Enable DEBUG logging juju model-config logging-config="=INFO;unit=DEBUG" # Deploy the charm -juju deploy ./mongodb-k8s_ubuntu-20.04-amd64.charm --resource mongodb-image=mongo:4.4 --num-units=1 +juju deploy ./mongodb-k8s_ubuntu-20.04-amd64.charm --resource mongodb-image=dataplatformoci/mongodb:5.0 --num-units=1 ``` ## Canonical Contributor Agreement diff --git a/README.md b/README.md index 218b3eefb..b76115083 100644 --- a/README.md +++ b/README.md @@ -29,12 +29,12 @@ tls internal key - `string`; TLS external key for encryption inside the cluster ### Basic Usage To deploy a single unit of MongoDB using its default configuration ```shell -juju deploy ./mongodb-k8s_ubuntu-20.04-amd64.charm --resource mongodb-image=mongo:4.4 +juju deploy ./mongodb-k8s_ubuntu-20.04-amd64.charm --resource mongodb-image=dataplatformoci/mongodb:5.0 ``` It is customary to use MongoDB with replication. Hence usually more than one unit (preferably an odd number to prohibit a "split-brain" scenario) is deployed. To deploy MongoDB with multiple replicas, specify the number of desired units with the `-n` option. ```shell -juju deploy ./mongodb-k8s_ubuntu-20.04-amd64.charm --resource mongodb-image=mongo:4.4 +juju deploy ./mongodb-k8s_ubuntu-20.04-amd64.charm --resource mongodb-image=dataplatformoci/mongodb:5.0 -n ``` diff --git a/metadata.yaml b/metadata.yaml index 7100126a7..4034cdf6c 100644 --- a/metadata.yaml +++ b/metadata.yaml @@ -31,7 +31,7 @@ resources: mongodb-image: type: oci-image description: OCI image for mongodb - upstream-source: 'mongo:latest' + upstream-source: 'dataplatformoci/mongodb:5.0' storage: db: type: filesystem diff --git a/tests/integration/ha_tests/helpers.py b/tests/integration/ha_tests/helpers.py index 9b3bef1e8..a7b7ec57c 100644 --- a/tests/integration/ha_tests/helpers.py +++ b/tests/integration/ha_tests/helpers.py @@ -24,7 +24,13 @@ wait_fixed, ) -from tests.integration.helpers import APP_NAME, get_password, mongodb_uri, primary_host +from tests.integration.helpers import ( + APP_NAME, + get_mongo_cmd, + get_password, + mongodb_uri, + primary_host, +) METADATA = yaml.safe_load(Path("./metadata.yaml").read_text()) MONGODB_CONTAINER_NAME = "mongod" @@ -440,7 +446,7 @@ async def set_log_level(ops_test: OpsTest, level: int, component: str = None) -> "--container", MONGODB_CONTAINER_NAME, "", - "mongosh", + await get_mongo_cmd(ops_test, pass_unit), "-u", "operator", "-p", diff --git a/tests/integration/helpers.py b/tests/integration/helpers.py index 419112b13..676332b76 100644 --- a/tests/integration/helpers.py +++ b/tests/integration/helpers.py @@ -68,6 +68,13 @@ async def get_password(ops_test: OpsTest, unit_id: int) -> str: return action.results["operator-password"] +async def get_mongo_cmd(ops_test: OpsTest, unit_name: str): + ls_code, _, _ = await ops_test.juju(f"ssh --container {unit_name} ls /usr/bin/mongosh") + + mongo_cmd = "/usr/bin/mongo" if ls_code != 0 else "/usr/bin/mongosh" + return mongo_cmd + + async def mongodb_uri(ops_test: OpsTest, unit_ids: List[int] = None) -> str: if unit_ids is None: unit_ids = UNIT_IDS diff --git a/tests/integration/tls_tests/helpers.py b/tests/integration/tls_tests/helpers.py index 16a9de651..f224f9cde 100644 --- a/tests/integration/tls_tests/helpers.py +++ b/tests/integration/tls_tests/helpers.py @@ -10,7 +10,7 @@ from pytest_operator.plugin import OpsTest from tenacity import RetryError, Retrying, stop_after_attempt, wait_exponential -from tests.integration.helpers import get_password +from tests.integration.helpers import get_mongo_cmd, get_password logger = logging.getLogger(__name__) @@ -62,8 +62,10 @@ async def run_tls_check(ops_test: OpsTest, unit: ops.model.Unit) -> int: password = await get_password(ops_test, unit_id=0) mongo_uri = f"mongodb://operator:{password}@{hosts}/admin?" - mongo_cmd = ( - f"/usr/bin/mongosh {mongo_uri} --eval 'rs.status()'" + mongo_cmd = await get_mongo_cmd(ops_test, unit.name) + + mongo_cmd += ( + f" {mongo_uri} --eval 'rs.status()'" f" --tls --tlsCAFile /etc/mongodb/external-ca.crt" f" --tlsCertificateKeyFile /etc/mongodb/external-cert.pem" )