Some Optimizations 31/39931/1
authorzhihui wu <wu.zhihui1@zte.com.cn>
Wed, 23 Aug 2017 02:34:52 +0000 (10:34 +0800)
committerzhihui wu <wu.zhihui1@zte.com.cn>
Wed, 23 Aug 2017 02:34:52 +0000 (10:34 +0800)
- remove container and image without -f
- remove duplicated code from verify_storage.sh, replaced by
the script launch_containers_by_testsuite.sh
- move the common sentences from periodic.sh to
launch_containers_by_testsuite.sh
- add 'QTIP' as prompt for print messages

Change-Id: Ia9aa61a3b60c1049af3499a06f2c6cd0dc181552
Signed-off-by: zhihui wu <wu.zhihui1@zte.com.cn>
tests/ci/launch_containers_by_testsuite.sh
tests/ci/periodic.sh
tests/ci/storperf/containers.sh
tests/ci/verify_storage.sh

index ff94a02..c291a79 100755 (executable)
@@ -11,6 +11,12 @@ if [[ -e $ENV_FILE ]];then
     rm $ENV_FILE
 fi
 
+case $INSTALLER_TYPE in
+    apex)
+        INSTALLER_IP=`sudo virsh domifaddr undercloud | grep ipv4 | awk '{print $4}' | cut -d/ -f1`
+        ;;
+esac
+
 echo "INSTALLER_TYPE=$INSTALLER_TYPE" >> $ENV_FILE
 echo "INSTALLER_IP=$INSTALLER_IP" >> $ENV_FILE
 echo "NODE_NAME=$NODE_NAME" >> $ENV_FILE
@@ -24,14 +30,14 @@ if [[ "$TEST_SUITE" == 'compute' ]];then
     echo "--------------------------------------------------------"
 
     if [[ ! -z $(docker ps -a | grep "opnfv/qtip:$DOCKER_TAG") ]]; then
-        echo "Removing existing opnfv/qtip containers..."
+        echo "QTIP: Removing existing opnfv/qtip containers..."
         container_id=$(docker ps -a | grep "opnfv/qtip:$DOCKER_TAG" | awk '{print $1}')
         docker stop $container_id
         docker rm $container_id
     fi
 
     if [[ $(docker images opnfv/qtip:${DOCKER_TAG} | wc -l) -gt 1 ]]; then
-        echo "Removing docker image opnfv/qtip:$DOCKER_TAG..."
+        echo "QTIP: Removing docker image opnfv/qtip:$DOCKER_TAG..."
         docker rmi opnfv/qtip:$DOCKER_TAG
     fi
 
@@ -65,6 +71,6 @@ elif [[ "$TEST_SUITE" == 'storage' ]];then
     clean_containers
     launch_containers
 else
-    echo "Sorry, not support test suite $TEST_SUITE!"
+    echo "QTIP: Sorry, not support test suite $TEST_SUITE!"
     exit 1
 fi
index f208cdc..5bbebb9 100755 (executable)
@@ -13,22 +13,16 @@ export DOCKER_TAG=${DOCKER_TAG:-latest}
 export ENV_FILE=$WORKSPACE/env_file
 QTIP_REPO=/home/opnfv/repos/qtip
 
-case $INSTALLER_TYPE in
-    apex)
-        INSTALLER_IP=`sudo virsh domifaddr undercloud | grep ipv4 | awk '{print $4}' | cut -d/ -f1`
-        ;;
-esac
-
 script_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
 source $script_dir/launch_containers_by_testsuite.sh
 
 container_id=$(docker ps | grep "opnfv/qtip:${DOCKER_TAG}" | awk '{print $1}' | head -1)
 
 if [[ -z "$container_id" ]]; then
-    echo "The container opnfv/qtip has not been properly started. Exiting..."
+    echo "QTIP: The container opnfv/qtip has not been properly started. Exiting..."
     exit 1
 else
-    echo "The container ID is: ${container_id}"
+    echo "QTIP: The container ID is: ${container_id}"
     docker exec -t ${container_id} bash -c "bash ${QTIP_REPO}/tests/ci/run_${TEST_SUITE}_qpi.sh"
 fi
 
index 1c48a62..02a947d 100755 (executable)
@@ -9,20 +9,20 @@
 
 clean_containers()
 {
-    echo "Cleanup existing qtip and storperf containers"
+    echo "QTIP: Cleanup existing qtip and storperf containers"
     docker-compose -f qtip-storperf-docker-compose.yaml down
 
     for name in qtip storperf-master storperf-swaggerui storperf-httpfrontend storperf-reporting
     do
         container=$(docker ps -a | grep "opnfv/${name}:${DOCKER_TAG}" | awk '{print $1}')
         if [[ ! -z "$container" ]]; then
-            echo "Removing any existing $name container"
-            docker rm -fv $container
+            echo "QTIP: Removing any existing $name container"
+            docker rm -v $container
         fi
 
         if [[ $(docker images opnfv/${name}:${DOCKER_TAG} | wc -l) -gt 1 ]]; then
             echo "QTIP: Removing docker image opnfv/$name :$DOCKER_TAG..."
-            docker rmi -f opnfv/${name}:${DOCKER_TAG}
+            docker rmi opnfv/${name}:${DOCKER_TAG}
         fi
     done
 }
@@ -34,16 +34,10 @@ launch_containers()
     docker-compose -f qtip-storperf-docker-compose.yaml pull
     docker-compose -f qtip-storperf-docker-compose.yaml up -d
 
-    echo "Waiting for StorPerf to become active"
+    echo "QTIP: Waiting for StorPerf to become active"
 
     while [ $(curl -s -o /dev/null -I -w "%{http_code}" -X GET http://127.0.0.1:5000/api/v1.0/configurations) != "200" ]
     do
         sleep 1
     done
-
-    container_id=$(docker ps | grep "opnfv/qtip:${DOCKER_TAG}"  | awk '{print $1}' | head -1)
-    if [[ -z "$container_id" ]]; then
-        echo "The container opnfv/qtip with ID=${container_id} has not been properly started. Exiting..."
-        exit 1
-    fi
-}
+}
\ No newline at end of file
index 0012021..32e94f9 100755 (executable)
@@ -7,56 +7,29 @@
 # http://www.apache.org/licenses/LICENSE-2.0
 ##############################################################################
 
-WORKSPACE=${WORKSPACE:=`pwd`}
+TEST_SUITE=storage
+QTIP_REPO=/home/opnfv/repos/qtip
 
 export DOCKER_TAG=${DOCKER_TAG:-latest}
 export ENV_FILE=$WORKSPACE/env_file
 
 script_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
 
-case $INSTALLER_TYPE in
-    apex)
-        INSTALLER_IP=`sudo virsh domifaddr undercloud | grep ipv4 | awk '{print $4}' | cut -d/ -f1`
-        ;;
-esac
-
-git clone --depth 1 https://gerrit.opnfv.org/gerrit/releng $WORKSPACE/releng
-$WORKSPACE/releng/utils/fetch_os_creds.sh -i $INSTALLER_TYPE -a $INSTALLER_IP -d $WORKSPACE/openrc
-
-grep "export" $WORKSPACE/openrc | sed "s/export //"  > $WORKSPACE/env_file
-echo "INSTALLER_TYPE=$INSTALLER_TYPE" >> $WORKSPACE/env_file
-echo "INSTALLER_IP=$INSTALLER_IP" >> $WORKSPACE/env_file
-echo "NODE_NAME=$NODE_NAME" >> $WORKSPACE/env_file
-echo "SCENARIO=$DEPLOY_SCENARIO" >> $WORKSPACE/env_file
-echo "TESTAPI_URL=$TESTAPI_URL" >> $WORKSPACE/env_file
-echo "DOCKER_TAG=$DOCKER_TAG" >> $WORKSPACE/env_file
-
-echo "--------------------ENV_FILE----------------------------"
-cat $WORKSPACE/env_file
-echo "--------------------------------------------------------"
-
-source $script_dir/storperf/containers.sh
-cd $script_dir/storperf
-clean_containers
-launch_containers
+source $script_dir/launch_containers_by_testsuite.sh
 
 container_id=$(docker ps | grep "opnfv/qtip:${DOCKER_TAG}" | awk '{print $1}' | head -1)
 
-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
+if [[ -z "$container_id" ]]; then
+    echo "QTIP: The container opnfv/qtip has not been properly started. Exiting..."
+    exit 1
+else
+    echo "QTIP: Copying current submit patch to the container ${container_id}"
+    cd $WORKSPACE
+    docker cp . ${container_id}:${QTIP_REPO}
+    docker exec ${container_id} bash -c "cd ${QTIP_REPO} && pip install -U -e ."
+    docker exec -t ${container_id} bash -c "bash ${QTIP_REPO}/tests/ci/run_${TEST_SUITE}_qpi.sh"
+    echo "QTIP: Verify ${TEST_SUITE} done!"
+    exit 0
 fi
 
-QTIP_REPO=/home/opnfv/repos/qtip
-
-echo "QTIP: Copying current submit patch to the container ${container_id}"
-cd $WORKSPACE
-docker cp . ${container_id}:${QTIP_REPO}
-docker exec ${container_id} bash -c "cd ${QTIP_REPO} && pip install -U -e ."
-
-docker exec -t ${container_id} bash -c "bash ${QTIP_REPO}/tests/ci/run_storage_qpi.sh"
 
-echo "Verify storage done!"
-exit 0
\ No newline at end of file