diff options
-rwxr-xr-x | tests/functest_run.sh | 74 | ||||
-rwxr-xr-x | tests/parser_install.sh | 2 |
2 files changed, 44 insertions, 32 deletions
diff --git a/tests/functest_run.sh b/tests/functest_run.sh index d60e894..e5341c0 100755 --- a/tests/functest_run.sh +++ b/tests/functest_run.sh @@ -8,7 +8,7 @@ # http://www.apache.org/licenses/LICENSE-2.0 ############################################################################## -PARSER_CI_DEBUG=${CI_DEBUG:-true} +PARSER_CI_DEBUG=${CI_DEBUG:-false} [[ "${PARSER_CI_DEBUG}" == "true" ]] && set -x PARSER_IMAGE_URL_FILE=cirros-0.3.0-x86_64-disk.img @@ -21,6 +21,7 @@ PARSER_VM_FLAVOR=m1.tiny PARSER_USER=parser PARSER_PASSWORD=parser +PARSER_EMAIL='shang.xiaodong@zte.com.cn' PARSER_PROJECT=parser PARSER_TENANT=${PARSER_PROJECT} @@ -41,7 +42,7 @@ download_parser_image() { } echo "Download image ${PARSER_IMAGE_URL_FILE}..." - wget "${PARSER_IMAGE_URL}" -o "${PARSER_IMAGE_FILE}" + wget ${PARSER_IMAGE_URL} -o ${PARSER_IMAGE_FILE} } register_parser_image() { @@ -53,36 +54,39 @@ register_parser_image() { echo "Registe image ${PARSER_IMAGE_NAME}..." openstack image create "${PARSER_IMAGE_NAME}" \ --public \ - --disk-format "${PARSER_IMAGE_FORMAT}" \ + --disk-format ${PARSER_IMAGE_FORMAT} \ --container-format bare \ - --file "${PARSER_IMAGE_FILE}" + --file ${PARSER_IMAGE_FILE} } create_parser_user_and_project() { - # 1. create parser user. - openstack user list | grep -qwo "${PARSER_USER}" && { - echo "User ${PARSER_USER} exist, doesn't create again." - } || { - openstack user create "${PARSER_USER}" --password "${PARSER_PASSWORD}" - echo "Create user ${PARSER_USER} successful." - } - # 2. create parser project + # 1. create parser project openstack project list | grep -qwo "${PARSER_PROJECT}" && { echo "Project ${PARSER_PROJECT} exist, doesn't create agian." } || { - openstack project create "${PARSER_PROJECT}" + openstack project create ${PARSER_PROJECT} \ + --description "Project for parser test" echo "Create project ${PARSER_PROJECT} successful." } + # 2. create parser user. + openstack user list | grep -qwo ${PARSER_USER} && { + echo "User ${PARSER_USER} exist, doesn't create again." + } || { + openstack user create ${PARSER_USER} --password ${PARSER_PASSWORD} \ + --project ${PARSER_PROJECT} --email ${PARSER_EMAIL} + echo "Create user ${PARSER_USER} successful." + } + # 3. grant role for parser user - openstack user role list "${PARSER_USER}" --project "${PARSER_PROJECT}" \ - | grep -qow " ${PARSER_ROLE}" && { + openstack user role list ${PARSER_USER} --project ${PARSER_PROJECT} \ + | grep -qow ${PARSER_ROLE} && { echo "User ${PARSER_USER} has role ${PARSER_ROLE} in project ${PARSER_PROJECT}, doesn't create." } || { - openstack role add "${PARSER_ROLE}" --user "${PARSER_USER}" \ - --project "${PARSER_PROJECT}" + openstack role add ${PARSER_ROLE} --user ${PARSER_USER} \ + --project ${PARSER_PROJECT} echo "Grant user ${PARSER_USER} the role ${PARSER_ROLE} in project ${PARSER_PROJECT} successful." } @@ -90,10 +94,10 @@ create_parser_user_and_project() { change_env_to_parser_user_project() { - export OS_USERNAME="$PARSER_USER" - export OS_PASSWORD="$PARSER_PASSWORD" - export OS_PROJECT_NAME="$PARSER_PROJECT" - export OS_TENANT_NAME="$PARSER_TENANT" + export OS_USERNAME=${PARSER_USER} + export OS_PASSWORD=${PARSER_PASSWORD} + export OS_PROJECT_NAME=${PARSER_PROJECT} + export OS_TENANT_NAME=${PARSER_TENANT} } @@ -105,7 +109,7 @@ translator_and_deploy_vRNC() { openstack stack delete --yes --wait ${PARSER_STACK_NAME} } # 2. Switch env to parser project temporally - echo "switch openstak env to parser project" + echo "switch openstack env to parser project" change_env_to_parser_user_project # 3. Translator yaml @@ -118,6 +122,7 @@ translator_and_deploy_vRNC() { openstack stack create -t ${VRNC_OUTPUT_TEMPLATE_FILE} ${PARSER_STACK_NAME} # 5. Wait for create vRNC + echo "Waiting for deploying stack..." sleep 180 # 6. Validate the deploy result. @@ -202,34 +207,39 @@ reset_parser_test() { --project "${PARSER_PROJECT}" } + openstack user list | grep -qow "${PARSER_USER}" && { + openstack user delete "${PARSER_USER}" + } + openstack project list | grep -qwo "${PARSER_PROJECT}" && { openstack project delete "${PARSER_PROJECT}" } - openstack user list | grep -qow "${PARSER_USER}" && { - openstack user delete "${PARSER_USER}" - } + echo "" + echo "======================= Parser functest end ==========================" + echo "" + echo "" } - +echo "" +echo "" echo "======================= Parser functest begin ==========================" +echo "" trap reset_parser_test EXIT # start syslog for loghander service rsyslog restart -echo " ========= 1/4. Preparing VM image for parser... ========= " +echo "|========= 1/4. Preparing VM image for parser... =========|" download_parser_image register_parser_image -echo " ========= 2/4. Creating test user for parser... ========= " +echo "|========= 2/4. Creating test user for parser... =========|" create_parser_user_and_project -echo " ========= 3/4. Parse -> translate -> deploy vRNC... ========= " +echo "|========= 3/4. Parse -> translate -> deploy vRNC... =========|" translator_and_deploy_vRNC -echo " ========= 4/4. Test ok... ========= " - -echo "======================= Parser functest end ==========================" +echo "|========= 4/4. Test ok... =========|" diff --git a/tests/parser_install.sh b/tests/parser_install.sh index 48f07ac..308b8bc 100755 --- a/tests/parser_install.sh +++ b/tests/parser_install.sh @@ -8,6 +8,8 @@ # http://www.apache.org/licenses/LICENSE-2.0 ############################################################################## +set +e + parser_repos_dir=$1 # start syslog for loghander |