Add a ceilometer test case and fix existing ones for trusty/mitaka

https://bugs.launchpad.net/charm-ceilometer/+bug/1828424
This commit is contained in:
Aurelien Lourot
2020-03-03 14:06:59 +01:00
parent 48470b7bd7
commit 707b36c0f8
3 changed files with 37 additions and 12 deletions

View File

@@ -44,6 +44,7 @@ install_require = [
'python-novaclient',
'python-neutronclient',
'python-octaviaclient',
'python-ceilometerclient',
'python-cinderclient',
'python-swiftclient',
'zaza@git+https://github.com/openstack-charmers/zaza.git#egg=zaza',

View File

@@ -19,8 +19,9 @@
import copy
import logging
import zaza.openstack.utilities.openstack as openstack_utils
import ceilometerclient.v2.client as ceilo_client
import zaza.openstack.charm_tests.test_utils as test_utils
import zaza.openstack.utilities.openstack as openstack_utils
class CeilometerTest(test_utils.OpenStackBaseTest):
@@ -39,11 +40,11 @@ class CeilometerTest(test_utils.OpenStackBaseTest):
def setUpClass(cls):
"""Run class setup for running Ceilometer tests."""
super(CeilometerTest, cls).setUpClass()
cls.current_release = openstack_utils.get_os_release()
@property
def services(self):
"""Return a list services for Openstack Release."""
self.current_release = openstack_utils.get_os_release()
"""Return a list of services for Openstack Release."""
services = []
if self.application_name == 'ceilometer-agent':
@@ -89,20 +90,43 @@ class CeilometerTest(test_utils.OpenStackBaseTest):
return services
# NOTE(beisner): need to add more functional tests
def test_900_restart_on_config_change(self):
"""Checking restart happens on config change."""
_services = copy.deepcopy(self.services)
@property
def restartable_services(self):
"""Return a list of services that are known to be restartable.
For Openstack Release these services are known to be able to be stopped
and started with no issues.
"""
# Due to Bug #1861321 ceilometer-collector does not reliably
# restart.
_services = copy.deepcopy(self.services)
if self.current_release <= CeilometerTest.TRUSTY_MITAKA:
try:
_services.remove('ceilometer-collector')
except ValueError:
pass
return _services
def test_400_api_connection(self):
"""Simple api calls to check service is up and responding."""
if self.current_release >= CeilometerTest.XENIAL_PIKE:
logging.info('Skipping API checks as ceilometer api has been '
'removed')
return
logging.info('Instantiating ceilometer client...')
ceil = ceilo_client.Client(
session=openstack_utils.get_overcloud_keystone_session()
)
logging.info('Checking api functionality...')
assert(ceil.samples.list() == [])
assert(ceil.meters.list() == [])
# NOTE(beisner): need to add more functional tests
def test_900_restart_on_config_change(self):
"""Checking restart happens on config change."""
config_name = 'debug'
if self.application_name == 'ceilometer-agent':
@@ -138,7 +162,7 @@ class CeilometerTest(test_utils.OpenStackBaseTest):
set_alternate,
default_entry,
alternate_entry,
_services)
self.restartable_services)
def test_901_pause_resume(self):
"""Run pause and resume tests.
@@ -146,5 +170,5 @@ class CeilometerTest(test_utils.OpenStackBaseTest):
Pause service and check services are stopped then resume and check
they are started.
"""
with self.pause_resume(self.services):
with self.pause_resume(self.restartable_services):
logging.info("Testing pause and resume")

View File

@@ -335,8 +335,8 @@ class OpenStackBaseTest(unittest.TestCase):
Pause and then resume a unit checking that services are in the
required state after each action
:param services: Services expected to be restarted when config_file is
changed.
:param services: Services expected to be restarted when the unit is
paused/resumed.
:type services: list
:param pgrep_full: Should pgrep be used rather than pidof to identify
a service.