summaryrefslogtreecommitdiffstats
path: root/framework/src/onos/tools/test/bin
diff options
context:
space:
mode:
Diffstat (limited to 'framework/src/onos/tools/test/bin')
-rwxr-xr-xframework/src/onos/tools/test/bin/onos-config19
-rwxr-xr-xframework/src/onos/tools/test/bin/onos-execute-expect27
-rwxr-xr-xframework/src/onos/tools/test/bin/onos-gen-partitions17
-rwxr-xr-xframework/src/onos/tools/test/bin/onos-secure-ssh3
-rwxr-xr-xframework/src/onos/tools/test/bin/stc4
5 files changed, 47 insertions, 23 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