diff options
author | Filip Tehlar <ftehlar@cisco.com> | 2017-03-20 13:11:25 +0100 |
---|---|---|
committer | Filip Tehlar <ftehlar@cisco.com> | 2017-03-20 17:08:06 +0100 |
commit | 2e74e404fc9b91beeeed9103d5f8337a230412e2 (patch) | |
tree | afa4af9047afdad6219d1e96b5e43a9de8bd001f /tests/data_plane/vpp_lite_topo/scripts | |
parent | 348f41abe845c78afd1f441ff6dcbd0876686b87 (diff) |
Add statistics test
Change-Id: If3d9e6c5f1d1737ecf9cf29d02860e37663a7121
Signed-off-by: Filip Tehlar <ftehlar@cisco.com>
Diffstat (limited to 'tests/data_plane/vpp_lite_topo/scripts')
3 files changed, 70 insertions, 1 deletions
diff --git a/tests/data_plane/vpp_lite_topo/scripts/cmd_mappings.py b/tests/data_plane/vpp_lite_topo/scripts/cmd_mappings.py index d6bde91..4d38fc0 100644 --- a/tests/data_plane/vpp_lite_topo/scripts/cmd_mappings.py +++ b/tests/data_plane/vpp_lite_topo/scripts/cmd_mappings.py @@ -61,6 +61,7 @@ SimpleMapping('lisp_map_request_mode', 'lisp map-request mode', 'lisp_map_reques SimpleMapping('set_if_ip', 'set int ip address', 'sw_interface_add_del_address') SimpleMapping('lisp_rloc_probe_state', 'lisp rloc-probe', 'lisp_rloc_probe_enable_disable') SimpleMapping('lisp_map_register_state', 'lisp map-register', 'lisp_map_register_enable_disable') +SimpleMapping('lisp_stats', 'one statistics', 'one_stats_enable_disable') CustomMapping('lisp_eid_map_bd', 'lisp eid-table map vni {0} bd {1}', diff --git a/tests/data_plane/vpp_lite_topo/scripts/vat/check_counters.py b/tests/data_plane/vpp_lite_topo/scripts/vat/check_counters.py new file mode 100644 index 0000000..1bb9fdc --- /dev/null +++ b/tests/data_plane/vpp_lite_topo/scripts/vat/check_counters.py @@ -0,0 +1,68 @@ +# Script for checking LISP counters + +help_string = """ + Params: + vat_exec - VAT executable + vpp_prefix - shared vpp memory prefix + vat_path - VAT template file + vni + seid + deid + loc_rloc + rmt_rloc + pkt_count + bytes +""" + +import sys +import subprocess +import json + +def get_stat_entry(json, vni, seid, deid, loc_rloc, rmt_rloc): + if len (json) == 0: + return None + + for obj in json: + if obj['vni'] == int(vni) and\ + obj['seid'] == seid and\ + obj['deid'] == deid and\ + obj['lloc'] == loc_rloc and\ + obj['rloc'] == rmt_rloc: + return obj + + return None + + +def check_counters(vat_exec, vat_path, vpp_prefix, vni, seid, deid, loc_rloc, + rmt_rloc, pkt_count, total_bytes): + vat_file = vat_path + '/' + 'dump_stats.tpl' + out = subprocess.Popen([vat_exec, "chroot", "prefix", vpp_prefix, "json", "script", + "in", vat_file], stdout=subprocess.PIPE).communicate()[0] + + o = json.loads(out) + stat_entry = get_stat_entry(o, vni, seid, deid, loc_rloc, rmt_rloc) + + if stat_entry is None: + return False + + if stat_entry['pkt_count'] != int(pkt_count): + return False + if stat_entry['bytes'] != int(total_bytes): + return False + return True + + +if __name__ == "__main__": + if len(sys.argv) < 10: + raise Exception('expected 10 parameters: ' + help_string) + + if check_counters(sys.argv[1], sys.argv[2], sys.argv[3], sys.argv[4], + sys.argv[5], + sys.argv[6], + sys.argv[7], + sys.argv[8], + sys.argv[9], + sys.argv[10]): + sys.exit(0) + else: + sys.exit(1) diff --git a/tests/data_plane/vpp_lite_topo/scripts/vat/mapping_exists.py b/tests/data_plane/vpp_lite_topo/scripts/vat/mapping_exists.py index 2015b4a..b666a9c 100755 --- a/tests/data_plane/vpp_lite_topo/scripts/vat/mapping_exists.py +++ b/tests/data_plane/vpp_lite_topo/scripts/vat/mapping_exists.py @@ -29,7 +29,7 @@ def verify_mapping(vat_exec, prefix, mapping, vat_path): if __name__ == "__main__": if len(sys.argv) < 4: - raise Exception('expecteds 4 parameters: VAT executable, shared prefix ' + raise Exception('expected 4 parameters: VAT executable, shared prefix ' + ' name, mapping expected, path to vat templates!') if verify_mapping(sys.argv[1], sys.argv[2], sys.argv[3], sys.argv[4]): |