Example #1
0
class DominoCases(testcase_base.TestcaseBase):
    DOMINO_REPO = ft_constants.DOMINO_REPO_DIR
    RESULTS_DIR = ft_constants.FUNCTEST_RESULTS_DIR
    logger = ft_logger.Logger("domino").getLogger()

    def __init__(self):
        super(DominoCases, self).__init__()
        self.project_name = "domino"
        self.case_name = "domino-multinode"

    def main(self, **kwargs):
        cmd = 'cd %s && ./tests/run_multinode.sh' % self.DOMINO_REPO
        log_file = os.path.join(self.RESULTS_DIR, "domino.log")
        start_time = time.time()

        ret = ft_utils.execute_command(cmd,
                                       output_file=log_file)

        stop_time = time.time()
        if ret == 0:
            self.logger.info("domino OK")
            status = 'PASS'
        else:
            self.logger.info("domino FAILED")
            status = "FAIL"

        # report status only if tests run (FAIL OR PASS)
        self.criteria = status
        self.start_time = start_time
        self.stop_time = stop_time
        self.details = {}

    def run(self):
        kwargs = {}
        return self.main(**kwargs)
Example #2
0
 def __init__(self):
     super(Parser, self).__init__()
     self.project_name = "parser"
     self.case_name = "parser-basics"
     self.logger = ft_logger.Logger("parser").getLogger()
     self.log_file = os.path.join(ft_constants.FUNCTEST_RESULTS_DIR,
                                  "parser.log")
Example #3
0
 def setUp(self):
     with mock.patch('__builtin__.open', mock.mock_open()):
         with mock.patch('functest.utils.functest_logger.os.path.exists',
                         return_value=True), \
             mock.patch('functest.utils.functest_logger.'
                        'json.load'), \
             mock.patch('functest.utils.functest_logger.'
                        'logging.config.dictConfig') as m:
             self.logger = functest_logger.Logger('os_utils')
             self.assertTrue(m.called)
         with mock.patch('functest.utils.functest_logger.os.path.exists',
                         return_value=False), \
             mock.patch('functest.utils.functest_logger.'
                        'logging.basicConfig') as m:
             self.logger = functest_logger.Logger('os_utils')
             self.assertTrue(m.called)
Example #4
0
    def __init__(self,
                 project='functest',
                 case_name='cloudify_ims',
                 repo='',
                 cmd=''):
        super(CloudifyIms, self).__init__(project, case_name, repo, cmd)
        self.logger = ft_logger.Logger(__name__).getLogger()

        # Retrieve the configuration
        try:
            self.config = CONST.__getattribute__('vnf_{}_config'.format(
                self.case_name))
        except Exception:
            raise Exception("VNF config file not found")

        config_file = os.path.join(self.case_dir, self.config)
        self.orchestrator = dict(
            requirements=get_config("cloudify.requirements", config_file),
            blueprint=get_config("cloudify.blueprint", config_file),
            inputs=get_config("cloudify.inputs", config_file))
        self.logger.debug("Orchestrator configuration: %s" % self.orchestrator)
        self.vnf = dict(blueprint=get_config("clearwater.blueprint",
                                             config_file),
                        deployment_name=get_config(
                            "clearwater.deployment_name", config_file),
                        inputs=get_config("clearwater.inputs", config_file),
                        requirements=get_config("clearwater.requirements",
                                                config_file))
        self.logger.debug("VNF configuration: %s" % self.vnf)

        self.images = get_config("tenant_images", config_file)
        self.logger.info("Images needed for vIMS: %s" % self.images)
Example #5
0
 def __init__(self, project='functest', case_name='', repo='', cmd=''):
     super(Feature, self).__init__(case_name=case_name)
     self.project_name = project
     self.cmd = cmd
     self.repo = CONST.__getattribute__(repo)
     self.result_file = self.get_result_file()
     self.logger = ft_logger.Logger(project).getLogger()
Example #6
0
 def __init__(self, testcase_dir, inputs={}):
     self.testcase_dir = testcase_dir
     self.blueprint_dir = testcase_dir + 'cloudify-manager-blueprint/'
     self.input_file = 'inputs.yaml'
     self.manager_blueprint = False
     self.config = inputs
     self.logger = ft_logger.Logger("Orchestrator").getLogger()
     self.manager_up = False
Example #7
0
    def __init__(self, case_name=''):
        super(SnapsTestRunner, self).__init__(case_name)

        self.ext_net_name = snaps_utils.get_ext_net_name()
        self.logger = ft_logger.Logger(self.project_name).getLogger()
        scenario = functest_utils.get_scenario()

        self.flavor_metadata = create_flavor.MEM_PAGE_SIZE_ANY
        if 'ovs' in scenario or 'fdio' in scenario:
            self.flavor_metadata = create_flavor.MEM_PAGE_SIZE_LARGE

        self.logger.info("Using flavor metatdata '%s'" % self.flavor_metadata)
Example #8
0
def main():

    logger = ft_logger.Logger("vRouter").getLogger()
    vrouter = vRouter(logger)
    result_data = vrouter.main()

    if result_data["status"] == "FAIL":
        logger.error("Error : Failed  vRouter Run ")
        return -1

    logger.info("Ok : Success vRouter Run")
    return 0
Example #9
0
 def __init__(self, project='functest', case_name='opera_ims',
              repo=CONST.dir_repo_opera, cmd=''):
     super(OperaIms, self).__init__(project, case_name, repo, cmd)
     self.logger = ft_logger.Logger(__name__).getLogger()
     self.ellis_file = os.path.join(self.result_dir, 'ellis.info')
     self.live_test_file = os.path.join(self.result_dir,
                                        'live_test_report.json')
     try:
         self.openo_msb_endpoint = os.environ['OPENO_MSB_ENDPOINT']
     except KeyError:
         raise Exception('OPENO_MSB_ENDPOINT is not specified,'
                         ' put it as <OPEN-O ip>:<port>')
     else:
         self.logger.info('OPEN-O endpoint is: %s', self.openo_msb_endpoint)
Example #10
0
class TestcaseBase(object):

    EX_OK = os.EX_OK
    EX_RUN_ERROR = os.EX_SOFTWARE
    EX_PUSH_TO_DB_ERROR = os.EX_SOFTWARE - 1
    EX_TESTCASE_FAILED = os.EX_SOFTWARE - 2

    logger = ft_logger.Logger(__name__).getLogger()

    def __init__(self):
        self.details = {}
        self.project_name = "functest"
        self.case_name = ""
        self.criteria = ""
        self.start_time = ""
        self.stop_time = ""

    def check_criteria(self):
        try:
            assert self.criteria
            if self.criteria == 'PASS':
                return TestcaseBase.EX_OK
        except:
            self.logger.error("Please run test before checking the results")
        return TestcaseBase.EX_TESTCASE_FAILED

    def run(self, **kwargs):
        self.logger.error("Run must be implemented")
        return TestcaseBase.EX_RUN_ERROR

    def push_to_db(self):
        try:
            assert self.project_name
            assert self.case_name
            assert self.criteria
            assert self.start_time
            assert self.stop_time
            if ft_utils.push_results_to_db(self.project_name, self.case_name,
                                           self.start_time, self.stop_time,
                                           self.criteria, self.details):
                self.logger.info("The results were successfully pushed to DB")
                return TestcaseBase.EX_OK
            else:
                self.logger.error("The results cannot be pushed to DB")
                return TestcaseBase.EX_PUSH_TO_DB_ERROR
        except Exception:
            self.logger.exception("The results cannot be pushed to DB")
            return TestcaseBase.EX_PUSH_TO_DB_ERROR
Example #11
0
class AaaVnf(vnf_base.VnfOnBoardingBase):

    logger = ft_logger.Logger("VNF AAA").getLogger()

    def __init__(self):
        super(AaaVnf, self).__init__(case_name="aaa")

    def deploy_orchestrator(self):
        self.logger.info("No VNFM needed to deploy a free radius here")
        return None


# TODO see how to use build in exception form releng module

    def deploy_vnf(self):
        self.logger.info("Freeradius VNF deployment")
        # TODO apt-get update + config tuning
        deploy_vnf = {}
        deploy_vnf['status'] = "PASS"
        deploy_vnf['result'] = {}
        return deploy_vnf

    def test_vnf(self):
        self.logger.info("Run test towards freeradius")
        # TODO:  once the freeradius is deployed..make some tests
        test_vnf = {}
        test_vnf['status'] = "PASS"
        test_vnf['result'] = {}
        return test_vnf

    def main(self, **kwargs):
        self.logger.info("AAA VNF onboarding")
        self.execute()
        if self.criteria is "PASS":
            return self.EX_OK
        else:
            return self.EX_RUN_ERROR

    def run(self):
        kwargs = {}
        return self.main(**kwargs)
Example #12
0
 def __init__(self, project='functest', case_name='orchestra_ims',
              repo='', cmd=''):
     super(ImsVnf, self).__init__(project, case_name, repo, cmd)
     self.ob_password = "******"
     self.ob_username = "******"
     self.ob_https = False
     self.ob_port = "8080"
     self.ob_ip = "localhost"
     self.ob_instance_id = ""
     self.logger = ft_logger.Logger("orchestra_ims").getLogger()
     self.case_dir = os.path.join(CONST.dir_functest_test, 'vnf/ims/')
     self.data_dir = CONST.dir_ims_data
     self.test_dir = CONST.dir_repo_vims_test
     self.ob_projectid = ""
     self.keystone_client = os_utils.get_keystone_client()
     self.ob_nsr_id = ""
     self.nsr = None
     self.main_agent = None
     # vIMS Data directory creation
     if not os.path.exists(self.data_dir):
         os.makedirs(self.data_dir)
     # Retrieve the configuration
     try:
         self.config = CONST.__getattribute__(
             'vnf_{}_config'.format(self.case_name))
     except BaseException:
         raise Exception("Orchestra VNF config file not found")
     config_file = self.case_dir + self.config
     self.imagename = get_config("openbaton.imagename", config_file)
     self.bootstrap_link = get_config("openbaton.bootstrap_link",
                                      config_file)
     self.bootstrap_config_link = get_config(
         "openbaton.bootstrap_config_link", config_file)
     self.market_link = get_config("openbaton.marketplace_link",
                                   config_file)
     self.images = get_config("tenant_images", config_file)
     self.ims_conf = get_config("vIMS", config_file)
     self.userdata_file = get_config("openbaton.userdata.file",
                                     config_file)
Example #13
0
import os
import os.path
import subprocess
import sys
import time

from cinderclient import client as cinderclient
import functest.utils.functest_logger as ft_logger
import functest.utils.functest_utils as ft_utils
from glanceclient import client as glanceclient
from keystoneclient.v2_0 import client as keystoneclient
from neutronclient.v2_0 import client as neutronclient
from novaclient import client as novaclient

logger = ft_logger.Logger("openstack_utils").getLogger()


# *********************************************
#   CREDENTIALS
# *********************************************
class MissingEnvVar(Exception):
    def __init__(self, var):
        self.var = var

    def __str__(self):
        return str.format("Please set the mandatory env var: {}", self.var)


def check_credentials():
    """
Example #14
0
#    [email protected]
#
#
# 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
#

import functest.utils.functest_logger as ft_logger
import functest.utils.openstack_utils as os_utils
import functest.utils.openstack_tacker as os_tacker
import yaml
import functest.utils.functest_constants as ft_constants

logger = ft_logger.Logger("openstack_snapshot").getLogger()

OS_SNAPSHOT_FILE = ft_constants.OPENSTACK_SNAPSHOT_FILE


def separator():
    logger.info("-------------------------------------------")


def get_instances(nova_client):
    logger.debug("Getting instances...")
    dic_instances = {}
    instances = os_utils.get_instances(nova_client)
    if not (instances is None or len(instances) == 0):
        for instance in instances:
            dic_instances.update(
Example #15
0
#
#
# 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
#

import time
import functest.utils.functest_logger as ft_logger
import functest.utils.openstack_utils as os_utils
import functest.utils.openstack_tacker as os_tacker
import yaml
import functest.utils.functest_constants as ft_constants

logger = ft_logger.Logger("openstack_clean").getLogger()

OS_SNAPSHOT_FILE = ft_constants.OPENSTACK_SNAPSHOT_FILE


def separator():
    logger.debug("-------------------------------------------")


def remove_instances(nova_client, default_instances):
    logger.debug("Removing Nova instances...")
    instances = os_utils.get_instances(nova_client)
    if instances is None or len(instances) == 0:
        logger.debug("No instances found.")
        return
Example #16
0
 def __init__(self):
     super(VPingSSH, self).__init__()
     self.case_name = 'vping_ssh'
     self.logger = ft_logger.Logger(self.case_name).getLogger()
Example #17
0
import sys
import fileinput

import yaml

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

from opnfv.utils import constants as opnfv_constants
from opnfv.deployment import factory

actions = ['start', 'check']
""" logging configuration """
logger = ft_logger.Logger("prepare_env").getLogger()
handler = None
# set the architecture to default
pod_arch = None
arch_filter = ['aarch64']

CONFIG_FUNCTEST_PATH = CONST.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")

Example #18
0
# Testcase 1 : Prerequisites configuration for SFC
# Testcase 2 : Creation of 3 VNF Nodes and Attaching Ports
# Testcase 3 : Configure  SFC [Port pair,Port Group ,Flow classifer
# Testcase 4 : Configure Port Chain and verify the flows are added.
# Testcase 5 : Verify  traffic with VNF node.
# Testcase 6 : Remove the Port Chain and Verify the traffic.
# Testcase 7 : Cleanup
# ###########################################################################
#

import time
import functest.utils.functest_logger as ft_logger
import functest.utils.functest_utils as ft_utils
from sfc_onos import SfcOnos

logger = ft_logger.Logger("sfc").getLogger()
Sfc_obj = SfcOnos()

OK = 200
CREATED = 201
ACCEPTED = 202
NO_CONTENT = 204

start_time = time.time()


def PreConfig():
    logger.info("Testcase 1 : Prerequisites configuration for SFC")
    logger.info("1.1 Creation of Auth-Token")
    check(Sfc_obj.getToken, OK, "Creation of Token")
    logger.info("1.2 Creation of Network")
Example #19
0
#
# 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
#

import os
import paramiko
import subprocess
import sys

import functest.utils.functest_logger as ft_logger


logger = ft_logger.Logger(__name__).getLogger()

SFC_REPO_DIR = "/home/opnfv/repos/sfc"

try:
    INSTALLER_IP = os.environ['INSTALLER_IP']
except:
    logger.debug("INSTALLER_IP does not exist. We create 10.20.0.2")
    INSTALLER_IP = "10.20.0.2"

os.environ['ODL_SFC_LOG'] = "/home/opnfv/functest/results/sfc.log"
os.environ['ODL_SFC_DIR'] = os.path.join(SFC_REPO_DIR,
                                         "sfc/tests/functest")
SETUP_SCRIPTS_DIR = os.path.join(os.environ['ODL_SFC_DIR'], 'setup_scripts')

command = SETUP_SCRIPTS_DIR + ("/server_presetup_CI.bash | "
Example #20
0
class Client(Environment):

    logger = ft_logger.Logger("client").getLogger()

    def __init__(self):
        Environment.__init__(self)
        self.loginfo = Environment()
        self.testcase = ''

    def RunScript(self, handle, testname, timeout=300):
        """
        Run ONOS Test Script
        Parameters:
        testname: ONOS Testcase Name
        masterusername: The server username of running ONOS
        masterpassword: The server password of running ONOS
        """
        self.testcase = testname
        self.ChangeTestCasePara(testname, self.masterusername,
                                self.masterpassword)
        runhandle = handle
        runtest = (self.home + "/OnosSystemTest/TestON/bin/cli.py run " +
                   testname)
        runhandle.sendline(runtest)
        circletime = 0
        lastshowscreeninfo = ''
        while True:
            Result = runhandle.expect(
                ["PEXPECT]#", pexpect.EOF, pexpect.TIMEOUT])
            curshowscreeninfo = runhandle.before
            if (len(lastshowscreeninfo) != len(curshowscreeninfo)):
                self.loginfo.log(
                    str(curshowscreeninfo)[len(lastshowscreeninfo)::])
                lastshowscreeninfo = curshowscreeninfo
            if Result == 0:
                self.logger.info("Done!")
                return
            time.sleep(1)
            circletime += 1
            if circletime > timeout:
                break
        self.loginfo.log("Timeout when running the test, please check!")

    def onosstart(self):
        # This is the compass run machine user&pass,you need to modify

        self.logger.info("Test Begin.....")
        self.OnosConnectionSet()
        masterhandle = self.SSHlogin(self.localhost, self.masterusername,
                                     self.masterpassword)
        self.OnosEnvSetup(masterhandle)
        return masterhandle

    def onosclean(self, handle):
        self.SSHRelease(handle)
        self.loginfo.log('Release onos handle Successful')

    def push_results_to_db(self, payload, pushornot=1):
        if pushornot != 1:
            return 1
        url = self.Result_DB + "/results"
        params = {
            "project_name": "functest",
            "case_name": "ONOS-" + self.testcase,
            "pod_name": 'huawei-build-2',
            "details": payload
        }

        headers = {'Content-Type': 'application/json'}
        try:
            r = requests.post(url, data=json.dumps(params), headers=headers)
            self.loginfo.log(r)
        except:
            self.loginfo.log('Error pushing results into Database')
Example #21
0
class TestCase(object):
    """Parent class of Functest TestCase."""

    EX_OK = os.EX_OK
    EX_RUN_ERROR = os.EX_SOFTWARE
    EX_PUSH_TO_DB_ERROR = os.EX_SOFTWARE - 1
    EX_TESTCASE_FAILED = os.EX_SOFTWARE - 2

    logger = ft_logger.Logger(__name__).getLogger()

    def __init__(self, case_name=""):
        self.details = {}
        self.project_name = "functest"
        self.case_name = case_name
        self.criteria = ""
        self.start_time = ""
        self.stop_time = ""

    def check_criteria(self):
        """Interpret the results of TestCase.

        It allows getting the results of TestCase. It completes run()
        which only returns the execution status.

        It can be overriden if checking criteria is not suitable.

        Returns:
            TestCase.EX_OK if criteria is 'PASS'.
            TestCase.EX_TESTCASE_FAILED otherwise.
        """
        try:
            assert self.criteria
            if self.criteria == 'PASS':
                return TestCase.EX_OK
        except AssertionError:
            self.logger.error("Please run test before checking the results")
        return TestCase.EX_TESTCASE_FAILED

    def run(self, **kwargs):
        """Run TestCase.

        It allows running TestCase and getting its execution
        status.

        The subclasses must override the default implementation which
        is false on purpose. The only prerequisite is to set the
        following attributes to push the results to DB:
            * case_name,
            * criteria,
            * start_time,
            * stop_time.

        Args:
            **kwargs: Arbitrary keyword arguments.

        Returns:
            TestCase.EX_RUN_ERROR.
        """
        # pylint: disable=unused-argument
        self.logger.error("Run must be implemented")
        return TestCase.EX_RUN_ERROR

    def push_to_db(self):
        """Push the results of TestCase to the DB.

        It allows publishing the results and to check the status.

        It could be overriden if the common implementation is not
        suitable. The following attributes must be set before pushing
        the results to DB:
            * project_name,
            * case_name,
            * criteria,
            * start_time,
            * stop_time.

        Returns:
            TestCase.EX_OK if results were pushed to DB.
            TestCase.EX_PUSH_TO_DB_ERROR otherwise.
        """
        try:
            assert self.project_name
            assert self.case_name
            assert self.criteria
            assert self.start_time
            assert self.stop_time
            if ft_utils.push_results_to_db(self.project_name, self.case_name,
                                           self.start_time, self.stop_time,
                                           self.criteria, self.details):
                self.logger.info("The results were successfully pushed to DB")
                return TestCase.EX_OK
            else:
                self.logger.error("The results cannot be pushed to DB")
                return TestCase.EX_PUSH_TO_DB_ERROR
        except Exception:  # pylint: disable=broad-except
            self.logger.exception("The results cannot be pushed to DB")
            return TestCase.EX_PUSH_TO_DB_ERROR
Example #22
0
File: utils.py Project: rski/sdnvpn
# 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
#
import sys
import time

import functest.utils.functest_logger as ft_logger
import functest.utils.openstack_utils as os_utils
import re

from sdnvpn.lib import config as sdnvpn_config

logger = ft_logger.Logger("sndvpn_test_utils").getLogger()

common_config = sdnvpn_config.CommonConfig()


def create_net(neutron_client, name):
    logger.debug("Creating network %s", name)
    net_id = os_utils.create_neutron_net(neutron_client, name)
    if not net_id:
        logger.error(
            "There has been a problem when creating the neutron network")
        sys.exit(-1)
    return net_id


def create_subnet(neutron_client, name, cidr, net_id):
Example #23
0
import sys
import time
import yaml

import functest.utils.functest_logger as ft_logger
import functest.utils.functest_utils as ft_utils
from sdnvpn.lib import config as sdnvpn_config


parser = argparse.ArgumentParser()
parser.add_argument("-r", "--report",
                    help="Create json result file",
                    action="store_true")
args = parser.parse_args()

logger = ft_logger.Logger("sdnvpn-run-tests").getLogger()

COMMON_CONFIG = sdnvpn_config.CommonConfig()
TEST_DB_URL = COMMON_CONFIG.test_db


def push_results(testname, start_time, end_time, criteria, details):
    logger.info("Push testcase '%s' results into the DB...\n" % testname)
    ft_utils.push_results_to_db("sdnvpn",
                                testname,
                                start_time,
                                end_time,
                                criteria,
                                details)

Example #24
0
import functest.utils.openstack_utils as openstack_utils

pp = pprint.PrettyPrinter(indent=4)

parser = argparse.ArgumentParser()
image_exists = False

parser.add_argument("-d", "--debug", help="Debug mode", action="store_true")
parser.add_argument("-r", "--report",
                    help="Create json result file",
                    action="store_true")

args = parser.parse_args()

""" logging configuration """
logger = ft_logger.Logger("vping_userdata").getLogger()

REPO_PATH = os.environ['repos_dir'] + '/functest/'
if not os.path.exists(REPO_PATH):
    logger.error("Functest repository directory not found '%s'" % REPO_PATH)
    exit(-1)

with open(os.environ["CONFIG_FUNCTEST_YAML"]) as f:
    functest_yaml = yaml.safe_load(f)
f.close()

HOME = os.environ['HOME'] + "/"
# vPing parameters
VM_BOOT_TIMEOUT = 180
VM_DELETE_TIMEOUT = 100
PING_TIMEOUT = functest_yaml.get("vping").get("ping_timeout")
Example #25
0
# Wrappers for trozet's python-tackerclient v1.0
# (https://github.com/trozet/python-tackerclient)
#
# 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
##########################################################################


from tackerclient.v1_0 import client as tackerclient
import functest.utils.functest_logger as ft_logger
import functest.utils.openstack_utils as os_utils
import time

logger = ft_logger.Logger("tacker_utils").getLogger()


def get_tacker_client(other_creds={}):
    sess = os_utils.get_session(other_creds)
    return tackerclient.Client(session=sess)


# *********************************************
#   TACKER
# *********************************************
def get_id_from_name(tacker_client, resource_type, resource_name):
    try:
        req_params = {'fields': 'id', 'name': resource_name}
        endpoint = '/{0}s'.format(resource_type)
        resp = tacker_client.get(endpoint, params=req_params)
Example #26
0
parser.add_argument("-z",
                    "--sanity",
                    help="Sanity test mode, execute only a subset of tests",
                    action="store_true")

args = parser.parse_args()

client_dict = {}
network_dict = {}

if args.verbose:
    RALLY_STDERR = subprocess.STDOUT
else:
    RALLY_STDERR = open(os.devnull, 'w')
""" logging configuration """
logger = ft_logger.Logger("run_rally").getLogger()

REPO_PATH = os.environ['repos_dir'] + '/functest/'
if not os.path.exists(REPO_PATH):
    logger.error("Functest repository directory not found '%s'" % REPO_PATH)
    exit(-1)

with open(os.environ["CONFIG_FUNCTEST_YAML"]) as f:
    functest_yaml = yaml.safe_load(f)
f.close()

HOME = os.environ['HOME'] + "/"
RALLY_DIR = REPO_PATH + functest_yaml.get("general").get("directories").get(
    "dir_rally")
TEMPLATE_DIR = RALLY_DIR + "scenario/templates"
SUPPORT_DIR = RALLY_DIR + "scenario/support"
Example #27
0
import functest.utils.openstack_utils as os_utils

from sdnvpn.lib import utils as test_utils
from sdnvpn.lib import config as sdnvpn_config
from sdnvpn.lib.results import Results

parser = argparse.ArgumentParser()

parser.add_argument("-r",
                    "--report",
                    help="Create json result file",
                    action="store_true")

args = parser.parse_args()

logger = ft_logger.Logger("sdnvpn-testcase-4").getLogger()

COMMON_CONFIG = sdnvpn_config.CommonConfig()
TESTCASE_CONFIG = sdnvpn_config.TestcaseConfig('testcase_4')


def main():
    results = Results(COMMON_CONFIG.line_length)

    results.add_to_summary(0, "=")
    results.add_to_summary(2, "STATUS", "SUBTEST")
    results.add_to_summary(0, "=")

    nova_client = os_utils.get_nova_client()
    neutron_client = os_utils.get_neutron_client()
    glance_client = os_utils.get_glance_client()
Example #28
0
import argparse
import datetime
import os
import re
import time
import yaml

import functest.utils.functest_logger as ft_logger
import functest.utils.functest_utils as functest_utils

parser = argparse.ArgumentParser()
parser.add_argument("-i", "--installer", help="Installer type")
args = parser.parse_args()
""" logging configuration """
logger = ft_logger.Logger("onos").getLogger()

with open(os.environ["CONFIG_FUNCTEST_YAML"]) as f:
    functest_yaml = yaml.safe_load(f)
f.close()

# onos parameters
TEST_DB = functest_yaml.get("results").get("test_db_url")
ONOS_REPO_PATH = functest_yaml.get("general").get("directories").get(
    "dir_repos")
ONOS_CONF_DIR = functest_yaml.get("general").get("directories").get(
    "dir_functest_conf")
REPO_PATH = ONOS_REPO_PATH + '/functest/'
if not os.path.exists(REPO_PATH):
    logger.error("Functest repository directory not found '%s'" % REPO_PATH)
    exit(-1)
Example #29
0
                    action='store',
                    help="Test case or tier (group of tests) to be executed. "
                    "It will run all the test if not specified.")
parser.add_argument("-n",
                    "--noclean",
                    help="Do not clean OpenStack resources"
                    " after running each test (default=false).",
                    action="store_true")
parser.add_argument("-r",
                    "--report",
                    help="Push results to database "
                    "(default=false).",
                    action="store_true")
args = parser.parse_args()
""" logging configuration """
logger = ft_logger.Logger("run_tests").getLogger()
""" global variables """
EXEC_SCRIPT = ("%s/functest/ci/exec_test.sh" % ft_constants.FUNCTEST_REPO_DIR)

# This will be the return code of this script. If any of the tests fails,
# this variable will change to -1


class GlobalVariables:
    EXECUTED_TEST_CASES = []
    OVERALL_RESULT = 0
    CLEAN_FLAG = True
    REPORT_FLAG = False


def print_separator(str, count=45):
Example #30
0
import shutil
import subprocess
import sys
import time
import urllib2
from datetime import datetime as dt

import dns.resolver
import requests
import yaml
from git import Repo

from functest.utils import decorators
import functest.utils.functest_logger as ft_logger

logger = ft_logger.Logger("functest_utils").getLogger()


# ----------------------------------------------------------
#
#               INTERNET UTILS
#
# -----------------------------------------------------------
def check_internet_connectivity(url='http://www.opnfv.org/'):
    """
    Check if there is access to the internet
    """
    try:
        urllib2.urlopen(url, timeout=5)
        return True
    except urllib2.URLError: