'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:
@@ -88,6 +88,13 @@ class PollsterListForbidden(Exception):
|
|||||||
super(PollsterListForbidden, self).__init__(msg)
|
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):
|
class Resources(object):
|
||||||
def __init__(self, agent_manager):
|
def __init__(self, agent_manager):
|
||||||
self.agent_manager = agent_manager
|
self.agent_manager = agent_manager
|
||||||
@@ -262,6 +269,9 @@ class AgentManager(service_base.BaseService):
|
|||||||
self.extensions = list(itertools.chain(*list(extensions))) + list(
|
self.extensions = list(itertools.chain(*list(extensions))) + list(
|
||||||
itertools.chain(*list(extensions_fb)))
|
itertools.chain(*list(extensions_fb)))
|
||||||
|
|
||||||
|
if self.extensions == []:
|
||||||
|
raise EmptyPollstersList()
|
||||||
|
|
||||||
self.discovery_manager = self._extensions('discover')
|
self.discovery_manager = self._extensions('discover')
|
||||||
self.context = context.RequestContext('admin', 'admin', is_admin=True)
|
self.context = context.RequestContext('admin', 'admin', is_admin=True)
|
||||||
self.partition_coordinator = coordination.PartitionCoordinator()
|
self.partition_coordinator = coordination.PartitionCoordinator()
|
||||||
|
@@ -65,12 +65,27 @@ class TestManager(base.BaseTestCase):
|
|||||||
# currently we do have 26 disk-related pollsters
|
# currently we do have 26 disk-related pollsters
|
||||||
self.assertEqual(26, len(list(mgr.extensions)))
|
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):
|
def test_load_plugins_no_intersection(self):
|
||||||
# Let's test nothing will be polled if namespace and pollsters
|
# Let's test nothing will be polled if namespace and pollsters
|
||||||
# list have no intersection.
|
# list have no intersection.
|
||||||
mgr = manager.AgentManager(namespaces=['compute'],
|
parameters = dict(namespaces=['compute'],
|
||||||
pollster_list=['storage.*'])
|
pollster_list=['storage.*'])
|
||||||
self.assertEqual(0, len(list(mgr.extensions)))
|
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.
|
# Test plugin load behavior based on Node Manager pollsters.
|
||||||
# pollster_list is just a filter, so sensor pollsters under 'ipmi'
|
# 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):
|
def test_load_failed_plugins(self, LOG):
|
||||||
# Here we additionally check that namespaces will be converted to the
|
# Here we additionally check that namespaces will be converted to the
|
||||||
# list if param was not set as a list.
|
# list if param was not set as a list.
|
||||||
mgr = manager.AgentManager(namespaces='ipmi',
|
try:
|
||||||
pollster_list=['hardware.ipmi.node.*'])
|
manager.AgentManager(namespaces='ipmi',
|
||||||
# 0 pollsters
|
pollster_list=['hardware.ipmi.node.*'])
|
||||||
self.assertEqual(0, len(mgr.extensions))
|
except manager.EmptyPollstersList:
|
||||||
|
err_msg = 'Skip loading extension for hardware.ipmi.node.%s'
|
||||||
err_msg = 'Skip loading extension for hardware.ipmi.node.%s'
|
pollster_names = [
|
||||||
pollster_names = [
|
'power', 'temperature', 'outlet_temperature',
|
||||||
'power', 'temperature', 'outlet_temperature',
|
'airflow', 'cups', 'cpu_util', 'mem_util', 'io_util']
|
||||||
'airflow', 'cups', 'cpu_util', 'mem_util', 'io_util']
|
calls = [mock.call(err_msg % n) for n in pollster_names]
|
||||||
calls = [mock.call(err_msg % n) for n in pollster_names]
|
LOG.exception.assert_has_calls(calls=calls, any_order=True)
|
||||||
LOG.exception.assert_has_calls(calls=calls, any_order=True)
|
|
||||||
|
|
||||||
# Skip loading pollster upon ImportError
|
# Skip loading pollster upon ImportError
|
||||||
@mock.patch('ceilometer.ipmi.pollsters.node._Base.__init__',
|
@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.patch('ceilometer.ipmi.pollsters.sensor.SensorPollster.__init__',
|
||||||
mock.Mock(return_value=None))
|
mock.Mock(return_value=None))
|
||||||
def test_import_error_in_plugin(self):
|
def test_import_error_in_plugin(self):
|
||||||
mgr = manager.AgentManager(namespaces=['ipmi'],
|
parameters = dict(namespaces=['ipmi'],
|
||||||
pollster_list=['hardware.ipmi.node.*'])
|
pollster_list=['hardware.ipmi.node.*'])
|
||||||
# 0 pollsters
|
self.assertRaisesRegexp(
|
||||||
self.assertEqual(0, len(mgr.extensions))
|
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
|
# Exceptions other than ExtensionLoadError are propagated
|
||||||
@mock.patch('ceilometer.ipmi.pollsters.node._Base.__init__',
|
@mock.patch('ceilometer.ipmi.pollsters.node._Base.__init__',
|
||||||
|
@@ -74,9 +74,11 @@ $CEILOMETER_BIN_DIR/ceilometer-dbsync || die $LINENO "DB sync error"
|
|||||||
start_ceilometer
|
start_ceilometer
|
||||||
|
|
||||||
# Note these are process names, not service names
|
# 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" \
|
ensure_services_started "ceilometer-polling --polling-namespaces compute" \
|
||||||
"ceilometer-polling --polling-namespaces central" \
|
"ceilometer-polling --polling-namespaces central" \
|
||||||
"ceilometer-polling --polling-namespaces ipmi" \
|
|
||||||
ceilometer-agent-notification \
|
ceilometer-agent-notification \
|
||||||
ceilometer-api \
|
ceilometer-api \
|
||||||
ceilometer-collector
|
ceilometer-collector
|
||||||
|
Reference in New Issue
Block a user