Exemple #1
0
    def setUp(self):
        super(DietTestCase, self).setUp()

        # FIXME(amuller): this must be called in the Neutron unit tests base
        # class. Moving this may cause non-deterministic failures. Bug #1489098
        # for more info.
        db_options.set_defaults(cfg.CONF, connection='sqlite://')

        # Configure this first to ensure pm debugging support for setUp()
        debugger = os.environ.get('OS_POST_MORTEM_DEBUGGER')
        if debugger:
            self.addOnException(
                post_mortem_debug.get_exception_handler(debugger))

        # Make sure we see all relevant deprecation warnings when running tests
        self.useFixture(tools.WarningsFixture())

        # NOTE(ihrachys): oslotest already sets stopall for cleanup, but it
        # does it using six.moves.mock (the library was moved into
        # unittest.mock in Python 3.4). So until we switch to six.moves.mock
        # everywhere in unit tests, we can't remove this setup. The base class
        # is used in 3party projects, so we would need to switch all of them to
        # six before removing the cleanup callback from here.
        self.addCleanup(mock.patch.stopall)

        self.addCleanup(self.reset_model_query_hooks)
        self.addCleanup(self.reset_resource_extend_functions)

        self.addOnException(self.check_for_systemexit)
        self.orig_pid = os.getpid()

        tools.reset_random_seed()
Exemple #2
0
    def setUp(self, environment):
        super(BaseFullStackTestCase, self).setUp()

        tests_base.setup_test_logging(cfg.CONF, DEFAULT_LOG_DIR,
                                      '%s.txt' % self.get_name())

        # NOTE(zzzeek): the opportunistic DB fixtures have built for
        # us a per-test (or per-process) database.  Set the URL of this
        # database in CONF as the full stack tests need to actually run a
        # neutron server against this database.
        _orig_db_url = cfg.CONF.database.connection
        cfg.CONF.set_override('connection',
                              str(self.engine.url),
                              group='database')
        self.addCleanup(cfg.CONF.set_override,
                        "connection",
                        _orig_db_url,
                        group="database")

        # NOTE(ihrachys): seed should be reset before environment fixture below
        # since the latter starts services that may rely on generated port
        # numbers
        tools.reset_random_seed()

        # configure test runner to use rootwrap
        self.setup_rootwrap()
        config.setup_privsep()

        self.environment = environment
        self.environment.test_name = self.get_name()
        self.useFixture(self.environment)
        self.client = self.environment.neutron_server.client
        self.safe_client = self.useFixture(
            client_resource.ClientFixture(self.client))
Exemple #3
0
    def setUp(self):
        super(DietTestCase, self).setUp()

        # FIXME(amuller): this must be called in the Neutron unit tests base
        # class to initialize the DB connection string. Moving this may cause
        # non-deterministic failures. Bug #1489098 for more info.
        config.set_db_defaults()

        # Configure this first to ensure pm debugging support for setUp()
        debugger = os.environ.get("OS_POST_MORTEM_DEBUGGER")
        if debugger:
            self.addOnException(post_mortem_debug.get_exception_handler(debugger))

        # Make sure we see all relevant deprecation warnings when running tests
        self.useFixture(tools.WarningsFixture())

        # NOTE(ihrachys): oslotest already sets stopall for cleanup, but it
        # does it using six.moves.mock (the library was moved into
        # unittest.mock in Python 3.4). So until we switch to six.moves.mock
        # everywhere in unit tests, we can't remove this setup. The base class
        # is used in 3party projects, so we would need to switch all of them to
        # six before removing the cleanup callback from here.
        self.addCleanup(mock.patch.stopall)

        self.addOnException(self.check_for_systemexit)
        self.orig_pid = os.getpid()

        tools.reset_random_seed()
Exemple #4
0
    def setUp(self, environment):
        super(BaseFullStackTestCase, self).setUp()

        tests_base.setup_test_logging(
            cfg.CONF, DEFAULT_LOG_DIR, '%s.txt' % self.get_name())

        # NOTE(zzzeek): the opportunistic DB fixtures have built for
        # us a per-test (or per-process) database.  Set the URL of this
        # database in CONF as the full stack tests need to actually run a
        # neutron server against this database.
        _orig_db_url = cfg.CONF.database.connection
        cfg.CONF.set_override(
            'connection', str(self.engine.url), group='database')
        self.addCleanup(
            cfg.CONF.set_override,
            "connection", _orig_db_url, group="database"
        )

        # NOTE(ihrachys): seed should be reset before environment fixture below
        # since the latter starts services that may rely on generated port
        # numbers
        tools.reset_random_seed()
        self.environment = environment
        self.environment.test_name = self.get_name()
        self.useFixture(self.environment)
        self.client = self.environment.neutron_server.client
        self.safe_client = self.useFixture(
            client_resource.ClientFixture(self.client))
Exemple #5
0
 def setUp(self, environment):
     super(BaseFullStackTestCase, self).setUp()
     # NOTE(ihrachys): seed should be reset before environment fixture below
     # since the latter starts services that may rely on generated port
     # numbers
     tools.reset_random_seed()
     self.create_db_tables()
     self.environment = environment
     self.environment.test_name = self.get_name()
     self.useFixture(self.environment)
     self.client = self.environment.neutron_server.client
     self.safe_client = self.useFixture(
         client_resource.ClientFixture(self.client))
Exemple #6
0
    def setUp(self):
        super(DietTestCase, self).setUp()

        # Suppress some log messages during test runs, otherwise it may cause
        # issues with subunit parser when running on Python 3. It happened for
        # example for neutron-functional tests.
        # With this suppress of log levels DEBUG logs will not be captured by
        # stestr on pythonlogging stream and will not cause this parser issue.
        supress_logs = [
            'neutron', 'neutron_lib', 'stevedore', 'oslo_policy',
            'oslo_concurrency', 'oslo_db', 'alembic', 'ovsdbapp'
        ]
        for supress_log in supress_logs:
            logger = logging.getLogger(supress_log)
            logger.setLevel(logging.ERROR)

        # FIXME(amuller): this must be called in the Neutron unit tests base
        # class. Moving this may cause non-deterministic failures. Bug #1489098
        # for more info.
        db_options.set_defaults(cfg.CONF, connection='sqlite://')

        # Configure this first to ensure pm debugging support for setUp()
        debugger = os.environ.get('OS_POST_MORTEM_DEBUGGER')
        if debugger:
            self.addOnException(
                post_mortem_debug.get_exception_handler(debugger))

        # Make sure we see all relevant deprecation warnings when running tests
        self.useFixture(tools.WarningsFixture())

        self.useFixture(fixture.DBQueryHooksFixture())

        # NOTE(ihrachys): oslotest already sets stopall for cleanup, but it
        # does it using six.moves.mock (the library was moved into
        # unittest.mock in Python 3.4). So until we switch to six.moves.mock
        # everywhere in unit tests, we can't remove this setup. The base class
        # is used in 3party projects, so we would need to switch all of them to
        # six before removing the cleanup callback from here.
        self.addCleanup(mock.patch.stopall)

        self.useFixture(fixture.DBResourceExtendFixture())

        self.addOnException(self.check_for_systemexit)
        self.orig_pid = os.getpid()

        tools.reset_random_seed()
Exemple #7
0
    def setUp(self, environment):
        super(BaseFullStackTestCase, self).setUp()

        tests_base.setup_test_logging(
            cfg.CONF, DEFAULT_LOG_DIR, '%s.log' % self.get_name())

        # NOTE(ihrachys): seed should be reset before environment fixture below
        # since the latter starts services that may rely on generated port
        # numbers
        tools.reset_random_seed()
        self.create_db_tables()
        self.environment = environment
        self.environment.test_name = self.get_name()
        self.useFixture(self.environment)
        self.client = self.environment.neutron_server.client
        self.safe_client = self.useFixture(
            client_resource.ClientFixture(self.client))
Exemple #8
0
    def setUp(self):
        super(DietTestCase, self).setUp()

        # Suppress some log messages during test runs, otherwise it may cause
        # issues with subunit parser when running on Python 3. It happened for
        # example for neutron-functional tests.
        # With this suppress of log levels DEBUG logs will not be captured by
        # stestr on pythonlogging stream and will not cause this parser issue.
        supress_logs = ['neutron', 'neutron_lib', 'stevedore', 'oslo_policy',
                        'oslo_concurrency', 'oslo_db', 'alembic', 'ovsdbapp']
        for supress_log in supress_logs:
            logger = logging.getLogger(supress_log)
            logger.setLevel(logging.ERROR)

        # FIXME(amuller): this must be called in the Neutron unit tests base
        # class. Moving this may cause non-deterministic failures. Bug #1489098
        # for more info.
        db_options.set_defaults(cfg.CONF, connection='sqlite://')

        # Configure this first to ensure pm debugging support for setUp()
        debugger = os.environ.get('OS_POST_MORTEM_DEBUGGER')
        if debugger:
            self.addOnException(post_mortem_debug.get_exception_handler(
                debugger))

        # Make sure we see all relevant deprecation warnings when running tests
        self.useFixture(tools.WarningsFixture())

        self.useFixture(fixture.DBQueryHooksFixture())

        # NOTE(ihrachys): oslotest already sets stopall for cleanup, but it
        # does it using six.moves.mock (the library was moved into
        # unittest.mock in Python 3.4). So until we switch to six.moves.mock
        # everywhere in unit tests, we can't remove this setup. The base class
        # is used in 3party projects, so we would need to switch all of them to
        # six before removing the cleanup callback from here.
        self.addCleanup(mock.patch.stopall)

        self.useFixture(fixture.DBResourceExtendFixture())

        self.addOnException(self.check_for_systemexit)
        self.orig_pid = os.getpid()

        tools.reset_random_seed()