From ac54d72c06e3af986bbd1f939003744568c3ac84 Mon Sep 17 00:00:00 2001 From: Sharada Shiddibhavi Date: Fri, 15 Sep 2017 09:52:46 +0000 Subject: Adding SNMP testcases to Functest-Barometer project This patch contains tetscases for another write plugin SNMP Change-Id: I281d21540cb95f1e74bfdaa6b5a355dc6f48c9b4 Signed-off-by: Sharada Shiddibhavi Change-Id: I281d21540cb95f1e74bfdaa6b5a355dc6f48c9b4 Signed-off-by: Sharada Shiddibhavi --- baro_tests/config_server.py | 65 ++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 61 insertions(+), 4 deletions(-) (limited to 'baro_tests/config_server.py') diff --git a/baro_tests/config_server.py b/baro_tests/config_server.py index 0b16ea6e..102a2377 100644 --- a/baro_tests/config_server.py +++ b/baro_tests/config_server.py @@ -372,6 +372,24 @@ class ConfigServer(object): return True return True + def check_snmp_plugin_included(self, compute): + """Check if SNMP plugin is active in compute node. + """ + snmp_mib = '/usr/share/snmp/mibs/Intel-Rdt.txt' + snmp_string = 'INTEL-RDT-MIB::intelRdt' + compute_name = compute.get_name() + nodes = get_apex_nodes() + for node in nodes: + if compute_name == node.get_dict()['name']: + stdout = node.run_cmd( + 'snmpwalk -v2c -m {0} -c public localhost {1}' .format( + snmp_mib, snmp_string)) + self.__logger.info("snmp output = {}" .format(stdout)) + if 'OID' in stdout: + return False + else: + return True + def enable_plugins( self, compute, plugins, error_plugins, create_backup=True): """Enable plugins on compute node @@ -465,8 +483,6 @@ class ConfigServer(object): line = line.replace('|', "") if line.split()[0] == 'timestamp': timestamps1 = line.split()[1] - self.__logger.info("timestamp_before = {}" .format( - timestamps1)) else: pass time.sleep(12) @@ -477,8 +493,6 @@ class ConfigServer(object): line = line.replace('|', "") if line.split()[0] == 'timestamp': timestamps2 = line.split()[1] - self.__logger.info("timestamp_after = {}" .format( - timestamps2)) else: pass if timestamps1 == timestamps2: @@ -536,3 +550,46 @@ class ConfigServer(object): else: self.__logger.info("PASS") return True + + def test_plugins_with_snmp( + self, compute, plugin_interval, logger, plugin, snmp_mib_files=[], + snmp_mib_strings=[], snmp_in_commands=[]): + + if plugin == 'intel_rdt': + nodes = get_apex_nodes() + for node in nodes: + if compute == node.get_dict()['name']: + stdout = node.run_cmd( + 'snmpwalk -v2c -m {0} -c public localhost {1}' .format( + snmp_mib_files, snmp_mib_strings)) + self.__logger.info("{}" .format(stdout)) + if 'OID' in stdout: + self.__logger.info("SNMP query failed") + return False + else: + counter1 = stdout.split()[3] + time.sleep(10) + stdout = node.run_cmd( + 'snmpwalk -v2c -m {0} -c public localhost {1}' .format( + snmp_mib_files, snmp_mib_strings)) + self.__logger.info("{}" .format(stdout)) + if 'OID' in stdout: + self.__logger.info( + "SNMP query failed during second check") + self.__logger.info("waiting for 10 sec") + time.sleep(10) + stdout = node.run_cmd( + 'snmpwalk -v2c -m {0} -c public localhost {1}' .format( + snmp_mib_files, snmp_mib_strings)) + self.__logger.info("{}" .format(stdout)) + if 'OID' in stdout: + self.__logger.info("SNMP query failed again") + self.__logger.info("Failing this test case") + return False + else: + counter2 = stdout.split()[3] + + if counter1 == counter2: + return False + else: + return True -- cgit 1.2.3-korg