summaryrefslogtreecommitdiffstats
path: root/testcases/features
diff options
context:
space:
mode:
Diffstat (limited to 'testcases/features')
-rwxr-xr-xtestcases/features/copper.py8
-rwxr-xr-xtestcases/features/doctor.py28
-rwxr-xr-xtestcases/features/domino.py35
-rwxr-xr-xtestcases/features/promise.py75
-rwxr-xr-xtestcases/features/sfc/prepare_odl_sfc.bash38
-rwxr-xr-xtestcases/features/sfc/sfc.py86
6 files changed, 179 insertions, 91 deletions
diff --git a/testcases/features/copper.py b/testcases/features/copper.py
index 50319d965..be6744a95 100755
--- a/testcases/features/copper.py
+++ b/testcases/features/copper.py
@@ -28,10 +28,10 @@ parser.add_argument("-r", "--report",
action="store_true")
args = parser.parse_args()
-COPPER_REPO = functest_utils.get_parameter_from_yaml(
- 'general.directories.dir_repo_copper')
-RESULTS_DIR = functest_utils.get_parameter_from_yaml(
- 'general.directories.dir_results')
+COPPER_REPO = \
+ functest_utils.get_functest_config('general.directories.dir_repo_copper')
+RESULTS_DIR = \
+ functest_utils.get_functest_config('general.directories.dir_results')
logger = ft_logger.Logger("copper").getLogger()
diff --git a/testcases/features/doctor.py b/testcases/features/doctor.py
index 5fc0713f9..6c26875d3 100755
--- a/testcases/features/doctor.py
+++ b/testcases/features/doctor.py
@@ -13,12 +13,14 @@
# 0.2: measure test duration and publish results under json format
#
#
+import argparse
+import os
import time
-import argparse
import functest.utils.functest_logger as ft_logger
import functest.utils.functest_utils as functest_utils
+
parser = argparse.ArgumentParser()
parser.add_argument("-r", "--report",
help="Create json result file",
@@ -27,28 +29,40 @@ args = parser.parse_args()
functest_yaml = functest_utils.get_functest_yaml()
-dirs = functest_yaml.get('general').get('directories')
-DOCTOR_REPO = dirs.get('dir_repo_doctor')
+DOCTOR_REPO = \
+ functest_utils.get_functest_config('general.directories.dir_repo_doctor')
+RESULTS_DIR = \
+ functest_utils.get_functest_config('general.directories.dir_results')
logger = ft_logger.Logger("doctor").getLogger()
def main():
exit_code = -1
+
+ # if the image name is explicitly set for the doctor suite, set it as
+ # enviroment variable
+ if 'doctor' in functest_yaml and 'image_name' in functest_yaml['doctor']:
+ os.environ["IMAGE_NAME"] = functest_yaml['doctor']['image_name']
+
cmd = 'cd %s/tests && ./run.sh' % DOCTOR_REPO
+ log_file = RESULTS_DIR + "/doctor.log"
+
start_time = time.time()
- ret = functest_utils.execute_command(cmd, info=True,
- exit_on_error=False)
+ ret = functest_utils.execute_command(cmd,
+ info=True,
+ exit_on_error=False,
+ output_file=log_file)
stop_time = time.time()
duration = round(stop_time - start_time, 1)
if ret == 0:
- logger.info("doctor OK")
+ logger.info("Doctor test case OK")
test_status = 'OK'
exit_code = 0
else:
- logger.info("doctor FAILED")
+ logger.info("Doctor test case FAILED")
test_status = 'NOK'
details = {
diff --git a/testcases/features/domino.py b/testcases/features/domino.py
index aaf38047b..75351a56e 100755
--- a/testcases/features/domino.py
+++ b/testcases/features/domino.py
@@ -14,11 +14,11 @@
# 0.3: add report flag to push results when needed
#
+import argparse
import time
-import argparse
import functest.utils.functest_logger as ft_logger
-import functest.utils.functest_utils as functest_utils
+import functest.utils.functest_utils as ft_utils
parser = argparse.ArgumentParser()
@@ -27,19 +27,23 @@ parser.add_argument("-r", "--report",
action="store_true")
args = parser.parse_args()
-functest_yaml = functest_utils.get_functest_yaml()
-dirs = functest_yaml.get('general').get('directories')
-DOMINO_REPO = dirs.get('dir_repo_domino')
+DOMINO_REPO = \
+ ft_utils.get_functest_config('general.directories.dir_repo_domino')
+RESULTS_DIR = \
+ ft_utils.get_functest_config('general.directories.dir_results')
logger = ft_logger.Logger("domino").getLogger()
def main():
cmd = 'cd %s && ./tests/run_multinode.sh' % DOMINO_REPO
+ log_file = RESULTS_DIR + "/domino.log"
start_time = time.time()
- ret = functest_utils.execute_command(cmd, exit_on_error=False)
+ ret = ft_utils.execute_command(cmd,
+ exit_on_error=False,
+ output_file=log_file)
stop_time = time.time()
duration = round(stop_time - start_time, 1)
@@ -65,17 +69,18 @@ def main():
elif details['status'] == "SKIPPED":
status = "SKIP"
- functest_utils.logger_test_results("Domino",
- "domino-multinode",
- status, details)
+ ft_utils.logger_test_results("Domino",
+ "domino-multinode",
+ status,
+ details)
if args.report:
if status is not "SKIP":
- functest_utils.push_results_to_db("domino",
- "domino-multinode",
- start_time,
- stop_time,
- status,
- details)
+ ft_utils.push_results_to_db("domino",
+ "domino-multinode",
+ start_time,
+ stop_time,
+ status,
+ details)
logger.info("Domino results pushed to DB")
diff --git a/testcases/features/promise.py b/testcases/features/promise.py
index 47e360ca3..cce0f5dc1 100755
--- a/testcases/features/promise.py
+++ b/testcases/features/promise.py
@@ -9,18 +9,19 @@
#
# Maintainer : jose.lausuch@ericsson.com
#
+import argparse
import json
import os
import subprocess
import time
-import argparse
import functest.utils.functest_logger as ft_logger
-import functest.utils.functest_utils as functest_utils
+import functest.utils.functest_utils as ft_utils
import functest.utils.openstack_utils as openstack_utils
import keystoneclient.v2_0.client as ksclient
-import novaclient.client as nvclient
from neutronclient.v2_0 import client as ntclient
+import novaclient.client as nvclient
+
parser = argparse.ArgumentParser()
@@ -30,35 +31,35 @@ parser.add_argument("-r", "--report",
action="store_true")
args = parser.parse_args()
-functest_yaml = functest_utils.get_functest_yaml()
-dirs = functest_yaml.get('general').get('directories')
+dirs = ft_utils.get_functest_config('general.directories')
PROMISE_REPO = dirs.get('dir_repo_promise')
-TEST_DB = functest_yaml.get('results').get('test_db_url')
-
-TENANT_NAME = functest_yaml.get('promise').get('general').get('tenant_name')
-TENANT_DESCRIPTION = functest_yaml.get('promise').get(
- 'general').get('tenant_description')
-USER_NAME = functest_yaml.get('promise').get('general').get('user_name')
-USER_PWD = functest_yaml.get('promise').get('general').get('user_pwd')
-IMAGE_NAME = functest_yaml.get('promise').get('general').get('image_name')
-FLAVOR_NAME = functest_yaml.get('promise').get('general').get('flavor_name')
-FLAVOR_VCPUS = functest_yaml.get('promise').get('general').get('flavor_vcpus')
-FLAVOR_RAM = functest_yaml.get('promise').get('general').get('flavor_ram')
-FLAVOR_DISK = functest_yaml.get('promise').get('general').get('flavor_disk')
-
-
-GLANCE_IMAGE_FILENAME = functest_yaml.get('general').get('openstack').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
-
-NET_NAME = functest_yaml.get('promise').get('general').get('network_name')
-SUBNET_NAME = functest_yaml.get('promise').get('general').get('subnet_name')
-SUBNET_CIDR = functest_yaml.get('promise').get('general').get('subnet_cidr')
-ROUTER_NAME = functest_yaml.get('promise').get('general').get('router_name')
+RESULTS_DIR = ft_utils.get_functest_config('general.directories.dir_results')
+
+TENANT_NAME = ft_utils.get_functest_config('promise.tenant_name')
+TENANT_DESCRIPTION = \
+ ft_utils.get_functest_config('promise.tenant_description')
+USER_NAME = ft_utils.get_functest_config('promise.user_name')
+USER_PWD = ft_utils.get_functest_config('promise.user_pwd')
+IMAGE_NAME = ft_utils.get_functest_config('promise.image_name')
+FLAVOR_NAME = ft_utils.get_functest_config('promise.flavor_name')
+FLAVOR_VCPUS = ft_utils.get_functest_config('promise.flavor_vcpus')
+FLAVOR_RAM = ft_utils.get_functest_config('promise.flavor_ram')
+FLAVOR_DISK = ft_utils.get_functest_config('promise.flavor_disk')
+
+
+GLANCE_IMAGE_FILENAME = \
+ ft_utils.get_functest_config('general.openstack.image_file_name')
+GLANCE_IMAGE_FORMAT = \
+ ft_utils.get_functest_config('general.openstack.image_disk_format')
+GLANCE_IMAGE_PATH = \
+ ft_utils.get_functest_config('general.directories.dir_functest_data') + \
+ "/" + GLANCE_IMAGE_FILENAME
+
+NET_NAME = ft_utils.get_functest_config('promise.network_name')
+SUBNET_NAME = ft_utils.get_functest_config('promise.subnet_name')
+SUBNET_CIDR = ft_utils.get_functest_config('promise.subnet_cidr')
+ROUTER_NAME = ft_utils.get_functest_config('promise.router_name')
""" logging configuration """
@@ -181,7 +182,7 @@ def main():
os.environ["OS_TEST_NETWORK"] = network_dic["net_id"]
os.chdir(PROMISE_REPO)
- results_file_name = 'promise-results.json'
+ results_file_name = RESULTS_DIR + '/' + 'promise-results.json'
results_file = open(results_file_name, 'w+')
cmd = 'npm run -s test -- --reporter json'
@@ -240,12 +241,12 @@ def main():
status = "PASS"
exit_code = 0
- functest_utils.push_results_to_db("promise",
- "promise",
- start_time,
- stop_time,
- status,
- json_results)
+ ft_utils.push_results_to_db("promise",
+ "promise",
+ start_time,
+ stop_time,
+ status,
+ json_results)
exit(exit_code)
diff --git a/testcases/features/sfc/prepare_odl_sfc.bash b/testcases/features/sfc/prepare_odl_sfc.bash
new file mode 100755
index 000000000..80ed9bd92
--- /dev/null
+++ b/testcases/features/sfc/prepare_odl_sfc.bash
@@ -0,0 +1,38 @@
+#!/bin/bash
+
+#
+# Author: George Paraskevopoulos (geopar@intracom-telecom.com)
+# Manuel Buil (manuel.buil@ericsson.com)
+# Prepares the controller and the compute nodes for the odl-sfc testcase
+#
+#
+# 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
+#
+
+ODL_SFC_LOG=/home/opnfv/functest/results/odl-sfc.log
+ODL_SFC_DIR=${FUNCTEST_REPO_DIR}/testcases/features/sfc
+
+# Split the output to the log file and redirect STDOUT and STDERR to /dev/null
+bash ${ODL_SFC_DIR}/server_presetup_CI.bash |& \
+ tee -a ${ODL_SFC_LOG} 1>/dev/null 2>&1
+
+# Get return value from PIPESTATUS array (bash specific feature)
+ret_val=${PIPESTATUS[0]}
+if [ $ret_val != 0 ]; then
+ echo "The tacker server deployment failed"
+ exit $ret_val
+fi
+echo "The tacker server was deployed successfully"
+
+bash ${ODL_SFC_DIR}/compute_presetup_CI.bash |& \
+ tee -a ${ODL_SFC_LOG} 1>/dev/null 2>&1
+
+ret_val=${PIPESTATUS[0]}
+if [ $ret_val != 0 ]; then
+ exit $ret_val
+fi
+
+exit 0
diff --git a/testcases/features/sfc/sfc.py b/testcases/features/sfc/sfc.py
index a228ed298..8aa7bb9a0 100755
--- a/testcases/features/sfc/sfc.py
+++ b/testcases/features/sfc/sfc.py
@@ -4,11 +4,11 @@ import sys
import time
import argparse
+import paramiko
+
import functest.utils.functest_logger as ft_logger
import functest.utils.functest_utils as ft_utils
import functest.utils.openstack_utils as os_utils
-import paramiko
-from functest.utils.functest_utils import FUNCTEST_REPO as FUNCTEST_REPO
parser = argparse.ArgumentParser()
@@ -21,6 +21,8 @@ args = parser.parse_args()
""" logging configuration """
logger = ft_logger.Logger("ODL_SFC").getLogger()
+FUNCTEST_REPO = ft_utils.FUNCTEST_REPO
+
HOME = os.environ['HOME'] + "/"
VM_BOOT_TIMEOUT = 180
@@ -56,13 +58,19 @@ def main():
# Allow any port so that tacker commands reaches the server.
# This will be deleted when tacker is included in OPNFV installation
+ status = "PASS"
+ failures = 0
+ start_time = time.time()
+ json_results = {}
+
ssh_options = '-o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no'
contr_cmd = ("sshpass -p r00tme ssh " + ssh_options + " root@10.20.0.2"
" 'fuel node'|grep controller|awk '{print $10}'")
logger.info("Executing script to get ip_server: '%s'" % contr_cmd)
process = subprocess.Popen(contr_cmd,
shell=True,
- stdout=subprocess.PIPE)
+ stdout=subprocess.PIPE,
+ stderr=subprocess.PIPE)
ip_server = process.stdout.readline().rstrip()
contr_cmd2 = ("sshpass -p r00tme ssh " + ssh_options + " root@10.20.0.2"
@@ -70,16 +78,27 @@ def main():
logger.info("Executing script to get ip_compute: '%s'" % contr_cmd2)
process = subprocess.Popen(contr_cmd2,
shell=True,
- stdout=subprocess.PIPE)
+ stdout=subprocess.PIPE,
+ stderr=subprocess.PIPE)
ip_compute = process.stdout.readline().rstrip()
iptable_cmd1 = ("sshpass -p r00tme ssh " + ssh_options + " root@10.20.0.2"
" ssh " + ip_server + " iptables -P INPUT ACCEPT ")
iptable_cmd2 = ("sshpass -p r00tme ssh " + ssh_options + " root@10.20.0.2"
" ssh " + ip_server + " iptables -t nat -P INPUT ACCEPT ")
+ iptable_cmd3 = ("sshpass -p r00tme ssh " + ssh_options + " root@10.20.0.2"
+ " ssh " + ssh_options + " " + ip_server +
+ " iptables -A INPUT -m state"
+ " --state NEW,ESTABLISHED,RELATED -j ACCEPT")
+
+ logger.info("Changing firewall policy in controller: '%s'" % iptable_cmd1)
+ subprocess.call(iptable_cmd1, shell=True, stderr=subprocess.PIPE)
- subprocess.call(iptable_cmd1, shell=True)
- subprocess.call(iptable_cmd2, shell=True)
+ logger.info("Changing firewall policy in controller: '%s'" % iptable_cmd2)
+ subprocess.call(iptable_cmd2, shell=True, stderr=subprocess.PIPE)
+
+ logger.info("Changing firewall policy in controller: '%s'" % iptable_cmd3)
+ subprocess.call(iptable_cmd2, shell=True, stderr=subprocess.PIPE)
# Getting the different clients
@@ -308,7 +327,7 @@ def main():
logger.info("Waiting for 60 seconds before TEST")
for j in range(0, 6):
- logger.info("Test starting in {0} seconds".format(str((6 - j)*10)))
+ logger.info("Test starting in {0} seconds".format(str((6 - j) * 10)))
time.sleep(10)
i = 0
@@ -326,10 +345,13 @@ def main():
logger.info('\033[92m' + "TEST 1 [PASSED] "
"==> SSH BLOCKED" + '\033[0m')
i = i + 1
+ json_results.update({"Test 1: SSH Blocked": "Passed"})
else:
logger.error('\033[91m' + "TEST 1 [FAILED] "
"==> SSH NOT BLOCKED" + '\033[0m')
- return
+ status = "FAIL"
+ json_results.update({"Test 1: SSH Blocked": "Failed"})
+ failures += 1
except:
logger.debug("Waiting for %s..." % floatip_client)
time.sleep(6)
@@ -346,10 +368,13 @@ def main():
logger.info('\033[92m' + "TEST 2 [PASSED] "
"==> HTTP WORKS" + '\033[0m')
i = i + 1
+ json_results.update({"Test 2: HTTP works": "Passed"})
else:
logger.error('\033[91m' + "TEST 2 [FAILED] "
"==> HTTP BLOCKED" + '\033[0m')
- return
+ status = "FAIL"
+ json_results.update({"Test 2: HTTP works": "Failed"})
+ failures += 1
except:
logger.debug("Waiting for %s..." % floatip_client)
time.sleep(6)
@@ -382,13 +407,16 @@ def main():
(stdin, stdout, stderr) = ssh.exec_command(command)
if "timed out" in stdout.readlines()[0]:
- logger.info('\033[92m' + "TEST 3 [WORKS] "
+ logger.info('\033[92m' + "TEST 3 [PASSED] "
"==> HTTP BLOCKED" + '\033[0m')
i = i + 1
+ json_results.update({"Test 3: HTTP Blocked": "Passed"})
else:
logger.error('\033[91m' + "TEST 3 [FAILED] "
"==> HTTP NOT BLOCKED" + '\033[0m')
- return
+ status = "FAIL"
+ json_results.update({"Test 3: HTTP Blocked": "Failed"})
+ failures += 1
except:
logger.debug("Waiting for %s..." % floatip_client)
time.sleep(6)
@@ -402,13 +430,16 @@ def main():
(stdin, stdout, stderr) = ssh.exec_command(command)
if "succeeded" in stdout.readlines()[0]:
- logger.info('\033[92m' + "TEST 4 [WORKS] "
+ logger.info('\033[92m' + "TEST 4 [PASSED] "
"==> SSH WORKS" + '\033[0m')
i = i + 1
+ json_results.update({"Test 4: SSH works": "Passed"})
else:
logger.error('\033[91m' + "TEST 4 [FAILED] "
"==> SSH BLOCKED" + '\033[0m')
- return
+ status = "FAIL"
+ json_results.update({"Test 4: SSH works": "Failed"})
+ failures += 1
except:
logger.debug("Waiting for %s..." % floatip_client)
time.sleep(6)
@@ -419,21 +450,20 @@ def main():
logger.info('\033[92m' + "SFC TEST WORKED"
" :) \n" + '\033[0m')
- # TODO report results to DB
- # functest_utils.logger_test_results("SFC",
- # "odl-sfc",
- # status, details)
- # see doctor, promise, domino, ...
- # if args.report:
- # logger.info("Pushing odl-SFC results")
- # functest_utils.push_results_to_db("functest",
- # "odl-sfc",
- # start_time,
- # stop_time,
- # status,
- # details)
-
- sys.exit(0)
+ if args.report:
+ stop_time = time.time()
+ json_results.update({"tests": "4", "failures": int(failures)})
+ logger.debug("Promise Results json: " + str(json_results))
+ ft_utils.push_results_to_db("sfc",
+ "functest-odl-sfc",
+ start_time,
+ stop_time,
+ status,
+ json_results)
+ if status == "PASS":
+ sys.exit(0)
+ else:
+ sys.exit(1)
if __name__ == '__main__':
main()