Commit d914fca1 authored by David Johnson's avatar David Johnson

Lots of automation for tests inside the OpenStack-Capnet setup.

parent 91df9e96
Pipeline #1364 skipped
#!/bin/sh
set -x
#
# A simple program that pssh's to all the nm node and stops its
# neutron-plugin-capnet-agent clears the flows in the specified capnet
# bridge ; stops the neutron-plugin-capnet-agent on all compute nodes
# and removes all flows from the specified capnet bridge ; restarts the
# neutron-plugin-capnet-agent on the NM; and restarts the
# neutron-plugin-capnet-agent on all compute nodes.
#
DIRNAME=`dirname $0`
. "$DIRNAME/test-lib.sh"
. "$SETUPLIB"
BRIDGE=$1
if [ -z "$BRIDGE" ]; then
echo "ERROR: must specify a bridge as argument"
exit 1
fi
$SSH $NETWORKMANAGER service neutron-plugin-capnet-agent stop
$SSH $NETWORKMANAGER ovs-ofctl del-flows $BRIDGE
$SSH $NETWORKMANAGER sh -c "'rm -fv /var/tmp/*'"
PHOSTS=""
for cn in $COMPUTENODES ; do
fqdn=`getfqdn $cn`
PHOSTS="$PHOSTS -H $fqdn"
done
$PSSH $PHOSTS service neutron-plugin-capnet-agent stop
$PSSH $PHOSTS sh -c "'rm -fv /var/tmp/*'"
$PSSH $PHOSTS ovs-ofctl del-flows $BRIDGE
service neutron-server stop
sleep 4
service neutron-server restart
sleep 8
$SSH $NETWORKMANAGER service neutron-plugin-capnet-agent start
$PSSH $PHOSTS service neutron-plugin-capnet-agent start
exit 0
#!/bin/sh
#
# A simple script that cleans up a single tenant: removes all its wfas
# and VMs. Everything else is left alone.
#
set -x
DIRNAME=`dirname $0`
. "$DIRNAME/test-lib.sh"
TENANTNAME=$1
if [ -z "$TENANTNAME" ]; then
echo "ERROR: must specify tenant name"
exit 1
fi
if [ ! -f $OURDIR/$TENANTNAME-user-openrc.sh ]; then
echo "ERROR: no Cloudlab openstack creds for tenant $TENANTNAME !"
exit 2
fi
. $OURDIR/$TENANTNAME-user-openrc.sh
# Delete all VMs:
vmlist=`nova list | awk ' / [0-9a-fA-F]*-[0-9a-fA-F-]* / { print $2 }' | xargs`
if [ -n "$vmlist" ]; then
nova delete $vmlist
fi
. $OURDIR/admin-openrc.sh
TENANTID=`openstack project show $TENANTNAME | awk " / id / {print \\$4}"`
WFA_IDS=`neutron capnet-wfagent-list | awk " / $TENANTID / { print \\$2 }" | xargs`
for wfa_id in $WFA_IDS ; do
neutron capnet-wfagent-delete $wfa_id
done
echo "Cleaned up tenant $TENANTNAME $TENANTID"
exit 0
#!/bin/sh
#
# Another test script; this one runs hadoop on a bunch of nodes.
#
# ./test-hadoop.sh <testdir> <user-tenant> <service-tenant> \
# <networkname> <bridgename> <num-slaves> [hadoop-args ...]
#
# First we fire off the service wfagent; then all the VMs (waiting for
# them to boot); and then the user wfagent.
# (Note: the master VM gets m1.large so it can create nearly 80GB input file
# if the job needs. The other VMs get m1.medium, so they have 4GB RAM.)
#
# To figure out when the test is done, we keep ssh'ing to the NM and
# looking through the user wfa's log looking for ^DONE$ .
#
# At the end, we have to scp the workflow agent logfile and controller
# logfile over here to the ctl node into our testdir.
#
set -x
DIRNAME=`dirname $0`
. "$DIRNAME/test-lib.sh"
. "$SETUPLIB"
if [ $# -lt 6 ]; then
echo "USAGE: $0 <testdir> <user-tenant> <service-tenant> <networkname>"
echo " <bridgename> <num-slaves> [<hadoop-args>]"
exit 1
fi
TESTDIR=$1
shift
UTENANT=$1
shift
STENANT=$1
shift
NETWORK=$1
shift
BRIDGE=$1
shift
NSLAVES=$1
shift
ARGS=""
if [ $# -gt 0 ]; then
ARGS="$@"
fi
#
# Create some parallel SSH command lines...
#
PCHOSTS=""
for cn in $COMPUTENODES ; do
fqdn=`getfqdn $cn`
PCHOSTS="$PCHOSTS -H $fqdn"
done
PNHOSTS="$PCHOSTS"
fqdn=`getfqdn $NETWORKMANAGER`
PNHOSTS="-H $fqdn $PCHOSTS"
echo "*** Testing hadoop: $TESTDIR $UTENANT $STENANT $NETWORK $BRIDGE $NSLAVES \"$ARGS\" ..."
mkdir -p $TESTDIR
# NB: Be admin when we fire off wfas...
. "$OURDIR/admin-openrc.sh"
NETWORKID=`openstack network show $NETWORK | awk ' / id / {print $4}'`
UTENANTID=`openstack project show $UTENANT | awk ' / id / {print $4}'`
STENANTID=`openstack project show $STENANT | awk ' / id / {print $4}'`
#
# Create the service WFA.
#
STENANTWFANAME="$STENANT-hadoop"
neutron capnet-wfagent-create --tenant-id $STENANTID --name $STENANTWFANAME \
--master --wfapp-path /usr/bin/capnet-wfagent-service-tenant-hadoop-membrane \
$NETWORK
if [ ! $? -eq 0 ]; then
print "ERROR: creating service wfa; aborting!"
exit 1
fi
while [ 1 -eq 1 ]; do
STENANTWFAID=`neutron capnet-wfagent-list | awk " / $STENANTWFANAME / { print \\$2 }"`
if [ ! "x$STENANTWFAID" = "x" ]; then
break
fi
done
sleep 5
#
# Fire off VMs.
# NB: Be the tenant user when we fire off VMs.
#
. "$OURDIR/$UTENANT-user-openrc.sh"
nova boot --image hadoop --flavor m1.large --nic net-id=$NETWORKID master
if [ ! $? -eq 0 ]; then
print "ERROR: failed to create master VM; aborting!"
exit 1
fi
nova boot --image hadoop --flavor m1.medium --nic net-id=$NETWORKID resourcemanager
if [ ! $? -eq 0 ]; then
print "ERROR: failed to create resourcemanager VM; aborting!"
exit 1
fi
i=0
while [ $i -lt $NSLAVES ]; do
nova boot --image hadoop --flavor m1.medium --nic net-id=$NETWORKID slave$i
if [ ! $? -eq 0 ]; then
print "ERROR: failed to create slave$i VM; aborting!"
exit 1
fi
i=`expr $i + 1`
done
#
# Wait for all nodes to have booted, then wait 10 seconds more...
#
allrunning=0
while [ $allrunning -eq 0 ]; do
print "*** Still waiting for nodes to reach Running state ..."
sleep 5
vsl=`nova list | awk ' / [0-9a-fA-F]*-[0-9a-fA-F-]* / { print $10 }' | xargs`
allrunning=1
for status in $vsl ; do
if [ ! "x$status" = "xRunning" ]; then
allrunning=0
break
fi
done
done
#
# Hedge our bets and hope all have booted to network by this point :)
#
print "*** Sleeping 16 seconds to let all VMs come online, hopefully ..."
sleep 16
#
# Grab the flow tables for all switches:
#
mkdir -p $TESTDIR/out.flowtables-post-node-boot $TESTDIR/err.flowtables-post-node-boot
$PSSH $PNHOSTS \
-o $TESTDIR/out.flowtables-post-node-boot \
-e $TESTDIR/err.flowtables-post-node-boot \
ovs-ofctl dump-flows $BRIDGE
# NB: Be admin when we fire off wfas...
. "$OURDIR/admin-openrc.sh"
#
# Create the user wfa.
#
UTENANTWFANAME="$UTENANT-hadoop"
neutron capnet-wfagent-create --tenant-id $UTENANTID --name $UTENANTWFANAME \
--master --wfapp-path /usr/bin/capnet-wfagent-user-tenant-hadoop-membrane \
$NETWORK
if [ ! $? -eq 0 ]; then
print "ERROR: creating user wfa; aborting!"
exit 1
fi
while [ 1 -eq 1 ]; do
UTENANTWFAID=`neutron capnet-wfagent-list | awk " / $UTENANTWFANAME / { print \\$2 }"`
if [ ! "x$UTENANTWFAID" = "x" ]; then
break
fi
done
#
# Wait for everything to finish, then sync back logfiles.
#
CONTROLLERLOGFILE="/var/tmp/${BRIDGE}-controller.log"
UWFALOGFILE="/var/tmp/wfagent.${UTENANTWFANAME}.${UTENANTWFAID}.log"
SWFALOGFILE="/var/tmp/wfagent.${STENANTWFANAME}.${STENANTWFAID}.log"
while [ 1 -eq 1 ]; do
$SSH $NETWORKMANAGER \
grep "'^DONE$'" $UWFALOGFILE
if [ $? -eq 0 ]; then
break
fi
done
echo "*** Test has completed, fetching logs ..."
#
# Grab the flow tables for all switches again:
#
mkdir -p $TESTDIR/out.flowtables-post-hadoop $TESTDIR/err.flowtables-post-hadoop
$PSSH $PNHOSTS \
-o $TESTDIR/out.flowtables-post-hadoop \
-e $TESTDIR/err.flowtables-post-hadoop \
ovs-ofctl dump-flows $BRIDGE
echo "*** Done ; results in $TESTDIR"
exit 0
#!/bin/sh
set -x
#
# The dir left by the Cloudlab setup scripts. Lots of stuff is here,
# including openstack credential files!
#
OURDIR=/root/setup
#
# This is the Cloudlab setup script install library. It has lots of
# useful variables.
#
SETUPLIB=/tmp/setup/setup-lib.sh
PSSH='/usr/bin/parallel-ssh -t 0 -O StrictHostKeyChecking=no '
PSCP='/usr/bin/parallel-scp -t 0 -O StrictHostKeyChecking=no '
SSH='/usr/bin/ssh -o StrictHostKeyChecking=no '
SCP='/usr/bin/scp -o StrictHostKeyChecking=no '
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment