aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJose Lausuch <jose.lausuch@ericsson.com>2017-06-21 08:33:02 +0000
committerGerrit Code Review <gerrit@opnfv.org>2017-06-21 08:33:02 +0000
commit51899de7927bbf6be76639508ae2970046add625 (patch)
treea2cc98e1a98b012e81d82ac8653932c00ea8ba3e
parente7ab53553d719b0fb35b4a74cd0bbc9572c7a48d (diff)
parent997a42438f2253aa9fe640c1cbdd8ea461901948 (diff)
Merge "Remove all references to /home/opnfv/repos/functest"
-rw-r--r--functest/ci/config_functest.yaml19
-rwxr-xr-xfunctest/ci/prepare_env.py31
-rwxr-xr-xfunctest/ci/run_tests.py7
-rw-r--r--functest/cli/cli_base.py6
-rw-r--r--functest/cli/commands/cli_env.py5
-rw-r--r--functest/cli/commands/cli_os.py6
-rw-r--r--functest/cli/commands/cli_testcase.py9
-rw-r--r--functest/cli/commands/cli_tier.py9
-rw-r--r--functest/opnfv_tests/openstack/rally/rally.py15
-rwxr-xr-xfunctest/opnfv_tests/openstack/refstack_client/refstack_client.py24
-rwxr-xr-xfunctest/opnfv_tests/openstack/refstack_client/tempest_conf.py8
-rw-r--r--functest/opnfv_tests/openstack/tempest/conf_utils.py22
-rw-r--r--functest/opnfv_tests/openstack/vping/vping_base.py6
-rwxr-xr-xfunctest/opnfv_tests/openstack/vping/vping_ssh.py6
-rw-r--r--functest/opnfv_tests/sdn/onos/onos.py5
-rw-r--r--functest/opnfv_tests/vnf/ims/clearwater_ims_base.py7
-rwxr-xr-xfunctest/opnfv_tests/vnf/ims/orchestra_ims.py6
-rw-r--r--functest/tests/unit/cli/commands/test_cli_env.py9
-rw-r--r--functest/tests/unit/cli/commands/test_cli_os.py10
-rw-r--r--functest/tests/unit/cli/commands/test_cli_testcase.py26
-rw-r--r--functest/tests/unit/cli/commands/test_cli_tier.py26
-rw-r--r--functest/tests/unit/openstack/refstack_client/test_refstack_client.py14
-rw-r--r--functest/tests/unit/openstack/tempest/test_conf_utils.py3
-rw-r--r--functest/tests/unit/utils/test_functest_utils.py14
-rw-r--r--functest/utils/functest_utils.py8
25 files changed, 138 insertions, 163 deletions
diff --git a/functest/ci/config_functest.yaml b/functest/ci/config_functest.yaml
index 1b2c83800..60270b6c8 100644
--- a/functest/ci/config_functest.yaml
+++ b/functest/ci/config_functest.yaml
@@ -1,17 +1,7 @@
general:
dir:
- # Relative to the path where the repo is cloned:
- vping: functest/opnfv_tests/openstack/vping
- dir_odl: functest/opnfv_tests/sdn/odl
- rally: functest/opnfv_tests/openstack/rally
- tempest_cases: functest/opnfv_tests/openstack/tempest/custom_tests
- onos: functest/opnfv_tests/sdn/onos/teston
- onos_sfc: functest/opnfv_tests/sdn/onos/sfc
-
- # Absolute path
home: /home/opnfv
repos: /home/opnfv/repos
- repo_functest: /home/opnfv/repos/functest
dir_repo_rally: /home/opnfv/repos/rally
repo_tempest: /home/opnfv/repos/tempest
dir_repo_releng: /home/opnfv/repos/releng
@@ -32,9 +22,7 @@ general:
repo_securityscan: /home/opnfv/repos/securityscanning
repo_vrouter: /home/opnfv/repos/vnfs/vrouter
functest: /home/opnfv/functest
- functest_test: /home/opnfv/repos/functest/functest/opnfv_tests
results: /home/opnfv/functest/results
- functest_logging_cfg: /home/opnfv/repos/functest/functest/ci/logging.ini
functest_conf: /home/opnfv/functest/conf
functest_data: /home/opnfv/functest/data
ims_data: /home/opnfv/functest/data/ims/
@@ -71,9 +59,6 @@ general:
neutron_private_subnet_gateway: 192.168.120.254
neutron_router_name: functest-router
- functest:
- testcases_yaml: /home/opnfv/repos/functest/functest/ci/testcases.yaml
-
snaps:
use_keystone: True
use_floating_ips: True
@@ -150,10 +135,6 @@ rally:
subnet_cidr: 192.168.140.0/24
router_name: rally-router
-refstack:
- tempest_conf_path: openstack/refstack_client/refstack_tempest.conf
- defcore_list: openstack/refstack_client/defcore.txt
-
vnf:
aaa:
tenant_name: aaa
diff --git a/functest/ci/prepare_env.py b/functest/ci/prepare_env.py
index 9e53e30bd..fd1f5dbfa 100755
--- a/functest/ci/prepare_env.py
+++ b/functest/ci/prepare_env.py
@@ -11,6 +11,7 @@ import json
import logging
import logging.config
import os
+import pkg_resources
import re
import subprocess
import sys
@@ -34,14 +35,15 @@ handler = None
pod_arch = None
arch_filter = ['aarch64']
-CONFIG_FUNCTEST_PATH = CONST.__getattribute__('CONFIG_FUNCTEST_YAML')
-CONFIG_PATCH_PATH = os.path.join(os.path.dirname(
- CONFIG_FUNCTEST_PATH), "config_patch.yaml")
-CONFIG_AARCH64_PATCH_PATH = os.path.join(os.path.dirname(
- CONFIG_FUNCTEST_PATH), "config_aarch64_patch.yaml")
-RALLY_CONF_PATH = os.path.join("/etc/rally/rally.conf")
-RALLY_AARCH64_PATCH_PATH = os.path.join(os.path.dirname(
- CONFIG_FUNCTEST_PATH), "rally_aarch64_patch.conf")
+CONFIG_FUNCTEST_PATH = pkg_resources.resource_filename(
+ 'functest', 'ci/config_functest.yaml')
+CONFIG_PATCH_PATH = pkg_resources.resource_filename(
+ 'functest', 'ci/config_patch.yaml')
+CONFIG_AARCH64_PATCH_PATH = pkg_resources.resource_filename(
+ 'functest', 'ci/config_aarch64_patch.yaml')
+RALLY_CONF_PATH = "/etc/rally/rally.conf"
+RALLY_AARCH64_PATCH_PATH = pkg_resources.resource_filename(
+ 'functest', 'ci/rally_aarch64_patch.conf')
class PrepareEnvParser(object):
@@ -114,9 +116,8 @@ def get_deployment_handler():
global handler
global pod_arch
- installer_params_yaml = os.path.join(
- CONST.__getattribute__('dir_repo_functest'),
- 'functest/ci/installer_params.yaml')
+ installer_params_yaml = pkg_resources.resource_filename(
+ 'functest', 'ci/installer_params.yaml')
if (CONST.__getattribute__('INSTALLER_IP') and
CONST.__getattribute__('INSTALLER_TYPE') and
CONST.__getattribute__('INSTALLER_TYPE') in
@@ -250,8 +251,8 @@ def update_db_url():
def verify_deployment():
print_separator()
logger.info("Verifying OpenStack services...")
- cmd = ("%s/functest/ci/check_os.sh" %
- CONST.__getattribute__('dir_repo_functest'))
+ cmd = ("sh %s" % pkg_resources.resource_filename(
+ 'functest', 'ci/check_os.sh'))
logger.debug("Executing command: %s" % cmd)
p = subprocess.Popen(cmd, stdout=subprocess.PIPE, shell=True)
@@ -386,8 +387,8 @@ def main(**kwargs):
if __name__ == '__main__':
- logging.config.fileConfig(
- CONST.__getattribute__('dir_functest_logging_cfg'))
+ logging.config.fileConfig(pkg_resources.resource_filename(
+ 'functest', 'ci/logging.ini'))
parser = PrepareEnvParser()
args = parser.parse_args(sys.argv[1:])
sys.exit(main(**args))
diff --git a/functest/ci/run_tests.py b/functest/ci/run_tests.py
index af45c3211..430f0ca8d 100755
--- a/functest/ci/run_tests.py
+++ b/functest/ci/run_tests.py
@@ -14,6 +14,7 @@ import importlib
import logging
import logging.config
import os
+import pkg_resources
import re
import sys
@@ -201,7 +202,7 @@ class Runner(object):
_tiers = tb.TierBuilder(
CONST.__getattribute__('INSTALLER_TYPE'),
CONST.__getattribute__('DEPLOY_SCENARIO'),
- CONST.__getattribute__("functest_testcases_yaml"))
+ pkg_resources.resource_filename('functest', 'ci/testcases.yaml'))
if kwargs['noclean']:
self.clean_flag = False
@@ -267,8 +268,8 @@ class Runner(object):
if __name__ == '__main__':
- logging.config.fileConfig(
- CONST.__getattribute__('dir_functest_logging_cfg'))
+ logging.config.fileConfig(pkg_resources.resource_filename(
+ 'functest', 'ci/logging.ini'))
parser = RunTestsParser()
args = parser.parse_args(sys.argv[1:])
runner = Runner()
diff --git a/functest/cli/cli_base.py b/functest/cli/cli_base.py
index 2f085834c..54b3e72b2 100644
--- a/functest/cli/cli_base.py
+++ b/functest/cli/cli_base.py
@@ -9,12 +9,12 @@
import click
import logging.config
+import pkg_resources
from functest.cli.commands.cli_env import CliEnv
from functest.cli.commands.cli_os import CliOpenStack
from functest.cli.commands.cli_testcase import CliTestcase
from functest.cli.commands.cli_tier import CliTier
-from functest.utils.constants import CONST
CONTEXT_SETTINGS = dict(help_option_names=['-h', '--help'])
@@ -23,8 +23,8 @@ CONTEXT_SETTINGS = dict(help_option_names=['-h', '--help'])
@click.group(context_settings=CONTEXT_SETTINGS)
@click.version_option(version='opnfv colorado.0.1 ')
def cli():
- logging.config.fileConfig(
- CONST.__getattribute__('dir_functest_logging_cfg'))
+ logging.config.fileConfig(pkg_resources.resource_filename(
+ 'functest', 'ci/logging.ini'))
_env = CliEnv()
diff --git a/functest/cli/commands/cli_env.py b/functest/cli/commands/cli_env.py
index 8094c84e5..ce9775725 100644
--- a/functest/cli/commands/cli_env.py
+++ b/functest/cli/commands/cli_env.py
@@ -8,6 +8,7 @@
#
import os
+import pkg_resources
import click
import prettytable
@@ -35,8 +36,8 @@ class CliEnv(object):
else:
answer = raw_input("Invalid answer. Please type [y|n]\n")
- cmd = ("python %s/functest/ci/prepare_env.py start" %
- CONST.__getattribute__('dir_repo_functest'))
+ cmd = ("python %s start" % pkg_resources.resource_filename(
+ 'functest', 'ci/prepare_env.py'))
ft_utils.execute_command(cmd)
def show(self):
diff --git a/functest/cli/commands/cli_os.py b/functest/cli/commands/cli_os.py
index c66362fce..875529f25 100644
--- a/functest/cli/commands/cli_os.py
+++ b/functest/cli/commands/cli_os.py
@@ -9,6 +9,7 @@
import os
+import pkg_resources
import click
@@ -49,9 +50,8 @@ class CliOpenStack(object):
def check(self):
self.ping_endpoint()
- cmd = os.path.join(CONST.__getattribute__('dir_repo_functest'),
- "functest/ci/check_os.sh")
- ft_utils.execute_command(cmd, verbose=False)
+ ft_utils.execute_command("sh %s" % pkg_resources.resource_filename(
+ 'functest', 'ci/check_os.sh'), verbose=False)
def snapshot_create(self):
self.ping_endpoint()
diff --git a/functest/cli/commands/cli_testcase.py b/functest/cli/commands/cli_testcase.py
index 3d3f1cb3e..91904d870 100644
--- a/functest/cli/commands/cli_testcase.py
+++ b/functest/cli/commands/cli_testcase.py
@@ -10,6 +10,7 @@
""" global variables """
import os
+import pkg_resources
import click
@@ -25,7 +26,7 @@ class CliTestcase(object):
self.tiers = tb.TierBuilder(
CONST.__getattribute__('INSTALLER_TYPE'),
CONST.__getattribute__('DEPLOY_SCENARIO'),
- CONST.__getattribute__('functest_testcases_yaml'))
+ pkg_resources.resource_filename('functest', 'ci/testcases.yaml'))
def list(self):
summary = ""
@@ -59,8 +60,8 @@ class CliTestcase(object):
else:
tests = testname.split(",")
for test in tests:
- cmd = ("python %s/functest/ci/run_tests.py "
- "%s -t %s" %
- (CONST.__getattribute__('dir_repo_functest'),
+ cmd = ("python %s %s -t %s" %
+ (pkg_resources.resource_filename(
+ 'functest', 'ci/run_tests.py'),
flags, test))
ft_utils.execute_command(cmd)
diff --git a/functest/cli/commands/cli_tier.py b/functest/cli/commands/cli_tier.py
index 531f0ff96..48e9f542a 100644
--- a/functest/cli/commands/cli_tier.py
+++ b/functest/cli/commands/cli_tier.py
@@ -10,6 +10,7 @@
""" global variables """
import os
+import pkg_resources
import click
@@ -24,7 +25,7 @@ class CliTier(object):
self.tiers = tb.TierBuilder(
CONST.__getattribute__('INSTALLER_TYPE'),
CONST.__getattribute__('DEPLOY_SCENARIO'),
- CONST.__getattribute__('functest_testcases_yaml'))
+ pkg_resources.resource_filename('functest', 'ci/testcases.yaml'))
def list(self):
summary = ""
@@ -67,8 +68,6 @@ class CliTier(object):
click.echo("Functest environment is not ready. "
"Run first 'functest env prepare'")
else:
- cmd = ("python %s/functest/ci/run_tests.py "
- "%s -t %s" %
- (CONST.__getattribute__('dir_repo_functest'),
- flags, tiername))
+ cmd = ("python %s %s -t %s" % (pkg_resources.resource_filename(
+ 'functest', 'ci/run_tests.py'), flags, tiername))
ft_utils.execute_command(cmd)
diff --git a/functest/opnfv_tests/openstack/rally/rally.py b/functest/opnfv_tests/openstack/rally/rally.py
index 2ae6817d0..8970a5c04 100644
--- a/functest/opnfv_tests/openstack/rally/rally.py
+++ b/functest/opnfv_tests/openstack/rally/rally.py
@@ -13,6 +13,7 @@ from __future__ import division
import json
import logging
import os
+import pkg_resources
import re
import subprocess
import time
@@ -38,12 +39,14 @@ class RallyBase(testcase.OSGCTestCase):
GLANCE_IMAGE_FORMAT = CONST.__getattribute__('openstack_image_disk_format')
FLAVOR_NAME = "m1.tiny"
- RALLY_DIR = os.path.join(
- CONST.__getattribute__('dir_repo_functest'),
- CONST.__getattribute__('dir_rally'))
- RALLY_SCENARIO_DIR = os.path.join(RALLY_DIR, "scenario")
- TEMPLATE_DIR = os.path.join(RALLY_SCENARIO_DIR, "templates")
- SUPPORT_DIR = os.path.join(RALLY_SCENARIO_DIR, "support")
+ RALLY_DIR = pkg_resources.resource_filename(
+ 'functest', 'opnfv_tests/openstack/rally')
+ RALLY_SCENARIO_DIR = pkg_resources.resource_filename(
+ 'functest', 'opnfv_tests/openstack/rally/scenario')
+ TEMPLATE_DIR = pkg_resources.resource_filename(
+ 'functest', 'opnfv_tests/openstack/rally/scenario/templates')
+ SUPPORT_DIR = pkg_resources.resource_filename(
+ 'functest', 'opnfv_tests/openstack/rally/scenario/support')
USERS_AMOUNT = 2
TENANTS_AMOUNT = 3
ITERATIONS_AMOUNT = 10
diff --git a/functest/opnfv_tests/openstack/refstack_client/refstack_client.py b/functest/opnfv_tests/openstack/refstack_client/refstack_client.py
index b2a215337..30d1cf089 100755
--- a/functest/opnfv_tests/openstack/refstack_client/refstack_client.py
+++ b/functest/opnfv_tests/openstack/refstack_client/refstack_client.py
@@ -12,6 +12,7 @@ from __future__ import division
import argparse
import logging
import os
+import pkg_resources
import re
import sys
import subprocess
@@ -33,13 +34,16 @@ class RefstackClient(testcase.OSGCTestCase):
if "case_name" not in kwargs:
kwargs["case_name"] = "refstack_defcore"
super(RefstackClient, self).__init__(**kwargs)
- self.FUNCTEST_TEST = CONST.__getattribute__('dir_functest_test')
- self.CONF_PATH = CONST.__getattribute__('refstack_tempest_conf_path')
- self.DEFCORE_LIST = CONST.__getattribute__('refstack_defcore_list')
+ self.CONF_PATH = pkg_resources.resource_filename(
+ 'functest',
+ 'opnfv_tests/openstack/refstack_client/refstack_tempest.conf')
+ self.FUNCTEST_TEST = pkg_resources.resource_filename(
+ 'functest', 'opnfv_tests')
+ self.DEFCORE_LIST = 'openstack/refstack_client/defcore.txt'
self.confpath = os.path.join(self.FUNCTEST_TEST,
self.CONF_PATH)
- self.defcorelist = os.path.join(self.FUNCTEST_TEST,
- self.DEFCORE_LIST)
+ self.defcorelist = pkg_resources.resource_filename(
+ 'functest', 'opnfv_tests/openstack/refstack_client/defcore.txt')
def source_venv(self):
@@ -202,9 +206,13 @@ class RefstackClient(testcase.OSGCTestCase):
class RefstackClientParser(object):
def __init__(self):
- self.FUNCTEST_TEST = CONST.__getattribute__('dir_functest_test')
- self.CONF_PATH = CONST.__getattribute__('refstack_tempest_conf_path')
- self.DEFCORE_LIST = CONST.__getattribute__('refstack_defcore_list')
+ self.FUNCTEST_TEST = pkg_resources.resource_filename(
+ 'functest', 'opnfv_tests')
+ self.CONF_PATH = pkg_resources.resource_filename(
+ 'functest',
+ 'opnfv_tests/openstack/refstack_client/refstack_tempest.conf')
+ self.DEFCORE_LIST = pkg_resources.resource_filename(
+ 'functest', 'opnfv_tests/openstack/refstack_client/defcore.txt')
self.confpath = os.path.join(self.FUNCTEST_TEST,
self.CONF_PATH)
self.defcorelist = os.path.join(self.FUNCTEST_TEST,
diff --git a/functest/opnfv_tests/openstack/refstack_client/tempest_conf.py b/functest/opnfv_tests/openstack/refstack_client/tempest_conf.py
index fbaad589e..5d429e7c2 100755
--- a/functest/opnfv_tests/openstack/refstack_client/tempest_conf.py
+++ b/functest/opnfv_tests/openstack/refstack_client/tempest_conf.py
@@ -6,7 +6,7 @@
# which accompanies this distribution, and is available at
# http://www.apache.org/licenses/LICENSE-2.0
import logging
-import os
+import pkg_resources
from functest.opnfv_tests.openstack.tempest import conf_utils
from functest.utils import openstack_utils
@@ -24,9 +24,9 @@ class TempestConf(object):
self.DEPLOYMENT_ID = conf_utils.get_verifier_deployment_id()
self.DEPLOYMENT_DIR = conf_utils.get_verifier_deployment_dir(
self.VERIFIER_ID, self.DEPLOYMENT_ID)
- self.confpath = os.path.join(
- CONST.__getattribute__('dir_functest_test'),
- CONST.__getattribute__('refstack_tempest_conf_path'))
+ self.confpath = pkg_resources.resource_filename(
+ 'functest',
+ 'opnfv_tests/openstack/refstack_client/refstack_tempest.conf')
def generate_tempestconf(self):
try:
diff --git a/functest/opnfv_tests/openstack/tempest/conf_utils.py b/functest/opnfv_tests/openstack/tempest/conf_utils.py
index 4eb5661e9..fa8f00fc8 100644
--- a/functest/opnfv_tests/openstack/tempest/conf_utils.py
+++ b/functest/opnfv_tests/openstack/tempest/conf_utils.py
@@ -10,6 +10,7 @@
import ConfigParser
import logging
import os
+import pkg_resources
import re
import shutil
import subprocess
@@ -21,19 +22,18 @@ import functest.utils.openstack_utils as os_utils
IMAGE_ID_ALT = None
FLAVOR_ID_ALT = None
-REPO_PATH = CONST.__getattribute__('dir_repo_functest')
GLANCE_IMAGE_PATH = os.path.join(
CONST.__getattribute__('dir_functest_images'),
CONST.__getattribute__('openstack_image_file_name'))
-TEMPEST_TEST_LIST_DIR = CONST.__getattribute__('dir_tempest_cases')
TEMPEST_RESULTS_DIR = os.path.join(CONST.__getattribute__('dir_results'),
'tempest')
-TEMPEST_CUSTOM = os.path.join(REPO_PATH, TEMPEST_TEST_LIST_DIR,
- 'test_list.txt')
-TEMPEST_BLACKLIST = os.path.join(REPO_PATH, TEMPEST_TEST_LIST_DIR,
- 'blacklist.txt')
-TEMPEST_DEFCORE = os.path.join(REPO_PATH, TEMPEST_TEST_LIST_DIR,
- 'defcore_req.txt')
+TEMPEST_CUSTOM = pkg_resources.resource_filename(
+ 'functest', 'opnfv_tests/openstack/tempest/custom_tests/test_list.txt')
+TEMPEST_BLACKLIST = pkg_resources.resource_filename(
+ 'functest', 'opnfv_tests/openstack/tempest/custom_tests/blacklist.txt')
+TEMPEST_DEFCORE = pkg_resources.resource_filename(
+ 'functest',
+ 'opnfv_tests/openstack/tempest/custom_tests/defcore_req.txt')
TEMPEST_RAW_LIST = os.path.join(TEMPEST_RESULTS_DIR, 'test_raw_list.txt')
TEMPEST_LIST = os.path.join(TEMPEST_RESULTS_DIR, 'test_list.txt')
REFSTACK_RESULTS_DIR = os.path.join(CONST.__getattribute__('dir_results'),
@@ -253,9 +253,9 @@ def configure_tempest_defcore(deployment_dir, img_flavor_dict):
with open(conf_file, 'wb') as config_file:
config.write(config_file)
- confpath = os.path.join(
- CONST.__getattribute__('dir_functest_test'),
- CONST.__getattribute__('refstack_tempest_conf_path'))
+ confpath = pkg_resources.resource_filename(
+ 'functest',
+ 'opnfv_tests/openstack/refstack_client/refstack_tempest.conf')
shutil.copyfile(conf_file, confpath)
diff --git a/functest/opnfv_tests/openstack/vping/vping_base.py b/functest/opnfv_tests/openstack/vping/vping_base.py
index 856d5f220..714606769 100644
--- a/functest/opnfv_tests/openstack/vping/vping_base.py
+++ b/functest/opnfv_tests/openstack/vping/vping_base.py
@@ -10,6 +10,7 @@
from datetime import datetime
import logging
import os
+import pkg_resources
import time
import uuid
@@ -37,7 +38,8 @@ class VPingBase(testcase.OSGCTestCase):
self.logger = logging.getLogger(self.__class__.__name__)
- self.functest_repo = CONST.__getattribute__('dir_repo_functest')
+ self.functest_repo = pkg_resources.resource_filename(
+ 'functest', '..')
self.guid = ''
if CONST.__getattribute__('vping_unique_names'):
self.guid = '-' + str(uuid.uuid4())
@@ -45,8 +47,6 @@ class VPingBase(testcase.OSGCTestCase):
self.os_creds = openstack_tests.get_credentials(
os_env_file=CONST.__getattribute__('openstack_creds'))
- self.repo = CONST.__getattribute__('dir_vping')
-
self.creators = list()
self.image_creator = None
self.network_creator = None
diff --git a/functest/opnfv_tests/openstack/vping/vping_ssh.py b/functest/opnfv_tests/openstack/vping/vping_ssh.py
index 6ac0d6764..1f663307c 100755
--- a/functest/opnfv_tests/openstack/vping/vping_ssh.py
+++ b/functest/opnfv_tests/openstack/vping/vping_ssh.py
@@ -8,7 +8,7 @@
# http://www.apache.org/licenses/LICENSE-2.0
import argparse
-import os
+import pkg_resources
from scp import SCPClient
import sys
import time
@@ -156,8 +156,8 @@ class VPingSSH(vping_base.VPingBase):
"""
self.logger.info("Trying to transfer ping.sh")
scp = SCPClient(ssh.get_transport())
- local_path = self.functest_repo + "/" + self.repo
- ping_script = os.path.join(local_path, "ping.sh")
+ ping_script = pkg_resources.resource_filename(
+ 'functest', 'opnfv_tests/openstack/vping/ping.sh')
try:
scp.put(ping_script, "~/")
except:
diff --git a/functest/opnfv_tests/sdn/onos/onos.py b/functest/opnfv_tests/sdn/onos/onos.py
index adcb41666..08ba4da31 100644
--- a/functest/opnfv_tests/sdn/onos/onos.py
+++ b/functest/opnfv_tests/sdn/onos/onos.py
@@ -9,6 +9,7 @@
import logging
import os
+import pkg_resources
import re
import subprocess
import shutil
@@ -27,8 +28,8 @@ class OnosBase(testcase.TestCase):
onos_sfc_image_path = os.path.join(
CONST.__getattribute__('dir_functest_images'),
CONST.__getattribute__('onos_sfc_image_file_name'))
- onos_sfc_path = os.path.join(CONST.__getattribute__('dir_repo_functest'),
- CONST.__getattribute__('dir_onos_sfc'))
+ onos_sfc_path = pkg_resources.resource_filename(
+ 'functest', 'opnfv_tests/sdn/onos/sfc')
installer_type = CONST.__getattribute__('INSTALLER_TYPE')
logger = logging.getLogger(__name__)
diff --git a/functest/opnfv_tests/vnf/ims/clearwater_ims_base.py b/functest/opnfv_tests/vnf/ims/clearwater_ims_base.py
index a645dfb2f..c1a35be31 100644
--- a/functest/opnfv_tests/vnf/ims/clearwater_ims_base.py
+++ b/functest/opnfv_tests/vnf/ims/clearwater_ims_base.py
@@ -9,6 +9,7 @@
import json
import logging
import os
+import pkg_resources
import shutil
import requests
@@ -27,10 +28,8 @@ class ClearwaterOnBoardingBase(vnf.VnfOnBoarding):
def __init__(self, **kwargs):
self.logger = logging.getLogger(__name__)
super(ClearwaterOnBoardingBase, self).__init__(**kwargs)
- self.case_dir = os.path.join(
- CONST.__getattribute__('dir_functest_test'),
- 'vnf',
- 'ims')
+ self.case_dir = pkg_resources.resource_filename(
+ 'functest', 'opnfv_tests/vnf/ims')
self.data_dir = CONST.__getattribute__('dir_ims_data')
self.result_dir = os.path.join(CONST.__getattribute__('dir_results'),
self.case_name)
diff --git a/functest/opnfv_tests/vnf/ims/orchestra_ims.py b/functest/opnfv_tests/vnf/ims/orchestra_ims.py
index a5d2a9222..207d6a672 100755
--- a/functest/opnfv_tests/vnf/ims/orchestra_ims.py
+++ b/functest/opnfv_tests/vnf/ims/orchestra_ims.py
@@ -10,6 +10,7 @@
import json
import logging
import os
+import pkg_resources
import socket
import sys
import time
@@ -76,9 +77,8 @@ class ImsVnf(vnf.VnfOnBoarding):
self.ob_port = "8080"
self.ob_ip = "localhost"
self.ob_instance_id = ""
- self.case_dir = os.path.join(
- CONST.__getattribute__('dir_functest_test'),
- 'vnf/ims/')
+ self.case_dir = pkg_resources.resource_filename(
+ 'functest', 'opnfv_tests/vnf/ims/')
self.data_dir = CONST.__getattribute__('dir_ims_data')
self.test_dir = CONST.__getattribute__('dir_repo_vims_test')
self.ob_projectid = ""
diff --git a/functest/tests/unit/cli/commands/test_cli_env.py b/functest/tests/unit/cli/commands/test_cli_env.py
index b4e987871..0b18554b2 100644
--- a/functest/tests/unit/cli/commands/test_cli_env.py
+++ b/functest/tests/unit/cli/commands/test_cli_env.py
@@ -6,6 +6,7 @@
# http://www.apache.org/licenses/LICENSE-2.0
import logging
+import pkg_resources
import unittest
import mock
@@ -24,8 +25,8 @@ class CliEnvTesting(unittest.TestCase):
return_value=False)
@mock.patch('functest.cli.commands.cli_testcase.ft_utils.execute_command')
def test_prepare_default(self, mock_ft_utils, mock_os):
- cmd = ("python %s/functest/ci/prepare_env.py start" %
- CONST.__getattribute__('dir_repo_functest'))
+ cmd = ("python %s start" % pkg_resources.resource_filename(
+ 'functest', 'ci/prepare_env.py'))
self.cli_environ.prepare()
mock_ft_utils.assert_called_with(cmd)
@@ -36,8 +37,8 @@ class CliEnvTesting(unittest.TestCase):
with mock.patch('__builtin__.raw_input', return_value="y"), \
mock.patch('functest.cli.commands.cli_testcase.os.remove') \
as mock_os_remove:
- cmd = ("python %s/functest/ci/prepare_env.py start" %
- CONST.__getattribute__('dir_repo_functest'))
+ cmd = ("python %s start" % pkg_resources.resource_filename(
+ 'functest', 'ci/prepare_env.py'))
self.cli_environ.prepare()
mock_os_remove.assert_called_once_with(
CONST.__getattribute__('env_active'))
diff --git a/functest/tests/unit/cli/commands/test_cli_os.py b/functest/tests/unit/cli/commands/test_cli_os.py
index c3285ecbe..50ebe4b5d 100644
--- a/functest/tests/unit/cli/commands/test_cli_os.py
+++ b/functest/tests/unit/cli/commands/test_cli_os.py
@@ -8,13 +8,13 @@
#
import logging
+import pkg_resources
import unittest
import os
import mock
from functest.cli.commands import cli_os
-from functest.utils.constants import CONST
class CliOpenStackTesting(unittest.TestCase):
@@ -25,7 +25,6 @@ class CliOpenStackTesting(unittest.TestCase):
self.installer_type = 'test_installer_type'
self.installer_ip = 'test_installer_ip'
self.openstack_creds = 'test_openstack_creds'
- self.dir_repo_functest = 'test_dir_repo_functest'
self.snapshot_file = 'test_snapshot_file'
self.cli_os = cli_os.CliOpenStack()
@@ -64,11 +63,10 @@ class CliOpenStackTesting(unittest.TestCase):
@mock.patch('functest.cli.commands.cli_os.ft_utils.execute_command')
def test_check(self, mock_ftutils_execute):
with mock.patch.object(self.cli_os, 'ping_endpoint'):
- CONST.__setattr__('dir_repo_functest', self.dir_repo_functest)
- cmd = os.path.join(CONST.__getattribute__('dir_repo_functest'),
- "functest/ci/check_os.sh")
self.cli_os.check()
- mock_ftutils_execute.assert_called_once_with(cmd, verbose=False)
+ mock_ftutils_execute.assert_called_once_with(
+ "sh %s" % pkg_resources.resource_filename(
+ 'functest', 'ci/check_os.sh'), verbose=False)
@mock.patch('functest.cli.commands.cli_os.os.path.isfile',
return_value=False)
diff --git a/functest/tests/unit/cli/commands/test_cli_testcase.py b/functest/tests/unit/cli/commands/test_cli_testcase.py
index fddfc3173..4d0bdc2f3 100644
--- a/functest/tests/unit/cli/commands/test_cli_testcase.py
+++ b/functest/tests/unit/cli/commands/test_cli_testcase.py
@@ -7,12 +7,12 @@
import logging
+import pkg_resources
import unittest
import mock
from functest.cli.commands import cli_testcase
-from functest.utils.constants import CONST
class CliTestCasesTesting(unittest.TestCase):
@@ -39,9 +39,9 @@ class CliTestCasesTesting(unittest.TestCase):
return_value=True)
@mock.patch('functest.cli.commands.cli_testcase.ft_utils.execute_command')
def test_run_default(self, mock_ft_utils, mock_os):
- cmd = ("python %s/functest/ci/run_tests.py "
- "%s -t %s" %
- (CONST.__getattribute__('dir_repo_functest'),
+ cmd = ("python %s %s -t %s" %
+ (pkg_resources.resource_filename(
+ 'functest', 'ci/run_tests.py'),
"-n -r ", self.testname))
self.cli_tests.run(self.testname, noclean=True, report=True)
mock_ft_utils.assert_called_with(cmd)
@@ -50,9 +50,9 @@ class CliTestCasesTesting(unittest.TestCase):
return_value=True)
@mock.patch('functest.cli.commands.cli_testcase.ft_utils.execute_command')
def test_run_noclean_missing_report(self, mock_ft_utils, mock_os):
- cmd = ("python %s/functest/ci/run_tests.py "
- "%s -t %s" %
- (CONST.__getattribute__('dir_repo_functest'),
+ cmd = ("python %s %s -t %s" %
+ (pkg_resources.resource_filename(
+ 'functest', 'ci/run_tests.py'),
"-n ", self.testname))
self.cli_tests.run(self.testname, noclean=True, report=False)
mock_ft_utils.assert_called_with(cmd)
@@ -61,9 +61,9 @@ class CliTestCasesTesting(unittest.TestCase):
return_value=True)
@mock.patch('functest.cli.commands.cli_testcase.ft_utils.execute_command')
def test_run_report_missing_noclean(self, mock_ft_utils, mock_os):
- cmd = ("python %s/functest/ci/run_tests.py "
- "%s -t %s" %
- (CONST.__getattribute__('dir_repo_functest'),
+ cmd = ("python %s %s -t %s" %
+ (pkg_resources.resource_filename(
+ 'functest', 'ci/run_tests.py'),
"-r ", self.testname))
self.cli_tests.run(self.testname, noclean=False, report=True)
mock_ft_utils.assert_called_with(cmd)
@@ -72,9 +72,9 @@ class CliTestCasesTesting(unittest.TestCase):
return_value=True)
@mock.patch('functest.cli.commands.cli_testcase.ft_utils.execute_command')
def test_run_missing_noclean_report(self, mock_ft_utils, mock_os):
- cmd = ("python %s/functest/ci/run_tests.py "
- "%s -t %s" %
- (CONST.__getattribute__('dir_repo_functest'),
+ cmd = ("python %s %s -t %s" %
+ (pkg_resources.resource_filename(
+ 'functest', 'ci/run_tests.py'),
"", self.testname))
self.cli_tests.run(self.testname, noclean=False, report=False)
mock_ft_utils.assert_called_with(cmd)
diff --git a/functest/tests/unit/cli/commands/test_cli_tier.py b/functest/tests/unit/cli/commands/test_cli_tier.py
index 550eec931..b42e35818 100644
--- a/functest/tests/unit/cli/commands/test_cli_tier.py
+++ b/functest/tests/unit/cli/commands/test_cli_tier.py
@@ -7,12 +7,12 @@
import logging
+import pkg_resources
import unittest
import mock
from functest.cli.commands import cli_tier
-from functest.utils.constants import CONST
class CliTierTesting(unittest.TestCase):
@@ -87,9 +87,9 @@ class CliTierTesting(unittest.TestCase):
return_value=True)
@mock.patch('functest.cli.commands.cli_tier.ft_utils.execute_command')
def test_run_default(self, mock_ft_utils, mock_os):
- cmd = ("python %s/functest/ci/run_tests.py "
- "%s -t %s" %
- (CONST.__getattribute__('dir_repo_functest'),
+ cmd = ("python %s %s -t %s" %
+ (pkg_resources.resource_filename(
+ 'functest', 'ci/run_tests.py'),
"-n -r ", self.tiername))
self.cli_tier.run(self.tiername, noclean=True, report=True)
mock_ft_utils.assert_called_with(cmd)
@@ -98,9 +98,9 @@ class CliTierTesting(unittest.TestCase):
return_value=True)
@mock.patch('functest.cli.commands.cli_tier.ft_utils.execute_command')
def test_run_report_missing_noclean(self, mock_ft_utils, mock_os):
- cmd = ("python %s/functest/ci/run_tests.py "
- "%s -t %s" %
- (CONST.__getattribute__('dir_repo_functest'),
+ cmd = ("python %s %s -t %s" %
+ (pkg_resources.resource_filename(
+ 'functest', 'ci/run_tests.py'),
"-r ", self.tiername))
self.cli_tier.run(self.tiername, noclean=False, report=True)
mock_ft_utils.assert_called_with(cmd)
@@ -109,9 +109,9 @@ class CliTierTesting(unittest.TestCase):
return_value=True)
@mock.patch('functest.cli.commands.cli_tier.ft_utils.execute_command')
def test_run_noclean_missing_report(self, mock_ft_utils, mock_os):
- cmd = ("python %s/functest/ci/run_tests.py "
- "%s -t %s" %
- (CONST.__getattribute__('dir_repo_functest'),
+ cmd = ("python %s %s -t %s" %
+ (pkg_resources.resource_filename(
+ 'functest', 'ci/run_tests.py'),
"-n ", self.tiername))
self.cli_tier.run(self.tiername, noclean=True, report=False)
mock_ft_utils.assert_called_with(cmd)
@@ -120,9 +120,9 @@ class CliTierTesting(unittest.TestCase):
return_value=True)
@mock.patch('functest.cli.commands.cli_tier.ft_utils.execute_command')
def test_run_missing_noclean_report(self, mock_ft_utils, mock_os):
- cmd = ("python %s/functest/ci/run_tests.py "
- "%s -t %s" %
- (CONST.__getattribute__('dir_repo_functest'),
+ cmd = ("python %s %s -t %s" %
+ (pkg_resources.resource_filename(
+ 'functest', 'ci/run_tests.py'),
"", self.tiername))
self.cli_tier.run(self.tiername, noclean=False, report=False)
mock_ft_utils.assert_called_with(cmd)
diff --git a/functest/tests/unit/openstack/refstack_client/test_refstack_client.py b/functest/tests/unit/openstack/refstack_client/test_refstack_client.py
index 8c149baa8..3a121245c 100644
--- a/functest/tests/unit/openstack/refstack_client/test_refstack_client.py
+++ b/functest/tests/unit/openstack/refstack_client/test_refstack_client.py
@@ -7,7 +7,7 @@
import logging
import mock
-import os
+import pkg_resources
import unittest
from functest.core import testcase
@@ -17,12 +17,11 @@ from functest.utils.constants import CONST
class OSRefstackClientTesting(unittest.TestCase):
- _config = os.path.join(
- CONST.__getattribute__('dir_functest_test'),
- CONST.__getattribute__('refstack_tempest_conf_path'))
- _testlist = os.path.join(
- CONST.__getattribute__('dir_functest_test'),
- CONST.__getattribute__('refstack_defcore_list'))
+ _config = pkg_resources.resource_filename(
+ 'functest',
+ 'opnfv_tests/openstack/refstack_client/refstack_tempest.conf')
+ _testlist = pkg_resources.resource_filename(
+ 'functest', 'opnfv_tests/openstack/refstack_client/defcore.txt')
def setUp(self):
self.defaultargs = {'config': self._config,
@@ -30,7 +29,6 @@ class OSRefstackClientTesting(unittest.TestCase):
self.refstackclient = refstack_client.RefstackClient()
def test_source_venv(self):
- CONST.__setattr__('dir_refstack_client', 'test_repo_dir')
with mock.patch('functest.opnfv_tests.openstack.refstack_client.'
'refstack_client.ft_utils.execute_command') as m:
cmd = ("cd {0};"
diff --git a/functest/tests/unit/openstack/tempest/test_conf_utils.py b/functest/tests/unit/openstack/tempest/test_conf_utils.py
index 23f6e45c7..379049653 100644
--- a/functest/tests/unit/openstack/tempest/test_conf_utils.py
+++ b/functest/tests/unit/openstack/tempest/test_conf_utils.py
@@ -238,8 +238,6 @@ class OSTempestConfUtilsTesting(unittest.TestCase):
mock.patch('__builtin__.open', mock.mock_open()), \
mock.patch('functest.opnfv_tests.openstack.tempest.'
'conf_utils.shutil.copyfile'):
- CONST.__setattr__('dir_functest_test', 'test_dir')
- CONST.__setattr__('refstack_tempest_conf_path', 'test_path')
conf_utils.configure_tempest_defcore('test_dep_dir',
img_flavor_dict)
mset.assert_any_call('compute', 'image_ref', 'test_image_id')
@@ -264,7 +262,6 @@ class OSTempestConfUtilsTesting(unittest.TestCase):
mock.patch('__builtin__.open', mock.mock_open()), \
mock.patch('functest.opnfv_tests.openstack.tempest.'
'conf_utils.backup_tempest_config'):
- CONST.__setattr__('dir_functest_test', 'test_dir')
CONST.__setattr__('OS_ENDPOINT_TYPE', None)
conf_utils.\
configure_tempest_update_params('test_conf_file',
diff --git a/functest/tests/unit/utils/test_functest_utils.py b/functest/tests/unit/utils/test_functest_utils.py
index fbfa420aa..98c7d6e9c 100644
--- a/functest/tests/unit/utils/test_functest_utils.py
+++ b/functest/tests/unit/utils/test_functest_utils.py
@@ -465,9 +465,7 @@ class FunctestUtilsTesting(unittest.TestCase):
def test_get_dict_by_test(self, mock_logger_error):
with mock.patch('six.moves.builtins.open', mock.mock_open()), \
mock.patch('functest.utils.functest_utils.yaml.safe_load') \
- as mock_yaml, \
- mock.patch('functest.utils.functest_utils.get_testcases_'
- 'file_dir'):
+ as mock_yaml:
mock_obj = mock.Mock()
attrs = {'get.return_value': [{'testcases': [self.testcase_dict]}]}
mock_obj.configure_mock(**attrs)
@@ -521,16 +519,6 @@ class FunctestUtilsTesting(unittest.TestCase):
assert_called_once_with(self.parameter,
self.config_yaml)
- # TODO: merge_dicts
-
- @mock.patch('functest.utils.functest_utils.get_functest_config')
- def test_get_testcases_file_dir(self, mock_get_functest_config):
- mock_get_functest_config.return_value = self.testcases_yaml
- resp = functest_utils.get_testcases_file_dir()
- self.assertEqual(resp, self.testcases_yaml)
- mock_get_functest_config.assert_called_once_with(
- 'general.functest.testcases_yaml')
-
def test_get_functest_yaml(self):
with mock.patch('six.moves.builtins.open', mock.mock_open()), \
mock.patch('functest.utils.functest_utils.yaml.safe_load') \
diff --git a/functest/utils/functest_utils.py b/functest/utils/functest_utils.py
index d8cfabce0..91781bd27 100644
--- a/functest/utils/functest_utils.py
+++ b/functest/utils/functest_utils.py
@@ -11,6 +11,7 @@ import functools
import json
import logging
import os
+import pkg_resources
import re
import shutil
import subprocess
@@ -316,7 +317,8 @@ def execute_command(cmd, info=False, error_msg="",
def get_dict_by_test(testname):
- with open(get_testcases_file_dir()) as f:
+ with open(pkg_resources.resource_filename(
+ 'functest', 'ci/testcases.yaml')) as f:
testcases_yaml = yaml.safe_load(f)
for dic_tier in testcases_yaml.get("tiers"):
@@ -376,10 +378,6 @@ def merge_dicts(dict1, dict2):
yield (k, dict2[k])
-def get_testcases_file_dir():
- return get_functest_config('general.functest.testcases_yaml')
-
-
def get_functest_yaml():
with open(constants.CONST.__getattribute__('CONFIG_FUNCTEST_YAML')) as f:
functest_yaml = yaml.safe_load(f)