From 884197104f9d1b420eeb85c8ea18b4538daf3418 Mon Sep 17 00:00:00 2001 From: Emma Foley Date: Tue, 20 Mar 2018 14:33:13 +0000 Subject: [functest] Update tests for Aodh * Update the check for timestamp to use state_timestamp instead state_timestamp indicates the last change in state of the alarm, timestamp is the last update to the alarm settings. This is not what we're looking for with aodh tests, so check the state update instead. * Trigger an alarm state change before checking whether the alram was updated. Notification in collectd aren't necessarily updated at a regular interval, so we have to do some action and check whether the alarm is updated. JIRA: BAROMETER-91 Change-Id: I26d9bb1ec7e50e07053e69068d241e4c4cbc30dc Signed-off-by: Emma Foley --- baro_tests/config_server.py | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/baro_tests/config_server.py b/baro_tests/config_server.py index 2a4bc167..4eb3ac9c 100644 --- a/baro_tests/config_server.py +++ b/baro_tests/config_server.py @@ -479,6 +479,16 @@ class ConfigServer(object): return False, warning return True, warning + def trigger_alarm_update(self, alarm, compute_node): + # TODO: move these actions to main, with criteria lists so that we can reference that + # i.e. test_plugin_with_aodh(self, compute, plugin.., logger, criteria_list, alarm_action) + if alarm == 'mcelog': + compute_node.run_cmd('sudo modprobe mce-inject') + compute_node.run_cmd('sudo ./mce-inject_ea < corrected') + if alarm == 'ovs_events': + compute_node.run_cmd('sudo ifconfig -a | grep br0') + compute_node.run_cmd('sudo ifconfig br0 down; sudo ifconfig br0 up') + def test_plugins_with_aodh( self, compute, plugin_interval, logger, criteria_list=[]): @@ -487,11 +497,13 @@ class ConfigServer(object): timestamps1 = {} timestamps2 = {} nodes = get_apex_nodes() + compute_node = [node for node in nodes if node.get_dict()['name'] == compute][0] for node in nodes: if node.is_controller(): self.__logger.info('Getting AODH Alarm list on {}' .format( (node.get_dict()['name']))) node.put_file(constants.ENV_FILE, 'overcloudrc.v3') + self.trigger_alarm_update(criteria_list, compute_node) stdout = node.run_cmd( "source overcloudrc.v3;" + "aodh alarm list | grep {0} | grep {1}" @@ -510,10 +522,9 @@ class ConfigServer(object): return False for line in stdout.splitlines()[3: -1]: line = line.replace('|', "") - if line.split()[0] == 'timestamp': + if line.split()[0] == 'state_timestamp': timestamps1 = line.split()[1] - else: - pass + self.trigger_alarm_update(criteria_list, compute_node) time.sleep(12) stdout = node.run_cmd( "source overcloudrc.v3; aodh alarm show {}" .format( @@ -523,10 +534,8 @@ class ConfigServer(object): return False for line in stdout.splitlines()[3:-1]: line = line.replace('|', "") - if line.split()[0] == 'timestamp': + if line.split()[0] == 'state_timestamp': timestamps2 = line.split()[1] - else: - pass if timestamps1 == timestamps2: self.__logger.info( "Data not updated after interval of 12 seconds") -- cgit 1.2.3-korg