diff options
Diffstat (limited to 'framework/src/onos/tools/test')
-rwxr-xr-x | framework/src/onos/tools/test/bin/onos-config | 19 | ||||
-rwxr-xr-x | framework/src/onos/tools/test/bin/onos-execute-expect | 27 | ||||
-rwxr-xr-x | framework/src/onos/tools/test/bin/onos-gen-partitions | 17 | ||||
-rwxr-xr-x | framework/src/onos/tools/test/bin/onos-secure-ssh | 3 | ||||
-rwxr-xr-x | framework/src/onos/tools/test/bin/stc | 4 | ||||
-rw-r--r-- | framework/src/onos/tools/test/scenarios/dist-test-seq.xml | 67 | ||||
-rw-r--r-- | framework/src/onos/tools/test/scenarios/dist-test.xml | 70 | ||||
-rw-r--r-- | framework/src/onos/tools/test/topos/opticalUtils.py | 10 |
8 files changed, 192 insertions, 25 deletions
diff --git a/framework/src/onos/tools/test/bin/onos-config b/framework/src/onos/tools/test/bin/onos-config index 348cb839..e37dc3b2 100755 --- a/framework/src/onos/tools/test/bin/onos-config +++ b/framework/src/onos/tools/test/bin/onos-config @@ -37,17 +37,6 @@ export ONOS_BOOT_FEATURES="${ONOS_BOOT_FEATURES:-webconsole,onos-api,onos-core,o # ONOS builtin apps and providers ignited by default export ONOS_APPS="${ONOS_APPS:-drivers,openflow}" -# Generate a cluster.json from the ON* environment variables -CDEF_FILE=/tmp/${remote}.cluster.json -echo "{ \"ipPrefix\": \"$ONOS_NIC\"," > $CDEF_FILE -echo " \"nodes\":[" >> $CDEF_FILE -for node in $(env | sort | egrep "OC[2-9]+" | cut -d= -f2); do - echo " { \"id\": \"$node\", \"ip\": \"$node\", \"tcpPort\": 9876 }," >> $CDEF_FILE -done -echo " { \"id\": \"$OC1\", \"ip\": \"$OC1\", \"tcpPort\": 9876 }" >> $CDEF_FILE -echo "]}" >> $CDEF_FILE -scp -q $CDEF_FILE $remote:$ONOS_INSTALL_DIR/config/cluster.json - ssh $remote " echo \"onos.ip = \$(sudo ifconfig | grep $ONOS_NIC | cut -d: -f2 | cut -d\\ -f1)\" \ >> $ONOS_INSTALL_DIR/$KARAF_DIST/etc/system.properties @@ -66,10 +55,10 @@ ssh $remote " done " -# Generate a default tablets.json from the ON* environment variables -TDEF_FILE=/tmp/${remote}.tablets.json -onos-gen-partitions $TDEF_FILE -scp -q $TDEF_FILE $remote:$ONOS_INSTALL_DIR/config/tablets.json +# Generate a default cluster.json from the ON* environment variables +CDEF_FILE=/tmp/${remote}.cluster.json +onos-gen-partitions $CDEF_FILE +scp -q $CDEF_FILE $remote:$ONOS_INSTALL_DIR/config/cluster.json # Copy tools/package/config/ to remote scp -qr ${ONOS_ROOT}/tools/package/config/ $remote:$ONOS_INSTALL_DIR/ diff --git a/framework/src/onos/tools/test/bin/onos-execute-expect b/framework/src/onos/tools/test/bin/onos-execute-expect new file mode 100755 index 00000000..6ad95699 --- /dev/null +++ b/framework/src/onos/tools/test/bin/onos-execute-expect @@ -0,0 +1,27 @@ +#!/bin/bash +# ----------------------------------------------------------------------------- +# Executes a command on the given ONOS instance and matches the output +# to the passed one. +# First argument is the IP address of the machine to run the command on, +# then you pass the command and it's arguments if needed, then --expect and +# after it the string of what the output should be. +# Example: +# onos-execute-expect 1.1.1.1 fooCommand fooParamenter --expect fooOutputString +# ----------------------------------------------------------------------------- + +[ ! -d "$ONOS_ROOT" ] && echo "ONOS_ROOT is not defined" >&2 && exit 1 +. $ONOS_ROOT/tools/build/envDefaults + + +aux=/tmp/stc-$$.log +trap "rm -f $aux 2>/dev/null" EXIT +ip=$1 +cmd="" +for a in ${*:2}; do shift; if [ "$a" = "--expect" ]; then break; fi; cmd="$cmd $a"; done +expect="${@: -1}" +onos $ip $cmd > $aux +cat $aux +grep -q $expect $aux && echo "expected value found" && exit 0 +exit 1 + + diff --git a/framework/src/onos/tools/test/bin/onos-gen-partitions b/framework/src/onos/tools/test/bin/onos-gen-partitions index a2558392..35195b04 100755 --- a/framework/src/onos/tools/test/bin/onos-gen-partitions +++ b/framework/src/onos/tools/test/bin/onos-gen-partitions @@ -23,22 +23,27 @@ def get_OC_vars(): return sorted(vars, key=alphanum_key) def get_nodes(vars, port=9876): - node = lambda k: { 'id': k, 'ip': k, 'tcpPort': port } + node = lambda k: { 'id': k, 'ip': k, 'port': port } return [ node(environ[v]) for v in vars ] def generate_permutations(nodes, k): l = deque(nodes) - perms = {} + perms = [] for i in range(1, len(nodes)+1): - perms['p%d' % i] = list(l)[:k] + part = { + 'name': 'p%d' % i, + 'members': list(l)[:k] + } + perms.append(part) l.rotate(-1) - return OrderedDict(sorted(perms.iteritems(), key=lambda (k, v): alphanum_key(k))) + return perms if __name__ == '__main__': vars = get_OC_vars() nodes = get_nodes(vars) - partitions = generate_permutations(nodes, 3) - data = { + partitions = generate_permutations([v.get('id') for v in nodes], 3) + data = { + 'name': 'default', 'nodes': nodes, 'partitions': partitions } diff --git a/framework/src/onos/tools/test/bin/onos-secure-ssh b/framework/src/onos/tools/test/bin/onos-secure-ssh index a3980e17..6d898ee8 100755 --- a/framework/src/onos/tools/test/bin/onos-secure-ssh +++ b/framework/src/onos/tools/test/bin/onos-secure-ssh @@ -10,7 +10,8 @@ nodes=$(env | sort | egrep "OC[0-9]+" | cut -d= -f2) for node in $nodes; do # Prune the node entry from the known hosts file since server key changes - ssh-keygen -f "$HOME/.ssh/known_hosts" -R [$node]:8101 + ssh-keygen -f "$HOME/.ssh/known_hosts" -R [$node]:8101 || + ( echo "Failed to remove key from known_hosts" >&2 && exit 1 ) # Setup passwordless login for the local user on the remote node ssh $ONOS_USER@$node " diff --git a/framework/src/onos/tools/test/bin/stc b/framework/src/onos/tools/test/bin/stc index 8737cf3f..60a1720e 100755 --- a/framework/src/onos/tools/test/bin/stc +++ b/framework/src/onos/tools/test/bin/stc @@ -20,6 +20,7 @@ scenario=${1:-smoke} # If stcColor is not set, we will enable color if this is an interactive session [ -t 1 ] && interactive=true || interactive=false +[ -t 1 ] && notInteractive=false || notInteractive=true # stc requires that ONOS_USE_SSH=true, but we will store the old value and reset it after sshSet=$([ -z ${ONOS_USE_SSH+x} ]) && oldSSH=$ONOS_USE_SSH @@ -27,7 +28,8 @@ export ONOS_USE_SSH=true # Run stc [ -z "$stcDebug" ] && DEBUG_OPTS="" -stcColor=${stcColor:-$interactive} java $DEBUG_OPTS -jar $JAR $scenario "$@" +stcColor=${stcColor:-$interactive} stcDumpLogs=${stcDumpLogs:-$notInteractive} \ + java $DEBUG_OPTS -jar $JAR $scenario "$@" # Reset the old value of ONOS_USE_SSH [ $sshSet ] && export ONOS_USE_SSH=oldSSH || unset ONOS_USE_SSH diff --git a/framework/src/onos/tools/test/scenarios/dist-test-seq.xml b/framework/src/onos/tools/test/scenarios/dist-test-seq.xml new file mode 100644 index 00000000..2e99fa27 --- /dev/null +++ b/framework/src/onos/tools/test/scenarios/dist-test-seq.xml @@ -0,0 +1,67 @@ +<!-- + ~ Copyright 20${OCI}5 Open Networking Laboratory + ~ + ~ Licensed under the Apache License, Version 2.0 (the "License"); + ~ you may not use this file except in compliance with the License. + ~ You may obtain a copy of the License at + ~ + ~ http://www.apache.org/licenses/LICENSE-2.0 + ~ + ~ Unless required by applicable law or agreed to in writing, software + ~ distributed under the License is distributed on an "AS IS" BASIS, + ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + ~ See the License for the specific language governing permissions and + ~ limitations under the License. + --> + +<scenario name="dist-test" + description="ONOS distributed primitives setup"> + <group name="Distributed-Primitives"> + <!--<import file="${ONOS_SCENARIOS}/prerequisites.xml"/>--> + + <!--<import file="${ONOS_SCENARIOS}/setup.xml"/> + <dependency name="Setup" requires="Prerequisites"/>--> + + <sequential var="${OC#}" starts="Distributed-App-${#}" ends="Check-Distributed-Exceptions-${#-1}"> + <step name="Distributed-App-${#}" + requires="Setup" + exec="onos ${OC#} app activate org.onosproject.distributedprimitives"/> + + <step name="Test-Counter-Increment-${#}" + requires="Distributed-App-${#}" + exec="onos-execute-expect ${OC#} counter-test-increment fooCounter 5 --expect updated"/> + + <step name="Test-Add-${#}" + requires="Distributed-App-${#}" + exec="onos-execute-expect ${OC#} set-test-add fooSet foo --expect added"/> + + <step name="Test-Get-${#}" + requires="Test-Add-${#}" + exec="onos-execute-expect ${OC#} set-test-get fooSet foo --expect contains"/> + + <step name="Test-Remove-${#}" + requires="Test-Get-${#}" + exec="onos-execute-expect ${OC#} set-test-remove fooSet foo --expect removed"/> + + <step name="Test-Add-Multiple-${#}" + requires="Test-Remove-${#}" + exec="onos-execute-expect ${OC#} set-test-add fooSet foo foo2 foo3 --expect added"/> + + <step name="Test-Get-Multiple-${#}" + requires="Test-Add-Multiple-${#}" + exec="onos-execute-expect ${OC#} set-test-get fooSet foo foo2 foo3 --expect contains"/> + + <step name="Test-Remove-Multiple-${#}" + requires="Test-Get-Multiple-${#}" + exec="onos-execute-expect ${OC#} set-test-remove fooSet foo foo2 foo3 --expect removed"/> + + <step name="Sleep-${#}" + exec="sleep 2" + requires="Test-Remove-Multiple-${#}"/> + <!--Check with check logs--> + <step name="Check-Distributed-Exceptions-${#}" + exec="onos-check-logs ${OC#}" + requires="Sleep-${#}"/> + </sequential> + </group> +</scenario>
\ No newline at end of file diff --git a/framework/src/onos/tools/test/scenarios/dist-test.xml b/framework/src/onos/tools/test/scenarios/dist-test.xml new file mode 100644 index 00000000..5e7dab0b --- /dev/null +++ b/framework/src/onos/tools/test/scenarios/dist-test.xml @@ -0,0 +1,70 @@ +<!-- + ~ Copyright 2015 Open Networking Laboratory + ~ + ~ Licensed under the Apache License, Version 2.0 (the "License"); + ~ you may not use this file except in compliance with the License. + ~ You may obtain a copy of the License at + ~ + ~ http://www.apache.org/licenses/LICENSE-2.0 + ~ + ~ Unless required by applicable law or agreed to in writing, software + ~ distributed under the License is distributed on an "AS IS" BASIS, + ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + ~ See the License for the specific language governing permissions and + ~ limitations under the License. +--> + +<scenario name="dist-test" + description="ONOS distributed primitives setup"> + <group name="Distributed-Primitives"> + + <!--<import file="${ONOS_SCENARIOS}/setup.xml"/> + <dependency name="Setup" requires="Prerequisites"/>--> + + <step name="Distributed-App" + requires="Setup" + exec="onos ${OCI} app activate org.onosproject.distributedprimitives"/> + + <step name="Test-Counter-Increment" + requires="Distributed-App" + exec="onos-execute-expect ${OCI} counter-test-increment fooCounter 5 --expect updated"/> + + <step name="Test-Add" + requires="Distributed-App" + exec="onos-execute-expect ${OCI} set-test-add fooSet foo --expect added"/> + + <step name="Test-Get" + requires="Test-Add" + exec="onos-execute-expect ${OCI} set-test-get fooSet foo --expect contains"/> + + <step name="Test-Remove" + requires="Test-Get" + exec="onos-execute-expect ${OCI} set-test-remove fooSet foo --expect removed"/> + + <step name="Test-Add-Multiple" + requires="Test-Remove" + exec="onos-execute-expect ${OCI} set-test-add fooSet foo foo2 foo3 --expect added"/> + + <step name="Test-Get-Multiple" + requires="Test-Add-Multiple" + exec="onos-execute-expect ${OCI} set-test-get fooSet foo foo2 foo3 --expect contains"/> + + <step name="Test-Remove-Multiple" + requires="Test-Get-Multiple" + exec="onos-execute-expect ${OCI} set-test-remove fooSet foo foo2 foo3 --expect removed"/> + + <step name="Test-Map-Put" + requires="Distributed-App" + exec="onos-execute-expect ${OCI} transactional-map-test-put 1 foo --expect Created"/> + + <step name="Test-Map-Get" + requires="Test-Map-Put" + exec="onos-execute-expect ${OCI} transactional-map-test-get Key1 --expect Key-value"/> + + <!--Check with check logs--> + <step name="Check-Distributed-Exceptions" + exec="onos-check-logs ${OCI}" + requires="Test-Map-Get"/> + </group> +</scenario> + diff --git a/framework/src/onos/tools/test/topos/opticalUtils.py b/framework/src/onos/tools/test/topos/opticalUtils.py index a1ae834b..5d955e51 100644 --- a/framework/src/onos/tools/test/topos/opticalUtils.py +++ b/framework/src/onos/tools/test/topos/opticalUtils.py @@ -344,7 +344,10 @@ class LINCSwitch(OpticalSwitch): continue portDict = {} portDict[ 'port' ] = port - portDict[ 'type' ] = 'FIBER' if isinstance(intf.link, LINCLink) else 'COPPER' + portType = 'COPPER' + if isinstance(intf.link, LINCLink): + portType = 'OCH' if intf.link.isCrossConnect else 'OMS' + portDict[ 'type' ] = portType intfList = [ intf.link.intf1, intf.link.intf2 ] intfList.remove(intf) portDict[ 'speed' ] = intfList[ 0 ].speed if isinstance(intf.link, LINCLink) else 0 @@ -787,7 +790,10 @@ class LINCIntf(OpticalIntf): configDict = {} configDict[ 'port' ] = self.port configDict[ 'speed' ] = self.speed - configDict[ 'type' ] = 'FIBER' + portType = 'COPPER' + if isinstance(self.link, LINCLink): + portType = 'OCH' if self.link.isCrossConnect else 'OMS' + configDict[ 'type' ] = portType return configDict def config(self, *args, **kwargs): |