aboutsummaryrefslogtreecommitdiffstats
path: root/baro_tests/tests.py
diff options
context:
space:
mode:
authorSharada Shiddibhavi <sharada.shiddibhavi@intel.com>2017-08-25 09:55:49 +0000
committerSharada Shiddibhavi <sharada.shiddibhavi@intel.com>2017-08-25 10:03:01 +0000
commit1ec9c3828ef6b1c0426b14138cc9b3a24cf88122 (patch)
tree90f133f511eab11b838d6a21f717f1186ea23807 /baro_tests/tests.py
parent52a749bd73579f521caae478f6825e8a1abd4005 (diff)
Added testcases for Gnocchi, AODH, SNMP and Intel_RDT
Added testcases for newly added plugins - Gnocchi, AODH, SNMP and Intel RDT for Functest-Barometer project Change-Id: Ice7db5a49852d95e9c3054a0670dbd193f40f26c Signed-off-by: Sharada Shiddibhavi <sharada.shiddibhavi@intel.com>
Diffstat (limited to 'baro_tests/tests.py')
-rw-r--r--baro_tests/tests.py52
1 files changed, 47 insertions, 5 deletions
diff --git a/baro_tests/tests.py b/baro_tests/tests.py
index 7d19d3f4..4cbd0e87 100644
--- a/baro_tests/tests.py
+++ b/baro_tests/tests.py
@@ -17,11 +17,53 @@
import time
-def test_gnocchi_node_sends_data(
- node_id, interval, logger, client, criteria_list=[],
- resource_id_substrings=['']):
- logger.info("Gnocchi test cases will be coming soon!!")
- return False
+def test_snmp_sends_data(
+ compute, interval, logger, client, mib_file=None,
+ mib_strings=None, in_command=None, conf=None):
+ """Check that SNMP deta are updated"""
+ logger.debug('Interval: {}'.format(interval))
+ if mib_file is not None:
+ logger.info(
+ 'Getting SNMP metrics of MIB file {} and '.format(mib_file)
+ + 'following MIB strings: {}...'.format(', '.join(mib_strings)))
+ snmp_metrics = client.get_snmp_metrics(compute, mib_file, mib_strings)
+ if mib_file is None:
+ return len(snmp_metrics) > 1
+ if in_command is not None and conf is not None:
+ conf.execute_command(in_command, compute.get_ip())
+
+ attempt = 1
+ is_passed = False
+ while (attempt <= 10) and not is_passed:
+ is_passed = True
+ # wait Interval time + 2 sec for db update
+ sleep_time = interval + 2
+ if attempt > 1:
+ logger.info('Starting attempt {}'.format(attempt))
+ logger.info(
+ 'Sleeping for {} seconds to get updated entries'.format(sleep_time)
+ + ' (interval is {} sec)...'.format(interval))
+ time.sleep(sleep_time)
+
+ logger.info(
+ 'Getting SNMP metrics of MIB file {} and '.format(mib_file)
+ + 'following MIB strings: {}...'.format(', '.join(mib_strings)))
+ snmp_metrics2 = client.get_snmp_metrics(compute, mib_file, mib_strings)
+ unchanged_snmp_metrics = [
+ snmp_metric for snmp_metric in snmp_metrics
+ if snmp_metrics[snmp_metric] == snmp_metrics2[snmp_metric]]
+ if len(unchanged_snmp_metrics) > 0:
+ logger.error("Following SNMP metrics didn't change: {}".format(
+ ', '.join(unchanged_snmp_metrics)))
+ is_passed = False
+ attempt += 1
+ if not is_passed:
+ logger.warning('After sleep new entries were not found.')
+ if not is_passed:
+ logger.error('This was the last attempt.')
+ return False
+ logger.info('All SNMP metrics are changed.')
+ return True
def test_ceilometer_node_sends_data(