67969423ffb1205f85e852e13d658bab6efd69a5
[one.git] / tests / data_plane / vpp_lite_topo / test_driver / nsh.sh
1 source config.sh
2 source odl_utils.sh
3 source topologies/2_node_topo.sh
4
5 ODL_CONFIG_FILE1="vpp1.json"
6 ODL_CONFIG_FILE2="vpp2.json"
7
8 if [ "$1" == "clean" ] ; then
9   2_node_topo_clean
10   exit 0
11 fi
12
13 if [[ $(id -u) != 0 ]]; then
14   echo "Error: run this as root."
15   exit 1
16 fi
17
18 function test_nsh
19 {
20   2_node_topo_setup
21   rc=1
22
23   maybe_pause
24
25   cat << EOF > scripts/lisp_nsh
26 create packet-generator interface pg0
27
28 packet-generator new {
29   name nsh1
30   limit 1
31   node lisp-cp-lookup-nsh
32   size 64-64
33   no-recycle
34   worker 0
35   interface pg0
36   pcap ${ONE_ROOT}/tests/data_plane/vpp_lite_topo/scripts/nsh.pcap
37 }
38 EOF
39
40   echo "trace add af-packet-input 100" | nc 0 5002
41   echo "trace add af-packet-input 100" | nc 0 5003
42   echo "exec ${ONE_ROOT}/tests/data_plane/vpp_lite_topo/scripts/lisp_nsh" | nc 0 5002
43
44   # add dummy node to ETR
45   echo "test one nsh add-dummy-decap-node" | nc 0 5003
46
47   echo "packet-generator enable-stream nsh1" | nc 0 5002
48
49   echo "enabling stream"
50   sleep 1
51   # inject NSH packet to ITR
52   echo "test one nsh pcap ${ONE_ROOT}/tests/data_plane/vpp_lite_topo/scripts/nsh.pcap" | nc 0 5002
53
54   sleep 1
55   # check decap stats
56   decap_stats="`echo "show errors" | nc 0 5003 | grep "lisp gpe dummy nsh decap" | awk '{print $1}'`"
57
58   if [ "$decap_stats" == "1" ] ; then
59     rc=0  # test pass
60   fi
61
62   maybe_pause
63   2_node_topo_clean
64   print_status $rc "NSH test failed!"
65   exit $rc
66 }