diff options
author | Filip Tehlar <ftehlar@cisco.com> | 2016-12-07 18:10:28 +0100 |
---|---|---|
committer | Filip Tehlar <ftehlar@cisco.com> | 2016-12-07 18:15:27 +0100 |
commit | aae5e3f47fb4ac59c36b55b3d91da9bb5f747c22 (patch) | |
tree | a42ebf9bfaff37ec22349068b07fef99e9f66b4f /tests/data_plane/vpp_lite_topo/scripts | |
parent | 4ff1fc154b4b7460beeda06612b907004b7838c8 (diff) |
Add a test for mapping expiration
Change-Id: I94004c1cf7651aef2bcfa408aafac6a9bec20b0b
Signed-off-by: Filip Tehlar <ftehlar@cisco.com>
Diffstat (limited to 'tests/data_plane/vpp_lite_topo/scripts')
-rwxr-xr-x | tests/data_plane/vpp_lite_topo/scripts/vat/mapping_exists.py | 38 |
1 files changed, 38 insertions, 0 deletions
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 new file mode 100755 index 0000000..2015b4a --- /dev/null +++ b/tests/data_plane/vpp_lite_topo/scripts/vat/mapping_exists.py @@ -0,0 +1,38 @@ +# Script for checking whether a mapping exists in the vpp's map-cache +# +# Params: +# vat_exec - VAT executable +# vpp_prefix - shared vpp memory prefix +# mapping - mapping to verify + +import sys +import subprocess +import json + +def has_mapping(json, mapping): + if len (json) == 0: + return False + + for obj in json: + if obj['eid'] == mapping: + return True; + + return False + +def verify_mapping(vat_exec, prefix, mapping, vat_path): + vat_file = vat_path + '/' + 'dump_remote_mappings.tpl' + out = subprocess.Popen([vat_exec, "chroot", "prefix", prefix, "json", "script", + "in", vat_file], stdout=subprocess.PIPE).communicate()[0] + + o = json.loads(out) + return has_mapping(o, mapping) + +if __name__ == "__main__": + if len(sys.argv) < 4: + raise Exception('expecteds 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]): + sys.exit(0) + else: + sys.exit(1) |