'ceilometer-polling' should fail with no valid pollsters
The command 'ceilometer-polling --pollster-list' should fail with invalid pollsters. When executing the command 'ceilometer-polling --pollster-list' with a wrong pollster like aaa, it still executes and no error will be shown. It occupies the system resources and shows no errors. Remove the test case for "ceilometer-polling --polling-namespaces ipmi" in the upgrade.sh. In the test environment, the ipmi is not ready. It should fail. Change-Id: If1f9f9fdbba1832e66d89d6b61f749790df5c2b6 Closes-Bug: #1553926
This commit is contained in:
parent
dd2c6509c8
commit
bb6032fd1b
@ -88,6 +88,13 @@ class PollsterListForbidden(Exception):
|
||||
super(PollsterListForbidden, self).__init__(msg)
|
||||
|
||||
|
||||
class EmptyPollstersList(Exception):
|
||||
def __init__(self):
|
||||
msg = ('No valid pollsters can be loaded with the startup parameters'
|
||||
' polling-namespaces and pollster-list.')
|
||||
super(EmptyPollstersList, self).__init__(msg)
|
||||
|
||||
|
||||
class Resources(object):
|
||||
def __init__(self, agent_manager):
|
||||
self.agent_manager = agent_manager
|
||||
@ -262,6 +269,9 @@ class AgentManager(service_base.BaseService):
|
||||
self.extensions = list(itertools.chain(*list(extensions))) + list(
|
||||
itertools.chain(*list(extensions_fb)))
|
||||
|
||||
if self.extensions == []:
|
||||
raise EmptyPollstersList()
|
||||
|
||||
self.discovery_manager = self._extensions('discover')
|
||||
self.context = context.RequestContext('admin', 'admin', is_admin=True)
|
||||
self.partition_coordinator = coordination.PartitionCoordinator()
|
||||
|
@ -65,12 +65,27 @@ class TestManager(base.BaseTestCase):
|
||||
# currently we do have 26 disk-related pollsters
|
||||
self.assertEqual(26, len(list(mgr.extensions)))
|
||||
|
||||
def test_load_invalid_plugins_pollster_list(self):
|
||||
# if no valid pollsters have been loaded, the ceilometer
|
||||
# polling program should exit
|
||||
self.assertRaisesRegexp(
|
||||
manager.EmptyPollstersList,
|
||||
'No valid pollsters can be loaded with the startup parameters'
|
||||
' polling-namespaces and pollster-list.',
|
||||
manager.AgentManager,
|
||||
pollster_list=['aaa'])
|
||||
|
||||
def test_load_plugins_no_intersection(self):
|
||||
# Let's test nothing will be polled if namespace and pollsters
|
||||
# list have no intersection.
|
||||
mgr = manager.AgentManager(namespaces=['compute'],
|
||||
pollster_list=['storage.*'])
|
||||
self.assertEqual(0, len(list(mgr.extensions)))
|
||||
parameters = dict(namespaces=['compute'],
|
||||
pollster_list=['storage.*'])
|
||||
self.assertRaisesRegexp(
|
||||
manager.EmptyPollstersList,
|
||||
'No valid pollsters can be loaded with the startup parameters'
|
||||
' polling-namespaces and pollster-list.',
|
||||
manager.AgentManager,
|
||||
parameters)
|
||||
|
||||
# Test plugin load behavior based on Node Manager pollsters.
|
||||
# pollster_list is just a filter, so sensor pollsters under 'ipmi'
|
||||
@ -94,17 +109,16 @@ class TestManager(base.BaseTestCase):
|
||||
def test_load_failed_plugins(self, LOG):
|
||||
# Here we additionally check that namespaces will be converted to the
|
||||
# list if param was not set as a list.
|
||||
mgr = manager.AgentManager(namespaces='ipmi',
|
||||
pollster_list=['hardware.ipmi.node.*'])
|
||||
# 0 pollsters
|
||||
self.assertEqual(0, len(mgr.extensions))
|
||||
|
||||
err_msg = 'Skip loading extension for hardware.ipmi.node.%s'
|
||||
pollster_names = [
|
||||
'power', 'temperature', 'outlet_temperature',
|
||||
'airflow', 'cups', 'cpu_util', 'mem_util', 'io_util']
|
||||
calls = [mock.call(err_msg % n) for n in pollster_names]
|
||||
LOG.exception.assert_has_calls(calls=calls, any_order=True)
|
||||
try:
|
||||
manager.AgentManager(namespaces='ipmi',
|
||||
pollster_list=['hardware.ipmi.node.*'])
|
||||
except manager.EmptyPollstersList:
|
||||
err_msg = 'Skip loading extension for hardware.ipmi.node.%s'
|
||||
pollster_names = [
|
||||
'power', 'temperature', 'outlet_temperature',
|
||||
'airflow', 'cups', 'cpu_util', 'mem_util', 'io_util']
|
||||
calls = [mock.call(err_msg % n) for n in pollster_names]
|
||||
LOG.exception.assert_has_calls(calls=calls, any_order=True)
|
||||
|
||||
# Skip loading pollster upon ImportError
|
||||
@mock.patch('ceilometer.ipmi.pollsters.node._Base.__init__',
|
||||
@ -112,10 +126,14 @@ class TestManager(base.BaseTestCase):
|
||||
@mock.patch('ceilometer.ipmi.pollsters.sensor.SensorPollster.__init__',
|
||||
mock.Mock(return_value=None))
|
||||
def test_import_error_in_plugin(self):
|
||||
mgr = manager.AgentManager(namespaces=['ipmi'],
|
||||
pollster_list=['hardware.ipmi.node.*'])
|
||||
# 0 pollsters
|
||||
self.assertEqual(0, len(mgr.extensions))
|
||||
parameters = dict(namespaces=['ipmi'],
|
||||
pollster_list=['hardware.ipmi.node.*'])
|
||||
self.assertRaisesRegexp(
|
||||
manager.EmptyPollstersList,
|
||||
'No valid pollsters can be loaded with the startup parameters'
|
||||
' polling-namespaces and pollster-list.',
|
||||
manager.AgentManager,
|
||||
parameters)
|
||||
|
||||
# Exceptions other than ExtensionLoadError are propagated
|
||||
@mock.patch('ceilometer.ipmi.pollsters.node._Base.__init__',
|
||||
|
@ -74,9 +74,11 @@ $CEILOMETER_BIN_DIR/ceilometer-dbsync || die $LINENO "DB sync error"
|
||||
start_ceilometer
|
||||
|
||||
# Note these are process names, not service names
|
||||
# Note(liamji): Disable the test for
|
||||
# "ceilometer-polling --polling-namespaces ipmi". In the test environment,
|
||||
# the impi is not ready. The ceilometer-polling should fail.
|
||||
ensure_services_started "ceilometer-polling --polling-namespaces compute" \
|
||||
"ceilometer-polling --polling-namespaces central" \
|
||||
"ceilometer-polling --polling-namespaces ipmi" \
|
||||
ceilometer-agent-notification \
|
||||
ceilometer-api \
|
||||
ceilometer-collector
|
||||
|
Loading…
x
Reference in New Issue
Block a user