"ovno")
${repos_dir}/ovno/Testcases/RunTests.sh
;;
+ *)
+ echo "The test case '${test_name}' does not exist."
+ exit 1
esac
}
# Source credentials
-echo "Sourcing Credentials ${FUNCTEST_CONF_DIR}/openstack.creds to run the tests.."
+echo "Sourcing Credentials ${FUNCTEST_CONF_DIR}/openstack.creds to run the test.."
source ${FUNCTEST_CONF_DIR}/openstack.creds
logger.debug("Executing command: %s" % cmd)
p = subprocess.Popen(cmd.split(), stdout=subprocess.PIPE)
output = p.communicate()[0]
- logger.debug(output)
+ logger.debug("\n%s" % output)
if p.returncode != 0:
logger.error("Failed to fetch credentials from installer.")
sys.exit(1)
sys.exit()
if args.action == "start":
- print ("\n######### Preparing Functest environment #########\n")
+ logger.info("\n######### Preparing Functest environment #########\n")
check_env_variables()
create_directories()
source_rc_file()
""" logging configuration """
-logger = ft_logger.Logger("run_test").getLogger()
+logger = ft_logger.Logger("run_tests").getLogger()
""" global variables """
line = ""
for i in range(0, count - 1):
line += str
-
logger.info("%s" % line)
def cleanup():
- print_separator("+")
- logger.info("Cleaning OpenStack resources...")
- print_separator("+")
clean_os.main()
- print_separator("")
def run_test(test):
test_name = test.get_name()
- print_separator("")
print_separator("=")
logger.info("Running test case '%s'..." % test_name)
print_separator("=")
cmd = ("%s%s" % (EXEC_SCRIPT, flags))
logger.debug("Executing command '%s'" % cmd)
- print_separator("")
p = subprocess.Popen(cmd, stdout=subprocess.PIPE, shell=True)
line = p.stdout.readline().rstrip()
logger.debug(line)
- if p != 0:
- logger.error("The command '%s' failed. Cleaning and exiting." % cmd)
+ if p.returncode != 0:
+ logger.error("The test case '%s' failed. Cleaning and exiting."
+ % test_name)
if CLEAN_FLAG:
cleanup()
sys.exit(1)
cleanup()
-
def run_tier(tier):
print_separator("#")
logger.info("Running tier '%s'" % tier.get_name())
def run_all(tiers):
- logger.debug("Tiers to be executed:")
+ summary = ""
for tier in tiers.get_tiers():
- logger.info("\n - %s. %s:\n\t%s"
- % (tier.get_order(), tier.get_name(), tier.get_tests()))
+ summary += ("\n - %s. %s:\n\t %s"
+ % (tier.get_order(),
+ tier.get_name(),
+ tier.get_test_names()))
+
+ logger.info("Tiers to be executed:%s" % summary)
for tier in tiers.get_tiers():
run_tier(tier)
testcases:
-
name: vping_ssh
- description: |-
- This test case verifies:
- ····1) SSH to an instance using floating IPs over the public network.
- ····2) Connectivity between 2 instances over a private network.
+ description: >-
+ This test case verifies: 1) SSH to an instance using floating
+ IPs over the public network. 2) Connectivity between 2 instances
+ over a private network.
dependencies:
installer: ''
scenario: '^((?!bgpvpn).)*$'
-
name: vping_userdata
- description: |-
- This test case verifies:
- ····1) Boot a VM with given userdata.
- ····2) Connectivity between 2 instances over a private network.
- dependencies:
- installer: ''
- scenario: ''
-
- -
- name: tempest_smoke_serial
- description: >-
- This test case runs the smoke subset of the OpenStack
- Tempest suite. The list of test cases is generated by
- Tempest automatically and depend on the parameters of
- the OpenStack deplopyment.
- dependencies:
- installer: ''
- scenario: ''
-
- -
- name: rally_sanity
description: >-
- This test case runs a sub group of tests of the OpenStack
- Rally suite in smoke mode.
+ This test case verifies: 1) Boot a VM with given userdata.
+ 2) Connectivity between 2 instances over a private network.
dependencies:
installer: ''
scenario: ''
+ #-
+ # name: tempest_smoke_serial
+ # description: >-
+ # This test case runs the smoke subset of the OpenStack
+ # Tempest suite. The list of test cases is generated by
+ # Tempest automatically and depend on the parameters of
+ # the OpenStack deplopyment.
+ # dependencies:
+ # installer: ''
+ # scenario: ''
+ #
+ #-
+ # name: rally_sanity
+ # description: >-
+ # This test case runs a sub group of tests of the OpenStack
+ # Rally suite in smoke mode.
+ # dependencies:
+ # installer: ''
+ # scenario: ''
+ #
#-
# name: security_groups
# description: >-
This test case runs the full set of the OpenStack Tempest suite.
testcases:
-
- name: tempest_full_parallel
+ name: tempest
description: >-
The list of test cases is generated by
Tempest automatically and depend on the parameters of
Rally suite from the OpenStack community.
testcases:
-
- name: rally_full
+ name: rally
description: >-
This test case runs the full suite of scenarios of the OpenStack
Rally suite using several threads and iterations.
# $ docker run -t -i \
# -e "INSTALLER_TYPE=fuel|apex|compass|joid \
# -e "INSTALLER_IP=10.20.0.2/172.30.10.73" \
-# -v $(pwd)/config_functest.yaml:/home/opnfv/functest/conf/config_functest.yaml
+# -v $(pwd)/config_functest.yaml:/home/opnfv/repos/functest/ci/config_functest.yaml
# opnfv/functest /bin/bash
#
# NOTE: providing config_functest.yaml is optional. If not provided, it will
ENV TERM xterm
ENV COLORTERM gnome-terminal
ENV PYTHONPATH $PYTHONPATH:/home/opnfv/repos/
+ENV CONFIG_FUNCTEST_YAML /home/opnfv/repos/functest/ci/config_functest.yaml
WORKDIR /home/opnfv
# Packaged dependencies
+++ /dev/null
-#!/bin/bash
-
-#
-# Author: Jose Lausuch (jose.lausuch@ericsson.com)
-#
-# Installs the Functest framework within the Docker container
-# and run the tests automatically
-#
-# If config_functest.yaml is given by the docker run command,
-# it must be run like this:
-#
-# docker run -ti \
-# -e "INSTALLER_TYPE=<something>" \
-# -e "INSTALLER_IP=<ip>" \
-# -v $(pwd)/config_functest.yaml:/home/opnfv/functest/conf/config_functest.yaml \
-# opnfv/functest /bin/bash
-#
-# NOTE: $(pwd)/config_functest.yaml means that it will take the one in the
-# current directory.
-#
-# If it is not provided, take the existing one in the functest repo
-#
-
-# this pull is to be removed right before the B release, once we build
-# a release candidate docker
-#
-# 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
-#
-
-mkdir -p /home/opnfv/functest/conf
-config_file=/home/opnfv/functest/conf/config_functest.yaml
-if [ ! -f ${config_file} ]; then
- default_config_file=$(find /home/opnfv/repos -name config_functest.yaml)
- cp $default_config_file $config_file
- echo "config_functest.yaml not provided. Using default one"
-fi
-
-
-# Parse config_functest.yaml file
-# TODO: this is not the best way to parse a yaml file in bash...
-
-# Directories
-REPOS_DIR=$(cat $config_file | grep -w dir_repos | awk 'END {print $NF}')
-FUNCTEST_REPO_DIR=$(cat $config_file | grep -w dir_repo_functest | awk 'END {print $NF}')
-FUNCTEST_DIR=$(cat $config_file | grep -w dir_functest | awk 'END {print $NF}')
-FUNCTEST_RESULTS_DIR=$(cat $config_file | grep -w dir_results | awk 'END {print $NF}')
-FUNCTEST_CONF_DIR=$(cat $config_file | grep -w dir_functest_conf | awk 'END {print $NF}')
-FUNCTEST_DATA_DIR=$(cat $config_file | grep -w dir_functest_data | awk 'END {print $NF}')
-RALLY_VENV_DIR=$(cat $config_file | grep -w dir_rally_inst | awk 'END {print $NF}')
-
-
-info () {
- logger -s -t "FUNCTEST.info" "$*"
-}
-
-error () {
- logger -s -t "FUNCTEST.error" "$*"
- exit 1
-}
+++ /dev/null
-#!/bin/bash
-
-#
-# Author: Jose Lausuch (jose.lausuch@ericsson.com)
-#
-# Installs the Functest framework within the Docker container
-# and run the tests automatically
-#
-#
-# 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
-#
-
-usage="Script to prepare the Functest environment.
-
-usage:
- bash $(basename "$0") [-h|--help] [-t <test_name>]
-
-where:
- -h|--help show this help text
-
-examples:
- $(basename "$0")"
-
-
-# Parse parameters
-while [[ $# > 0 ]]
- do
- key="$1"
- case $key in
- -h|--help)
- echo "$usage"
- exit 0
- shift
- ;;
- *)
- error "unknown option $1"
- exit 1
- ;;
- esac
- shift # past argument or value
-done
-
-BASEDIR=`dirname $0`
-source ${BASEDIR}/common.sh
-
-debug=""
-if [[ "${CI_DEBUG,,}" == "true" ]];then
- debug="--debug"
-fi
-
-
-info "######### Preparing Functest environment #########"
-
-# definition of available installer names
-INSTALLERS=(fuel compass apex joid)
-
-if [ ! -f ${FUNCTEST_CONF_DIR}/openstack.creds ]; then
- # If credentials file is not given, check if environment variables are set
- # to get the creds using fetch_os_creds.sh later on
- info "Checking environment variables INSTALLER_TYPE and INSTALLER_IP"
- if [ -z ${INSTALLER_TYPE} ]; then
- error "Environment variable 'INSTALLER_TYPE' is not defined."
- elif [[ ${INSTALLERS[@]} =~ ${INSTALLER_TYPE} ]]; then
- info "INSTALLER_TYPE env variable found: ${INSTALLER_TYPE}"
- else
- error "Invalid environment variable INSTALLER_TYPE=${INSTALLER_TYPE}"
- fi
-
- if [ -z ${INSTALLER_IP} ]; then
- error "Environment variable 'INSTALLER_IP' is not defined."
- fi
- info "INSTALLER_IP env variable found: ${INSTALLER_IP}"
-fi
-
-
-# Create directories
-mkdir -p ${FUNCTEST_CONF_DIR}
-mkdir -p ${FUNCTEST_DATA_DIR}
-mkdir -p ${FUNCTEST_RESULTS_DIR}/ODL
-
-
-# Create Openstack credentials file
-# $creds is an env varialbe in the docker container pointing to
-# /home/opnfv/functest/conf/openstack.creds
-if [ ! -f ${creds} ]; then
- ${REPOS_DIR}/releng/utils/fetch_os_creds.sh -d ${creds} \
- -i ${INSTALLER_TYPE} -a ${INSTALLER_IP}
- retval=$?
- if [ $retval != 0 ]; then
- error "Cannot retrieve credentials file from installation. Check logs."
- exit $retval
- fi
-else
- info "OpenStack credentials file given to the docker and stored in ${FUNCTEST_CONF_DIR}/openstack.creds."
-fi
-
-# If we use SSL, by default use option OS_INSECURE=true which means that
-# the cacert will be self-signed
-if grep -Fq "OS_CACERT" ${creds}; then
- echo "OS_INSECURE=true">>${creds};
-fi
-
-# Source credentials
-source ${creds}
-
-# Check OpenStack
-info "Checking that the basic OpenStack services are functional..."
-${FUNCTEST_REPO_DIR}/testcases/VIM/OpenStack/CI/libraries/check_os.sh
-RETVAL=$?
-if [ $RETVAL -ne 0 ]; then
- exit 1
-fi
-
-# Prepare Functest Environment
-info "Preparing Functest environment..."
-python ${FUNCTEST_REPO_DIR}/testcases/config_functest.py $debug start
-retval=$?
-if [ $retval != 0 ]; then
- error "Error when configuring Functest environment"
- exit $retval
-fi
-
-
-# Generate OpenStack defaults
-info "Generating OpenStack defaults..."
-python ${FUNCTEST_REPO_DIR}/utils/generate_defaults.py $debug
-
-ifconfig eth0 mtu 1450
-
-echo "1" > ${FUNCTEST_CONF_DIR}/env_active
+++ /dev/null
-#!/bin/bash
-
-#
-# Author: Jose Lausuch (jose.lausuch@ericsson.com)
-# Morgan Richomme (morgan.richomme@orange.com)
-# Installs the Functest framework within the Docker container
-# and run the tests automatically
-#
-#
-# 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
-#
-
-usage="Script to trigger the tests automatically.
-
-usage:
- bash $(basename "$0") [-h|--help] [-t <test_name>]
-
-where:
- -h|--help show this help text
- -r|--report push results to database (false by default)
- -n|--no-clean do not clean OpenStack resources after test run
- -s|--serial run Tempest tests in one thread
- -t|--test run specific set of tests
- <test_name> one or more of the following separated by comma:
- healthcheck,vping_ssh,vping_userdata,odl,onos,
- tempest,rally,vims,promise,doctor
-
-
-examples:
- $(basename "$0")
- $(basename "$0") --test vping_ssh,odl
- $(basename "$0") -t tempest,rally"
-
-
-BASEDIR=`dirname $0`
-source ${BASEDIR}/common.sh
-
-report=""
-clean=true
-serial=false
-
-# Get the list of runnable tests
-# Check if we are in CI mode
-debug=""
-if [[ "${CI_DEBUG,,}" == "true" ]];then
- debug="--debug"
-fi
-
-function clean_openstack(){
- if [ $clean == true ]; then
- echo -e "\n"
- info "Cleaning Openstack environment..."
- python ${FUNCTEST_REPO_DIR}/utils/clean_openstack.py \
- $debug
- echo -e "\n"
- fi
-}
-
-function odl_tests(){
- keystone_ip=$(openstack catalog show identity |grep publicURL| cut -f3 -d"/" | cut -f1 -d":")
- # historically most of the installers use the same IP for neutron and keystone API
- neutron_ip=$keystone_ip
- odl_ip=$(openstack catalog show network | grep publicURL | cut -f3 -d"/" | cut -f1 -d":")
- usr_name=$(env | grep OS | grep OS_USERNAME | cut -f2 -d'=')
- password=$(env | grep OS | grep OS_PASSWORD | cut -f2 -d'=')
- odl_port=8181
- if [ $INSTALLER_TYPE == "fuel" ]; then
- odl_port=8282
- elif [ $INSTALLER_TYPE == "apex" ]; then
- :
- elif [ $INSTALLER_TYPE == "joid" ]; then
- odl_ip=$(env | grep SDN_CONTROLLER | cut -f2 -d'=')
- neutron_ip=$(openstack catalog show network | grep publicURL | cut -f3 -d"/" | cut -f1 -d":")
- odl_port=8080
- :
- elif [ $INSTALLER_TYPE == "compass" ]; then
- :
- else
- error "INSTALLER_TYPE not valid."
- exit 1
- fi
-}
-function run_test(){
- test_name=$1
- echo -e "\n\n\n\n"
- echo "----------------------------------------------"
- echo " Running test case: $i"
- echo "----------------------------------------------"
- echo ""
- clean_flag=""
- if [ $clean == "false" ]; then
- clean_flag="-n"
- fi
- serial_flag=""
- if [ $serial == "true" ]; then
- serial_flag="-s"
- fi
-
- case $test_name in
- "healthcheck")
- info "Running health check test..."
- ${FUNCTEST_REPO_DIR}/testcases/VIM/OpenStack/CI/libraries/healthcheck.sh
- ;;
- "vping_ssh")
- info "Running vPing-SSH test..."
- python ${FUNCTEST_REPO_DIR}/testcases/vPing/CI/libraries/vPing_ssh.py \
- $debug $report
- ;;
- "vping_userdata")
- info "Running vPing-userdata test... "
- python ${FUNCTEST_REPO_DIR}/testcases/vPing/CI/libraries/vPing_userdata.py \
- $debug $report
- ;;
- "odl")
- info "Running ODL test..."
- odl_tests
- ODL_PORT=$odl_port ODL_IP=$odl_ip KEYSTONE_IP=$keystone_ip NEUTRON_IP=$neutron_ip USR_NAME=$usr_name PASS=$password \
- ${FUNCTEST_REPO_DIR}/testcases/Controllers/ODL/CI/start_tests.sh
-
- # push results to the DB in case of CI
- if [[ -n "$DEPLOY_SCENARIO" && "$DEPLOY_SCENARIO" != "none" ]]; then
- odl_logs="/home/opnfv/functest/results/odl/logs/2"
- odl_path="${FUNCTEST_REPO_DIR}/testcases/Controllers/ODL/CI"
- node_name=$(env | grep NODE_NAME | cut -f2 -d'=')
- python ${odl_path}/odlreport2db.py -x ${odl_logs}/output.xml -i ${INSTALLER_TYPE} -p ${node_name} -s ${DEPLOY_SCENARIO}
- fi
- ;;
- "tempest")
- info "Running Tempest tests..."
- python ${FUNCTEST_REPO_DIR}/testcases/VIM/OpenStack/CI/libraries/run_tempest.py \
- $debug $serial_flag $clean_flag -m smoke $report
- # save tempest.conf for further troubleshooting
- tempest_conf="${RALLY_VENV_DIR}/tempest/for-deployment-*/tempest.conf"
- if [ -f ${tempest_conf} ]; then
- cp $tempest_conf ${FUNCTEST_CONF_DIR}
- fi
- ;;
- "vims")
- info "Running vIMS test..."
- python ${FUNCTEST_REPO_DIR}/testcases/vIMS/CI/vIMS.py \
- $debug $clean_flag $report
- ;;
- "rally")
- info "Running Rally benchmark suite..."
- python ${FUNCTEST_REPO_DIR}/testcases/VIM/OpenStack/CI/libraries/run_rally-cert.py \
- $debug $clean_flag all $report
-
- ;;
- "bgpvpn")
- info "Running BGPVPN Tempest test case..."
- pushd ${repos_dir}/bgpvpn/
- pip install --no-deps -e .
- popd
- tempest_dir=$(ls -t /home/opnfv/.rally/tempest/ |grep for-deploy |tail -1)
- if [[ $tempest_dir == "" ]]; then
- error "Make sure tempest was running before"
- fi
- tempest_dir=/home/opnfv/.rally/tempest/$tempest_dir
- pushd $tempest_dir
- mkdir -p /etc/tempest/
- cp tempest.conf /etc/tempest/
- echo "[service_available]
-bgpvpn = True" >> /etc/tempest/tempest.conf
- ./run_tempest.sh -t -N -- networking_bgpvpn_tempest
- rm -rf /etc/tempest/tempest.conf
- popd
- ;;
- "onos")
- info "Running ONOS test case..."
- if [ $INSTALLER_TYPE == "joid" ]; then
- python ${FUNCTEST_REPO_DIR}/testcases/Controllers/ONOS/Teston/CI/onosfunctest.py -i joid
- else
- python ${FUNCTEST_REPO_DIR}/testcases/Controllers/ONOS/Teston/CI/onosfunctest.py
- fi
- ;;
- "promise")
- info "Running PROMISE test case..."
- python ${FUNCTEST_REPO_DIR}/testcases/features/promise.py $debug $report
- sleep 10 # to let the instances terminate
- ;;
- "doctor")
- info "Running Doctor test..."
- python ${FUNCTEST_REPO_DIR}/testcases/features/doctor.py
- ;;
- "ovno")
- info "Running OpenContrail test..."
- ${repos_dir}/ovno/Testcases/RunTests.sh
- ;;
- esac
-
- if [ $clean == "true" ]; then
- clean_openstack
- fi
-}
-
-
-# Parse parameters
-while [[ $# > 0 ]]
- do
- key="$1"
- case $key in
- -h|--help)
- echo "$usage"
- exit 0
- shift
- ;;
- -r|--report)
- report="-r"
- ;;
- -n|--no-clean)
- clean=false
- ;;
- -s|--serial)
- serial=true
- ;;
- -t|--test|--tests)
- TEST="$2"
- shift
- ;;
- *)
- echo "unknown option $1 $2"
- exit 1
- ;;
- esac
- shift # past argument or value
-done
-
-
-tests_file="/home/opnfv/functest/conf/testcase-list.txt"
-if [[ -n "$DEPLOY_SCENARIO" && "$DEPLOY_SCENARIO" != "none" ]] &&\
- [[ -f $tests_file ]]; then
- arr_test=($(cat $tests_file))
-else
- arr_test=(healthcheck vping_ssh vping_userdata tempest vims rally)
-fi
-
-
-info "Tests to be executed: ${arr_test[@]}"
-
-# Check that the given tests are correct
-if [ "${TEST}" != "" ]; then
- arr_test_exec=(${TEST//,/ })
- for i in "${arr_test_exec[@]}"; do
- if [[ " ${arr_test[*]} " != *" $i "* ]]; then
- error "Unknown test: $i. Available tests are: ${arr_test[@]}"
- fi
- done
- info "Tests to execute: ${TEST}."
-fi
-
-# Check that the functest environment has been installed
-if [ ! -f ${FUNCTEST_CONF_DIR}/env_active ]; then
- error "The Functest environment is not installed. \
- Please run prepare_env.sh before running this script...."
-fi
-
-
-# Source credentials
-info "Sourcing Credentials ${FUNCTEST_CONF_DIR}/openstack.creds to run the tests.."
-source ${FUNCTEST_CONF_DIR}/openstack.creds
-
-# Run tests
-if [ "${TEST}" != "" ]; then
- for i in "${arr_test_exec[@]}"; do
- run_test $i
- done
-else
- info "Executing tests..."
- for i in "${arr_test[@]}"; do
- run_test $i
- done
-fi
docker run -ti -e \
"INSTALLER_TYPE=fuel" -e "INSTALLER_IP=10.20.0.2" \
opnfv/functest:brahmaputra.1.0 \
- -v $(pwd)/config_functest.yaml:/home/opnfv/functest/conf/config_functest.yaml \
+ -v $(pwd)/config_functest.yaml:/home/opnfv/repos/functest/ci/config_functest.yaml \
/bin/bash\
However, this is not recommended since most of the test cases rely on static
import getopt
import json
+import os
import sys
import xmltodict
import yaml
json.dumps(data, indent=4, separators=(',', ': '))
# Only used from container, we can set up absolute path
- with open("/home/opnfv/functest/conf/config_functest.yaml") as f:
+ with open(os.environ["CONFIG_FUNCTEST_YAML"]) as f:
functest_yaml = yaml.safe_load(f)
f.close()
""" logging configuration """
logger = ft_logger.Logger("onos").getLogger()
-with open("/home/opnfv/functest/conf/config_functest.yaml") as f:
+with open(os.environ["CONFIG_FUNCTEST_YAML"]) as f:
functest_yaml = yaml.safe_load(f)
f.close()
set -e
+#Redirect all the output (stdout) to a log file and show only possible errors.
+LOG_FILE=/home/opnfv/functest/results/healthcheck.log
+echo "">$LOG_FILE
+exec 1<>$LOG_FILE
+
+info () {
+ echo -e "$(date '+%Y-%m-%d %H:%M:%S,%3N') - healtcheck - INFO - " "$*" | tee -a $LOG_FILE 1>&2
+}
+
+debug () {
+ if [[ "${CI_DEBUG,,}" == "true" ]]; then
+ echo -e "$(date '+%Y-%m-%d %H:%M:%S,%3N') - healtcheck - DEBUG - " "$*" | tee -a $LOG_FILE 1>&2
+ fi
+}
+
+error () {
+ echo -e "$(date '+%Y-%m-%d %H:%M:%S,%3N') - healtcheck - ERROR - " "$*" | tee -a $LOG_FILE 1>&2
+ exit 1
+}
+
if [ -z $OS_AUTH_URL ]; then
echo "Source credentials first."
exit 1
fi
-#Redirect all the output (stdout) to a log file and show only possible errors.
-LOG_FILE=/home/opnfv/functest/results/healthcheck.log
-exec 1<>$LOG_FILE
echo "Using following credentials:"
env | grep OS
timeout=60
while [[ ${timeout} > 0 ]]; do
if [[ $(nova console-log $1|grep "No lease, failing") ]]; then
- echo "ERROR: The instance $1 couldn't get an IP from the DHCP agent." | tee -a $LOG_FILE 1>&2
+ error "The instance $1 couldn't get an IP from the DHCP agent." | tee -a $LOG_FILE 1>&2
exit 1
elif [[ $(nova console-log $1|grep "^Lease"|grep "obtained") ]]; then
- echo "The instance $1 got an IP successfully from the DHCP agent."
+ debug "The instance $1 got an IP successfully from the DHCP agent." | tee -a $LOG_FILE 1>&2
break
fi
let timeout=timeout-1
#################################
-echo "Testing Keystone API..." | tee -a $LOG_FILE 1>&2
+info "Testing Keystone API..." | tee -a $LOG_FILE 1>&2
#################################
openstack project create ${project_1}
+debug "project '${project_1}' created."
openstack project create ${project_2}
-
+debug "project '${project_2}' created."
openstack user create ${user_1} --project ${project_1}
+debug "user '${user_1}' created in project ${project_1}."
openstack user create ${user_2} --project ${project_1}
+debug "user '${user_2}' created in project ${project_1}."
openstack user create ${user_3} --project ${project_1}
+debug "user '${user_3}' created in project ${project_1}."
openstack user create ${user_4} --project ${project_2}
+debug "user '${user_4}' created in project ${project_2}."
openstack user create ${user_5} --project ${project_2}
+debug "user '${user_5}' created in project ${project_2}."
openstack user create ${user_6} --project ${project_2}
-
-echo "...OK" | tee -a $LOG_FILE 1>&2
+debug "user '${user_6}' created in project ${project_2}."
+info "...Keystone OK!"
#################################
-echo "Testing Glance API..." | tee -a $LOG_FILE 1>&2
+info "Testing Glance API..."
#################################
image=/home/opnfv/functest/data/cirros-0.3.4-x86_64-disk.img
glance image-create --name ${image_1} --disk-format qcow2 --container-format bare < ${image}
+debug "image '${image_1}' created."
glance image-create --name ${image_2} --disk-format qcow2 --container-format bare < ${image}
-
-echo "...OK" | tee -a $LOG_FILE 1>&2
+debug "image '${image_2}' created."
+info "... Glance OK!"
#################################
-echo "Testing Cinder API..." | tee -a $LOG_FILE 1>&2
+info "Testing Cinder API..."
#################################
cinder create --display_name ${volume_1} 1
+debug "volume '${volume_1}' created."
cinder create --display_name ${volume_2} 10
-
-echo "...OK" | tee -a $LOG_FILE 1>&2
+debug "volume '${volume_2}' created."
+info "...Cinder OK!"
#################################
-echo "Testing Neutron API..." | tee -a $LOG_FILE 1>&2
+info "Testing Neutron API..."
#################################
network_ids=($(neutron net-list|grep -v "+"|grep -v name|awk '{print $2}'))
[[ $(neutron net-show ${id}|grep 'router:external'|grep -i "true") != "" ]] && ext_net_id=${id}
done
if [[ "${ext_net_id}" == "" ]]; then
- echo "ERROR: No external network found. Exiting Health Check..." | tee -a $LOG_FILE 1>&2
+ error "No external network found. Exiting Health Check..."
exit 1
else
- echo "External network found. ${ext_net_id}"
+ info "External network found. ${ext_net_id}"
fi
-echo "1. Create Networks..."
+info "1. Create Networks..."
neutron net-create ${net_1}
+debug "net '${net_1}' created."
neutron net-create ${net_2}
+debug "net '${net_2}' created."
net1_id=$(neutron net-list | grep ${net_1} | awk '{print $2}')
net2_id=$(neutron net-list | grep ${net_2} | awk '{print $2}')
-echo "2. Create subnets..."
+info "2. Create subnets..."
neutron subnet-create --name ${subnet_1} --allocation-pool start=10.6.0.2,end=10.6.0.253 --gateway 10.6.0.254 ${net_1} 10.6.0.0/24
+debug "subnet '${subnet_1}' created."
neutron subnet-create --name ${subnet_2} --allocation-pool start=10.7.0.2,end=10.7.0.253 --gateway 10.7.0.254 ${net_2} 10.7.0.0/24
+debug "subnet '${subnet_2}' created."
-echo "4. Create Routers..."
+info "4. Create Routers..."
neutron router-create ${router_1}
+debug "router '${router_1}' created."
neutron router-create ${router_2}
+debug "router '${router_2}' created."
neutron router-gateway-set ${router_1} ${ext_net_id}
+debug "router '${router_1}' gateway set to ${ext_net_id}."
neutron router-gateway-set ${router_2} ${ext_net_id}
+debug "router '${router_2}' gateway set to ${ext_net_id}."
neutron router-interface-add ${router_1} ${subnet_1}
+debug "router '${router_1}' interface added ${subnet_1}."
neutron router-interface-add ${router_2} ${subnet_2}
+debug "router '${router_2}' interface added ${subnet_2}."
-echo "...OK" | tee -a $LOG_FILE 1>&2
+info "...Neutron OK!"
#################################
-echo "Testing Nova API..." | tee -a $LOG_FILE 1>&2
+info "Testing Nova API..."
#################################
nova boot --flavor 2 --image ${image_1} --nic net-id=${net1_id} ${instance_1}
+debug "nova instance '${instance_1}' booted on ${net_1}."
nova boot --flavor 2 --image ${image_1} --nic net-id=${net1_id} ${instance_2}
+debug "nova instance '${instance_2}' booted on ${net_1}."
nova boot --flavor 2 --image ${image_2} --nic net-id=${net2_id} ${instance_3}
+debug "nova instance '${instance_3}' booted on ${net_2}."
nova boot --flavor 2 --image ${image_2} --nic net-id=${net2_id} ${instance_4}
+debug "nova instance '${instance_4}' booted on ${net_2}."
vm1_id=$(nova list | grep ${instance_1} | awk '{print $2}')
vm2_id=$(nova list | grep ${instance_2} | awk '{print $2}')
vm3_id=$(nova list | grep ${instance_3} | awk '{print $2}')
vm4_id=$(nova list | grep ${instance_4} | awk '{print $2}')
+info "...Nova OK!"
-echo "...OK" | tee -a $LOG_FILE 1>&2
-
-echo "Checking if instances get an IP from DHCP..." | tee -a $LOG_FILE 1>&2
-
+info "Checking if instances get an IP from DHCP..."
wait_for_ip ${instance_1} "10.6"
wait_for_ip ${instance_2} "10.6"
wait_for_ip ${instance_3} "10.7"
wait_for_ip ${instance_4} "10.7"
+info "...DHCP OK!"
-echo "Health check passed!" | tee -a $LOG_FILE 1>&2
+info "Health check passed!"
exit 0
exit(-1)
-with open("/home/opnfv/functest/conf/config_functest.yaml") as f:
+with open(os.environ["CONFIG_FUNCTEST_YAML"]) as f:
functest_yaml = yaml.safe_load(f)
f.close()
REPO_PATH = os.environ['repos_dir'] + '/functest/'
-with open("/home/opnfv/functest/conf/config_functest.yaml") as f:
+with open(os.environ["CONFIG_FUNCTEST_YAML"]) as f:
functest_yaml = yaml.safe_load(f)
f.close()
TEST_DB = functest_yaml.get("results").get("test_db_url")
+++ /dev/null
-#!/usr/bin/env python
-#
-# Copyright (c) 2015 Ericsson
-# jose.lausuch@ericsson.com
-# 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
-#
-import argparse
-import logging
-import os
-import shutil
-import subprocess
-import sys
-import yaml
-
-from neutronclient.v2_0 import client as neutronclient
-
-import functest.utils.functest_utils as functest_utils
-import functest.utils.openstack_utils as openstack_utils
-
-
-actions = ['start', 'check', 'clean']
-parser = argparse.ArgumentParser()
-parser.add_argument("action", help="Possible actions are: "
- "'{d[0]}|{d[1]}|{d[2]}' ".format(d=actions))
-parser.add_argument("-d", "--debug", help="Debug mode", action="store_true")
-parser.add_argument("-f", "--force", help="Force", action="store_true")
-args = parser.parse_args()
-
-
-""" logging configuration """
-logger = logging.getLogger('config_functest')
-logger.setLevel(logging.DEBUG)
-
-ch = logging.StreamHandler()
-if args.debug:
- ch.setLevel(logging.DEBUG)
-else:
- ch.setLevel(logging.INFO)
-
-formatter = logging.Formatter('%(asctime)s - %(name)s - '
- '%(levelname)s - %(message)s')
-ch.setFormatter(formatter)
-logger.addHandler(ch)
-
-REPOS_DIR = os.environ['repos_dir']
-FUNCTEST_REPO = REPOS_DIR + '/functest/'
-if not os.path.exists(FUNCTEST_REPO):
- logger.error("Functest repository directory not found '%s'"
- % FUNCTEST_REPO)
- exit(-1)
-sys.path.append(FUNCTEST_REPO + "testcases/")
-
-with open("/home/opnfv/functest/conf/config_functest.yaml") as f:
- functest_yaml = yaml.safe_load(f)
-f.close()
-
-
-""" global variables """
-# Directories
-RALLY_DIR = FUNCTEST_REPO + functest_yaml.get("general").get(
- "directories").get("dir_rally")
-RALLY_REPO_DIR = functest_yaml.get("general").get(
- "directories").get("dir_repo_rally")
-RALLY_INSTALLATION_DIR = functest_yaml.get("general").get(
- "directories").get("dir_rally_inst")
-RALLY_RESULT_DIR = functest_yaml.get("general").get(
- "directories").get("dir_rally_res")
-TEMPEST_REPO_DIR = functest_yaml.get("general").get(
- "directories").get("dir_repo_tempest")
-VPING_DIR = FUNCTEST_REPO + functest_yaml.get("general").get(
- "directories").get("dir_vping")
-ODL_DIR = FUNCTEST_REPO + functest_yaml.get("general").get(
- "directories").get("dir_odl")
-DATA_DIR = functest_yaml.get("general").get(
- "directories").get("dir_functest_data")
-
-# Tempest/Rally configuration details
-DEPLOYMENT_MAME = functest_yaml.get("rally").get("deployment_name")
-
-# Image (cirros)
-IMAGE_FILE_NAME = functest_yaml.get("general").get("openstack").get(
- "image_file_name")
-IMAGE_PATH = DATA_DIR + "/" + IMAGE_FILE_NAME
-
-# NEUTRON Private Network parameters
-NEUTRON_PRIVATE_NET_NAME = functest_yaml.get("general").get(
- "openstack").get("neutron_private_net_name")
-NEUTRON_PRIVATE_SUBNET_NAME = functest_yaml.get("general").get(
- "openstack").get("neutron_private_subnet_name")
-NEUTRON_PRIVATE_SUBNET_CIDR = functest_yaml.get("general").get(
- "openstack").get("neutron_private_subnet_cidr")
-NEUTRON_ROUTER_NAME = functest_yaml.get("general").get(
- "openstack").get("neutron_router_name")
-
-creds_neutron = openstack_utils.get_credentials("neutron")
-neutron_client = neutronclient.Client(**creds_neutron)
-
-
-def action_start():
- """
- Start the functest environment installation
- """
- if not functest_utils.check_internet_connectivity():
- logger.info("No Internet connectivity. "
- "This may affect some test case suites.")
-
- if action_check():
- logger.info("Functest environment already installed. Nothing to do.")
- exit(0)
-
- else:
- # Clean in case there are left overs
- logger.debug("Cleaning possible functest environment leftovers.")
- action_clean()
- logger.info("Starting installation of functest environment")
-
- private_net = openstack_utils.get_private_net(neutron_client)
- if private_net is None:
- # If there is no private network in the deployment we create one
- if not create_private_neutron_net(neutron_client):
- logger.error("There has been a problem while "
- "creating the functest network.")
- action_clean()
- exit(-1)
- else:
- logger.info("Private network '%s' already existing in "
- "the deployment." % private_net['name'])
-
- logger.info("Installing Rally...")
- if not install_rally():
- logger.error("There has been a problem while installing Rally.")
- action_clean()
- exit(-1)
-
- # Create result folder under functest if necessary
- if not os.path.exists(RALLY_RESULT_DIR):
- os.makedirs(RALLY_RESULT_DIR)
-
- try:
- logger.info("CI: Generate the list of executable tests.")
- runnable_test = functest_utils.generateTestcaseList(functest_yaml)
- logger.info("List of runnable tests generated: %s" % runnable_test)
- except:
- logger.error("Impossible to generate the list of runnable tests")
-
- exit(0)
-
-
-def action_check():
- """
- Check if the functest environment is properly installed
- """
- errors_all = False
- logger.info("Checking current functest configuration...")
-
- logger.debug("Checking script directories...")
-
- dirs = [RALLY_DIR, RALLY_INSTALLATION_DIR, VPING_DIR, ODL_DIR]
- for dir in dirs:
- if not os.path.exists(dir):
- logger.debug(" %s NOT found" % dir)
- errors_all = True
- else:
- logger.debug(" %s found" % dir)
-
- logger.debug("Checking Rally deployment...")
- if not check_rally():
- logger.debug(" Rally deployment NOT installed.")
- errors_all = True
-
- logger.debug("Checking Image...")
- if not os.path.isfile(IMAGE_PATH):
- logger.debug(" Image file '%s' NOT found." % IMAGE_PATH)
- errors_all = True
- else:
- logger.debug(" Image file found in %s" % IMAGE_PATH)
-
- # TODO: check OLD environment setup
- return not errors_all
-
-
-def action_clean():
- """
- Clean the existing functest environment
- """
- logger.info("Removing current functest environment...")
- if os.path.exists(RALLY_INSTALLATION_DIR):
- logger.debug("Removing Rally installation directory %s"
- % RALLY_INSTALLATION_DIR)
- shutil.rmtree(RALLY_INSTALLATION_DIR, ignore_errors=True)
-
- if os.path.exists(RALLY_RESULT_DIR):
- logger.debug("Removing Result directory")
- shutil.rmtree(RALLY_RESULT_DIR, ignore_errors=True)
-
- logger.info("Functest environment clean!")
-
-
-def install_rally():
- if check_rally():
- logger.info("Rally is already installed.")
- else:
- logger.debug("Creating Rally environment...")
- cmd = "rally deployment create --fromenv --name=" + DEPLOYMENT_MAME
- functest_utils.execute_command(cmd, logger)
-
- logger.debug("Installing tempest from existing repo...")
- cmd = ("rally verify install --source " + TEMPEST_REPO_DIR +
- " --system-wide")
- functest_utils.execute_command(cmd, logger)
-
- cmd = "rally deployment check"
- functest_utils.execute_command(cmd, logger)
- # TODO: check that everything is 'Available' and warn if not
-
- cmd = "rally show images"
- functest_utils.execute_command(cmd, logger)
-
- cmd = "rally show flavors"
- functest_utils.execute_command(cmd, logger)
-
- return True
-
-
-def check_rally():
- """
- Check if Rally is installed and properly configured
- """
- if os.path.exists(RALLY_INSTALLATION_DIR):
- logger.debug(" Rally installation directory found in %s"
- % RALLY_INSTALLATION_DIR)
- FNULL = open(os.devnull, 'w')
- cmd = "rally deployment list | grep " + DEPLOYMENT_MAME
- logger.debug(' Executing command : {}'.format(cmd))
- p = subprocess.Popen(cmd, shell=True,
- stdout=subprocess.PIPE, stderr=FNULL)
- # if the command does not exist or there is no deployment
- line = p.stdout.readline()
- if line == "":
- logger.debug(" Rally deployment NOT found")
- return False
- logger.debug(" Rally deployment found")
- return True
- else:
- return False
-
-
-def create_private_neutron_net(neutron):
- neutron.format = 'json'
- logger.info("Creating network '%s'..." % NEUTRON_PRIVATE_NET_NAME)
- network_id = openstack_utils.create_neutron_net(
- neutron, NEUTRON_PRIVATE_NET_NAME)
-
- if not network_id:
- return False
- logger.debug("Network '%s' created successfully." % network_id)
-
- logger.info("Updating network '%s' with shared=True..."
- % NEUTRON_PRIVATE_NET_NAME)
- if openstack_utils.update_neutron_net(neutron, network_id, shared=True):
- logger.debug("Network '%s' updated successfully." % network_id)
- else:
- logger.info("Updating neutron network '%s' failed" % network_id)
-
- logger.info("Creating Subnet....")
- subnet_id = openstack_utils.create_neutron_subnet(
- neutron, NEUTRON_PRIVATE_SUBNET_NAME, NEUTRON_PRIVATE_SUBNET_CIDR,
- network_id)
- if not subnet_id:
- return False
- logger.debug("Subnet '%s' created successfully." % subnet_id)
- logger.info("Creating Router...")
- router_id = openstack_utils.create_neutron_router(neutron,
- NEUTRON_ROUTER_NAME)
-
- if not router_id:
- return False
-
- logger.debug("Router '%s' created successfully." % router_id)
- logger.info("Adding router to subnet...")
-
- result = openstack_utils.add_interface_router(neutron,
- router_id,
- subnet_id)
-
- if not result:
- return False
-
- logger.debug("Interface added successfully.")
- return True
-
-
-def main():
- if not (args.action in actions):
- logger.error('argument not valid')
- exit(-1)
-
- if not openstack_utils.check_credentials():
- logger.error("Please source the openrc credentials and "
- "run the script again.")
- # TODO: source the credentials in this script
- exit(-1)
-
- if args.action == "start":
- action_start()
-
- if args.action == "check":
- if action_check():
- logger.info("Functest environment correctly installed")
- else:
- logger.info("Functest environment not found or faulty")
-
- if args.action == "clean":
- if args.force:
- action_clean()
- else:
- while True:
- print("Are you sure? [y|n]")
- answer = raw_input("")
- if answer == "y":
- action_clean()
- break
- elif answer == "n":
- break
- else:
- print("Invalid option.")
- exit(0)
-
-
-if __name__ == '__main__':
- main()
#
#
+import os
import time
import yaml
import functest.utils.functest_logger as ft_logger
import functest.utils.functest_utils as functest_utils
-with open('/home/opnfv/functest/conf/config_functest.yaml') as f:
+with open(os.environ["CONFIG_FUNCTEST_YAML"]) as f:
functest_yaml = yaml.safe_load(f)
dirs = functest_yaml.get('general').get('directories')
action="store_true")
args = parser.parse_args()
-with open('/home/opnfv/functest/conf/config_functest.yaml') as f:
+with open(os.environ["CONFIG_FUNCTEST_YAML"]) as f:
functest_yaml = yaml.safe_load(f)
dirs = functest_yaml.get('general').get('directories')
logger.error("Functest repository directory not found '%s'" % REPO_PATH)
exit(-1)
-with open("/home/opnfv/functest/conf/config_functest.yaml") as f:
+with open(os.environ["CONFIG_FUNCTEST_YAML"]) as f:
functest_yaml = yaml.safe_load(f)
f.close()
logger.error("Functest repository directory not found '%s'" % REPO_PATH)
exit(-1)
-with open("/home/opnfv/functest/conf/config_functest.yaml") as f:
+with open(os.environ["CONFIG_FUNCTEST_YAML"]) as f:
functest_yaml = yaml.safe_load(f)
f.close()
logger.error("Functest repository directory not found '%s'" % REPO_PATH)
exit(-1)
-with open("/home/opnfv/functest/conf/config_functest.yaml") as f:
+with open(os.environ["CONFIG_FUNCTEST_YAML"]) as f:
functest_yaml = yaml.safe_load(f)
f.close()
""" logging configuration """
-logger = ft_logger.Logger("run_rally").getLogger()
+logger = ft_logger.Logger("clean_openstack").getLogger()
REPO_PATH = os.environ['repos_dir'] + '/functest/'
def main():
+ logger.info("+++++++++++++++++++++++++++++++")
+ logger.info("Cleaning OpenStack resources...")
+ logger.info("+++++++++++++++++++++++++++++++")
creds_nova = os_utils.get_credentials("nova")
nova_client = novaclient.Client('2', **creds_nova)
remove_tenants(keystone_client)
separator()
- exit(0)
-
if __name__ == '__main__':
main()
with open(DEFAULTS_FILE, 'w+') as yaml_file:
yaml_file.write(yaml.safe_dump(defaults, default_flow_style=False))
yaml_file.seek(0)
- logger.debug("Openstack Defaults found in the deployment:")
- print yaml_file.read()
+ logger.info("Openstack Defaults found in the deployment:\n%s"
+ % yaml_file.read())
logger.debug("NOTE: These objects will NOT be deleted after " +
"running the tests.")