summaryrefslogtreecommitdiffstats
path: root/tests/data_plane/vpp_lite_topo/test_driver/basic.sh
blob: 0575bb34dc479b26c7f9bc2560ef7a22d3e33b53 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
source config.sh
source odl_utils.sh
source topologies/2_node_topo.sh

ODL_CONFIG_FILE1="vpp1.json"
ODL_CONFIG_FILE2="vpp2.json"
ODL_CONFIG_FILE3="update_vpp2.json"

if [ "$1" == "clean" ] ; then
  2_node_topo_clean
  exit 0
fi

if [[ $(id -u) != 0 ]]; then
  echo "Error: run this as a root."
  exit 1
fi

function test_basic
{
  if [ "$3" != "no_setup" ] ; then
    2_node_topo_setup
  fi

  maybe_pause
  test_result=1

  ip netns exec vppns1 "${1}" -w 15 -c 1 "${2}"
  assert_rc_ok $? 2_node_topo_clean "No ICMP response!"

  maybe_pause
  # change IP addresses of destination RLOC
  echo "set int ip address del host-intervpp2 6.0.3.2/24" | nc 0 5003
  echo "set int ip address host-intervpp2 6.0.3.20/24" | nc 0 5003
  echo "set int ip address del host-intervpp2 6:0:3::2/64" | nc 0 5003
  echo "set int ip address host-intervpp2 6:0:3::20/64" | nc 0 5003
  post_curl "update-mapping" ${ODL_CONFIG_FILE3}

  ip netns exec vppns1 "${1}" -w 15 -c 1 "${2}"
  rc=$?

  # test done

  maybe_pause
  2_node_topo_clean
  print_status $rc "No ICMP response!"
  exit $test_result
}

function test_basic_map_register_fallback
{
  2_node_topo_setup no_odl

  maybe_pause

  test_result=1

  start_map_server "6.0.3.200"

  wait_for_map_register=20
  echo "Waiting for map registration $wait_for_map_register seconds .."
  sleep $wait_for_map_register

  rc=1

  count="`echo "show error" | nc 0 5002 | grep 'map-notifies received' | awk '{print $1}'`"
  if [ "$count" != "" ] ; then
    if [ $count -gt 0 ] ; then
      echo "no map-notifies received! ($count)"
      rc=0 # test passed
    fi
  fi

  maybe_pause
  kill $ms_id

  # test done
  2_node_topo_clean no_odl
  print_status $rc "map server fallback does not work!"
  exit $test_result
}

function test_basic_map_register
{
  2_node_topo_setup no_odl
  post_curl "add-key" ${ODL_CONFIG_FILE1}
  post_curl "add-key" ${ODL_CONFIG_FILE2}

  maybe_pause

  test_result=1

  wait_for_map_register=10
  echo "Waiting for map registration $wait_for_map_register seconds .."
  sleep $wait_for_map_register

  ip netns exec vppns1 "${1}" -w 15 -c 1 "${2}"
  rc=$?

  count=`echo "show error" | nc 0 5002 | grep 'map-notifies received' | awk '{print $1}'`
  if [ "$count" -eq 0 ] ; then
    echo "no map-notifies received! ($count)"
    rc=1
  fi

  maybe_pause

  # test done
  2_node_topo_clean
  print_status $rc "No ICMP response!"
  exit $test_result
}

function test_rloc_probe
{
  2_node_topo_setup

  maybe_pause
  test_result=1

  ip netns exec vppns1 "${1}" -w 15 -c 1 "${2}"
  rc=$?
  assert_rc_ok $rc 2_node_topo_clean "No ICMP response!"

  sleep 65

  count=`echo "show error" | nc 0 5002 | grep 'rloc-probe replies received' | awk '{print $1}'`
  if [ "$count" != "1" ] ; then
    echo "rloc-probe replies received is not 1! ($count)"
    rc=1
  fi

  count=`echo "show error" | nc 0 5003 | grep 'rloc-probe requests received' | awk '{print $1}'`
  if [ "$count" != "1" ] ; then
    echo "rloc-probe requests received is not 1! ($count)"
    rc=1
  fi

  # test done

  maybe_pause
  2_node_topo_clean
  print_status $rc "unexpected value"
  exit $test_result
}

function test_enable_disable
{
  if [ "$3" != "no_setup" ] ; then
    2_node_topo_setup
  fi

  maybe_pause
  test_result=1

  ip netns exec vppns1 "${1}" -w 15 -c 1 "${2}"
  assert_rc_ok $? 2_node_topo_clean "No ICMP response!"

  maybe_pause

  # disable control plane
  echo "one disable" | nc 0 5002
  ip netns exec vppns1 "${1}" -w 15 -c 1 "${2}"
  assert_rc_not_ok $? 2_node_topo_clean "Nothing expected, but received ICMP reply!"

  # enable control plane
  echo "one enable" | nc 0 5002
  ip netns exec vppns1 "${1}" -w 15 -c 1 "${2}"
  assert_rc_ok $? 2_node_topo_clean "No ICMP response!"

  # disable dataplane
  echo "gpe disable" | nc 0 5002
  ip netns exec vppns1 "${1}" -w 15 -c 1 "${2}"
  assert_rc_not_ok $? 2_node_topo_clean "Nothing expected, but received ICMP reply!"

  # enable LISP again from control plane
  echo "one enable" | nc 0 5002
  ip netns exec vppns1 "${1}" -w 15 -c 1 "${2}"
  assert_rc_ok $? 2_node_topo_clean "No ICMP response!"
  rc=$?

  # test done
  maybe_pause
  2_node_topo_clean
  print_status $rc "No ICMP response!"
  exit $test_result
}