diff options
Diffstat (limited to 'framework/src/onos/tools')
16 files changed, 242 insertions, 43 deletions
diff --git a/framework/src/onos/tools/build/conf/pom.xml b/framework/src/onos/tools/build/conf/pom.xml index 29e4dea0..d56168f2 100644 --- a/framework/src/onos/tools/build/conf/pom.xml +++ b/framework/src/onos/tools/build/conf/pom.xml @@ -27,7 +27,7 @@ <groupId>org.onosproject</groupId> <artifactId>onos-build-conf</artifactId> - <version>1.1</version> + <version>1.1-SNAPSHOT</version> <description>Various ONOS build settings</description> <properties> diff --git a/framework/src/onos/tools/build/conf/src/main/resources/onos/checkstyle.xml b/framework/src/onos/tools/build/conf/src/main/resources/onos/checkstyle.xml index 1bb3b0bf..e04479c5 100644 --- a/framework/src/onos/tools/build/conf/src/main/resources/onos/checkstyle.xml +++ b/framework/src/onos/tools/build/conf/src/main/resources/onos/checkstyle.xml @@ -67,9 +67,7 @@ --> <!-- Checks that a package-info.java file exists for each package. --> <!-- See http://checkstyle.sf.net/config_javadoc.html#JavadocPackage --> - <!-- ONOS does not currently supply package level Javadoc information - in package-info files --> - <!-- <module name="JavadocPackage"/> --> + <module name="JavadocPackage"/> <!-- Checks whether files end with a new line. --> <!-- See http://checkstyle.sf.net/config_misc.html#NewlineAtEndOfFile --> diff --git a/framework/src/onos/tools/build/conf/src/main/resources/onos/suppressions.xml b/framework/src/onos/tools/build/conf/src/main/resources/onos/suppressions.xml index a71d941f..6d8f1982 100644 --- a/framework/src/onos/tools/build/conf/src/main/resources/onos/suppressions.xml +++ b/framework/src/onos/tools/build/conf/src/main/resources/onos/suppressions.xml @@ -29,4 +29,12 @@ <suppress files=".*" checks="HiddenField"/> <suppress files=".java" checks="NewlineAtEndOfFile"/> + <!-- Suppressions for unit testing code --> + <suppress checks="JavadocPackage" + files=".*/src/test/.*.java" + /> + + <suppress checks="JavadocPackage" + files=".*/thirdparty/.*.java"/> + </suppressions> diff --git a/framework/src/onos/tools/dev/bin/onos-build-selective b/framework/src/onos/tools/dev/bin/onos-build-selective index ac2dec8e..351c53ac 100755 --- a/framework/src/onos/tools/dev/bin/onos-build-selective +++ b/framework/src/onos/tools/dev/bin/onos-build-selective @@ -15,9 +15,11 @@ if [ -n "$projects" ]; then # Ascertain artifact IDs of the projects to be rebuilt modulesERE="" for pd in ${projects//,/ }; do - artifactId=$(grep -E "^ <artifactId>.*</artifactId>$" ${pd}/pom.xml | \ - sed 's/.[^>]*>//;s/<.*//') - modulesERE="$modulesERE|$artifactId" + if [ -f ${pd}/pom.xml ]; then + artifactId=$(grep -E "^ <artifactId>.*</artifactId>$" ${pd}/pom.xml | \ + sed 's/.[^>]*>//;s/<.*//') + modulesERE="$modulesERE|$artifactId" + fi done modulesERE=${modulesERE#|*} diff --git a/framework/src/onos/tools/dev/bin/onos-build-selective.exclude b/framework/src/onos/tools/dev/bin/onos-build-selective.exclude index 1265494e..487f848c 100644 --- a/framework/src/onos/tools/dev/bin/onos-build-selective.exclude +++ b/framework/src/onos/tools/dev/bin/onos-build-selective.exclude @@ -6,4 +6,5 @@ .*/cord-gui/.* .*/jdvue/.* .*/ovsdb/api/.* -.*/netconf/flow/.*
\ No newline at end of file +.*/netconf/flow/.* +.*/vtn/sfcmgr/.*
\ No newline at end of file diff --git a/framework/src/onos/tools/dev/bin/onos-setup-karaf b/framework/src/onos/tools/dev/bin/onos-setup-karaf index 3323d9d1..cbe62253 100755 --- a/framework/src/onos/tools/dev/bin/onos-setup-karaf +++ b/framework/src/onos/tools/dev/bin/onos-setup-karaf @@ -97,13 +97,11 @@ fi echo "Creating local cluster configs for IP $IP..." [ -d $STAGE/config ] || mkdir -p $STAGE/config cat > $STAGE/config/cluster.json <<EOF - { "ipPrefix": "$SUBNET.*", - "nodes":[ { "id": "$IP", "ip": "$IP", "tcpPort": 9876 }]} -EOF - -cat > $STAGE/config/tablets.json <<EOF - { "nodes": [ { "ip": "$IP", "id": "$IP", "tcpPort": 9876 }], - "partitions": { "p1": [ { "ip": "$IP", "id": "$IP", "tcpPort": 9876 }]}} +{ + "name": "default", + "nodes": [ {"id": "$IP", "ip": "$IP", "port": 9876 } ], + "partitions": [ { "name": "p1", "members": [ "$IP" ] } ] +} EOF if [ "$CLEAN" = "true" ]; then diff --git a/framework/src/onos/tools/package/archetypes/uitopo/src/main/resources/archetype-resources/src/main/java/AppUiTopovMessageHandler.java b/framework/src/onos/tools/package/archetypes/uitopo/src/main/resources/archetype-resources/src/main/java/AppUiTopovMessageHandler.java index 7c35cc53..65e3489f 100644 --- a/framework/src/onos/tools/package/archetypes/uitopo/src/main/resources/archetype-resources/src/main/java/AppUiTopovMessageHandler.java +++ b/framework/src/onos/tools/package/archetypes/uitopo/src/main/resources/archetype-resources/src/main/java/AppUiTopovMessageHandler.java @@ -33,7 +33,10 @@ import org.onosproject.net.link.LinkService; import org.onosproject.ui.RequestHandler; import org.onosproject.ui.UiConnection; import org.onosproject.ui.UiMessageHandler; +import org.onosproject.ui.topo.DeviceHighlight; import org.onosproject.ui.topo.Highlights; +import org.onosproject.ui.topo.NodeBadge; +import org.onosproject.ui.topo.NodeBadge.Status; import org.onosproject.ui.topo.TopoJson; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -224,11 +227,26 @@ public class AppUiTopovMessageHandler extends UiMessageHandler { if (elementOfNote != null && elementOfNote instanceof Device) { DeviceId devId = (DeviceId) elementOfNote.id(); Set<Link> links = linkService.getDeviceEgressLinks(devId); - sendHighlights(fromLinks(links, devId)); + Highlights highlights = fromLinks(links, devId); + addDeviceBadge(highlights, devId, links.size()); + sendHighlights(highlights); } // Note: could also process Host, if available } + private void addDeviceBadge(Highlights h, DeviceId devId, int n) { + DeviceHighlight dh = new DeviceHighlight(devId.toString()); + dh.setBadge(createBadge(n)); + h.add(dh); + } + + private NodeBadge createBadge(int n) { + Status status = n > 3 ? Status.ERROR : Status.WARN; + String noun = n > 3 ? "(critical)" : "(problematic)"; + String msg = "Egress links: " + n + " " + noun; + return NodeBadge.number(status, n, msg); + } + private Highlights fromLinks(Set<Link> links, DeviceId devId) { DemoLinkMap linkMap = new DemoLinkMap(); if (links != null) { diff --git a/framework/src/onos/tools/package/archetypes/uitopo/src/main/resources/archetype-resources/src/main/java/AppUiTopovOverlay.java b/framework/src/onos/tools/package/archetypes/uitopo/src/main/resources/archetype-resources/src/main/java/AppUiTopovOverlay.java index 98999825..48e75a5a 100644 --- a/framework/src/onos/tools/package/archetypes/uitopo/src/main/resources/archetype-resources/src/main/java/AppUiTopovOverlay.java +++ b/framework/src/onos/tools/package/archetypes/uitopo/src/main/resources/archetype-resources/src/main/java/AppUiTopovOverlay.java @@ -18,13 +18,20 @@ */ package ${package}; +import org.onosproject.net.DeviceId; import org.onosproject.ui.UiTopoOverlay; import org.onosproject.ui.topo.ButtonId; import org.onosproject.ui.topo.PropertyPanel; import org.onosproject.ui.topo.TopoConstants.CoreButtons; import org.onosproject.ui.topo.TopoConstants.Glyphs; -import static org.onosproject.ui.topo.TopoConstants.Properties.*; +import static org.onosproject.ui.topo.TopoConstants.Properties.FLOWS; +import static org.onosproject.ui.topo.TopoConstants.Properties.INTENTS; +import static org.onosproject.ui.topo.TopoConstants.Properties.LATITUDE; +import static org.onosproject.ui.topo.TopoConstants.Properties.LONGITUDE; +import static org.onosproject.ui.topo.TopoConstants.Properties.TOPOLOGY_SSCS; +import static org.onosproject.ui.topo.TopoConstants.Properties.TUNNELS; +import static org.onosproject.ui.topo.TopoConstants.Properties.VERSION; /** * Our topology overlay. @@ -61,7 +68,7 @@ public class AppUiTopovOverlay extends UiTopoOverlay { } @Override - public void modifyDeviceDetails(PropertyPanel pp) { + public void modifyDeviceDetails(PropertyPanel pp, DeviceId deviceId) { pp.title(MY_DEVICE_TITLE); pp.removeProps(LATITUDE, LONGITUDE); 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): |