Claudine Chiu
Committed by Gerrit Code Review

- bidrectional vnet link creation

- optionally specify expected number of intents in "onos-check-intent"

Change-Id: I523a7fd9e1aaa72b441d2428fb9ebb692b07bdd0

-  bidrectional vnet link creation (when using ssh)
- optionally specify expected number of intents in "onos-check-intent"

Change-Id: I5c6fe1f269eddeaa70dfec819853d42af59fbd8e
...@@ -6,10 +6,11 @@ ...@@ -6,10 +6,11 @@
6 function _usage () { 6 function _usage () {
7 cat << _EOF_ 7 cat << _EOF_
8 usage: 8 usage:
9 - $(basename $0) [-w] [node] 9 + $(basename $0) [-w] [-f] [node]
10 10
11 flags: 11 flags:
12 - -w : Waits for ONOS instance to reach run-level 100, i.e. to be fully started. 12 - -w : Waits for ONOS instance to reach run-level 100, i.e. to be fully started.
13 +- -f : (Affects non-secure client only) - use bash's IFS expansion of positional parameters
13 14
14 options: 15 options:
15 - [node] : the node to attach to 16 - [node] : the node to attach to
...@@ -29,13 +30,18 @@ _EOF_ ...@@ -29,13 +30,18 @@ _EOF_
29 . $ONOS_ROOT/tools/test/bin/find-node.sh 30 . $ONOS_ROOT/tools/test/bin/find-node.sh
30 31
31 [ "$1" = "-w" ] && shift && onos-wait-for-start $1 32 [ "$1" = "-w" ] && shift && onos-wait-for-start $1
33 +[ "$1" = "-f" ] && shift && flat=1
32 34
33 [ -n "$1" ] && OCI=$(find_node $1) && shift 35 [ -n "$1" ] && OCI=$(find_node $1) && shift
34 36
35 if which client 1>/dev/null 2>&1 && [ -z "$ONOS_USE_SSH" ]; then 37 if which client 1>/dev/null 2>&1 && [ -z "$ONOS_USE_SSH" ]; then
36 # Use Karaf client only if we can and are allowed to 38 # Use Karaf client only if we can and are allowed to
37 unset KARAF_HOME 39 unset KARAF_HOME
38 - client -h $OCI -u karaf "$@" 2>/dev/null 40 + if [ -z "$flat" ]; then
41 + client -h $OCI -u karaf "$@" 2>/dev/null
42 + else
43 + client -h $OCI -u karaf "$*" 2>/dev/null
44 + fi
39 else 45 else
40 # Otherwise use raw ssh; strict checking is off for dev environments only 46 # Otherwise use raw ssh; strict checking is off for dev environments only
41 ssh -p 8101 -o StrictHostKeyChecking=no $OCI "$@" 47 ssh -p 8101 -o StrictHostKeyChecking=no $OCI "$@"
......
...@@ -13,9 +13,29 @@ target=${1:-$OCI} ...@@ -13,9 +13,29 @@ target=${1:-$OCI}
13 echo onos-check-intent: $* 13 echo onos-check-intent: $*
14 14
15 set -x 15 set -x
16 +
17 +# $1: target host
18 +# $2: intent key
19 +# $3: intent state
20 +# $4: number of expected intents
21 +re='^[0-9]+$'
22 +[[ $4 =~ $re ]] && numIntentsExpected=$4 # silently ignore if not positive
23 +
16 for i in {1..15}; do 24 for i in {1..15}; do
25 + echo "Attempt #$i"
17 onos $target "onos:intents" | tee $aux 26 onos $target "onos:intents" | tee $aux
18 - ( cat $aux | grep "key=$2" | grep "state=$3" ) && cat $aux && exit 0 27 + if [ -z "$numIntentsExpected" ]; then
28 + ( cat $aux | grep "key=$2" | grep "state=$3" ) && cat $aux && exit 0
29 + else
30 + # exit 0 only if expected number of intents (with required key)
31 + # are present and all intents match state (if expected no. of intents > 0)
32 + numIntents=`grep "key=$2" $aux | wc -l`
33 + numIntentsOfState=0
34 + [ $numIntentsExpected -gt 0 ] && numIntentsOfState=`grep "key=$2" $aux | grep "state=$3" | wc -l`
35 + [ $numIntents -eq $numIntentsOfState ] \
36 + && [ $numIntents -eq $numIntentsExpected ] \
37 + && cat $aux && exit 0
38 + fi
19 sleep 1 39 sleep 1
20 done 40 done
21 41
......
...@@ -46,19 +46,14 @@ ...@@ -46,19 +46,14 @@
46 <step name="Create-Port-2" requires="^" 46 <step name="Create-Port-2" requires="^"
47 exec="onos ${OCI} vnet-create-port ${networkId} device2 2 of:0000000000000009 1"/> 47 exec="onos ${OCI} vnet-create-port ${networkId} device2 2 of:0000000000000009 1"/>
48 48
49 - <step name="Create-Link-1" requires="^" 49 + <step name="Create-Bidirectional-Link" requires="^"
50 - exec="onos ${OCI} vnet-create-link ${networkId} device1 1 device2 2"/> 50 + exec="onos -f ${OCI} vnet-create-link --bidirectional ${networkId} device2 2 device1 1"/>
51 51
52 - <step name="Create-Link-2" requires="^" 52 + <step name="Check-intents-installed" requires="^"
53 - exec="onos ${OCI} vnet-create-link ${networkId} device2 2 device1 1"/> 53 + exec="onos-check-intent ${OCI} networkId=${networkId} INSTALLED 2"/>
54 54
55 - <step name="Check-intents-installed" requires="^" env="~" 55 + <step name="Ping-hosts-1" requires="^"
56 - exec="onos-check-intent ${OCI} networkId=${networkId} INSTALLED"/>
57 - <!-- TODO: ignore return code once intent is working -->
58 -
59 - <step name="Ping-hosts-1" requires="^" env="~"
60 exec="onos-mininet sendAndExpect h4 ping -c1 h9 --expect \ 0% packet loss"/> 56 exec="onos-mininet sendAndExpect h4 ping -c1 h9 --expect \ 0% packet loss"/>
61 - <!-- TODO: ignore return code once intent is working -->
62 57
63 </group> 58 </group>
64 </scenario> 59 </scenario>
......
...@@ -22,11 +22,11 @@ ...@@ -22,11 +22,11 @@
22 <step name="Check-Vnet-Link" requires="^" 22 <step name="Check-Vnet-Link" requires="^"
23 exec="onos ${OCI} vnet-links ${networkId}"/> 23 exec="onos ${OCI} vnet-links ${networkId}"/>
24 24
25 - <step name="Remove-Link-1" requires="^" 25 + <step name="Remove-Bidirectional-Link" requires="^"
26 - exec="onos ${OCI} vnet-remove-link ${networkId} device1 1 device2 2"/> 26 + exec="onos -f ${OCI} vnet-remove-link --bidirectional ${networkId} device2 2 device1 1"/>
27 27
28 - <step name="Remove-Link-2" requires="^" 28 + <step name="Check-intents-removed" requires="^"
29 - exec="onos ${OCI} vnet-remove-link ${networkId} device2 2 device1 1"/> 29 + exec="onos-check-intent ${OCI} networkId=${networkId} IGNORE_STATE 0"/>
30 30
31 <step name="Ping-hosts-2" requires="^" 31 <step name="Ping-hosts-2" requires="^"
32 exec="onos-mininet sendAndExpect h4 ping -c1 h9 --expect \ 100% packet loss"/> 32 exec="onos-mininet sendAndExpect h4 ping -c1 h9 --expect \ 100% packet loss"/>
......