Committed by
Gerrit Code Review
Added onos-cluster-execute-expect as a cluster version of onos-execute-expect + …
…updated stc scenarios for dist primitives to use this for verification Change-Id: Ife3bde21118ebd21e8abf807070a72ac58341120
Showing
6 changed files
with
56 additions
and
20 deletions
tools/test/bin/onos-cluster-execute-expect
0 → 100755
1 | +#!/bin/bash | ||
2 | +# ----------------------------------------------------------------------------- | ||
3 | +# Executes a command on all ONOS instances in a cluster and matches the output | ||
4 | +# from each instance to the passed one. | ||
5 | +# First argument is the command and it's arguments if needed, then --expect and | ||
6 | +# after it the string of what the output should be. | ||
7 | +# Example: | ||
8 | +# onos-cluster-execute-expect fooCommand fooParamenter --expect fooOutputString | ||
9 | +# ----------------------------------------------------------------------------- | ||
10 | + | ||
11 | +[ ! -d "$ONOS_ROOT" ] && echo "ONOS_ROOT is not defined" >&2 && exit 1 | ||
12 | +. $ONOS_ROOT/tools/build/envDefaults | ||
13 | + | ||
14 | + | ||
15 | +aux=/tmp/stc-$$.log | ||
16 | +trap "rm -f $aux 2>/dev/null" EXIT | ||
17 | +cmd="" | ||
18 | +for a in ${*:1}; do shift; if [ "$a" = "--expect" ]; then break; fi; cmd="$cmd $a"; done | ||
19 | +expect="${@: -1}" | ||
20 | +echo $cmd | ||
21 | +echo $expect | ||
22 | +node_count=`onos $OC1 nodes | wc -l` | ||
23 | +for i in `seq 1 $node_count`; do | ||
24 | + node_var="OC$i" | ||
25 | + onos ${!node_var} $cmd > $aux | ||
26 | + cat $aux | ||
27 | + grep -q $expect $aux || exit 1 | ||
28 | +done | ||
29 | +echo "expected value found" | ||
30 | +exit 0 |
... | @@ -25,13 +25,13 @@ | ... | @@ -25,13 +25,13 @@ |
25 | exec="onos ${OCI} app activate org.onosproject.distributedprimitives"/> | 25 | exec="onos ${OCI} app activate org.onosproject.distributedprimitives"/> |
26 | 26 | ||
27 | <step name="Test-Counter-Initial-Value" requires="^" | 27 | <step name="Test-Counter-Initial-Value" requires="^" |
28 | - exec="onos-execute-expect ${OCI} counter-test test-counter get --expect 0"/> | 28 | + exec="onos-cluster-execute-expect counter-test test-counter get --expect 0"/> |
29 | 29 | ||
30 | <step name="Test-Counter-Set" requires="^" | 30 | <step name="Test-Counter-Set" requires="^" |
31 | exec="onos ${OCI} counter-test test-counter set 1"/> | 31 | exec="onos ${OCI} counter-test test-counter set 1"/> |
32 | 32 | ||
33 | <step name="Test-Counter-Get" requires="^" | 33 | <step name="Test-Counter-Get" requires="^" |
34 | - exec="onos-execute-expect ${OCI} counter-test test-counter get --expect 1"/> | 34 | + exec="onos-cluster-execute-expect counter-test test-counter get --expect 1"/> |
35 | 35 | ||
36 | <step name="Test-Counter-IncrementAndGet" requires="^" | 36 | <step name="Test-Counter-IncrementAndGet" requires="^" |
37 | exec="onos-execute-expect ${OCI} counter-test test-counter incrementAndGet --expect 2"/> | 37 | exec="onos-execute-expect ${OCI} counter-test test-counter incrementAndGet --expect 2"/> |
... | @@ -40,7 +40,7 @@ | ... | @@ -40,7 +40,7 @@ |
40 | exec="onos-execute-expect ${OCI} counter-test test-counter getAndIncrement --expect 2"/> | 40 | exec="onos-execute-expect ${OCI} counter-test test-counter getAndIncrement --expect 2"/> |
41 | 41 | ||
42 | <step name="Test-Counter-Incremented" requires="^" | 42 | <step name="Test-Counter-Incremented" requires="^" |
43 | - exec="onos-execute-expect ${OCI} counter-test test-counter get --expect 3"/> | 43 | + exec="onos-cluster-execute-expect counter-test test-counter get --expect 3"/> |
44 | 44 | ||
45 | <step name="Test-Counter-AddAndGet" requires="^" | 45 | <step name="Test-Counter-AddAndGet" requires="^" |
46 | exec="onos-execute-expect ${OCI} counter-test test-counter addAndGet 10 --expect 13"/> | 46 | exec="onos-execute-expect ${OCI} counter-test test-counter addAndGet 10 --expect 13"/> |
... | @@ -49,19 +49,25 @@ | ... | @@ -49,19 +49,25 @@ |
49 | exec="onos-execute-expect ${OCI} counter-test test-counter getAndAdd 10 --expect 13"/> | 49 | exec="onos-execute-expect ${OCI} counter-test test-counter getAndAdd 10 --expect 13"/> |
50 | 50 | ||
51 | <step name="Test-Counter-Updated-After-GetAndAdd" requires="^" | 51 | <step name="Test-Counter-Updated-After-GetAndAdd" requires="^" |
52 | - exec="onos-execute-expect ${OCI} counter-test test-counter get --expect 23"/> | 52 | + exec="onos-cluster-execute-expect counter-test test-counter get --expect 23"/> |
53 | 53 | ||
54 | <step name="Test-Counter-CompareAndSet-False" requires="^" | 54 | <step name="Test-Counter-CompareAndSet-False" requires="^" |
55 | exec="onos-execute-expect ${OCI} counter-test test-counter compareAndSet 1 2 --expect false"/> | 55 | exec="onos-execute-expect ${OCI} counter-test test-counter compareAndSet 1 2 --expect false"/> |
56 | 56 | ||
57 | <step name="Test-Counter-Not-Updated-After-CAS" requires="^" | 57 | <step name="Test-Counter-Not-Updated-After-CAS" requires="^" |
58 | - exec="onos-execute-expect ${OCI} counter-test test-counter get --expect 23"/> | 58 | + exec="onos-cluster-execute-expect counter-test test-counter get --expect 23"/> |
59 | 59 | ||
60 | <step name="Test-Counter-CompareAndSet-True" requires="^" | 60 | <step name="Test-Counter-CompareAndSet-True" requires="^" |
61 | exec="onos-execute-expect ${OCI} counter-test test-counter compareAndSet 23 25 --expect true"/> | 61 | exec="onos-execute-expect ${OCI} counter-test test-counter compareAndSet 23 25 --expect true"/> |
62 | 62 | ||
63 | <step name="Test-Counter-Updated-After-CAS" requires="^" | 63 | <step name="Test-Counter-Updated-After-CAS" requires="^" |
64 | - exec="onos-execute-expect ${OCI} counter-test test-counter get --expect 25"/> | 64 | + exec="onos-cluster-execute-expect counter-test test-counter get --expect 25"/> |
65 | + | ||
66 | + <step name="Test-Counter-Reset" requires="^" | ||
67 | + exec="onos ${OCI} counter-test test-counter set 0"/> | ||
68 | + | ||
69 | + <step name="Test-Counter-Get-After-Reset" requires="^" | ||
70 | + exec="onos-cluster-execute-expect counter-test test-counter get --expect 0"/> | ||
65 | 71 | ||
66 | <!--Check with check logs--> | 72 | <!--Check with check logs--> |
67 | <step name="Check-Log-Exceptions" requires="^" | 73 | <step name="Check-Log-Exceptions" requires="^" | ... | ... |
... | @@ -25,7 +25,7 @@ | ... | @@ -25,7 +25,7 @@ |
25 | exec="onos ${OCI} app activate org.onosproject.distributedprimitives"/> | 25 | exec="onos ${OCI} app activate org.onosproject.distributedprimitives"/> |
26 | 26 | ||
27 | <step name="Test-Initial-No-Leader" requires="^" | 27 | <step name="Test-Initial-No-Leader" requires="^" |
28 | - exec="onos-execute-expect ${OCI} leader-test test-elector show foo --expect leader=none#candidates=none"/> | 28 | + exec="onos-cluster-execute-expect leader-test test-elector show foo --expect leader=none#candidates=none"/> |
29 | 29 | ||
30 | <step name="Test-Leader-Run" requires="^" | 30 | <step name="Test-Leader-Run" requires="^" |
31 | exec="onos-execute-expect ${OCI} leader-test test-elector run foo --expect leader=${OCI}#term=1#candidates=${OCI}"/> | 31 | exec="onos-execute-expect ${OCI} leader-test test-elector run foo --expect leader=${OCI}#term=1#candidates=${OCI}"/> |
... | @@ -34,7 +34,7 @@ | ... | @@ -34,7 +34,7 @@ |
34 | exec="onos ${OCI} leader-test test-elector withdraw foo"/> | 34 | exec="onos ${OCI} leader-test test-elector withdraw foo"/> |
35 | 35 | ||
36 | <step name="Test-No-Leader-After-Withdraw" requires="^" | 36 | <step name="Test-No-Leader-After-Withdraw" requires="^" |
37 | - exec="onos-execute-expect ${OCI} leader-test test-elector show foo --expect leader=none#candidates=none"/> | 37 | + exec="onos-cluster-execute-expect leader-test test-elector show foo --expect leader=none#candidates=none"/> |
38 | 38 | ||
39 | <!--Check with check logs--> | 39 | <!--Check with check logs--> |
40 | <step name="Check-Log-Exceptions" requires="^" | 40 | <step name="Check-Log-Exceptions" requires="^" | ... | ... |
... | @@ -25,13 +25,13 @@ | ... | @@ -25,13 +25,13 @@ |
25 | exec="onos ${OCI} app activate org.onosproject.distributedprimitives"/> | 25 | exec="onos ${OCI} app activate org.onosproject.distributedprimitives"/> |
26 | 26 | ||
27 | <step name="Test-Map-Get" requires="^" | 27 | <step name="Test-Map-Get" requires="^" |
28 | - exec="onos-execute-expect ${OCI} map-test foo get a --expect null"/> | 28 | + exec="onos-cluster-execute-expect map-test foo get a --expect null"/> |
29 | 29 | ||
30 | <step name="Test-Map-Put" requires="^" | 30 | <step name="Test-Map-Put" requires="^" |
31 | exec="onos-execute-expect ${OCI} map-test foo put a b --expect null"/> | 31 | exec="onos-execute-expect ${OCI} map-test foo put a b --expect null"/> |
32 | 32 | ||
33 | <step name="Test-Map-Updated-After-Put" requires="^" | 33 | <step name="Test-Map-Updated-After-Put" requires="^" |
34 | - exec="onos-execute-expect ${OCI} map-test foo get a --expect b"/> | 34 | + exec="onos-cluster-execute-expect map-test foo get a --expect b"/> |
35 | 35 | ||
36 | <step name="Test-Map-PutIfAbsent-When-Key-Present" requires="^" | 36 | <step name="Test-Map-PutIfAbsent-When-Key-Present" requires="^" |
37 | exec="onos-execute-expect ${OCI} map-test foo putIfAbsent a c --expect b"/> | 37 | exec="onos-execute-expect ${OCI} map-test foo putIfAbsent a c --expect b"/> |
... | @@ -40,7 +40,7 @@ | ... | @@ -40,7 +40,7 @@ |
40 | exec="onos-execute-expect ${OCI} map-test foo putIfAbsent b c --expect null"/> | 40 | exec="onos-execute-expect ${OCI} map-test foo putIfAbsent b c --expect null"/> |
41 | 41 | ||
42 | <step name="Test-Map-Updated-After-PutIfAbsent" requires="^" | 42 | <step name="Test-Map-Updated-After-PutIfAbsent" requires="^" |
43 | - exec="onos-execute-expect ${OCI} map-test foo get b --expect c"/> | 43 | + exec="onos-cluster-execute-expect map-test foo get b --expect c"/> |
44 | 44 | ||
45 | <step name="Test-Map-Updated-After-PutAndGet" requires="^" | 45 | <step name="Test-Map-Updated-After-PutAndGet" requires="^" |
46 | exec="onos-execute-expect ${OCI} map-test foo putAndGet b d --expect d"/> | 46 | exec="onos-execute-expect ${OCI} map-test foo putAndGet b d --expect d"/> |
... | @@ -58,16 +58,16 @@ | ... | @@ -58,16 +58,16 @@ |
58 | exec="onos-execute-expect ${OCI} map-test foo replace b e f --expect true"/> | 58 | exec="onos-execute-expect ${OCI} map-test foo replace b e f --expect true"/> |
59 | 59 | ||
60 | <step name="Test-Map-ContainsValue-False-Case" requires="^" | 60 | <step name="Test-Map-ContainsValue-False-Case" requires="^" |
61 | - exec="onos-execute-expect ${OCI} map-test foo containsValue x --expect false"/> | 61 | + exec="onos-cluster-execute-expect map-test foo containsValue x --expect false"/> |
62 | 62 | ||
63 | <step name="Test-Map-ContainsValue-True-Case" requires="^" | 63 | <step name="Test-Map-ContainsValue-True-Case" requires="^" |
64 | - exec="onos-execute-expect ${OCI} map-test foo containsValue f --expect true"/> | 64 | + exec="onos-cluster-execute-expect map-test foo containsValue f --expect true"/> |
65 | 65 | ||
66 | <step name="Test-Map-Size" requires="^" | 66 | <step name="Test-Map-Size" requires="^" |
67 | - exec="onos-execute-expect ${OCI} map-test foo size --expect 2"/> | 67 | + exec="onos-cluster-execute-expect map-test foo size --expect 2"/> |
68 | 68 | ||
69 | <step name="Test-Map-IsEmpty" requires="^" | 69 | <step name="Test-Map-IsEmpty" requires="^" |
70 | - exec="onos-execute-expect ${OCI} map-test foo isEmpty --expect false"/> | 70 | + exec="onos-cluster-execute-expect map-test foo isEmpty --expect false"/> |
71 | 71 | ||
72 | <step name="Test-Map-Remove" requires="^" | 72 | <step name="Test-Map-Remove" requires="^" |
73 | exec="onos-execute-expect ${OCI} map-test foo remove b --expect f"/> | 73 | exec="onos-execute-expect ${OCI} map-test foo remove b --expect f"/> | ... | ... |
... | @@ -25,25 +25,25 @@ | ... | @@ -25,25 +25,25 @@ |
25 | exec="onos ${OCI} app activate org.onosproject.distributedprimitives"/> | 25 | exec="onos ${OCI} app activate org.onosproject.distributedprimitives"/> |
26 | 26 | ||
27 | <step name="Test-Value-Initial-Value" requires="^" | 27 | <step name="Test-Value-Initial-Value" requires="^" |
28 | - exec="onos-execute-expect ${OCI} value-test test-value get --expect null"/> | 28 | + exec="onos-cluster-execute-expect value-test test-value get --expect null"/> |
29 | 29 | ||
30 | <step name="Test-Value-Set" requires="^" | 30 | <step name="Test-Value-Set" requires="^" |
31 | exec="onos ${OCI} value-test test-value set v0"/> | 31 | exec="onos ${OCI} value-test test-value set v0"/> |
32 | 32 | ||
33 | <step name="Test-Value-Get" requires="^" | 33 | <step name="Test-Value-Get" requires="^" |
34 | - exec="onos-execute-expect ${OCI} value-test test-value get --expect v0"/> | 34 | + exec="onos-cluster-execute-expect value-test test-value get --expect v0"/> |
35 | 35 | ||
36 | <step name="Test-Value-CompareAndSet-False" requires="^" | 36 | <step name="Test-Value-CompareAndSet-False" requires="^" |
37 | exec="onos-execute-expect ${OCI} value-test test-value compareAndSet v1 v2 --expect false"/> | 37 | exec="onos-execute-expect ${OCI} value-test test-value compareAndSet v1 v2 --expect false"/> |
38 | 38 | ||
39 | <step name="Test-Value-Not-Updated-After-CAS" requires="^" | 39 | <step name="Test-Value-Not-Updated-After-CAS" requires="^" |
40 | - exec="onos-execute-expect ${OCI} value-test test-value get --expect v0"/> | 40 | + exec="onos-cluster-execute-expect value-test test-value get --expect v0"/> |
41 | 41 | ||
42 | <step name="Test-Value-CompareAndSet-True" requires="^" | 42 | <step name="Test-Value-CompareAndSet-True" requires="^" |
43 | exec="onos-execute-expect ${OCI} value-test test-value compareAndSet v0 v1 --expect true"/> | 43 | exec="onos-execute-expect ${OCI} value-test test-value compareAndSet v0 v1 --expect true"/> |
44 | 44 | ||
45 | <step name="Test-Value-Updated-After-CAS" requires="^" | 45 | <step name="Test-Value-Updated-After-CAS" requires="^" |
46 | - exec="onos-execute-expect ${OCI} value-test test-value get --expect v1"/> | 46 | + exec="onos-cluster-execute-expect value-test test-value get --expect v1"/> |
47 | 47 | ||
48 | <!--Check with check logs--> | 48 | <!--Check with check logs--> |
49 | <step name="Check-Log-Exceptions" requires="^" | 49 | <step name="Check-Log-Exceptions" requires="^" | ... | ... |
-
Please register or login to post a comment