aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMorgan Richomme <morgan.richomme@orange.com>2016-05-17 13:27:40 +0000
committerGerrit Code Review <gerrit@172.30.200.206>2016-05-17 13:27:40 +0000
commitd338cc665efc9a2d73d6dff1567dc6de6bc63bd8 (patch)
treec64a765136c0330ec72872166af1a7fe57f73a32
parent8f645a8d931da93f99c15593e2bd1f4d93a6d987 (diff)
parent9bdb8955ba266abc34e1ab069ad0ee013dcf57ba (diff)
Merge "BGPVPN test case refactored"
-rwxr-xr-xci/exec_test.sh17
-rw-r--r--testcases/VIM/OpenStack/CI/libraries/run_tempest.py17
-rw-r--r--testcases/features/bgpvpn.py58
-rw-r--r--utils/functest_utils.py26
4 files changed, 86 insertions, 32 deletions
diff --git a/ci/exec_test.sh b/ci/exec_test.sh
index cdf70e05..013b98c2 100755
--- a/ci/exec_test.sh
+++ b/ci/exec_test.sh
@@ -113,22 +113,7 @@ function run_test(){
$debug $clean_flag --sanity all $report
;;
"bgpvpn")
- 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
- echo "Make sure tempest was running before" >&2
- 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
+ python ${FUNCTEST_REPO_DIR}/testcases/features/bgpvpn.py
;;
"onos")
if [ "$INSTALLER_TYPE" == "joid" ]; then
diff --git a/testcases/VIM/OpenStack/CI/libraries/run_tempest.py b/testcases/VIM/OpenStack/CI/libraries/run_tempest.py
index 9eca6cbd..bf62ce30 100644
--- a/testcases/VIM/OpenStack/CI/libraries/run_tempest.py
+++ b/testcases/VIM/OpenStack/CI/libraries/run_tempest.py
@@ -172,21 +172,6 @@ def create_tempest_resources():
exit(-1)
-def get_deployment_dir():
- logger.debug("Resolving deployment UUID and directory...")
- 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.error("Rally deployment NOT found.")
- exit(-1)
- deployment_dir = (RALLY_INSTALLATION_DIR + "/tempest/for-deployment-" +
- deployment_uuid)
- return deployment_dir
-
-
def configure_tempest(deployment_dir):
"""
Add/update needed parameters into tempest.conf file generated by Rally
@@ -345,7 +330,7 @@ def main():
if not os.path.exists(TEMPEST_RESULTS_DIR):
os.makedirs(TEMPEST_RESULTS_DIR)
- deployment_dir = get_deployment_dir()
+ deployment_dir = ft_utils.get_deployment_dir(logger)
configure_tempest(deployment_dir)
create_tempest_resources()
generate_test_list(deployment_dir, args.mode)
diff --git a/testcases/features/bgpvpn.py b/testcases/features/bgpvpn.py
new file mode 100644
index 00000000..a6e66b1f
--- /dev/null
+++ b/testcases/features/bgpvpn.py
@@ -0,0 +1,58 @@
+#!/usr/bin/python
+#
+# Copyright (c) 2015 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
+#
+# Execute BGPVPN Tempest test cases
+#
+
+import os
+import yaml
+import ConfigParser
+
+import functest.utils.functest_logger as ft_logger
+import functest.utils.functest_utils as ft_utils
+
+with open(os.environ["CONFIG_FUNCTEST_YAML"]) as f:
+ functest_yaml = yaml.safe_load(f)
+
+dirs = functest_yaml.get('general').get('directories')
+FUNCTEST_REPO = dirs.get('dir_repo_functest')
+BGPVPN_REPO = dirs.get('dir_repo_bgpvpn')
+TEST_DB_URL = functest_yaml.get('results').get('test_db_url')
+
+logger = ft_logger.Logger("bgpvpn").getLogger()
+
+
+def main():
+ logger.info("Running BGPVPN Tempest test case...")
+
+ cmd = 'cd ' + BGPVPN_REPO + ';pip install --no-deps -e .'
+ ft_utils.execute_command(cmd, logger, exit_on_error=False)
+
+ src_tempest_dir = ft_utils.get_deployment_dir(logger)
+ if not src_tempest_dir:
+ logger.error("Rally deployment not found.")
+ exit(-1)
+
+ src_tempest_conf = src_tempest_dir + '/tempest.conf'
+ dst_tempest_conf = src_tempest_dir + '/etc/tempest.conf'
+
+ config = ConfigParser.RawConfigParser()
+ config.read(src_tempest_conf)
+ config.set('service_available', 'bgpvpn', 'True')
+ with open(dst_tempest_conf, 'wb') as config_file:
+ config.write(config_file)
+
+ cmd = (src_tempest_dir +
+ '/run_tempest.sh -t -N -- networking_bgpvpn_tempest;'
+ 'rm -rf ' + dst_tempest_conf)
+ ft_utils.execute_command(cmd, logger, exit_on_error=False)
+
+
+if __name__ == '__main__':
+ main()
diff --git a/utils/functest_utils.py b/utils/functest_utils.py
index 2d871615..8ee5346c 100644
--- a/utils/functest_utils.py
+++ b/utils/functest_utils.py
@@ -18,6 +18,7 @@ import socket
import subprocess
import sys
import urllib2
+import yaml
from git import Repo
@@ -235,3 +236,28 @@ def execute_command(cmd, logger=None,
sys.exit(1)
return p.returncode
+
+
+def get_deployment_dir(logger=None):
+ """
+ Returns current Rally deployment directory
+ """
+ with open(os.environ["CONFIG_FUNCTEST_YAML"]) as f:
+ functest_yaml = yaml.safe_load(f)
+ f.close()
+ deployment_name = functest_yaml.get("rally").get("deployment_name")
+ rally_dir = functest_yaml.get("general").get("directories").get(
+ "dir_rally_inst")
+ cmd = ("rally deployment list | awk '/" + deployment_name +
+ "/ {print $2}'")
+ p = subprocess.Popen(cmd, shell=True,
+ stdout=subprocess.PIPE,
+ stderr=subprocess.STDOUT)
+ deployment_uuid = p.stdout.readline().rstrip()
+ if deployment_uuid == "":
+ if logger:
+ logger.error("Rally deployment not found.")
+ exit(-1)
+ deployment_dir = (rally_dir + "/tempest/for-deployment-" +
+ deployment_uuid)
+ return deployment_dir