Add push bits scripts for Atomix uploads to test cells
Change-Id: I2b6f2fbd19558f08e549b366ae2ecfdbb9227efd
diff --git a/tools/test/bin/atomix-install b/tools/test/bin/atomix-install
index af210ae..a076d00 100755
--- a/tools/test/bin/atomix-install
+++ b/tools/test/bin/atomix-install
@@ -47,8 +47,7 @@
[ -f $ATOMIX_INSTALL_DIR/bin/atomix-agent ] && echo \"Atomix is already installed\" && exit 1
sudo mkdir -p $ATOMIX_INSTALL_DIR && sudo chown ${ONOS_USER}:${ONOS_GROUP} $ATOMIX_INSTALL_DIR
- sudo wget -O $ATOMIX_INSTALL_DIR/atomix-dist.tar.gz https://oss.sonatype.org/content/repositories/releases/io/atomix/atomix-dist/3.0.7/atomix-dist-3.0.7.tar.gz
- tar -xvf $ATOMIX_INSTALL_DIR/atomix-dist.tar.gz -C $ATOMIX_INSTALL_DIR
+ tar -xvf /tmp/atomix.tar.gz -C $ATOMIX_INSTALL_DIR
"
# Configure the ONOS installation
diff --git a/tools/test/bin/atomix-push-bits b/tools/test/bin/atomix-push-bits
new file mode 100755
index 0000000..6b5d68b
--- /dev/null
+++ b/tools/test/bin/atomix-push-bits
@@ -0,0 +1,64 @@
+#!/bin/bash
+# -----------------------------------------------------------------------------
+# Remotely pushes bits to a remote node in preparation for install.
+# -----------------------------------------------------------------------------
+function _usage () {
+cat << _EOF_
+usage:
+ $(basename $0) [node]
+
+options:
+- [node] : the target node to prime for installation
+
+summary:
+ Remotely pushes Atomix bits to a remote node in preparation for install.
+
+ $(basename $0) is invoked as part of 'atomix-install', and shouldn't be
+ directly invoked for the most part.
+
+_EOF_
+}
+
+[ $# -gt 1 ] || [ "$1" = "-h" ] && _usage && exit 0
+[ ! -d "$ONOS_ROOT" ] && echo "ONOS_ROOT isn't set correctly" >&2 && exit 1
+
+set -e
+
+. $ONOS_ROOT/tools/build/envDefaults
+
+ATOMIX_VERSION=${ATOMIX_VERSION:-3.0.7}
+ATOMIX_MAVEN=~/.m2/repository/io/atomix/atomix-dist/$ATOMIX_VERSION/atomix-dist-$ATOMIX_VERSION.tar.gz
+ATOMIX_LOCAL=/tmp/atomix-$ATOMIX_VERSION.tar.gz
+ATOMIX_REMOTE=https://oss.sonatype.org/content/repositories/releases/io/atomix/atomix-dist/$ATOMIX_VERSION/atomix-dist-$ATOMIX_VERSION.tar.gz
+
+node=${1:-$OCI}
+remote=$ONOS_USER@$node
+remote_with_bracket=$ONOS_USER@[$node]
+SSH_OPTIONS=" -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null \
+ -o ControlMaster=auto -o ControlPath=~/.ssh/mux-%r@%h:%p \
+ -o ControlPersist=300 "
+
+if [ ! -z "$ATOMIX_ROOT" ]; then
+ echo "Pushing to $node from $ATOMIX_ROOT"
+ ATOMIX_TAR=$ATOMIX_ROOT/dist/target/atomix.tar.gz
+elif [ -e $ATOMIX_MAVEN ]; then
+ echo "Pushing to $node from $ATOMIX_MAVEN"
+ ATOMIX_TAR=$ATOMIX_MAVEN
+else
+ echo "Pushing to $node from $ATOMIX_LOCAL"
+ rm $ATOMIX_LOCAL
+ wget -O $ATOMIX_LOCAL $ATOMIX_REMOTE
+ ATOMIX_TAR=$ATOMIX_LOCAL
+fi
+
+echo "Using scp"
+
+locHash=$(cksum $ATOMIX_TAR | cut -d' ' -f1,2)
+remHash=$(ssh $remote cksum /tmp/atomix.tar.gz 2>/dev/null | cut -d' ' -f1,2)
+
+if [ -n "$locHash" ] && [ "$locHash" = "$remHash" ]; then
+ echo "Atomix bits /tmp/atomix.tar.gz already up-to-date on $node..."
+else
+ ssh $remote rm -f $ATOMIX_TAR
+ scp -q $ATOMIX_TAR $remote_with_bracket:/tmp/atomix.tar.gz
+fi
diff --git a/tools/test/bin/atomix-push-bits-through-proxy b/tools/test/bin/atomix-push-bits-through-proxy
new file mode 100755
index 0000000..24e2174
--- /dev/null
+++ b/tools/test/bin/atomix-push-bits-through-proxy
@@ -0,0 +1,27 @@
+#!/bin/bash
+# -----------------------------------------------------------------------------
+# Remotely pushes Atomix bits to all remote nodes in preparation for install.
+# -----------------------------------------------------------------------------
+
+[ ! -d "$ONOS_ROOT" ] && echo "ONOS_ROOT is not defined" >&2 && exit 1
+. $ONOS_ROOT/tools/build/envDefaults
+
+OCT=${OCT:-$OCI}
+node=${1:-$OCT}
+remote=$ONOS_USER@$node
+shift
+
+echo "Pushing to proxy $node..."
+atomix-push-bits $node
+
+others=$(env | sort | egrep "^OCC[0-9]+" | cut -d= -f2 | grep -vE "^$OCT\$")
+
+ssh $remote "
+ for other in ${others//$'\n'/ } ; do
+ echo \"Pushing to \$other ...\";
+ ssh -o StrictHostKeyChecking=no $ONOS_USER@\$other rm -rf /tmp/atomix.tar.gz &&
+ scp -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null \
+ /tmp/atomix.tar.gz \
+ $ONOS_USER@[\$other]:/tmp/atomix.tar.gz
+ done
+"
diff --git a/tools/test/scenarios/setup.xml b/tools/test/scenarios/setup.xml
index ab31d66..41eb65d 100644
--- a/tools/test/scenarios/setup.xml
+++ b/tools/test/scenarios/setup.xml
@@ -15,14 +15,16 @@
-->
<scenario name="setup" description="ONOS cluster setup">
<group name="Setup">
- <step name="Push-Bits" exec="onos-push-bits-through-proxy" if="${OCT}"/>
+ <step name="Push-Atomix-Bits" exec="atomix-push-bits-through-proxy" if="${OCT}"/>
+ <step name="Push-ONOS-Bits" exec="onos-push-bits-through-proxy" if="${OCT}"/>
+
<step name="Enable-Flow-Objective-Intents" if="${ONOS_USE_FOI}"
exec="onos ${OC1} cfg set org.onosproject.net.intent.impl.compiler.IntentConfigurableRegistrator useFlowObjectives true"/>
<group name="Cleanup">
<group name="Cleanup-ONOS">
<parallel var="${OC#}">
- <step name="Push-Bits-${#}" exec="onos-push-bits ${OC#}"
+ <step name="Push-ONOS-Bits-${#}" exec="onos-push-bits ${OC#}"
unless="${OCT}"/>
<step name="Uninstall-${#}" exec="onos-uninstall ${OC#}"/>
<step name="Kill-${#}" env="~" exec="onos-kill ${OC#}"
@@ -31,6 +33,8 @@
</group>
<group name="Cleanup-Atomix-OC" unless="${OCC1}">
<parallel var="${OC#}">
+ <step name="Push-Atomix-Bits-${#}" exec="atomix-push-bits ${OC#}"
+ unless="${OCT}"/>
<step name="Atomix-Kill-${#}"
env="~"
exec="atomix-kill ${OC#}"/>
@@ -41,6 +45,8 @@
</group>
<group name="Cleanup-Atomix-OCC" if="${OCC1}">
<parallel var="${OCC#}">
+ <step name="Push-Atomix-Bits-${#}" exec="atomix-push-bits ${OC#}"
+ unless="${OCT}"/>
<step name="Atomix-Kill-${#}"
env="~"
exec="atomix-kill ${OCC#}"/>
@@ -58,7 +64,7 @@
<group name="Parallel-Install-Atomix">
<parallel var="${OC#}">
<step name="Parallel-Install-Atomix-${#}" exec="atomix-install ${OC#}"
- requires="Generate-Cluster-Key,Push-Bits-${#},Push-Bits,Cleanup"/>
+ requires="Generate-Cluster-Key,Push-Atomix-Bits-${#},Push-Atomix-Bits,Cleanup"/>
</parallel>
</group>
</group>
@@ -67,7 +73,7 @@
<group name="Parallel-Install-Atomix">
<parallel var="${OCC#}">
<step name="Parallel-Install-Atomix-${#}" exec="atomix-install ${OCC#}"
- requires="Generate-Cluster-Key,Push-Bits-${#},Push-Bits,Cleanup"/>
+ requires="Generate-Cluster-Key,Push-Atomix-Bits-${#},Push-Atomix-Bits,Cleanup"/>
</parallel>
</group>
</group>
@@ -79,14 +85,14 @@
starts="Sequential-Install-${#}"
ends="Sequential-Install-${#-1}">
<step name="Sequential-Install-${#}" exec="onos-install ${OC#}"
- requires="Generate-Cluster-Key,Push-Bits-${#},Push-Bits,Cleanup,Install-Atomix"/>
+ requires="Generate-Cluster-Key,Push-ONOS-Bits-${#},Push-ONOS-Bits,Cleanup,Install-Atomix"/>
</sequential>
</group>
<group name="Parallel-Install-ONOS" unless="${ONOS_STC_SEQ_START}">
<parallel var="${OC#}">
<step name="Parallel-Install-${#}" exec="onos-install ${OC#}"
- requires="Generate-Cluster-Key,Push-Bits-${#},Push-Bits,Cleanup,Install-Atomix"/>
+ requires="Generate-Cluster-Key,Push-ONOS-Bits-${#},Push-ONOS-Bits,Cleanup,Install-Atomix"/>
</parallel>
</group>
</group>