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

[DPE-2636] Mongodb 6 with 6/edge and server built from source #255

Merged
merged 7 commits into from
Sep 22, 2023
Merged
Show file tree
Hide file tree
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
14 changes: 6 additions & 8 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,9 @@ jobs:
with:
credentials: "${{ secrets.CHARMHUB_TOKEN }}"
github-token: "${{ secrets.GITHUB_TOKEN }}"
# TODO - wait until track request is approved:
# https://discourse.charmhub.io/t/request-track-6-for-charmed-mongodb-operator/11900
# - name: Upload charm to charmhub
# uses: canonical/charming-actions/[email protected]
# with:
# credentials: "${{ secrets.CHARMHUB_TOKEN }}"
# github-token: "${{ secrets.GITHUB_TOKEN }}"
# channel: "6/edge"
- name: Upload charm to charmhub
uses: canonical/charming-actions/[email protected]
with:
credentials: "${{ secrets.CHARMHUB_TOKEN }}"
github-token: "${{ secrets.GITHUB_TOKEN }}"
channel: "6/edge"
phvalguima marked this conversation as resolved.
Show resolved Hide resolved
5 changes: 2 additions & 3 deletions lib/charms/mongodb/v0/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
MONGODB_COMMON_DIR = "/var/snap/charmed-mongodb/common"
MONGODB_SNAP_DATA_DIR = "/var/snap/charmed-mongodb/current"

MONGO_SHELL = "charmed-mongodb.mongosh"

DATA_DIR = "/var/lib/mongodb"
CONF_DIR = "/etc/mongod"
Expand All @@ -49,9 +50,7 @@


# noinspection GrazieInspection
def get_create_user_cmd(
config: MongoDBConfiguration, mongo_path="charmed-mongodb.mongo"
) -> List[str]:
def get_create_user_cmd(config: MongoDBConfiguration, mongo_path=MONGO_SHELL) -> List[str]:
"""Creates initial admin user for MongoDB.

Initial admin user can be created only through localhost connection.
Expand Down
2 changes: 1 addition & 1 deletion src/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class Config:
MONGODB_SNAP_DATA_DIR = "/var/snap/charmed-mongodb/current"
MONGOD_CONF_DIR = f"{MONGODB_SNAP_DATA_DIR}/etc/mongod"
MONGOD_CONF_FILE_PATH = f"{MONGOD_CONF_DIR}/mongod.conf"
SNAP_PACKAGES = [("charmed-mongodb", "5/edge", 84)]
SNAP_PACKAGES = [("charmed-mongodb", "6/edge", 87)]

class Role:
"""Role config names for MongoDB Charm."""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ async def mongo_tls_command(ops_test: OpsTest) -> str:
replica_set_uri = f"mongodb://{hosts}/admin?replicaSet={app}"

return (
f"charmed-mongodb.mongo '{replica_set_uri}' --eval 'rs.status()'"
f"charmed-mongodb.mongosh '{replica_set_uri}' --eval 'rs.status()'"
phvalguima marked this conversation as resolved.
Show resolved Hide resolved
f" --tls --tlsCAFile {EXTERNAL_CERT_PATH}"
f" --tlsCertificateKeyFile {EXTERNAL_PEM_PATH}"
)
Expand Down
4 changes: 3 additions & 1 deletion tests/integration/test_charm.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from uuid import uuid4

import pytest
from charms.mongodb.v0.helpers import MONGO_SHELL
from pymongo import MongoClient
from pymongo.errors import PyMongoError, ServerSelectionTimeoutError
from pytest_operator.plugin import OpsTest
Expand Down Expand Up @@ -180,7 +181,8 @@ async def test_monitor_user(ops_test: OpsTest) -> None:
]
hosts = ",".join(replica_set_hosts)
replica_set_uri = f"mongodb://monitor:{password}@{hosts}/admin?replicaSet=mongodb"
admin_mongod_cmd = f"charmed-mongodb.mongo '{replica_set_uri}' --eval 'rs.conf()'"

admin_mongod_cmd = f"{MONGO_SHELL} '{replica_set_uri}' --eval 'rs.conf()'"
check_monitor_cmd = f"exec --unit {unit.name} -- {admin_mongod_cmd}"
return_code, _, _ = await ops_test.juju(*check_monitor_cmd.split())
assert return_code == 0, "command rs.conf() on monitor user does not work"
Expand Down
3 changes: 2 additions & 1 deletion tests/integration/tls_tests/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from datetime import datetime

import ops
from charms.mongodb.v0.helpers import MONGO_SHELL
from pytest_operator.plugin import OpsTest
from tenacity import RetryError, Retrying, stop_after_attempt, wait_exponential

Expand Down Expand Up @@ -33,7 +34,7 @@ async def mongo_tls_command(ops_test: OpsTest) -> str:
replica_set_uri = f"mongodb://operator:" f"{password}@" f"{hosts}/admin?replicaSet={app}"

return (
f"charmed-mongodb.mongo '{replica_set_uri}' --eval 'rs.status()'"
f"{MONGO_SHELL} '{replica_set_uri}' --eval 'rs.status()'"
f" --tls --tlsCAFile {EXTERNAL_CERT_PATH}"
f" --tlsCertificateKeyFile {EXTERNAL_PEM_PATH}"
)
Expand Down
Loading