summaryrefslogtreecommitdiffstats
path: root/tests/data_plane/vpp_lite_topo/scripts/cmd_mappings.py
diff options
context:
space:
mode:
authorFilip Tehlar <ftehlar@cisco.com>2016-09-07 15:47:47 +0200
committerFilip Tehlar <ftehlar@cisco.com>2016-09-12 14:41:10 +0200
commitbf231ba795387064e7c4f1781240619429a4ef29 (patch)
tree86da34369910ca1c85672ed30d4374d4ecda9ac3 /tests/data_plane/vpp_lite_topo/scripts/cmd_mappings.py
parent1df1d674eaace35d52973786403eb1dbe3c0d5eb (diff)
Introduce an option for testing binary API
This patch introduces an option for choosing a configuration method in tests. Supported methods are VAT and vpp's debug CLI. * Added new aprameter to run.sh to define method (--cfg-method [vat|cli]). Defaults to vat. * When running a test separately the method can be set as follows: $ sudo CFG_METHOD=cli ./tests/<test_case>.sh Again, it defaults to 'vat' if not provided. * Increased readability in test driver scripts when checking test status * When debugging you can stop test execution by running the test with WAIT=1: $ sudo WAIT=1 tests/<test_case>.sh Change-Id: If851139cff072ba2e3b3594a3345763d360f3b59 Signed-off-by: Filip Tehlar <ftehlar@cisco.com>
Diffstat (limited to 'tests/data_plane/vpp_lite_topo/scripts/cmd_mappings.py')
-rw-r--r--tests/data_plane/vpp_lite_topo/scripts/cmd_mappings.py110
1 files changed, 110 insertions, 0 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
new file mode 100644
index 0000000..87ec8cb
--- /dev/null
+++ b/tests/data_plane/vpp_lite_topo/scripts/cmd_mappings.py
@@ -0,0 +1,110 @@
+
+mappings = {}
+
+class SimpleMapping(object):
+
+ def __init__(self, cmd, cli, vat):
+ if cmd in mappings:
+ raise Exception('{} already in cmd db!'.format(cmd))
+
+ self.cmd = cmd
+ self.cli = cli
+ self.vat = vat
+ mappings[cmd] = self
+
+ def generate(self, mode, args):
+ s = ''
+ # simply append arguments string to right command
+ if mode == 'vat':
+ s = self.vat + ' ' + args
+ else:
+ s = self.cli + ' ' + args
+ return s
+
+
+class CustomMapping(SimpleMapping):
+
+ def generate(self, mode, args):
+ s = ''
+ if mode == 'vat':
+ s = self.vat
+ else:
+ s = self.cli
+
+ args = args.split(' ')
+ return s.format(*args)
+
+
+class RepeatableLocators(SimpleMapping):
+
+ def append_locs(self, locs):
+ pass
+
+ def generate(self, mode, args):
+ name = args[:args.index(' ')] # first word is ls name
+ locs = args[args.index(' '):]
+
+ if mode == 'vat':
+ s = self.vat
+ else:
+ s = self.cli
+
+ s = s + ' ' + name + locs
+ return s
+
+
+SimpleMapping('lisp_state', 'lisp', 'lisp_enable_disable')
+SimpleMapping('lisp_map_resolver', 'lisp map-resolver', 'lisp_add_del_map_resolver')
+SimpleMapping('lisp_local_eid', 'lisp eid-table', 'lisp_add_del_local_eid')
+SimpleMapping('lisp_remote_mapping', 'lisp remote-mapping', 'lisp_add_del_remote_mapping')
+SimpleMapping('lisp_pitr', 'lisp pitr ls', 'lisp_pitr_set_locator_set locator-set')
+SimpleMapping('set_if_ip', 'set int ip address', 'sw_interface_add_del_address')
+
+CustomMapping('lisp_eid_map_bd',
+ 'lisp eid-table map vni {0} bd {1}',
+ 'lisp_eid_table_add_del_map vni {0} bd_index {1}')
+CustomMapping('lisp_eid_map_vrf',
+ 'lisp eid-table map vni {0} vrf {1}',
+ 'lisp_eid_table_add_del_map vni {0} vrf {1}')
+CustomMapping('set_if_l2_bridge', 'set interface l2 bridge {0} {1}',
+ 'sw_interface_set_l2_bridge {0} bd_id {1}')
+CustomMapping('set_if_ip_table', 'set interface ip table {0} {1}',
+ 'sw_interface_set_table {0} vrf {1}')
+CustomMapping('lisp_locator_set_with_locator',
+ 'lisp locator-set add {0} iface {1} p {2} w {3}',
+ 'lisp_add_del_locator_set locator-set {0} iface {1} p {2} w {3}')
+CustomMapping('create_host_iface',
+ 'create host-interface name {0}\n'
+ 'set int state host-{0} up\n'
+ 'set int ip address host-{0} {1}',
+
+ 'af_packet_create name {0}\n'
+ 'sw_interface_set_flags host-{0} admin-up link-up\n'
+ 'sw_interface_add_del_address host-{0} {1}')
+
+CustomMapping('create_host_iface_vrf',
+ 'create host-interface name {0}\n'
+ 'set int state host-{0} up\n'
+ 'set interface ip table host-{0} {2}\n'
+ 'set int ip address host-{0} {1}',
+
+ 'af_packet_create name {0}\n'
+ 'sw_interface_set_flags host-{0} admin-up link-up\n'
+ 'sw_interface_set_table host-{0} vrf {2}\n'
+ 'sw_interface_add_del_address host-{0} {1}')
+
+CustomMapping('create_host_iface_vrf_v6',
+ 'create host-interface name {0}\n'
+ 'set int state host-{0} up\n'
+ 'set interface ip6 table host-{0} {2}\n'
+ 'set int ip address host-{0} {1}',
+
+ 'af_packet_create name {0}\n'
+ 'sw_interface_set_flags host-{0} admin-up link-up\n'
+ 'sw_interface_set_table host-{0} vrf {2} ipv6\n'
+ 'sw_interface_add_del_address host-{0} {1}')
+
+RepeatableLocators('lisp_ls_multiple_locs',
+ 'lisp locator-set add',
+ 'lisp_add_del_locator_set locator-set')
+