Exemplo n.º 1
0
class TestODLFullStackBase(test_plugin.Ml2PluginV2TestCase):

    _mechanism_drivers = ['logger', 'opendaylight_v2']
    _extension_drivers = ['port_security']
    l3_plugin = 'networking_odl.l3.l3_odl_v2.OpenDaylightL3RouterPlugin'

    # this is stolen from neutron.tests.fullstack.base
    #
    # This is the directory from which infra fetches log files
    # for fullstack tests
    DEFAULT_LOG_DIR = os.path.join(helpers.get_test_log_path(),
                                   'dsvm-fullstack-logs')

    def setUp(self):
        # NOTE(yamahata):
        # When tox is using virtualenv and oslo.privsep is also installed
        # in system, sudo chooses system one.
        # However for privsep-helper to find python module in virtualenv
        # we need to use the on under .tox. So specify the full path
        # and preserve environmental variables.
        privsep_helper = "privsep-helper"
        if "VIRTUAL_ENV" in os.environ:
            privsep_helper = os.path.join(os.environ["VIRTUAL_ENV"], "bin",
                                          privsep_helper)
        cfg.CONF.set_override("helper_command",
                              "sudo --preserve-env " + privsep_helper,
                              group="privsep")

        cfg.CONF.set_override('extension_drivers',
                              self._extension_drivers,
                              group='ml2')
        cfg.CONF.set_override('tenant_network_types', ['vxlan'], group='ml2')
        cfg.CONF.set_override('vni_ranges', ['1:1000'], group='ml2_type_vxlan')

        odl_url = 'http://127.0.0.1:8087/controller/nb/v2/neutron'
        odl_config.cfg.CONF.set_override('url', odl_url, group='ml2_odl')
        odl_config.cfg.CONF.set_override('username', 'admin', group='ml2_odl')
        odl_config.cfg.CONF.set_override('password', 'admin', group='ml2_odl')
        odl_config.cfg.CONF.set_override('port_binding_controller',
                                         'legacy-port-binding',
                                         group='ml2_odl')
        odl_config.cfg.CONF.set_override('odl_features', ['no-feature'],
                                         group='ml2_odl')
        super(TestODLFullStackBase, self).setUp()
        tests_base.setup_test_logging(cfg.CONF, self.DEFAULT_LOG_DIR,
                                      '%s.txt' % self.get_name())

    def get_name(self):
        class_name, test_name = self.id().split(".")[-2:]
        return "%s.%s" % (class_name, test_name)
Exemplo n.º 2
0
class TestODLFullStackBase(test_plugin.Ml2PluginV2TestCase):

    _mechanism_drivers = ['logger', 'opendaylight_v2']
    _extension_drivers = ['port_security']
    l3_plugin = 'networking_odl.l3.l3_odl_v2.OpenDaylightL3RouterPlugin'

    # this is stolen from neutron.tests.fullstack.base
    #
    # This is the directory from which infra fetches log files
    # for fullstack tests
    DEFAULT_LOG_DIR = os.path.join(helpers.get_test_log_path(),
                                   'dsvm-fullstack-logs')

    def setUp(self):
        config.cfg.CONF.set_override('extension_drivers',
                                     self._extension_drivers,
                                     group='ml2')
        config.cfg.CONF.set_override('tenant_network_types', ['vxlan'],
                                     group='ml2')
        config.cfg.CONF.set_override('vni_ranges', ['1:1000'],
                                     group='ml2_type_vxlan')

        odl_url = 'http://127.0.0.1:8087/controller/nb/v2/neutron'
        odl_config.cfg.CONF.set_override('url', odl_url, group='ml2_odl')
        odl_config.cfg.CONF.set_override('username', 'admin', group='ml2_odl')
        odl_config.cfg.CONF.set_override('password', 'admin', group='ml2_odl')
        odl_config.cfg.CONF.set_override('port_binding_controller',
                                         'legacy-port-binding',
                                         group='ml2_odl')
        odl_config.cfg.CONF.set_override('odl_features', ['no-feature'],
                                         group='ml2_odl')
        super(TestODLFullStackBase, self).setUp()
        tests_base.setup_test_logging(cfg.CONF, self.DEFAULT_LOG_DIR,
                                      '%s.txt' % self.get_name())

    def get_name(self):
        class_name, test_name = self.id().split(".")[-2:]
        return "%s.%s" % (class_name, test_name)
Exemplo n.º 3
0
#    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
#    License for the specific language governing permissions and limitations
#    under the License.

import os

from oslo_config import cfg

from neutron.agent.linux import utils
from neutron.conf.agent import common as config
from neutron.tests import base
from neutron.tests.common import base as common_base
from neutron.tests.common import helpers

# This is the directory from which infra fetches log files for functional tests
DEFAULT_LOG_DIR = os.path.join(helpers.get_test_log_path(),
                               'dsvm-functional-logs')


class BaseLoggingTestCase(base.BaseTestCase):
    def setUp(self):
        super(BaseLoggingTestCase, self).setUp()
        base.setup_test_logging(
            cfg.CONF, DEFAULT_LOG_DIR, "%s.txt" % self.id())


class BaseSudoTestCase(BaseLoggingTestCase):
    """
    Base class for tests requiring invocation of commands via a root helper.

    This class skips (during setUp) its tests unless sudo is enabled, ie:
Exemplo n.º 4
0
import os
import warnings

import mock
from oslo_config import cfg

from neutron.agent.linux import utils
from neutron.conf.agent import common as config
from neutron.conf.agent import ovs_conf
from neutron.tests import base
from neutron.tests.common import base as common_base
from neutron.tests.common import helpers

# This is the directory from which infra fetches log files for functional tests
DEFAULT_LOG_DIR = os.path.join(helpers.get_test_log_path(),
                               'dsvm-functional-logs')


def config_decorator(method_to_decorate, config_tuples):
    def wrapper(*args, **kwargs):
        method_to_decorate(*args, **kwargs)
        for config_tuple in config_tuples:
            cfg.CONF.set_override(*config_tuple)
    return wrapper


class BaseLoggingTestCase(base.BaseTestCase):
    def setUp(self):
        super(BaseLoggingTestCase, self).setUp()
        # NOTE(slaweq): Because of issue with stestr and Python3, we need
Exemplo n.º 5
0
class OdlTestsBase(object):
    #  this is stolen from neutron.tests.functional.base
    # This is the directory from which infra fetches log files
    # for functional tests.
    DEFAULT_LOG_DIR = os.path.join(helpers.get_test_log_path(),
                                   'dsvm-functional-logs')

    def setUp(self):
        self.cfg = self.useFixture(config_fixture.Config())
        self.cfg.config(url='http://127.0.0.1:8181/controller/nb/v2/neutron',
                        group='ml2_odl')
        self.cfg.config(username='******', group='ml2_odl')
        self.cfg.config(password='******', group='ml2_odl')
        self.cfg.config(mechanism_drivers=self._mechanism_drivers, group='ml2')
        self.cfg.config(extension_drivers=['qos', 'port_security'],
                        group='ml2')
        self.client = client.OpenDaylightRestClient.create_client()
        super(OdlTestsBase, self).setUp()
        base.setup_test_logging(cfg.CONF, self.DEFAULT_LOG_DIR,
                                "%s.txt" % self.id())

    def setup_parent(self):
        """Perform parent setup with the common plugin configuration class."""
        # Ensure that the parent setup can be called without arguments
        # by the common configuration setUp.
        service_plugins = {'l3_plugin_name': self.l3_plugin}
        service_plugins.update(self.get_additional_service_plugins())
        parent_setup = functools.partial(super(test_plugin.Ml2PluginV2TestCase,
                                               self).setUp,
                                         plugin=self.get_plugins(),
                                         ext_mgr=self.get_ext_managers(),
                                         service_plugins=service_plugins)
        self.useFixture(test_plugin.Ml2ConfFixture(parent_setup))

    def get_plugins(self):
        return test_plugin.PLUGIN_NAME

    def get_ext_managers(self):
        return None

    def get_odl_resource(self, resource_type, resource):
        return self.client.get_resource(resource_type,
                                        resource[resource_type]['id'])

    def assert_resource_created(self, resource_type, resource):
        odl_resource = self.get_odl_resource(resource_type, resource)
        self.assertIsNotNone(odl_resource)

    def resource_update_test(self, resource_type, resource):
        update_field = 'name'
        update_value = 'bubu'
        resource = self.get_odl_resource(resource_type, resource)
        self.assertNotEqual(update_value,
                            resource[resource_type][update_field])

        self._update(odl_utils.make_url_object(resource_type),
                     resource[resource_type]['id'],
                     {resource_type: {
                         update_field: update_value
                     }})
        resource = self.get_odl_resource(resource_type, resource)
        self.assertEqual(update_value, resource[resource_type][update_field])

    def resource_delete_test(self, resource_type, resource):
        self._delete(odl_utils.make_url_object(resource_type),
                     resource[resource_type]['id'])
        self.assertIsNone(self.get_odl_resource(resource_type, resource))