aboutsummaryrefslogtreecommitdiffstats
path: root/functest/opnfv_tests/openstack
diff options
context:
space:
mode:
Diffstat (limited to 'functest/opnfv_tests/openstack')
-rwxr-xr-xfunctest/opnfv_tests/openstack/examples/create_instance_and_ip.py28
-rw-r--r--functest/opnfv_tests/openstack/snaps/api_check.py18
-rw-r--r--functest/opnfv_tests/openstack/snaps/connection_check.py18
-rw-r--r--functest/opnfv_tests/openstack/snaps/smoke.py22
-rw-r--r--functest/opnfv_tests/openstack/snaps/snaps_utils.py5
-rw-r--r--functest/opnfv_tests/openstack/tempest/tempest.py52
6 files changed, 73 insertions, 70 deletions
diff --git a/functest/opnfv_tests/openstack/examples/create_instance_and_ip.py b/functest/opnfv_tests/openstack/examples/create_instance_and_ip.py
index 4a9ff713..b4400864 100755
--- a/functest/opnfv_tests/openstack/examples/create_instance_and_ip.py
+++ b/functest/opnfv_tests/openstack/examples/create_instance_and_ip.py
@@ -14,9 +14,9 @@ import argparse
import os
import sys
+from functest.utils.constants import CONST
import functest.utils.functest_logger as ft_logger
import functest.utils.openstack_utils as os_utils
-import functest.utils.functest_constants as ft_constants
parser = argparse.ArgumentParser()
@@ -29,26 +29,26 @@ args = parser.parse_args()
""" logging configuration """
logger = ft_logger.Logger("create_instance_and_ip").getLogger()
-HOME = ft_constants.HOME + "/"
+HOME = CONST.dir_home + "/"
VM_BOOT_TIMEOUT = 180
-EXAMPLE_INSTANCE_NAME = ft_constants.EXAMPLE_INSTANCE_NAME
-EXAMPLE_FLAVOR = ft_constants.EXAMPLE_FLAVOR
-EXAMPLE_IMAGE_NAME = ft_constants.EXAMPLE_IMAGE_NAME
-IMAGE_FILENAME = ft_constants.GLANCE_IMAGE_FILENAME
-IMAGE_FORMAT = ft_constants.GLANCE_IMAGE_FORMAT
-IMAGE_PATH = os.path.join(ft_constants.FUNCTEST_DATA_DIR, IMAGE_FILENAME)
+EXAMPLE_INSTANCE_NAME = CONST.example_vm_name
+EXAMPLE_FLAVOR = CONST.example_flavor
+EXAMPLE_IMAGE_NAME = CONST.example_image_name
+IMAGE_FILENAME = CONST.openstack_image_file_name
+IMAGE_FORMAT = CONST.openstack_image_disk_format
+IMAGE_PATH = os.path.join(CONST.dir_functest_data, IMAGE_FILENAME)
# NEUTRON Private Network parameters
-EXAMPLE_PRIVATE_NET_NAME = ft_constants.EXAMPLE_PRIVATE_NET_NAME
-EXAMPLE_PRIVATE_SUBNET_NAME = ft_constants.EXAMPLE_PRIVATE_SUBNET_NAME
-EXAMPLE_PRIVATE_SUBNET_CIDR = ft_constants.EXAMPLE_PRIVATE_SUBNET_CIDR
-EXAMPLE_ROUTER_NAME = ft_constants.EXAMPLE_ROUTER_NAME
+EXAMPLE_PRIVATE_NET_NAME = CONST.example_private_net_name
+EXAMPLE_PRIVATE_SUBNET_NAME = CONST.example_private_subnet_name
+EXAMPLE_PRIVATE_SUBNET_CIDR = CONST.example_private_subnet_cidr
+EXAMPLE_ROUTER_NAME = CONST.example_router_name
-EXAMPLE_SECGROUP_NAME = ft_constants.EXAMPLE_SECGROUP_NAME
-EXAMPLE_SECGROUP_DESCR = ft_constants.EXAMPLE_SECGROUP_DESCR
+EXAMPLE_SECGROUP_NAME = CONST.example_sg_name
+EXAMPLE_SECGROUP_DESCR = CONST.example_sg_desc
def main():
diff --git a/functest/opnfv_tests/openstack/snaps/api_check.py b/functest/opnfv_tests/openstack/snaps/api_check.py
index 27889209..17d05b92 100644
--- a/functest/opnfv_tests/openstack/snaps/api_check.py
+++ b/functest/opnfv_tests/openstack/snaps/api_check.py
@@ -5,11 +5,13 @@
#
# http://www.apache.org/licenses/LICENSE-2.0
-import functest.utils.functest_utils as ft_utils
+import unittest
+
+from snaps import test_suite_builder
+
from functest.core.pytest_suite_runner import PyTestSuiteRunner
from functest.opnfv_tests.openstack.snaps import snaps_utils
-from snaps import test_suite_builder
-import unittest
+from functest.utils.constants import CONST
class ApiCheck(PyTestSuiteRunner):
@@ -23,10 +25,10 @@ class ApiCheck(PyTestSuiteRunner):
self.suite = unittest.TestSuite()
self.case_name = "api_check"
- creds_file = ft_utils.get_functest_config('general.openstack.creds')
- use_key = ft_utils.get_functest_config('snaps.use_keystone')
ext_net_name = snaps_utils.get_ext_net_name()
- test_suite_builder.add_openstack_api_tests(self.suite, creds_file,
- ext_net_name,
- use_keystone=use_key)
+ test_suite_builder.add_openstack_api_tests(
+ self.suite,
+ CONST.openstack_creds,
+ ext_net_name,
+ use_keystone=CONST.snaps_use_keystone)
diff --git a/functest/opnfv_tests/openstack/snaps/connection_check.py b/functest/opnfv_tests/openstack/snaps/connection_check.py
index c2f5b102..11f8ad07 100644
--- a/functest/opnfv_tests/openstack/snaps/connection_check.py
+++ b/functest/opnfv_tests/openstack/snaps/connection_check.py
@@ -5,11 +5,13 @@
#
# http://www.apache.org/licenses/LICENSE-2.0
-import functest.utils.functest_utils as ft_utils
+import unittest
+
+from snaps import test_suite_builder
+
from functest.core.pytest_suite_runner import PyTestSuiteRunner
from functest.opnfv_tests.openstack.snaps import snaps_utils
-from snaps import test_suite_builder
-import unittest
+from functest.utils.constants import CONST
class ConnectionCheck(PyTestSuiteRunner):
@@ -23,10 +25,10 @@ class ConnectionCheck(PyTestSuiteRunner):
self.suite = unittest.TestSuite()
self.case_name = "connection_check"
- creds_file = ft_utils.get_functest_config('general.openstack.creds')
- use_key = ft_utils.get_functest_config('snaps.use_keystone')
ext_net_name = snaps_utils.get_ext_net_name()
- test_suite_builder.add_openstack_client_tests(self.suite, creds_file,
- ext_net_name,
- use_keystone=use_key)
+ test_suite_builder.add_openstack_client_tests(
+ self.suite,
+ CONST.openstack_creds,
+ ext_net_name,
+ use_keystone=CONST.snaps_use_keystone)
diff --git a/functest/opnfv_tests/openstack/snaps/smoke.py b/functest/opnfv_tests/openstack/snaps/smoke.py
index 691f8138..83eb6600 100644
--- a/functest/opnfv_tests/openstack/snaps/smoke.py
+++ b/functest/opnfv_tests/openstack/snaps/smoke.py
@@ -5,12 +5,14 @@
#
# http://www.apache.org/licenses/LICENSE-2.0
-import functest.utils.functest_utils as ft_utils
+import os
+import unittest
+
+from snaps import test_suite_builder
+
from functest.core.pytest_suite_runner import PyTestSuiteRunner
from functest.opnfv_tests.openstack.snaps import snaps_utils
-from snaps import test_suite_builder
-import unittest
-import os
+from functest.utils.constants import CONST
class SnapsSmoke(PyTestSuiteRunner):
@@ -24,18 +26,18 @@ class SnapsSmoke(PyTestSuiteRunner):
self.suite = unittest.TestSuite()
self.case_name = "snaps_smoke"
- creds_file = ft_utils.get_functest_config('general.openstack.creds')
- use_key = ft_utils.get_functest_config('snaps.use_keystone')
- use_fip = ft_utils.get_functest_config('snaps.use_floating_ips')
+ use_fip = CONST.snaps_use_floating_ips
ext_net_name = snaps_utils.get_ext_net_name()
# Tests requiring floating IPs leverage files contained within the
# SNAPS repository and are found relative to that path
if use_fip:
- snaps_dir = ft_utils.get_functest_config(
- 'general.dir.dir_repo_snaps') + '/snaps'
+ snaps_dir = CONST.dir_repo_snaps + '/snaps'
os.chdir(snaps_dir)
test_suite_builder.add_openstack_integration_tests(
- self.suite, creds_file, ext_net_name, use_keystone=use_key,
+ self.suite,
+ CONST.openstack_creds,
+ ext_net_name,
+ use_keystone=CONST.snaps_use_keystone,
use_floating_ips=use_fip)
diff --git a/functest/opnfv_tests/openstack/snaps/snaps_utils.py b/functest/opnfv_tests/openstack/snaps/snaps_utils.py
index a25ad3e0..4ea1a04a 100644
--- a/functest/opnfv_tests/openstack/snaps/snaps_utils.py
+++ b/functest/opnfv_tests/openstack/snaps/snaps_utils.py
@@ -5,17 +5,18 @@
#
# http://www.apache.org/licenses/LICENSE-2.0
-import functest.utils.functest_utils as ft_utils
from snaps.openstack.tests import openstack_tests
from snaps.openstack.utils import neutron_utils
+from functest.utils.constants import CONST
+
def get_ext_net_name():
"""
Returns the first external network name
:return:
"""
- os_env_file = ft_utils.get_functest_config('general.openstack.creds')
+ os_env_file = CONST.openstack_creds
os_creds = openstack_tests.get_credentials(os_env_file=os_env_file)
neutron = neutron_utils.neutron_client(os_creds)
ext_nets = neutron_utils.get_external_networks(neutron)
diff --git a/functest/opnfv_tests/openstack/tempest/tempest.py b/functest/opnfv_tests/openstack/tempest/tempest.py
index 6ad55335..20b1ebb4 100644
--- a/functest/opnfv_tests/openstack/tempest/tempest.py
+++ b/functest/opnfv_tests/openstack/tempest/tempest.py
@@ -14,15 +14,14 @@ import shutil
import subprocess
import time
-import opnfv.utils.constants as releng_constants
import yaml
import conf_utils
import functest.core.testcase_base as testcase_base
+from functest.utils.constants import CONST
import functest.utils.functest_logger as ft_logger
import functest.utils.functest_utils as ft_utils
import functest.utils.openstack_utils as os_utils
-from functest.utils.constants import CONST
""" logging configuration """
logger = ft_logger.Logger("Tempest").getLogger()
@@ -31,7 +30,7 @@ logger = ft_logger.Logger("Tempest").getLogger()
class TempestCommon(testcase_base.TestcaseBase):
def __init__(self):
- self.case_name = ""
+ super(TempestCommon, self).__init__()
self.MODE = ""
self.OPTION = ""
self.FLAVOR_ID = None
@@ -89,7 +88,7 @@ class TempestCommon(testcase_base.TestcaseBase):
CONST.tempest_router_name,
CONST.tempest_private_subnet_cidr)
if not network_dic:
- return releng_constants.EXIT_RUN_ERROR
+ return testcase_base.TestcaseBase.EX_RUN_ERROR
if CONST.tempest_use_custom_images:
# adding alternative image should be trivial should we need it
@@ -98,7 +97,7 @@ class TempestCommon(testcase_base.TestcaseBase):
CONST.openstack_image_name, conf_utils.GLANCE_IMAGE_PATH,
CONST.openstack_image_disk_format)
if not self.IMAGE_ID:
- return releng_constants.EXIT_RUN_ERROR
+ return testcase_base.TestcaseBase.EX_RUN_ERROR
if CONST.tempest_use_custom_flavors:
# adding alternative flavor should be trivial should we need it
@@ -109,9 +108,9 @@ class TempestCommon(testcase_base.TestcaseBase):
CONST.openstack_flavor_disk,
CONST.openstack_flavor_vcpus)
if not self.FLAVOR_ID:
- return releng_constants.EXIT_RUN_ERROR
+ return testcase_base.TestcaseBase.EX_RUN_ERROR
- return releng_constants.EXIT_OK
+ return testcase_base.TestcaseBase.EX_OK
def generate_test_list(self, DEPLOYMENT_DIR):
logger.debug("Generating test case list...")
@@ -125,7 +124,7 @@ class TempestCommon(testcase_base.TestcaseBase):
else:
logger.error("Tempest test list file %s NOT found."
% conf_utils.TEMPEST_CUSTOM)
- return releng_constants.EXIT_RUN_ERROR
+ return testcase_base.TestcaseBase.EX_RUN_ERROR
else:
if self.MODE == 'smoke':
testr_mode = "smoke"
@@ -139,7 +138,7 @@ class TempestCommon(testcase_base.TestcaseBase):
testr_mode + ">" + conf_utils.TEMPEST_RAW_LIST + ";cd")
ft_utils.execute_command(cmd)
- return releng_constants.EXIT_OK
+ return testcase_base.TestcaseBase.EX_OK
def apply_tempest_blacklist(self):
logger.debug("Applying tempest blacklist...")
@@ -175,30 +174,33 @@ class TempestCommon(testcase_base.TestcaseBase):
else:
result_file.write(str(cases_line) + '\n')
result_file.close()
- return releng_constants.EXIT_OK
+ return testcase_base.TestcaseBase.EX_OK
def run(self):
+
+ self.start_time = time.time()
+
if not os.path.exists(conf_utils.TEMPEST_RESULTS_DIR):
os.makedirs(conf_utils.TEMPEST_RESULTS_DIR)
# Pre-configuration
res = self.create_tempest_resources()
- if res != releng_constants.EXIT_OK:
+ if res != testcase_base.TestcaseBase.EX_OK:
return res
res = conf_utils.configure_tempest(logger,
self.DEPLOYMENT_DIR,
self.IMAGE_ID,
self.FLAVOR_ID)
- if res != releng_constants.EXIT_OK:
+ if res != testcase_base.TestcaseBase.EX_OK:
return res
res = self.generate_test_list(self.DEPLOYMENT_DIR)
- if res != releng_constants.EXIT_OK:
+ if res != testcase_base.TestcaseBase.EX_OK:
return res
res = self.apply_tempest_blacklist()
- if res != releng_constants.EXIT_OK:
+ if res != testcase_base.TestcaseBase.EX_OK:
return res
self.OPTION += (" --tests-file %s " % conf_utils.TEMPEST_LIST)
@@ -271,23 +273,17 @@ class TempestCommon(testcase_base.TestcaseBase):
except:
success_rate = 0
- if 'smoke' in self.MODE:
- self.CASE_NAME = 'tempest_smoke_serial'
- elif 'feature' in self.MODE:
- self.CASE_NAME = self.MODE.replace(
- "feature_", "")
- else:
- self.CASE_NAME = 'tempest_full_parallel'
-
- status = ft_utils.check_success_rate(
- self.CASE_NAME, success_rate)
+ self.criteria = ft_utils.check_success_rate(
+ self.case_name, success_rate)
logger.info("Tempest %s success_rate is %s%%, is marked as %s"
- % (self.CASE_NAME, success_rate, status))
+ % (self.case_name, success_rate, self.criteria))
+
+ self.stop_time = time.time()
- if status == "PASS":
- return releng_constants.EXIT_OK
+ if self.criteria == "PASS":
+ return testcase_base.TestcaseBase.EX_OK
else:
- return releng_constants.EXIT_RUN_ERROR
+ return testcase_base.TestcaseBase.EX_TESTCASE_FAILED
class TempestSmokeSerial(TempestCommon):