aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwuwb1989 <wuwenbin2@huawei.com>2016-07-04 10:55:44 +0800
committerJose Lausuch <jose.lausuch@ericsson.com>2016-07-04 11:14:36 +0000
commit0e3995a63d1a82fbc508dbb3ff591da2b8c0f22a (patch)
treed54165b18ca41fc59317c37e3a1dcf3b7014536c
parented39c21344dc4b4209eb4319ba15ce60defc3e90 (diff)
Add interface to run sfc functests.
Varified only in fuel. Prerequisite: no floating ip exists. Change-Id: If6ef4c395992ba1544559b47c5c97f7cd5ce004c Signed-off-by: wuwb1989 <wuwenbin2@huawei.com>
-rw-r--r--ci/config_functest.yaml7
-rwxr-xr-xci/exec_test.sh6
-rw-r--r--docker/Dockerfile1
-rw-r--r--testcases/Controllers/ONOS/Teston/onosfunctest.py76
4 files changed, 78 insertions, 12 deletions
diff --git a/ci/config_functest.yaml b/ci/config_functest.yaml
index ea502dac..78e71432 100644
--- a/ci/config_functest.yaml
+++ b/ci/config_functest.yaml
@@ -7,6 +7,7 @@ general:
dir_tempest_cases: testcases/OpenStack/tempest/custom_tests/
dir_vIMS: testcases/vIMS/
dir_onos: testcases/Controllers/ONOS/Teston/
+ dir_onos_sfc: testcases/Controllers/ONOS/Sfc/
# Absolute path
dir_repos: /home/opnfv/repos
@@ -34,7 +35,7 @@ general:
image_name: Cirros-0.3.4
image_file_name: cirros-0.3.4-x86_64-disk.img
image_disk_format: qcow2
-
+
# Private network for functest. Will be created by config_functest.py
neutron_private_net_name: functest-net
neutron_private_subnet_name: functest-subnet
@@ -57,6 +58,10 @@ vping:
vping_sg_name: vPing-sg
vping_sg_descr: Security group for vPing test case
+onos_sfc:
+ image_name: TestSfcVm
+ image_file_name: firewall_block_image.img
+
tempest:
identity:
tenant_name: tempest
diff --git a/ci/exec_test.sh b/ci/exec_test.sh
index 4a75bcbd..c0bdf96b 100755
--- a/ci/exec_test.sh
+++ b/ci/exec_test.sh
@@ -115,11 +115,7 @@ function run_test(){
python ${FUNCTEST_REPO_DIR}/testcases/features/bgpvpn.py
;;
"onos")
- if [ "$INSTALLER_TYPE" == "joid" ]; then
- python ${FUNCTEST_REPO_DIR}/testcases/Controllers/ONOS/Teston/onosfunctest.py -i joid
- else
- python ${FUNCTEST_REPO_DIR}/testcases/Controllers/ONOS/Teston/onosfunctest.py
- fi
+ python ${FUNCTEST_REPO_DIR}/testcases/Controllers/ONOS/Teston/onosfunctest.py
;;
"promise")
python ${FUNCTEST_REPO_DIR}/testcases/features/promise.py $report
diff --git a/docker/Dockerfile b/docker/Dockerfile
index ae1343c2..20df28ba 100644
--- a/docker/Dockerfile
+++ b/docker/Dockerfile
@@ -86,6 +86,7 @@ RUN pip install -r ${repos_dir}/tempest/requirements.txt
RUN ${repos_dir}/rally/install_rally.sh --yes
ADD http://download.cirros-cloud.net/0.3.4/cirros-0.3.4-x86_64-disk.img /home/opnfv/functest/data/
+ADD http://205.177.226.237:9999/onosfw/firewall_block_image.img /home/opnfv/functest/data/
RUN gpg --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3
RUN curl -L https://get.rvm.io | bash -s stable
diff --git a/testcases/Controllers/ONOS/Teston/onosfunctest.py b/testcases/Controllers/ONOS/Teston/onosfunctest.py
index f97d415d..780e36c9 100644
--- a/testcases/Controllers/ONOS/Teston/onosfunctest.py
+++ b/testcases/Controllers/ONOS/Teston/onosfunctest.py
@@ -14,19 +14,23 @@ lanqinglong@huawei.com
#
"""
-import argparse
+# import argparse
import datetime
import os
import re
import time
import yaml
+from keystoneclient.v2_0 import client as keystoneclient
+from glanceclient import client as glanceclient
+
import functest.utils.functest_logger as ft_logger
import functest.utils.functest_utils as functest_utils
+import functest.utils.openstack_utils as openstack_utils
-parser = argparse.ArgumentParser()
-parser.add_argument("-i", "--installer", help="Installer type")
-args = parser.parse_args()
+# parser = argparse.ArgumentParser()
+# parser.add_argument("-i", "--installer", help="Installer type")
+# args = parser.parse_args()
""" logging configuration """
logger = ft_logger.Logger("onos").getLogger()
@@ -49,6 +53,17 @@ ONOSCI_PATH = ONOS_REPO_PATH + "/"
starttime = datetime.datetime.now()
HOME = os.environ['HOME'] + "/"
+INSTALLER_TYPE = os.environ['INSTALLER_TYPE']
+DEPLOY_SCENARIO = os.environ['DEPLOY_SCENARIO']
+ONOSCI_PATH = ONOS_REPO_PATH + "/"
+GLANCE_IMAGE_NAME = functest_yaml.get("onos_sfc").get("image_name")
+GLANCE_IMAGE_FILENAME = functest_yaml.get("onos_sfc").get("image_file_name")
+GLANCE_IMAGE_FORMAT = functest_yaml.get("general").get("openstack").get(
+ "image_disk_format")
+GLANCE_IMAGE_PATH = functest_yaml.get("general").get("directories").get(
+ "dir_functest_data") + "/" + GLANCE_IMAGE_FILENAME
+SFC_PATH = REPO_PATH + functest_yaml.get("general").get("directories").get(
+ "dir_onos_sfc")
def RunScript(testname):
@@ -163,18 +178,67 @@ def CleanOnosTest():
logger.debug("Clean ONOS Teston")
+def CreateImage():
+ creds_keystone = openstack_utils.get_credentials("keystone")
+ keystone_client = keystoneclient.Client(**creds_keystone)
+ glance_endpoint = keystone_client.service_catalog.url_for(
+ service_type='image', endpoint_type='publicURL')
+ glance_client = glanceclient.Client(1, glance_endpoint,
+ token=keystone_client.auth_token)
+ EXIT_CODE = -1
+ # Check if the given image exists
+ image_id = openstack_utils.get_image_id(glance_client, GLANCE_IMAGE_NAME)
+ if image_id != '':
+ logger.info("Using existing image '%s'..." % GLANCE_IMAGE_NAME)
+ global image_exists
+ image_exists = True
+ else:
+ logger.info("Creating image '%s' from '%s'..." % (GLANCE_IMAGE_NAME,
+ GLANCE_IMAGE_PATH))
+ image_id = openstack_utils.create_glance_image(glance_client,
+ GLANCE_IMAGE_NAME,
+ GLANCE_IMAGE_PATH)
+ if not image_id:
+ logger.error("Failed to create a Glance image...")
+ return(EXIT_CODE)
+ logger.debug("Image '%s' with ID=%s created successfully."
+ % (GLANCE_IMAGE_NAME, image_id))
+
+
+def SfcTest():
+ cmd = "python " + SFC_PATH + "Sfc.py"
+ logger.debug("Run sfc tests")
+ os.system(cmd)
+
+
+def SetSfcIp():
+ cmd = "openstack catalog show network | grep publicURL"
+ cmd_output = os.popen(cmd).read()
+ ip = re.search(r"\d+\.\d+\.\d+\.\d+", cmd_output).group()
+ cmd_onos_ip = "sed -i 's/onos_ip/" + ip + "/g' " + SFC_PATH + "Sfc_fun.py"
+ cmd_openstack_ip = "sed -i 's/openstack_ip/" + ip\
+ + "/g' " + SFC_PATH + "Sfc_fun.py"
+ logger.info("Modify ip for SFC")
+ os.system(cmd_onos_ip)
+ os.system(cmd_openstack_ip)
+
+
def main():
start_time = time.time()
stop_time = start_time
# DownloadCodes()
- if args.installer == "joid":
+ # if args.installer == "joid":
+ if INSTALLER_TYPE == "joid":
logger.debug("Installer is Joid")
SetOnosIpForJoid()
else:
SetOnosIp()
RunScript("FUNCvirNetNB")
RunScript("FUNCvirNetNBL3")
-
+ if DEPLOY_SCENARIO == "os-onos-sfc-ha":
+ CreateImage()
+ SetSfcIp()
+ SfcTest()
try:
logger.debug("Push ONOS results into DB")
# TODO check path result for the file