diff --git a/src/charm.py b/src/charm.py index 1a8de1791..cba18f686 100755 --- a/src/charm.py +++ b/src/charm.py @@ -21,7 +21,6 @@ ) from charms.mongodb.v0.mongodb_secrets import SecretCache, generate_secret_label from charms.mongodb.v0.mongodb_tls import MongoDBTLS -from charms.mongodb.v0.upgrade import MongoDBDependencyModel, MongoDBUpgrade from charms.mongodb.v1.helpers import ( KEY_FILE, TLS_EXT_CA_FILE, @@ -77,6 +76,7 @@ from tenacity import Retrying, before_log, retry, stop_after_attempt, wait_fixed from config import Config, Package +from events.upgrade import MongoDBDependencyModel, MongoDBUpgrade from exceptions import AdminUserCreationError, ApplicationHostNotFoundError from machine_helpers import MONGO_USER, ROOT_USER_GID, update_mongod_service diff --git a/lib/charms/mongodb/v0/upgrade.py b/src/events/upgrade.py similarity index 96% rename from lib/charms/mongodb/v0/upgrade.py rename to src/events/upgrade.py index 88a889c86..237653a15 100644 --- a/lib/charms/mongodb/v0/upgrade.py +++ b/src/events/upgrade.py @@ -1,4 +1,4 @@ -# Copyright 2023 Canonical Ltd. +# Copyright 2024 Canonical Ltd. # See LICENSE file for licensing details. """Manager for handling MongoDB in-place upgrades.""" @@ -29,15 +29,6 @@ WRITE_KEY = "write_value" MONGOD_SERVICE = "mongod" -# The unique Charmhub library identifier, never change it -LIBID = "aad46b9f0ddb4cb392982a52a596ec9b" - -# Increment this major API version when introducing breaking changes -LIBAPI = 0 - -# Increment this PATCH version before using `charmcraft publish-lib` or reset -# to 0 if you are raising the major API version -LIBPATCH = 3 ROLLBACK_INSTRUCTIONS = """Unit failed to upgrade and requires manual rollback to previous stable version. 1. Re-run `pre-upgrade-check` action on the leader unit to enter 'recovery' state diff --git a/tests/unit/test_upgrade.py b/tests/unit/test_upgrade.py index fdf9c1b52..93df5c721 100644 --- a/tests/unit/test_upgrade.py +++ b/tests/unit/test_upgrade.py @@ -23,7 +23,7 @@ def setUp(self, *unused): self.peer_rel_id = self.harness.add_relation("upgrade", "upgrade") @patch_network_get(private_address="1.1.1.1") - @patch("charms.mongodb.v0.upgrade.MongoDBConnection") + @patch("events.upgrade.MongoDBConnection") def test_is_cluster_healthy(self, connection): """Test is_cluster_healthy function.""" @@ -59,7 +59,7 @@ def is_replication_mock_call(*args): assert self.harness.charm.upgrade.is_cluster_healthy() @patch_network_get(private_address="1.1.1.1") - @patch("charms.mongodb.v0.upgrade.MongoDBConnection") + @patch("events.upgrade.MongoDBConnection") @patch("charm.MongoDBUpgrade.is_excepted_write_on_replica") def test_is_replica_set_able_read_write(self, is_excepted_write_on_replica, connection): """Test test_is_replica_set_able_read_write function.""" @@ -81,11 +81,11 @@ def test_build_upgrade_stack(self, connection): assert self.harness.charm.upgrade.build_upgrade_stack() == [0, 1] @patch_network_get(private_address="1.1.1.1") - @patch("charms.mongodb.v0.upgrade.Retrying") + @patch("events.upgrade.Retrying") @patch("charm.MongoDBUpgrade.is_excepted_write_on_replica") @patch("charm.MongodbOperatorCharm.restart_charm_services") @patch("charm.MongoDBConnection") - @patch("charms.mongodb.v0.upgrade.MongoDBConnection") + @patch("events.upgrade.MongoDBConnection") @patch("charm.MongodbOperatorCharm.install_snap_packages") @patch("charm.MongodbOperatorCharm.stop_charm_services") @patch("charm.MongoDBUpgrade.post_upgrade_check")