
Currently the ceilometer services are configured and ceilometer dbsync is run as an action. A new interface gnocchi_service is introduced that updates relation data when gnocchi service is up. Add new relation gnocchi_service in metadata.yaml as a mandatory relation. Update dbsync commands so that they are run as part of configure_charm. Remove the action ceilometer-upgrade that does the dbsync as it is no more required. Change-Id: Iba72250f3d31ef9dafa5b3bd16abefd43a74366a
69 lines
2.3 KiB
Python
69 lines
2.3 KiB
Python
#!/usr/bin/env python3
|
|
|
|
# Copyright 2021 Canonical Ltd.
|
|
#
|
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
# you may not use this file except in compliance with the License.
|
|
# You may obtain a copy of the License at
|
|
#
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
#
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
# See the License for the specific language governing permissions and
|
|
# limitations under the License.
|
|
|
|
"""Tests for gnocchi charm."""
|
|
|
|
import ops_sunbeam.test_utils as test_utils
|
|
|
|
import charm
|
|
|
|
|
|
class _CeilometerOperatorCharm(charm.CeilometerOperatorCharm):
|
|
def __init__(self, framework):
|
|
self.seen_events = []
|
|
super().__init__(framework)
|
|
|
|
def _log_event(self, event):
|
|
self.seen_events.append(type(event).__name__)
|
|
|
|
def configure_charm(self, event):
|
|
super().configure_charm(event)
|
|
self._log_event(event)
|
|
|
|
|
|
class TestCeilometerOperatorCharm(test_utils.CharmTestCase):
|
|
"""Class for testing gnocchi charm."""
|
|
|
|
PATCHES = []
|
|
|
|
def setUp(self):
|
|
"""Run setup for unit tests."""
|
|
super().setUp(charm, self.PATCHES)
|
|
self.harness = test_utils.get_harness(
|
|
_CeilometerOperatorCharm, container_calls=self.container_calls
|
|
)
|
|
|
|
def test_pebble_ready_handler(self):
|
|
"""Test Pebble ready event is captured."""
|
|
self.harness.begin()
|
|
self.assertEqual(self.harness.charm.seen_events, [])
|
|
test_utils.set_all_pebbles_ready(self.harness)
|
|
self.assertEqual(len(self.harness.charm.seen_events), 2)
|
|
|
|
def test_all_relations(self):
|
|
"""Test all the charms relations."""
|
|
self.harness.begin_with_initial_hooks()
|
|
self.harness.set_leader()
|
|
test_utils.set_all_pebbles_ready(self.harness)
|
|
test_utils.add_complete_identity_credentials_relation(self.harness)
|
|
test_utils.add_complete_amqp_relation(self.harness)
|
|
self.harness.add_relation(
|
|
"gnocchi-db", "gnocchi", app_data={"ready": "true"}
|
|
)
|
|
|
|
for c in ["ceilometer-central", "ceilometer-notification"]:
|
|
self.check_file(c, "/etc/ceilometer/ceilometer.conf")
|