aboutsummaryrefslogtreecommitdiffstats
path: root/test/ete/scripts
diff options
context:
space:
mode:
Diffstat (limited to 'test/ete/scripts')
-rwxr-xr-xtest/ete/scripts/deploy-onap.sh87
-rwxr-xr-xtest/ete/scripts/dns-zones/delete-dns-zones.sh27
-rwxr-xr-xtest/ete/scripts/get-floating-ip.sh7
-rwxr-xr-xtest/ete/scripts/install_openstack_cli.sh4
-rwxr-xr-xtest/ete/scripts/post-jenkins-results.sh6
-rwxr-xr-xtest/ete/scripts/pull-docker-images.sh22
-rwxr-xr-xtest/ete/scripts/remote/run-robot.sh16
-rwxr-xr-xtest/ete/scripts/run-healthcheck.sh12
-rwxr-xr-xtest/ete/scripts/teardown-onap.sh54
9 files changed, 206 insertions, 29 deletions
diff --git a/test/ete/scripts/deploy-onap.sh b/test/ete/scripts/deploy-onap.sh
index 69296ab17..68ca34830 100755
--- a/test/ete/scripts/deploy-onap.sh
+++ b/test/ete/scripts/deploy-onap.sh
@@ -1,26 +1,91 @@
-#!/bin/bash
+#!/bin/bash -x
+
+if [ "$#" -ne 1 ]; then
+ echo "Usage: $0 <lab-name>"
+ exit 1
+fi
if [ -z "$WORKSPACE" ]; then
export WORKSPACE=`git rev-parse --show-toplevel`
fi
+LAB_DIR=${WORKSPACE}/test/ete/labs/$1
+
+if [ ! -d "$LAB_DIR" ]; then
+ echo "Directory $LAB_DIR not found"
+ exit 2
+fi
+
source $WORKSPACE/test/ete/scripts/install_openstack_cli.sh
-# Delete all existing stacks
-STACKS=$(openstack stack list -c "Stack Name" -f value)
-if [ ! -z "${STACKS}" ]; then
- echo "Deleting Stacks ${STACKS}"
- openstack stack delete -y $STACKS
-else
- echo "No existing stacks to delete."
+
+SENTINEL='Docker versions and branches'
+
+mkdir -p ${LAB_DIR}/target
+YAML_FILE=${LAB_DIR}/target/onap_openstack.yaml
+ENV_FILE=${LAB_DIR}/target/onap_openstack.env
+YAML_SRC=${ONAP_WORKDIR}/demo/heat/ONAP/onap_openstack.yaml
+ENV_SRC=${ONAP_WORKDIR}/demo/heat/ONAP/onap_openstack.env
+
+# copy heat template to WORKSPACE
+cp ${YAML_SRC} ${YAML_FILE}
+
+# generate final env file
+pushd ${ONAP_WORKDIR}/demo
+envsubst < ${LAB_DIR}/onap-openstack-template.env | sed -n "1,/${SENTINEL}/p" > ${ENV_FILE}
+echo " # Rest of the file was AUTO-GENERATED from" | tee -a ${ENV_FILE}
+echo " #" $(git config --get remote.origin.url) heat/ONAP/onap_openstack.env $(git rev-parse HEAD) | tee -a ${ENV_FILE}
+popd
+sed "1,/${SENTINEL}/d" ${ENV_SRC} >> ${ENV_FILE}
+cat ${ENV_FILE}
+
+sdiff -w 180 ${ENV_SRC} ${ENV_FILE}
+
+# generate final heat template
+# add apt proxy to heat template if applicable
+if [ -x $LAB_DIR/apt-proxy.sh ]; then
+ $LAB_DIR/apt-proxy.sh ${YAML_FILE}
+ sdiff -w 180 ${YAML_SRC} ${YAML_FILE}
fi
+
+#exit 0
+
+#diff ${LAB_DIR}/onap-openstack-template.env ${LAB_DIR}/onap-openstack.env
+
+
+# tear down old deployment
+$WORKSPACE/test/ete/scripts/teardown-onap.sh
+
+# create new stack
STACK="ete-$(uuidgen | cut -c-8)"
echo "New Stack Name: ${STACK}"
+openstack stack create -t ${YAML_FILE} -e ${ENV_FILE} $STACK
+
+while [ "CREATE_IN_PROGRESS" == "$(openstack stack show -c stack_status -f value $STACK)" ]; do
+ sleep 20
+done
+STATUS=$(openstack stack show -c stack_status -f value $STACK)
+echo $STATUS
+if [ "CREATE_COMPLETE" != "$STATUS" ]; then
+ exit 1
+fi
+
+
+# wait until Robot VM initializes
+ROBOT_IP=$($WORKSPACE/test/ete/scripts/get-floating-ip.sh onap-robot)
+echo "ROBOT_IP=${ROBOT_IP}"
+
+if [ "" == "${ROBOT_IP}" ]; then
+ exit 1
+fi
-cp ${ONAP_WORKDIR}/demo/heat/ONAP/onap_openstack.env ${WORKSPACE}/test/ete/labs/windriver/onap-openstack-demo.env
-envsubst < ${WORKSPACE}/test/ete/labs/windriver/onap-openstack-template.env > ${WORKSPACE}/test/ete/labs/windriver/onap-openstack.env
+ssh-keygen -R ${ROBOT_IP}
-openstack stack create -t ${ONAP_WORKDIR}/demo/heat/ONAP/onap_openstack.yaml -e ${WORKSPACE}/test/ete/labs/windriver/onap-openstack.env $STACK
+SSH_KEY=~/.ssh/onap_key
+until ssh -o StrictHostKeychecking=no -i ${SSH_KEY} ubuntu@${ROBOT_IP} "sudo docker ps" | grep openecompete_container
+do
+ sleep 2m
+done
diff --git a/test/ete/scripts/dns-zones/delete-dns-zones.sh b/test/ete/scripts/dns-zones/delete-dns-zones.sh
new file mode 100755
index 000000000..54cafecd8
--- /dev/null
+++ b/test/ete/scripts/dns-zones/delete-dns-zones.sh
@@ -0,0 +1,27 @@
+#!/bin/bash -x
+
+if [ "$#" -ne 1 ]; then
+ echo "Usage: $0 <project-name>"
+ exit 1
+fi
+
+if [ -z "$WORKSPACE" ]; then
+ export WORKSPACE=`git rev-parse --show-toplevel`
+fi
+
+MULTICLOUD_IP=$($WORKSPACE/test/ete/scripts/get-floating-ip.sh onap-multi-service)
+
+export MULTICLOUD_PLUGIN_ENDPOINT=http://$MULTICLOUD_IP:9005/api/multicloud-titanium_cloud/v0/pod25_RegionOne
+
+export TOKEN=$(curl -v -s -H "Content-Type: application/json" -X POST -d '{"auth": {"identity": {"methods": ["password"],"password": {"user": {"name": "'$OS_USERNAME'","password": "'$OS_PASSWORD'"}}},"scope": {"project":{"domain":{"name":"Default"},"name": "'$1'" } }}}' $MULTICLOUD_PLUGIN_ENDPOINT/identity/v3/auth/tokens 2>&1 | grep X-Subject-Token | sed "s/^.*: //")
+
+
+ZONES=$(curl -v -s -H "Content-Type: application/json" -H "X-Auth-Token: $TOKEN" -X GET $MULTICLOUD_PLUGIN_ENDPOINT/dns-delegate/v2/zones | jq '.["zones"][] | .name' | tr -d '"' )
+
+echo $ZONES
+
+for ZONENAME in $ZONES; do
+ echo $ZONENAME;
+ export ZONEID=$(curl -v -s -H "Content-Type: application/json" -H "X-Auth-Token: $TOKEN" -X GET $MULTICLOUD_PLUGIN_ENDPOINT/dns-delegate/v2/zones?name=$ZONENAME |sed 's/^.*"id":"\([a-zA-Z0-9-]*\)",.*$/\1/')
+ curl -v -s -H "Content-Type: application/json" -H "X-Auth-Token: $TOKEN" -X DELETE $MULTICLOUD_PLUGIN_ENDPOINT/dns-delegate/v2/zones/$ZONEID
+done
diff --git a/test/ete/scripts/get-floating-ip.sh b/test/ete/scripts/get-floating-ip.sh
index 55854e73f..196f6d244 100755
--- a/test/ete/scripts/get-floating-ip.sh
+++ b/test/ete/scripts/get-floating-ip.sh
@@ -1,6 +1,3 @@
-#!/bin/sh
+#!/bin/bash
# Get floating IP assigned to a server name
-
-PORT_ID=$(openstack server show -f json $1 | python -c 'import sys, json; print json.load(sys.stdin)["wrs-if:nics"][0]["nic1"]["port_id"]')
-FLOATING_IP=$(openstack floating ip list -f json --port $PORT_ID | python -c 'import sys, json; print json.load(sys.stdin)[0]["Floating IP Address"]')
-echo $FLOATING_IP
+openstack server show -c addresses -f json $1 | jq -r '.addresses' | tr -d ' ' | cut -d ',' -f 2
diff --git a/test/ete/scripts/install_openstack_cli.sh b/test/ete/scripts/install_openstack_cli.sh
index ec5ad1f76..8f1529606 100755
--- a/test/ete/scripts/install_openstack_cli.sh
+++ b/test/ete/scripts/install_openstack_cli.sh
@@ -26,7 +26,7 @@ else
source ${ONAP_VENV}/bin/activate
pip install --upgrade pip
- pip install --upgrade python-openstackclient python-heatclient
+ pip install openstacksdk==0.9.19 python-openstackclient python-heatclient python-designateclient
echo "ONAP_VENV=${ONAP_VENV}" >> $WORKSPACE/env.properties
fi
@@ -38,7 +38,7 @@ if [ -z "$ONAP_WORKDIR" ]; then
fi
echo "ONAP_WORKDIR=${ONAP_WORKDIR}"
if [ ! -d ${ONAP_WORKDIR}/demo ]; then
- git clone http://gerrit.onap.org/r/demo ${ONAP_WORKDIR}/demo
+ git clone https://gerrit.onap.org/r/demo ${ONAP_WORKDIR}/demo
else
pushd ${ONAP_WORKDIR}/demo
git pull
diff --git a/test/ete/scripts/post-jenkins-results.sh b/test/ete/scripts/post-jenkins-results.sh
new file mode 100755
index 000000000..8e01e6cde
--- /dev/null
+++ b/test/ete/scripts/post-jenkins-results.sh
@@ -0,0 +1,6 @@
+#!/bin/bash -x
+
+CRUMB=$(curl -s -u "lf:lf" 'http://12.234.32.117/jenkins/crumbIssuer/api/xml?xpath=concat(//crumbRequestField,":",//crumb)')
+
+curl -v -u "lf:eea50a6d845752e1d2fa459a3c0ca25e" -H "$CRUMB" -d '<run><log encoding="hexBinary">4142430A</log><result>0</result><duration>17</duration></run>' http://12.234.32.117/jenkins/job/external-job/postBuildResult
+
diff --git a/test/ete/scripts/pull-docker-images.sh b/test/ete/scripts/pull-docker-images.sh
new file mode 100755
index 000000000..e14ee8349
--- /dev/null
+++ b/test/ete/scripts/pull-docker-images.sh
@@ -0,0 +1,22 @@
+#!/bin/bash -x
+
+# this script will pull all the docker images listed in the manifest
+# specify a parameter to override the default proxy of nexus3.onap.org:100001
+
+if [ "$#" -ne 1 ]; then
+ PROXY=nexus3.onap.org:10001
+else
+ PROXY=$1
+fi
+
+
+if [ -z "$WORKSPACE" ]; then
+ export WORKSPACE=`git rev-parse --show-toplevel`
+fi
+
+MANIFEST=${WORKSPACE}/version-manifest/src/main/resources/docker-manifest.csv
+IMAGES=$(tail -n +2 $MANIFEST | tr ',' ':')
+
+for image in $IMAGES; do
+ docker pull ${PROXY}/${image}
+done
diff --git a/test/ete/scripts/remote/run-robot.sh b/test/ete/scripts/remote/run-robot.sh
index ff7223a17..162acbe24 100755
--- a/test/ete/scripts/remote/run-robot.sh
+++ b/test/ete/scripts/remote/run-robot.sh
@@ -1,18 +1,20 @@
-#!/bin/bash
+#!/bin/bash -x
cd /opt
-if [ ! -x /opt/demo.sh ]; then
- echo "Robot VM not initialized"
+docker ps | grep -q openecompete_container
+if [ ! $? -eq 0 ]; then
+ echo "Robot not initialized"
exit 2
fi
if [ ! -d eteshare/logs/demo ]; then
- echo "09d8566ea45e43aa974cf447ed591d77" > /opt/config/openstack_tenant_id.txt
- echo "gary_wu" > /opt/config/openstack_username.txt
- echo $OS_PASSWORD_INPUT > /opt/config/openstack_password.txt
+ echo $OS_PROJECT_ID > /opt/config/openstack_tenant_id.txt
+ echo $OS_USERNAME > /opt/config/openstack_username.txt
+ echo $OS_PASSWORD > /opt/config/openstack_password.txt
/bin/bash /opt/eteshare/config/vm_config2robot.sh
- echo "test" | /opt/demo.sh init_robot
+ # set robot VM http server password
+ echo "admin" | /opt/demo.sh init_robot
fi
/opt/ete.sh health
diff --git a/test/ete/scripts/run-healthcheck.sh b/test/ete/scripts/run-healthcheck.sh
index 1555dad85..2f0f014d3 100755
--- a/test/ete/scripts/run-healthcheck.sh
+++ b/test/ete/scripts/run-healthcheck.sh
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/bin/bash -x
SSH_KEY=~/.ssh/onap_key
@@ -13,10 +13,14 @@ cd $WORKSPACE/test/ete/scripts
ROBOT_IP=$(./get-floating-ip.sh onap-robot)
echo "ROBOT_IP=${ROBOT_IP}"
-# allow direct login as root
-ssh -o StrictHostKeychecking=no -i ${SSH_KEY} ubuntu@${ROBOT_IP} 'sudo cp /home/ubuntu/.ssh/authorized_keys /root/.ssh/'
+if [ "" == "${ROBOT_IP}" ]; then
+ exit 1
+fi
+
+ssh-keygen -R ${ROBOT_IP}
+
+ssh -o StrictHostKeychecking=no -i ${SSH_KEY} root@${ROBOT_IP} "OS_PROJECT_ID=$OS_PROJECT_ID OS_USERNAME=$OS_USERNAME OS_PASSWORD=$OS_PASSWORD bash -s" < ./remote/run-robot.sh
-ssh -o StrictHostKeychecking=no -i ${SSH_KEY} root@${ROBOT_IP} "OS_PASSWORD_INPUT=$OS_PASSWORD_INPUT bash -s" < ./remote/run-robot.sh
LOG_DIR=$(ssh -o StrictHostKeychecking=no -i ${SSH_KEY} root@${ROBOT_IP} "ls -1t /opt/eteshare/logs | head -1")
echo "Browse Robot results at http://${ROBOT_IP}:88/logs/${LOG_DIR}/"
rsync -e "ssh -i ${SSH_KEY}" -avPz root@${ROBOT_IP}:/opt/eteshare/logs/${LOG_DIR}/ $WORKSPACE/archives/
diff --git a/test/ete/scripts/teardown-onap.sh b/test/ete/scripts/teardown-onap.sh
new file mode 100755
index 000000000..eecef876b
--- /dev/null
+++ b/test/ete/scripts/teardown-onap.sh
@@ -0,0 +1,54 @@
+#!/bin/bash -x
+
+if [ -z "$WORKSPACE" ]; then
+ export WORKSPACE=`git rev-parse --show-toplevel`
+fi
+
+source $WORKSPACE/test/ete/scripts/install_openstack_cli.sh
+
+# delete all Designate DNS records; do this first since we rely on multi-vim for this
+$WORKSPACE/test/ete/scripts/dns-zones/delete-dns-zones.sh $OS_PROJECT_NAME
+sleep 1
+
+# delete all instances
+openstack server delete $(openstack server list -c ID -f value)
+sleep 1
+
+# miscellaneous cleanup
+openstack floating ip delete $(openstack floating ip list -c ID -f value)
+sleep 1
+
+ROUTERS=$(openstack router list -c ID -f value)
+echo $ROUTERS
+for ROUTER in $ROUTERS; do
+ echo $ZONENAME;
+ PORTS=$(openstack router show $ROUTER -c "interfaces_info" -f "value" | jq -r '.[].port_id')
+ for PORT in $PORTS; do
+ openstack router remove port $ROUTER $PORT
+ done
+ openstack router delete $ROUTER
+done
+
+openstack port delete $(openstack port list -f value -c ID)
+openstack volume delete $(openstack volume list -f value -c ID)
+
+# delete all except "default" security group
+SECURITY_GROUPS=$(openstack security group list -c Name -f value | grep -v default)
+openstack security group delete $SECURITY_GROUPS
+sleep 1
+
+
+# Delete all existing stacks
+STACKS=$(openstack stack list -c "Stack Name" -f value)
+
+if [ ! -z "${STACKS}" ]; then
+ echo "Deleting Stacks ${STACKS}"
+ openstack stack delete -y $STACKS
+ for STACK in ${STACKS}; do
+ until [ "DELETE_IN_PROGRESS" != "$(openstack stack show -c stack_status -f value $STACK)" ]; do
+ sleep 2
+ done
+ done
+else
+ echo "No existing stacks to delete."
+fi