From 2e74e404fc9b91beeeed9103d5f8337a230412e2 Mon Sep 17 00:00:00 2001 From: Filip Tehlar Date: Mon, 20 Mar 2017 13:11:25 +0100 Subject: Add statistics test Change-Id: If3d9e6c5f1d1737ecf9cf29d02860e37663a7121 Signed-off-by: Filip Tehlar --- .../basic/4o4_no_odl_adj/vpp1.config | 1 + .../basic/6o6_no_odl_adj/vpp1.config | 1 + .../basic/l2o4_with_adj/vpp1.config | 11 ++++ .../basic/l2o4_with_adj/vpp2.config | 10 ++++ tests/data_plane/vat_templates/dump_stats.tpl | 1 + tests/data_plane/vpp_lite_topo/config.sh | 6 ++ .../vpp_lite_topo/scripts/cmd_mappings.py | 1 + .../vpp_lite_topo/scripts/vat/check_counters.py | 68 ++++++++++++++++++++++ .../vpp_lite_topo/scripts/vat/mapping_exists.py | 2 +- .../vpp_lite_topo/test_driver/basic_l2.sh | 22 +++++++ .../vpp_lite_topo/test_driver/basic_single_icmp.sh | 4 ++ .../tests/test_basic_4o4_no_odl_with_adjacency.sh | 3 +- .../tests/test_basic_6o6_no_odl_with_adjacency.sh | 3 +- .../tests/test_basic_l2o4_with_adj.sh | 10 ++++ 14 files changed, 140 insertions(+), 3 deletions(-) create mode 100644 tests/data_plane/configs/vpp_lite_config/basic/l2o4_with_adj/vpp1.config create mode 100644 tests/data_plane/configs/vpp_lite_config/basic/l2o4_with_adj/vpp2.config create mode 100644 tests/data_plane/vat_templates/dump_stats.tpl create mode 100644 tests/data_plane/vpp_lite_topo/scripts/vat/check_counters.py create mode 100755 tests/data_plane/vpp_lite_topo/tests/test_basic_l2o4_with_adj.sh diff --git a/tests/data_plane/configs/vpp_lite_config/basic/4o4_no_odl_adj/vpp1.config b/tests/data_plane/configs/vpp_lite_config/basic/4o4_no_odl_adj/vpp1.config index 54d8448..076a439 100644 --- a/tests/data_plane/configs/vpp_lite_config/basic/4o4_no_odl_adj/vpp1.config +++ b/tests/data_plane/configs/vpp_lite_config/basic/4o4_no_odl_adj/vpp1.config @@ -2,6 +2,7 @@ create_host_iface vpp1 6.0.1.1/24 create_host_iface intervpp1 6.0.3.1/24 lisp_state enable +lisp_stats enable lisp_locator_set_with_locator ls1 host-intervpp1 1 1 lisp_local_eid eid 6.0.1.0/24 locator-set ls1 lisp_remote_mapping eid 6.0.2.0/24 rloc 6.0.3.2 diff --git a/tests/data_plane/configs/vpp_lite_config/basic/6o6_no_odl_adj/vpp1.config b/tests/data_plane/configs/vpp_lite_config/basic/6o6_no_odl_adj/vpp1.config index 84a9985..7da87bd 100644 --- a/tests/data_plane/configs/vpp_lite_config/basic/6o6_no_odl_adj/vpp1.config +++ b/tests/data_plane/configs/vpp_lite_config/basic/6o6_no_odl_adj/vpp1.config @@ -2,6 +2,7 @@ create_host_iface vpp1 6:0:1::1/64 create_host_iface intervpp1 6:0:3::1/64 lisp_state enable +lisp_stats enable lisp_locator_set_with_locator ls1 host-intervpp1 1 1 lisp_local_eid eid 6:0:1::0/64 locator-set ls1 lisp_remote_mapping eid 6:0:2::0/64 rloc 6:0:3::2 diff --git a/tests/data_plane/configs/vpp_lite_config/basic/l2o4_with_adj/vpp1.config b/tests/data_plane/configs/vpp_lite_config/basic/l2o4_with_adj/vpp1.config new file mode 100644 index 0000000..cecd6d8 --- /dev/null +++ b/tests/data_plane/configs/vpp_lite_config/basic/l2o4_with_adj/vpp1.config @@ -0,0 +1,11 @@ +create_host_iface vpp1 6.0.1.1/24 +set_if_l2_bridge host-vpp1 10 +create_host_iface intervpp1 6.0.3.1/24 + +lisp_state enable +lisp_stats enable +lisp_locator_set_with_locator ls1 host-intervpp1 1 1 +lisp_eid_map_bd 10 10 +lisp_local_eid vni 10 eid 08:11:11:11:11:11 locator-set ls1 +lisp_remote_mapping vni 10 eid 08:22:22:22:22:22 rloc 6.0.3.2 +lisp_adjacency vni 10 leid 08:11:11:11:11:11 reid 08:22:22:22:22:22 diff --git a/tests/data_plane/configs/vpp_lite_config/basic/l2o4_with_adj/vpp2.config b/tests/data_plane/configs/vpp_lite_config/basic/l2o4_with_adj/vpp2.config new file mode 100644 index 0000000..e3953a8 --- /dev/null +++ b/tests/data_plane/configs/vpp_lite_config/basic/l2o4_with_adj/vpp2.config @@ -0,0 +1,10 @@ +create_host_iface vpp2 6.0.1.2/24 +set_if_l2_bridge host-vpp2 10 +create_host_iface intervpp2 6.0.3.2/24 + +lisp_state enable +lisp_locator_set_with_locator ls1 host-intervpp2 1 1 +lisp_eid_map_bd 10 10 +lisp_local_eid vni 10 eid 08:22:22:22:22:22 locator-set ls1 +lisp_remote_mapping vni 10 eid 08:11:11:11:11:11 rloc 6.0.3.1 +lisp_adjacency vni 10 leid 08:22:22:22:22:22 reid 08:11:11:11:11:11 diff --git a/tests/data_plane/vat_templates/dump_stats.tpl b/tests/data_plane/vat_templates/dump_stats.tpl new file mode 100644 index 0000000..838bbac --- /dev/null +++ b/tests/data_plane/vat_templates/dump_stats.tpl @@ -0,0 +1 @@ +one_stats_dump diff --git a/tests/data_plane/vpp_lite_topo/config.sh b/tests/data_plane/vpp_lite_topo/config.sh index f938bfa..375dddc 100644 --- a/tests/data_plane/vpp_lite_topo/config.sh +++ b/tests/data_plane/vpp_lite_topo/config.sh @@ -158,3 +158,9 @@ function start_map_resolver python scripts/dummy_mr.py "$1" 4342 & mr_id=$! } + +function check_counters +{ + python scripts/vat/check_counters.py ${VPP_API_TEST} ${VAT_TEMPLATES} "$1" "$2" "$3" "$4" "$5" "$6" "$7" "$8" +} + 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]): diff --git a/tests/data_plane/vpp_lite_topo/test_driver/basic_l2.sh b/tests/data_plane/vpp_lite_topo/test_driver/basic_l2.sh index b3d53aa..a5bd61e 100644 --- a/tests/data_plane/vpp_lite_topo/test_driver/basic_l2.sh +++ b/tests/data_plane/vpp_lite_topo/test_driver/basic_l2.sh @@ -36,3 +36,25 @@ function test_basic print_status $rc "No ICM response!" exit $test_result } + +function test_single_icmp +{ + if [ "$3" != "no_setup" ] ; then + basic_topo_setup no_odl + fi + + maybe_pause + test_result=1 + + ip netns exec vppns1 "${1}" -c 1 "${2}" + rc=$? + + check_counters "vpp1" "10" $3 $4 $5 $6 $7 $8 + assert_rc_ok $? "basic_topo_clean no_odl" "Counters do not match!" + + # test done + maybe_pause + basic_topo_clean no_odl + print_status $rc "No ICM response!" + exit $test_result +} diff --git a/tests/data_plane/vpp_lite_topo/test_driver/basic_single_icmp.sh b/tests/data_plane/vpp_lite_topo/test_driver/basic_single_icmp.sh index 63c8b5a..39f4f4c 100644 --- a/tests/data_plane/vpp_lite_topo/test_driver/basic_single_icmp.sh +++ b/tests/data_plane/vpp_lite_topo/test_driver/basic_single_icmp.sh @@ -21,6 +21,10 @@ function test_single_icmp ip netns exec vppns1 "${1}" -c 1 "${2}" rc=$? + # SEID DEID LLOC RLOC PKTS BYTES + check_counters "vpp1" "0" $3 $4 $5 $6 $7 $8 + assert_rc_ok $? "2_node_topo_clean no_odl" "Counters do not match!" + # test done maybe_pause 2_node_topo_clean no_odl diff --git a/tests/data_plane/vpp_lite_topo/tests/test_basic_4o4_no_odl_with_adjacency.sh b/tests/data_plane/vpp_lite_topo/tests/test_basic_4o4_no_odl_with_adjacency.sh index 7c3f0c3..f5f6b93 100755 --- a/tests/data_plane/vpp_lite_topo/tests/test_basic_4o4_no_odl_with_adjacency.sh +++ b/tests/data_plane/vpp_lite_topo/tests/test_basic_4o4_no_odl_with_adjacency.sh @@ -4,7 +4,8 @@ # (ip4 over ip4) VPP_LITE_CONF=`pwd`/../configs/vpp_lite_config/basic/4o4_no_odl_adj +VAT_TEMPLATES=`pwd`/../vat_templates source test_driver/basic_single_icmp.sh -test_single_icmp ping "6.0.2.2" +test_single_icmp ping "6.0.2.2" "6.0.1.0/24" "6.0.2.0/24" "6.0.3.1" "6.0.3.2" "1" "84" diff --git a/tests/data_plane/vpp_lite_topo/tests/test_basic_6o6_no_odl_with_adjacency.sh b/tests/data_plane/vpp_lite_topo/tests/test_basic_6o6_no_odl_with_adjacency.sh index ef40096..9746bfa 100755 --- a/tests/data_plane/vpp_lite_topo/tests/test_basic_6o6_no_odl_with_adjacency.sh +++ b/tests/data_plane/vpp_lite_topo/tests/test_basic_6o6_no_odl_with_adjacency.sh @@ -4,7 +4,8 @@ # (ip6 over ip6) VPP_LITE_CONF=`pwd`/../configs/vpp_lite_config/basic/6o6_no_odl_adj +VAT_TEMPLATES=`pwd`/../vat_templates source test_driver/basic_single_icmp.sh -test_single_icmp ping6 "6:0:2::2" +test_single_icmp ping6 "6:0:2::2" "6:0:1::/64" "6:0:2::/64" "6:0:3::1" "6:0:3::2" "1" "104" diff --git a/tests/data_plane/vpp_lite_topo/tests/test_basic_l2o4_with_adj.sh b/tests/data_plane/vpp_lite_topo/tests/test_basic_l2o4_with_adj.sh new file mode 100755 index 0000000..f827afa --- /dev/null +++ b/tests/data_plane/vpp_lite_topo/tests/test_basic_l2o4_with_adj.sh @@ -0,0 +1,10 @@ +#!/usr/bin/env bash + +# Test basic LISP functionality (l2 over ip4) + +VPP_LITE_CONF=`pwd`/../configs/vpp_lite_config/basic/l2o4_with_adj +VAT_TEMPLATES=`pwd`/../vat_templates + +source test_driver/basic_l2.sh + +test_single_icmp ping "6.0.1.12" "08:11:11:11:11:11" "08:22:22:22:22:22" "6.0.3.1" "6.0.3.2" "1" "98" -- cgit 1.2.3-korg