From 4a4017165a7d6d63d7ad79bd9681f0e9302bf42b Mon Sep 17 00:00:00 2001 From: zhihui wu Date: Fri, 11 Aug 2017 17:23:49 +0800 Subject: compute-qpi CI scripts - Move compute-qpi ci scripts in releng repos to qtip repos. - Support apex - Introduce TEST_SUITE JIRA: QTIP-65 Change-Id: I3633463e1bb5226ebcaffb4b53a3c56b433f6efb Signed-off-by: zhihui wu --- tests/ci/periodic.sh | 77 +++++++++++++++++++++++++++++++++++ tests/ci/run_ci.sh | 99 --------------------------------------------- tests/ci/run_compute_qpi.sh | 95 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 172 insertions(+), 99 deletions(-) create mode 100755 tests/ci/periodic.sh delete mode 100644 tests/ci/run_ci.sh create mode 100644 tests/ci/run_compute_qpi.sh (limited to 'tests') diff --git a/tests/ci/periodic.sh b/tests/ci/periodic.sh new file mode 100755 index 00000000..4235cdee --- /dev/null +++ b/tests/ci/periodic.sh @@ -0,0 +1,77 @@ +#! /bin/bash +############################################################################## +# Copyright (c) 2017 ZTE and others. +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Apache License, Version 2.0 +# which accompanies this distribution, and is available at +# http://www.apache.org/licenses/LICENSE-2.0 +############################################################################## +set -e + + +case $INSTALLER_TYPE in + apex) + INSTALLER_IP=`sudo virsh domifaddr undercloud | grep ipv4 | awk '{print $4}' | cut -d/ -f1` + ;; +esac + +cat << EOF > $WORKSPACE/env_file +INSTALLER_TYPE=$INSTALLER_TYPE +INSTALLER_IP=$INSTALLER_IP +POD_NAME=$NODE_NAME +SCENARIO=$DEPLOY_SCENARIO +TESTAPI_URL=$TESTAPI_URL +EOF + +echo "--------------------------------------------------------" +cat $WORKSPACE/env_file +echo "--------------------------------------------------------" + +# Remove previous running containers if exist +if [[ ! -z $(docker ps -a | grep "opnfv/qtip:$DOCKER_TAG") ]]; then + echo "Removing existing opnfv/qtip containers..." + # workaround: sometimes it throws an error when stopping qtip container. + # To make sure ci job unblocked, remove qtip container by force without stopping it. + docker rm -f $(docker ps -a | grep "opnfv/qtip:$DOCKER_TAG" | awk '{print $1}') +fi + +# Remove existing images if exist +if [[ $(docker images opnfv/qtip:${DOCKER_TAG} | wc -l) -gt 1 ]]; then + echo "Removing docker image opnfv/qtip:$DOCKER_TAG..." + docker rmi -f opnfv/qtip:$DOCKER_TAG +fi + +echo "Qtip: Pulling docker image: opnfv/qtip:${DOCKER_TAG}" +docker pull opnfv/qtip:$DOCKER_TAG >/dev/null + +envs="--env-file $WORKSPACE/env_file" +docker_volume="-v /var/run/docker.sock:/var/run/docker.sock" + +cmd="docker run -id ${envs} ${docker_volume} opnfv/qtip:${DOCKER_TAG} /bin/bash" +echo "Qtip: Running docker command: ${cmd}" +${cmd} + +container_id=$(docker ps | grep "opnfv/qtip:${DOCKER_TAG}" | awk '{print $1}' | head -1) +if [ $(docker ps | grep 'opnfv/qtip' | wc -l) == 0 ]; then + echo "The container opnfv/qtip with ID=${container_id} has not been properly started. Exiting..." + exit 1 +fi + +echo "The container ID is: ${container_id}" +QTIP_REPO=/home/opnfv/repos/qtip + +if [[ "$INSTALLER_TYPE" == "apex" ]];then + if [ -f /root/.ssh/id_rsa ]; then + sudo chmod 600 /root/.ssh/id_rsa + sudo docker cp /root/.ssh/id_rsa ${container_id}:/root/.ssh/ + fi +fi + +case $TEST_SUITE in + compute) + docker exec -t ${container_id} bash -c "bash ${QTIP_REPO}/tests/ci/run_compute_qpi.sh" + ;; +esac + +echo "Qtip done!" +exit 0 \ No newline at end of file diff --git a/tests/ci/run_ci.sh b/tests/ci/run_ci.sh deleted file mode 100644 index 02dfca09..00000000 --- a/tests/ci/run_ci.sh +++ /dev/null @@ -1,99 +0,0 @@ -#!/bin/bash -############################################################################## -# Copyright (c) 2017 ZTE and others. -# All rights reserved. This program and the accompanying materials -# are made available under the terms of the Apache License, Version 2.0 -# which accompanies this distribution, and is available at -# http://www.apache.org/licenses/LICENSE-2.0 -############################################################################## -set -e - -usage(){ - echo "usage: $0 -t -i -p -s -r " >&2 -} - -verify_connectivity(){ - local ip=$1 - echo "Verifying connectivity to $ip..." - for i in $(seq 0 10); do - if ping -c 1 -W 1 $ip > /dev/null; then - echo "$ip is reachable!" - return 0 - fi - sleep 1 - done - error "Can not talk to $ip." -} - -#Getoptions -while getopts ":t:i:p:s:r:he" optchar; do - case "${optchar}" in - t) installer_type=${OPTARG} ;; - i) installer_ip=${OPTARG} ;; - p) pod_name=${OPTARG} ;; - s) scenario=${OPTARG} ;; - r) testapi_url=${OPTARG} ;; - h) usage - exit 0 - ;; - *) echo "Non-option argument: '-${OPTARG}'" >&2 - usage - exit 2 - ;; - esac -done - -#set vars from env if not provided by user as options -installer_type=${installer_type:-$INSTALLER_TYPE} -installer_ip=${installer_ip:-$INSTALLER_IP} -pod_name=${pod_name:-$POD_NAME} -scenario=${scenario:-$SCENARIO} -testapi_url=${testapi_url:-$TESTAPI_URL} - -sshoptions="-o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null" - -verify_connectivity ${installer_ip} - -ssh-keygen -t rsa -N "" -f ~/.ssh/id_rsa -q - -# ssh-copy-id publickey to installer -case "$installer_type" in - fuel) - sshpass -p r00tme ssh-copy-id $sshoptions ${installer_ip} - ;; - *) - echo "Unkown installer $installer_type specified" - exit 1 - ;; -esac - -cd /home/opnfv - -qtip create --pod-name ${pod_name} --installer-type ${installer_type} \ ---installer-host ${installer_ip} --scenario ${scenario} workspace - -cd /home/opnfv/workspace/ - -qtip setup -eval `ssh-agent` -if [[ -z $testapi_url ]];then - qtip run -else - qtip run --extra-vars "testapi_url=$testapi_url" -fi -qtip teardown - -# Remove ssh public key from installer -case "$installer_type" in - fuel) - publickey=$(sed -r 's/\//\\\//g' /root/.ssh/id_rsa.pub) - ssh $sshoptions root@${installer_ip} "sed -i '/$publickey/d' /root/.ssh/authorized_keys" - ;; - *) - echo "Not support $installer_type." - exit 1 - ;; -esac - -echo "Qtip done!" -exit 0 \ No newline at end of file diff --git a/tests/ci/run_compute_qpi.sh b/tests/ci/run_compute_qpi.sh new file mode 100644 index 00000000..09762b15 --- /dev/null +++ b/tests/ci/run_compute_qpi.sh @@ -0,0 +1,95 @@ +#!/bin/bash +############################################################################## +# Copyright (c) 2017 ZTE and others. +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Apache License, Version 2.0 +# which accompanies this distribution, and is available at +# http://www.apache.org/licenses/LICENSE-2.0 +############################################################################## +set -e + +usage(){ + echo "usage: $0 -t -i -p -s -r " >&2 +} + +verify_connectivity(){ + local ip=$1 + echo "Verifying connectivity to $ip..." + for i in $(seq 0 10); do + if ping -c 1 -W 1 $ip > /dev/null; then + echo "$ip is reachable!" + return 0 + fi + sleep 1 + done + error "Can not talk to $ip." +} + +#Getoptions +while getopts ":t:i:p:s:r:he" optchar; do + case "${optchar}" in + t) installer_type=${OPTARG} ;; + i) installer_ip=${OPTARG} ;; + p) pod_name=${OPTARG} ;; + s) scenario=${OPTARG} ;; + r) testapi_url=${OPTARG} ;; + h) usage + exit 0 + ;; + *) echo "Non-option argument: '-${OPTARG}'" >&2 + usage + exit 2 + ;; + esac +done + +#set vars from env if not provided by user as options +installer_type=${installer_type:-$INSTALLER_TYPE} +installer_ip=${installer_ip:-$INSTALLER_IP} +pod_name=${pod_name:-$POD_NAME} +scenario=${scenario:-$SCENARIO} +testapi_url=${testapi_url:-$TESTAPI_URL} + +# we currently support ericsson, intel, lf and zte labs +if [[ ! "$installer_type" =~ (fuel|apex) ]]; then + echo "Unsupported/unidentified installer $installer_type. Cannot continue!" + exit 1 +fi + +sshoptions="-o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null" + +verify_connectivity ${installer_ip} + +case "$installer_type" in + fuel) + ssh-keygen -t rsa -N "" -f ~/.ssh/id_rsa -q + sshpass -p r00tme ssh-copy-id $sshoptions ${installer_ip} + ;; +esac + +cd /home/opnfv + +qtip create --pod-name ${pod_name} --installer-type ${installer_type} \ +--installer-host ${installer_ip} --scenario ${scenario} workspace + +cd /home/opnfv/workspace/ + +qtip setup +eval `ssh-agent` +if [[ -z $testapi_url ]];then + qtip run +else + qtip run --extra-vars "testapi_url=$testapi_url" +fi +qtip teardown + +# Remove ssh public key from installer +case "$installer_type" in + fuel) + publickey=$(sed -r 's/\//\\\//g' /root/.ssh/id_rsa.pub) + ssh $sshoptions root@${installer_ip} "sed -i '/$publickey/d' /root/.ssh/authorized_keys" + ;; +esac + +echo "Compute QPI done!" +exit 0 \ No newline at end of file -- cgit 1.2.3-korg