aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--INFO12
-rw-r--r--docker/Dockerfile52
-rw-r--r--docker/requirements.pip9
-rw-r--r--docker/start.sh142
-rw-r--r--testcases/Controllers/ONOS/Teston/CI/adapters/environment.py212
-rw-r--r--testcases/Controllers/ONOS/Teston/CI/adapters/foundation.py32
-rwxr-xr-x[-rw-r--r--]testcases/config_functest.py108
-rw-r--r--testcases/config_functest.yaml23
-rw-r--r--testcases/functest_utils.py2
9 files changed, 531 insertions, 61 deletions
diff --git a/INFO b/INFO
index b0b7db6a..b9a02737 100644
--- a/INFO
+++ b/INFO
@@ -3,7 +3,7 @@ Project Creation Date: January 20, 2015
Project Category: Integration & Testing
Lifecycle State: Incubation
Primary Contact: Morgan Richomme (morgan.richomme@orange.com)
-Project Lead: Morgan Richomme (morgan.richomme@orange.comtrevor.cooper@inte)
+Project Lead: Morgan Richomme (morgan.richomme@orange.com)
Jira Project Name: Base System Functionality Testing Project
Jira Project Prefix: FUNCTEST
Mailing list tag: [functest]
@@ -26,10 +26,16 @@ koffirodrigue@gmail.com
dk068x@att.com
meimei@huawei.com
valentin.boucher@orange.com
+lanqinglong@huawei.com
+viktor.tikkanen@nokia.com
+juha.kosonen@nokia.com
+zhanghaoyu7@huawei.com
Link to TSC approval of the project: http://meetbot.opnfv.org/meetings/opnfv-meeting/2015/opnfv-meeting.2015-01-20-14.57.html
-Link(s) to approval of additional committers: http://lists.opnfv.org/pipermail/opnfv-tech-discuss/2015-April/001971.html
+Link(s) to approval of additional committers:
+http://lists.opnfv.org/pipermail/opnfv-tech-discuss/2015-April/001971.html
+http://ircbot.wl.linuxfoundation.org/meetings/opnfv-testperf/2015/opnfv-testperf.2015-09-29-13.00.html
-* Addition of the following committers was approved by majority vote of exisitng committers: pbandzi@cisco.com, sama@docomolab-euro.com, jose.lausuch@ericsson.com ,Andrew.Caldwell@metaswitch.com, morgan.richomme@orange.com, iben.rodriguez@spirent.com
+* Addition of the following committers was approved by majority vote of exisitng committers: pbandzi@cisco.com, sama@docomolab-euro.com, jose.lausuch@ericsson.com ,Andrew.Caldwell@metaswitch.com, morgan.richomme@orange.com, iben.rodriguez@spirent.com, koffirodrigue@gmail.com, dk068x@att.com, meimei@huawei.com, valentin.boucher@orange.com, lanqinglong@huawei.com, viktor.tikkanen@nokia.com, juha.kosonen@nokia.com, zhanghaoyu7@huawei.com
diff --git a/docker/Dockerfile b/docker/Dockerfile
new file mode 100644
index 00000000..f1a28027
--- /dev/null
+++ b/docker/Dockerfile
@@ -0,0 +1,52 @@
+########################################
+# Docker container for FUNCTEST
+########################################
+# Purpose: run all the tests against the POD
+# from a pre-installed docker image
+#
+# Maintained by Jose Lausuch
+# Build:
+# $ docker build -t opnfv/functest:tag .
+#
+# Execution:
+# $ docker run -t -i -e "INSTALLER_TYPE=fuel/foreman" \
+# -e "INSTALLER_IP=10.20.0.2/172.30.10.73" opnfv/functest
+#
+
+
+FROM ubuntu:14.04
+MAINTAINER Jose Lausuch <jose.lausuch@ericsson.com>
+LABEL version="0.1" description="OPNFV Functest Docker container"
+
+ENV repos_dir /home/opnfv/repos
+
+# Packaged dependencies
+RUN apt-get update && apt-get install -y \
+ssh \
+sshpass \
+git \
+gcc \
+wget \
+python-dev \
+python-pip \
+postgresql \
+build-essential \
+libpq-dev \
+libxslt-dev \
+libssl-dev \
+libgmp3-dev \
+libxml2-dev \
+libffi-dev \
+crudini \
+--no-install-recommends
+
+
+RUN mkdir -p ${repos_dir}
+
+RUN git config --global http.sslVerify false
+RUN git clone https://gerrit.opnfv.org/gerrit/functest ${repos_dir}/functest
+RUN git clone https://gerrit.opnfv.org/gerrit/releng ${repos_dir}/releng
+RUN git clone https://github.com/openstack/rally.git ${repos_dir}/rally
+
+RUN pip install -r ${repos_dir}/functest/docker/requirements.pip
+RUN chmod 744 ${repos_dir}/functest/docker/start.sh \ No newline at end of file
diff --git a/docker/requirements.pip b/docker/requirements.pip
new file mode 100644
index 00000000..22c8199d
--- /dev/null
+++ b/docker/requirements.pip
@@ -0,0 +1,9 @@
+pyyaml==3.10
+gitpython==1.0.1
+python-neutronclient==2.6.0
+python-novaclient==2.28.1
+python-glanceclient==1.1.0
+python-keystoneclient==1.6.0
+cloudify==3.2.1
+virtualenv==1.11.4
+pexpect==4.0 \ No newline at end of file
diff --git a/docker/start.sh b/docker/start.sh
new file mode 100644
index 00000000..bd2308ca
--- /dev/null
+++ b/docker/start.sh
@@ -0,0 +1,142 @@
+#!/bin/bash
+
+#
+# Author: Jose Lausuch (jose.lausuch@ericsson.com)
+#
+# Installs the Functest framework within the Docker container
+# and run the tests automatically
+#
+
+
+config_file=$(find / -name config_functest.yaml)
+
+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}')
+RALLY_REPO_DIR=$(cat $config_file | grep -w dir_repo_rally | awk 'END {print $NF}')
+RELENG_REPO_DIR=$(cat $config_file | grep -w dir_repo_releng | 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=$(cat $config_file | grep -w dir_rally_inst | awk 'END {print $NF}')
+RALLY_COMMIT=$(cat $config_file | grep -w rally_stable_commit | awk 'END {print $NF}')
+
+
+echo "REPOS_DIR=${REPOS_DIR}"
+echo "FUNCTEST_REPO_DIR=${FUNCTEST_REPO_DIR}"
+echo "RALLY_REPO_DIR=${RALLY_REPO_DIR}"
+echo "RELENG_REPO_DIR=${RELENG_REPO_DIR}"
+echo "FUNCTEST_DIR=${FUNCTEST_DIR}"
+echo "FUNCTEST_RESULTS_DIR=${FUNCTEST_RESULTS_DIR}"
+echo "FUNCTEST_CONF_DIR=${FUNCTEST_CONF_DIR}"
+echo "FUNCTEST_DATA_DIR=${FUNCTEST_DATA_DIR}"
+echo "RALLY_VENV=${RALLY_VENV}"
+echo "RALLY_COMMIT=${RALLY_COMMIT}"
+
+
+info () {
+ logger -s -t "start.info" "$*"
+}
+
+
+error () {
+ logger -s -t "start.error" "$*"
+ exit 1
+}
+
+# Check if environment variables are set
+if [ -z ${INSTALLER_TYPE} ]; then
+ error "Environment variable 'INSTALLER_TYPE' is not defined."
+elif [ "${INSTALLER_TYPE}" != "fuel" ] && [ "${INSTALLER_TYPE}" != "foreman" ]; then
+ error "Invalid environment variable INSTALLER_TYPE=${INSTALLER_TYPE}"
+fi
+
+if [ -z ${INSTALLER_IP} ]; then
+ error "Environment variable 'INSTALLER_IP' is not defined."
+fi
+
+
+# Update repos
+cd ${FUNCTEST_REPO_DIR}
+git pull
+cd ${RELENG_REPO_DIR}
+git pull
+cd ${RALLY_REPO_DIR}
+git reset --hard ${RALLY_COMMIT}
+
+
+# Create directories
+mkdir -p ${FUNCTEST_CONF_DIR}
+mkdir -p ${FUNCTEST_DATA_DIR}
+mkdir -p ${FUNCTEST_RESULTS_DIR}/ODL
+
+# Detect type of installer
+# NOTE: this is tricky, since the IPs will have to be the same ALWAYS
+
+
+# Create Openstack credentials file
+${REPOS_DIR}/releng/utils/fetch_os_creds.sh -d ${FUNCTEST_CONF_DIR}/openstack.creds \
+ -i ${INSTALLER_TYPE} -a ${INSTALLER_IP}
+retval=$?
+if [ $retval != 0 ]; then
+ echo "Cannot retrieve credentials file from installation. Check logs."
+ exit $retval
+fi
+
+
+# Source credentials
+source ${FUNCTEST_CONF_DIR}/openstack.creds
+
+
+# Prepare Functest Environment
+echo "Functest: prepare Functest environment"
+python ${FUNCTEST_REPO_DIR}/testcases/config_functest.py --debug ${FUNCTEST_REPO_DIR}/ start
+retval=$?
+if [ $retval != 0 ]; then
+ echo "Error when configuring Functest environment"
+ exit $retval
+fi
+
+# vPing
+echo "Functest: run vPing"
+python ${FUNCTEST_REPO_DIR}/testcases/vPing/CI/libraries/vPing.py --debug ${FUNCTEST_REPO_DIR}/ -r
+
+# ODL
+echo "Functest: run ODL suite"
+
+if [ $INSTALLER_TYPE == "fuel" ]; then
+ odl_ip=$(keystone catalog --service network | grep publicURL | cut -f3 -d"/" | cut -f1 -d":")
+ neutron_ip=$(keystone catalog --service identity | grep publicURL | cut -f3 -d"/" | cut -f1 -d":")
+ usr_name=$(env | grep OS | grep OS_USERNAME | cut -f2 -d'=')
+ pass=$(env | grep OS | grep OS_PASSWORD | cut -f2 -d'=')
+ odl_port=8181
+ ODL_PORT=$odl_port ODL_IP=$odl_ip NEUTRON_IP=$neutron_ip USR_NAME=$usr_name PASS=$pass \
+ ${FUNCTEST_REPO_DIR}/testcases/Controllers/ODL/CI/start_tests.sh
+elif [ $INSTALLER_TYPE == "foreman" ]; then
+ #odl_port=8081
+ ${FUNCTEST_REPO_DIR}/testcases/Controllers/ODL/CI/start_tests.sh
+else
+ echo "INSTALLER_TYPE not valid."
+ exit 1
+fi
+
+# rally
+echo "Functest: run Functest Rally Bench suites"
+python ${FUNCTEST_REPO_DIR}/testcases/VIM/OpenStack/CI/libraries/run_rally.py --debug ${FUNCTEST_REPO_DIR}/ all
+
+# tempest
+echo "Functest: run Tempest suite"
+rally verify start smoke
+rally verify list
+
+# collect results
+echo "Functest: copy results and clean Functest environment"
+
+# save ODL results
+cp -Rf ${FUNCTEST_REPO_DIR}/testcases/Controllers/ODL/CI/logs ${FUNCTEST_RESULTS_DIR}/ODL
+
+# save tempest.conf for further troubleshooting
+cp $RALLY_VENV/tempest/for-deployment-*/tempest.conf ${FUNCTEST_CONF_DIR}
+
+
diff --git a/testcases/Controllers/ONOS/Teston/CI/adapters/environment.py b/testcases/Controllers/ONOS/Teston/CI/adapters/environment.py
new file mode 100644
index 00000000..0578d62f
--- /dev/null
+++ b/testcases/Controllers/ONOS/Teston/CI/adapters/environment.py
@@ -0,0 +1,212 @@
+"""
+Description:
+ This file is used to setup the running environment
+ Include Download code,setup environment variable
+ Set onos running config
+ Set user name/password
+ Onos-push-keys and so on
+ lanqinglong@huawei.com
+"""
+
+import os
+import time
+import pexpect
+import re
+import sys
+import pxssh
+from foundation import foundation
+
+class environment:
+
+ def __init__( self ):
+ self.loginfo = foundation( )
+ self.masterhandle = ''
+
+ def DownLoadCode( self, handle, codeurl ):
+ """
+ Download Code use 'git clone'
+ parameters:
+ handle: current working handle
+ codeurl: clone code url
+ """
+ print "Now loading test codes! Please wait in patient..."
+ originalfolder = os.getcwd()
+ gitclone = handle
+ gitclone.sendline( "git clone " + codeurl )
+ index = 0
+ while index != 1 or index != 4:
+ index = gitclone.expect ( ['already exists', 'resolving deltas: 100%', \
+ 'Receiving objects', 'Already up-to-date', \
+ pexpect.EOF] )
+
+ filefolder = originalfolder + '/' + codeurl.split('/')[-1].split('.')[0]
+ if index == 0 :
+ os.chdir( filefolder )
+ os.system( 'git pull' )
+ os.chdir( originalfolder )
+ self.loginfo.log( 'Download code success!' )
+ break
+ elif index == 1 :
+ self.loginfo.log( 'Download code success!' )
+ break
+ elif index == 2 :
+ increment += 1
+ if increment == 20:
+ print '\n'
+ print '.'
+ else :
+ self.loginfo.log( 'Download code failed!' )
+ self.loginfo.log( 'Information before' + gitclone.before )
+ break
+ time.sleep(5)
+ gitclone.prompt( )
+
+ def InstallDefaultSoftware( self, handle ):
+ """
+ Install default software
+ parameters:
+ handle(input): current working handle
+ """
+ print "Now Cleaning test environment"
+ handle.sendline("sudo apt-get install -y mininet")
+ handle.prompt( )
+ handle.sendline("sudo pip install configobj")
+ handle.prompt( )
+ handle.sendline("sudo apt-get install -y sshpass")
+ handle.prompt( )
+ handle.sendline("OnosSystemTest/TestON/bin/cleanup.sh")
+ handle.prompt( )
+ time.sleep(5)
+ self.loginfo.log( 'Clean environment success!' )
+
+ def OnosPushKeys(self, handle, cmd, password):
+ """
+ Using onos-push-keys to make ssh device without password
+ parameters:
+ handle(input): working handle
+ cmd(input): onos-push-keys xxx(xxx is device)
+ password(input): login in password
+ """
+ print "Now Pushing Onos Keys:"+cmd
+ Pushkeys = handle
+ Pushkeys.sendline( cmd )
+ Result = 0
+ while Result != 2:
+ Result = Pushkeys.expect( ["yes", "password", "#|$", pexpect.EOF, \
+ pexpect.TIMEOUT])
+ if ( Result == 0 ):
+ Pushkeys.sendline( "yes" )
+ if ( Result == 1 ):
+ Pushkeys.sendline( password )
+ if ( Result == 2 ):
+ self.loginfo.log( "ONOS Push keys Success!" )
+ if ( Result == 3 ):
+ self.loginfo.log( "ONOS Push keys Error!" )
+ Pushkeys.prompt( )
+ print "Done!"
+
+ def SetOnosEnvVar( self, handle, masterpass, agentpass):
+ """
+ Setup onos pushkeys to all devices(3+2)
+ parameters:
+ handle(input): current working handle
+ masterpass: scripts running server's password
+ agentpass: onos cluster&compute node password
+ """
+ print "Now Setting test environment"
+ self.OnosPushKeys( handle, "onos-push-keys " + self.OCT, masterpass)
+ self.OnosPushKeys( handle, "onos-push-keys " + self.OC1, agentpass)
+ self.OnosPushKeys( handle, "onos-push-keys " + self.OC2, agentpass)
+ self.OnosPushKeys( handle, "onos-push-keys " + self.OC3, agentpass)
+ self.OnosPushKeys( handle, "onos-push-keys " + self.OCN, agentpass)
+ self.OnosPushKeys( handle, "onos-push-keys " + self.OCN2, agentpass)
+
+ def ChangeOnosName( self, user, password):
+ """
+ Change onos name in envDefault file
+ Because some command depend on this
+ parameters:
+ user: onos&compute node user
+ password: onos&compute node password
+ """
+ print "Now Changing ONOS name&password"
+ if masterusername is 'root':
+ filepath = '/root/'
+ else :
+ filepath = '/home/' +masterusername + '/'
+ line = open(filepath + "onos/tools/build/envDefaults", 'r').readlines()
+ lenall = len(line)-1
+ for i in range(lenall):
+ if "ONOS_USER=" in line[i]:
+ line[i]=line[i].replace("sdn",user)
+ if "ONOS_GROUP" in line[i]:
+ line[i]=line[i].replace("sdn",user)
+ if "ONOS_PWD" in line[i]:
+ line[i]=line[i].replace("rocks",password)
+ NewFile = open("onos/tools/build/envDefaults",'w')
+ NewFile.writelines(line)
+ NewFile.close
+ print "Done!"
+
+ def ChangeTestCasePara(testcase,user,password):
+ """
+ When running test script, there's something need \
+ to change in every test folder's *.param & *.topo files
+ user: onos&compute node user
+ password: onos&compute node password
+ """
+ print "Now Changing " + testcase + " name&password"
+ if masterusername is 'root':
+ filepath = '/root/'
+ else :
+ filepath = '/home/' + masterusername + '/'
+ filepath = filepath +"OnosSystemTest/TestON/tests/" + testcase + "/" + \
+ testcase + ".topo"
+ line = open(filepath,'r').readlines()
+ lenall = len(line)-1
+ for i in range(lenall-2):
+ if ("localhost" in line[i]) or ("OCT" in line[i]):
+ line[i+1]=re.sub(">\w+",">"+user,line[i+1])
+ line[i+2]=re.sub(">\w+",">"+password,line[i+2])
+ if "OC1" in line [i] \
+ or "OC2" in line [i] \
+ or "OC3" in line [i] \
+ or "OCN" in line [i] \
+ or "OCN2" in line[i]:
+ line[i+1]=re.sub(">\w+",">root",line[i+1])
+ line[i+2]=re.sub(">\w+",">root",line[i+2])
+ NewFile = open(filepath,'w')
+ NewFile.writelines(line)
+ NewFile.close
+
+ def SSHlogin ( self, ipaddr, username, password ) :
+ """
+ SSH login provide a connection to destination.
+ parameters:
+ ipaddr: ip address
+ username: login user name
+ password: login password
+ return: handle
+ """
+ login = pxssh.pxssh( )
+ login.login ( ipaddr, username, password, original_prompt='[$#>]')
+ #send command ls -l
+ login.sendline ('ls -l')
+ #match prompt
+ login.prompt()
+ print ("SSH login " + ipaddr + " success!")
+ return login
+
+ def SSHRelease( self, handle ):
+ #Release ssh
+ handle.logout()
+
+ def OnosEnvSetup( self, handle ):
+ """
+ Onos Environment Setup function
+ """
+ self.DownLoadCode( handle, 'https://github.com/sunyulin/OnosSystemTest.git' )
+ self.DownLoadCode( handle, 'https://gerrit.onosproject.org/onos' )
+ self.ChangeOnosName(self.agentusername,self.agentpassword)
+ self.InstallDefaultSoftware( handle )
+ self.SetOnosEnvVar(handle, self.masterpassword,self.agentpassword) \ No newline at end of file
diff --git a/testcases/Controllers/ONOS/Teston/CI/adapters/foundation.py b/testcases/Controllers/ONOS/Teston/CI/adapters/foundation.py
new file mode 100644
index 00000000..2d6b8768
--- /dev/null
+++ b/testcases/Controllers/ONOS/Teston/CI/adapters/foundation.py
@@ -0,0 +1,32 @@
+"""
+Description:
+ This file include basis functions
+ lanqinglong@huawei.com
+"""
+
+import logging
+import os
+import time
+
+class foundation:
+
+ def __init__(self):
+ self.dir = os.path.join( os.getcwd(), 'log' )
+
+ def log (self, loginfo):
+ """
+ Record log in log directory for deploying test environment
+ parameters:
+ loginfo(input): record info
+ """
+ filename = time.strftime( '%Y-%m-%d-%H-%M-%S' ) + '.log'
+ filepath = os.path.join( self.dir, filename )
+ logging.basicConfig( level=logging.INFO,
+ format = '%(asctime)s %(filename)s:%(message)s',
+ datefmt = '%d %b %Y %H:%M:%S',
+ filename = filepath,
+ filemode = 'w')
+ filelog = logging.FileHandler( filepath )
+ logging.getLogger( 'Functest' ).addHandler( filelog )
+ print loginfo
+ logging.info(loginfo) \ No newline at end of file
diff --git a/testcases/config_functest.py b/testcases/config_functest.py
index 7fbd0604..507e2469 100644..100755
--- a/testcases/config_functest.py
+++ b/testcases/config_functest.py
@@ -13,6 +13,7 @@ import functest_utils
from git import Repo
from os import stat
from pwd import getpwuid
+from neutronclient.v2_0 import client as neutronclient
actions = ['start', 'check', 'clean']
parser = argparse.ArgumentParser()
@@ -50,33 +51,31 @@ f.close()
""" global variables """
# Directories
-HOME = os.environ['HOME']+"/"
REPO_PATH = args.repo_path
RALLY_DIR = REPO_PATH + functest_yaml.get("general").get("directories").get("dir_rally")
-RALLY_REPO_DIR = HOME + functest_yaml.get("general").get("directories").get("dir_rally_repo")
-RALLY_INSTALLATION_DIR = HOME + functest_yaml.get("general").get("directories").get("dir_rally_inst")
-RALLY_RESULT_DIR = HOME + functest_yaml.get("general").get("directories").get("dir_rally_res")
+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")
VPING_DIR = REPO_PATH + functest_yaml.get("general").get("directories").get("dir_vping")
ODL_DIR = REPO_PATH + functest_yaml.get("general").get("directories").get("dir_odl")
+IMAGE_DIR = functest_yaml.get("general").get("directories").get("dir_functest_data")
+# Tempest/Rally configuration details
+DEPLOYMENT_MAME = "opnfv-rally"
+RALLY_COMMIT = functest_yaml.get("general").get("openstack").get("rally_stable_commit")
#GLANCE image parameters
IMAGE_URL = functest_yaml.get("general").get("openstack").get("image_url")
IMAGE_DISK_FORMAT = functest_yaml.get("general").get("openstack").get("image_disk_format")
IMAGE_NAME = functest_yaml.get("general").get("openstack").get("image_name")
IMAGE_FILE_NAME = IMAGE_URL.rsplit('/')[-1]
-IMAGE_DIR = HOME + functest_yaml.get("general").get("openstack").get("image_download_path")
-IMAGE_PATH = IMAGE_DIR + IMAGE_FILE_NAME
+IMAGE_PATH = IMAGE_DIR + "/" + IMAGE_FILE_NAME
def action_start():
"""
Start the functest environment installation
"""
- if not check_permissions():
- logger.error("Bad Python cache directory ownership.")
- exit(-1)
-
if not functest_utils.check_internet_connectivity():
logger.error("There is no Internet connectivity. Please check the network configuration.")
exit(-1)
@@ -90,11 +89,6 @@ def action_start():
logger.debug("Cleaning possible functest environment leftovers.")
action_clean()
- logger.info("Installing needed libraries on the host")
- cmd = "sudo yum -y install gcc libffi-devel python-devel openssl-devel gmp-devel libxml2-devel libxslt-devel postgresql-devel git wget"
- if not functest_utils.execute_command(cmd, logger):
- logger.error("There has been a problem while installing software packages.")
- exit(-1)
logger.info("Installing ODL environment...")
if not install_odl():
@@ -109,6 +103,12 @@ def action_start():
action_clean()
exit(-1)
+ logger.info("Configuring Tempest...")
+ if not configure_tempest():
+ logger.error("There has been a problem while configuring Tempest.")
+ action_clean()
+ exit(-1)
+
# Create result folder under functest if necessary
if not os.path.exists(RALLY_RESULT_DIR):
os.makedirs(RALLY_RESULT_DIR)
@@ -133,11 +133,11 @@ def action_check():
Check if the functest environment is properly installed
"""
errors_all = False
-
+ errors = False
logger.info("Checking current functest configuration...")
logger.debug("Checking script directories...")
- errors = False
+
dirs = [RALLY_DIR, RALLY_INSTALLATION_DIR, VPING_DIR, ODL_DIR]
for dir in dirs:
if not os.path.exists(dir):
@@ -188,11 +188,7 @@ def action_check():
logger.debug("...FAIL")
#TODO: check OLD environment setup
- if errors_all:
- return False
- else:
- return True
-
+ return not errors_all
@@ -205,11 +201,6 @@ def action_clean():
logger.debug("Removing Rally installation directory %s" % RALLY_INSTALLATION_DIR)
shutil.rmtree(RALLY_INSTALLATION_DIR,ignore_errors=True)
- if os.path.exists(RALLY_REPO_DIR):
- logger.debug("Removing Rally repository %s" % RALLY_REPO_DIR)
- cmd = "sudo rm -rf " + RALLY_REPO_DIR #need to be sudo, not possible with rmtree
- functest_utils.execute_command(cmd,logger)
-
if os.path.exists(IMAGE_PATH):
logger.debug("Deleting image")
os.remove(IMAGE_PATH)
@@ -231,35 +222,17 @@ def action_clean():
-def check_permissions():
- current_user = getpass.getuser()
- cache_dir = HOME+".cache/pip"
- logger.info("Checking permissions of '%s'..." %cache_dir)
- logger.debug("Current user is '%s'" %current_user)
- cache_user = getpwuid(stat(cache_dir).st_uid).pw_name
- logger.debug("Cache directory owner is '%s'" %cache_user)
- if cache_user != current_user:
- logger.info("The owner of '%s' is '%s'. Please run 'sudo chown -R %s %s'." %(cache_dir, cache_user, current_user, cache_dir))
- return False
-
- return True
-
-
def install_rally():
if check_rally():
logger.info("Rally is already installed.")
else:
- logger.debug("Cloning repository...")
- url = "https://git.openstack.org/openstack/rally"
- Repo.clone_from(url, RALLY_REPO_DIR)
-
- logger.debug("Executing %s./install_rally.sh..." %RALLY_REPO_DIR)
- install_script = RALLY_REPO_DIR + "install_rally.sh --yes"
+ logger.debug("Executing %s/install_rally.sh..." %RALLY_REPO_DIR)
+ install_script = RALLY_REPO_DIR + "/install_rally.sh --yes"
cmd = 'sudo ' + install_script
functest_utils.execute_command(cmd,logger)
logger.debug("Creating Rally environment...")
- cmd = "rally deployment create --fromenv --name=opnfv-arno-rally"
+ cmd = "rally deployment create --fromenv --name="+DEPLOYMENT_MAME
functest_utils.execute_command(cmd,logger)
logger.debug("Installing tempest...")
@@ -279,6 +252,40 @@ def install_rally():
return True
+def configure_tempest():
+ """
+ Add/update needed parameters into tempest.conf file generated by Rally
+ """
+
+ creds_neutron = functest_utils.get_credentials("neutron")
+ neutron_client = neutronclient.Client(**creds_neutron)
+
+ logger.debug("Generating tempest.conf file...")
+ cmd = "rally verify genconfig"
+ functest_utils.execute_command(cmd,logger)
+
+ logger.debug("Resolving deployment UUID...")
+ cmd = "rally deployment list | awk '/"+DEPLOYMENT_MAME+"/ {print $2}'"
+ p = subprocess.Popen(cmd, shell=True,
+ stdout=subprocess.PIPE,
+ stderr=subprocess.STDOUT);
+ deployment_uuid = p.stdout.readline().rstrip()
+ if deployment_uuid == "":
+ logger.debug(" Rally deployment NOT found")
+ return False
+
+ logger.debug("Finding tempest.conf file...")
+ tempest_conf_file = RALLY_INSTALLATION_DIR+"/tempest/for-deployment-" \
+ +deployment_uuid+"/tempest.conf"
+
+ logger.debug(" Updating fixed_network_name...")
+ fixed_network = functest_utils.get_network_list(neutron_client)[0]['name']
+ if fixed_network != None:
+ cmd = "crudini --set "+tempest_conf_file+" compute fixed_network_name "+fixed_network
+ functest_utils.execute_command(cmd,logger)
+
+ return True
+
def check_rally():
"""
@@ -287,7 +294,7 @@ def check_rally():
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 opnfv";
+ 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
@@ -316,7 +323,8 @@ def create_glance_image(path,name,disk_format):
"""
Create a glance image given the absolute path of the image, its name and the disk format
"""
- cmd = "glance image-create --name "+name+" --is-public true --disk-format "+disk_format+" --container-format bare --file "+path
+ cmd = ("glance image-create --name "+name+" --visibility public "
+ "--disk-format "+disk_format+" --container-format bare --file "+path)
functest_utils.execute_command(cmd,logger)
return True
diff --git a/testcases/config_functest.yaml b/testcases/config_functest.yaml
index e8ee6d9c..dcbac092 100644
--- a/testcases/config_functest.yaml
+++ b/testcases/config_functest.yaml
@@ -6,17 +6,26 @@ general:
dir_rally: testcases/VIM/OpenStack/CI/libraries/
dir_rally_scn: testcases/VIM/OpenStack/CI/suites/
dir_vIMS: testcases/vIMS/CI/
- # Relative to $HOME:
- dir_vIMS_data: functest/vIMS_data/ # $HOME/functest/vIMS_data/
- dir_rally_res: functest/results/ # $HOME/functest/results
- dir_rally_repo: functest/Rally_repo/ # $HOME/Rally_repo/
- dir_rally_inst: .rally/ # $HOME/.rally/ usually
+
+ # Absolute path
+ dir_repos: /home/opnfv/repos
+ dir_repo_functest: /home/opnfv/repos/functest
+ dir_repo_rally: /home/opnfv/repos/rally
+ dir_repo_releng: /home/opnfv/repos/releng
+ dir_functest: /home/opnfv/functest
+ dir_results: /home/opnfv/functest/results
+ dir_functest_conf: /home/opnfv/functest/conf
+ dir_rally_res: /home/opnfv/functest/results/rally
+ dir_functest_data: /home/opnfv/functest/data
+ dir_vIMS_data: /home/opnfv/functest/data/vIMS
+ dir_rally_inst: ~/.rally
openstack:
image_name: functest-img
image_url: http://download.cirros-cloud.net/0.3.4/cirros-0.3.4-x86_64-disk.img
image_disk_format: qcow2
- image_download_path: functest/ # $HOME/functest/
+ rally_stable_commit: 9a17d8490e7fb4afee2f5629e6db41eabe4bc4d4
+
#Public network. Optional
neutron_public_net_name: net04_ext
neutron_public_subnet_name: net04_ext__subnet
@@ -88,4 +97,4 @@ vIMS:
external_network_name: ''
public_domain: clearwater.opnfv
results:
- test_db_url: http://213.77.62.197 \ No newline at end of file
+ test_db_url: http://213.77.62.197
diff --git a/testcases/functest_utils.py b/testcases/functest_utils.py
index 6d60fbce..c2e4bc6d 100644
--- a/testcases/functest_utils.py
+++ b/testcases/functest_utils.py
@@ -344,7 +344,7 @@ def download_url(url, dest_path):
Download a file to a destination path given a URL
"""
name = url.rsplit('/')[-1]
- dest = dest_path + name
+ dest = dest_path + "/" + name
try:
response = urllib2.urlopen(url)
except (urllib2.HTTPError, urllib2.URLError):