Example #1
0
    def setUp(self):
        super(BaseTestCase, self).setUp()

        self.useFixture(lockutils.ExternalLockFixture())

        cfg.CONF.set_override('state_path', self.get_default_temp_dir().path)

        self.addCleanup(CONF.reset)
        self.useFixture(ProcessMonitorFixture())

        self.useFixture(
            fixtures.MonkeyPatch(
                'neutron_lib.exceptions.NeutronException.use_fatal_exceptions',
                fake_use_fatal_exceptions))

        self.useFixture(
            fixtures.MonkeyPatch(
                'oslo_config.cfg.find_config_files',
                lambda project=None, prog=None, extension=None: []))

        self.setup_rpc_mocks()
        self.setup_config()
        self.setup_test_registry_instance()

        policy.init()
        self.addCleanup(policy.reset)
        self.addCleanup(resource_registry.unregister_all_resources)
        self.addCleanup(rpc_consumer_reg.clear)
Example #2
0
    def setUp(self):
        super(IptablesFirewallTestCase, self).setUp()
        self.useFixture(lock_fixture.ExternalLockFixture())
        self.useFixture(fakelibvirt.FakeLibvirtFixture())

        self.fw = firewall.IptablesFirewallDriver(
            host=host.Host("qemu:///system"))
Example #3
0
    def setUp(self):
        super(BaseTestCase, self).setUp()

        # suppress all but errors here
        capture_logs = bool_from_env('OS_LOG_CAPTURE')
        self.useFixture(
            fixtures.FakeLogger(
                name='neutron.api.extensions',
                format=LOG_FORMAT,
                level=std_logging.ERROR,
                nuke_handlers=capture_logs,
            ))

        self.useFixture(lockutils.ExternalLockFixture())

        cfg.CONF.set_override('state_path', self.get_default_temp_dir().path)

        self.addCleanup(CONF.reset)
        self.useFixture(ProcessMonitorFixture())

        self.useFixture(fixtures.MonkeyPatch(
            'neutron.common.exceptions.NeutronException.use_fatal_exceptions',
            fake_use_fatal_exceptions))

        self.useFixture(fixtures.MonkeyPatch(
            'oslo_config.cfg.find_config_files',
            lambda project=None, prog=None, extension=None: []))

        self.setup_rpc_mocks()
        self.setup_config()
        self.setup_test_registry_instance()

        policy.init()
        self.addCleanup(policy.reset)
Example #4
0
 def setUp(self):
     super(TestNotLockingAccount, self).setUp()
     self.useFixture(fake_config.ConfigFixture())
     self.stubs.Set(config, 'TempestConfigPrivate', fake_config.FakePrivate)
     self.useFixture(lockutils_fixtures.ExternalLockFixture())
     self.test_accounts = [
         {
             'username': '******',
             'tenant_name': 'test_tenant1',
             'password': '******'
         },
         {
             'username': '******',
             'tenant_name': 'test_tenant2',
             'password': '******'
         },
         {
             'username': '******',
             'tenant_name': 'test_tenant3',
             'password': '******'
         },
     ]
     self.useFixture(
         mockpatch.Patch('tempest.common.accounts.read_accounts_yaml',
                         return_value=self.test_accounts))
     cfg.CONF.set_default('test_accounts_file', '', group='auth')
     self.useFixture(mockpatch.Patch('os.path.isfile', return_value=True))
Example #5
0
    def setUp(self):
        super(BaseTestCase, self).setUp()

        # suppress all but errors here
        capture_logs = bool_from_env('OS_LOG_CAPTURE')
        self.useFixture(
            fixtures.FakeLogger(
                name='neutron.api.extensions',
                format=LOG_FORMAT,
                level=std_logging.ERROR,
                nuke_handlers=capture_logs,
            ))

        self.useFixture(lockutils.ExternalLockFixture())

        cfg.CONF.set_override('state_path', self.get_default_temp_dir().path)

        self.addCleanup(CONF.reset)

        self.useFixture(
            fixtures.MonkeyPatch(
                'neutron.common.exceptions.NeutronException.use_fatal_exceptions',
                fake_use_fatal_exceptions))

        self.setup_rpc_mocks()
        self.setup_config()
Example #6
0
    def setUp(self):
        """Run before each test method to initialize test environment."""

        super(TestCase, self).setUp()
        test_timeout = os.environ.get('OS_TEST_TIMEOUT', 0)
        try:
            test_timeout = int(test_timeout)
        except ValueError:
            # If timeout value is invalid do not set a timeout.
            test_timeout = 0
        if test_timeout > 0:
            self.useFixture(fixtures.Timeout(test_timeout, gentle=True))

        env_test_db = os.environ.get('STORYBOARD_TEST_DB')
        if env_test_db is not None:
            self.test_connection = env_test_db
        else:
            self.test_connection = ("mysql+pymysql://openstack_citest:"
                                    "[email protected]:3306")

        self.useFixture(fixtures.NestedTempfile())
        self.useFixture(fixtures.TempHomeDir())
        self.useFixture(lockutils_fixture.ExternalLockFixture())

        self.addCleanup(CONF.reset)

        if os.environ.get('OS_STDOUT_CAPTURE') in _TRUE_VALUES:
            stdout = self.useFixture(fixtures.StringStream('stdout')).stream
            self.useFixture(fixtures.MonkeyPatch('sys.stdout', stdout))
        if os.environ.get('OS_STDERR_CAPTURE') in _TRUE_VALUES:
            stderr = self.useFixture(fixtures.StringStream('stderr')).stream
            self.useFixture(fixtures.MonkeyPatch('sys.stderr', stderr))

        self.log_fixture = self.useFixture(fixtures.FakeLogger())
Example #7
0
 def setUp(self):
     super(TestPreProvisionedCredentials, self).setUp()
     self.useFixture(fake_config.ConfigFixture())
     self.patchobject(config, 'TempestConfigPrivate',
                      fake_config.FakePrivate)
     self.patch(self.token_client, side_effect=self.identity_response)
     self.useFixture(lockutils_fixtures.ExternalLockFixture())
     self.test_accounts = self._fake_accounts(cfg.CONF.identity.admin_role)
     self.accounts_mock = self.useFixture(
         mockpatch.Patch('tempest.common.preprov_creds.read_accounts_yaml',
                         return_value=self.test_accounts))
     self.useFixture(mockpatch.Patch('os.path.isfile', return_value=True))
Example #8
0
    def setUp(self):
        super(IptablesFirewallTestCase, self).setUp()
        self.useFixture(lock_fixture.ExternalLockFixture())

        class FakeLibvirtDriver(object):
            def nwfilterDefineXML(*args, **kwargs):
                """setup_basic_rules in nwfilter calls this."""
                pass

        self.fake_libvirt_connection = FakeLibvirtDriver()
        self.fw = firewall.IptablesFirewallDriver(
            FakeVirtAPI(), get_connection=lambda: self.fake_libvirt_connection)
Example #9
0
    def setUp(self):
        self.useFixture(lock_fixture.ExternalLockFixture())
        super(TestCasoManager, self).setUp()
        self.patchers = {
            "makedirs": mock.patch('caso.utils.makedirs'),
            "extract": mock.patch('caso.extract.manager.Manager'),
            "messenger": mock.patch('caso.messenger.Manager'),
        }
        self.mocks = {}
        for k, p in six.iteritems(self.patchers):
            self.mocks[k] = p.start()

        self.manager = manager.Manager()
Example #10
0
 def setUp(self):
     """Run before each test method to initialize test environment."""
     super(base.BaseTestCase, self).setUp()
     ovsvapp_config.register_options()
     self.setup_rpc_mocks()
     self.useFixture(lockutils.ExternalLockFixture())
     self.useFixture(fixture.APIDefinitionFixture())
     self.useFixture(tools.WarningsFixture())
     self.mock = mock.Mock()
     self.logger = self.useFixture(
         fixtures.FakeLogger(name="neutron", level=logging.INFO))
     self._overridden_opts = []
     self.addCleanup(self.del_attributes)
     self.addCleanup(self.reset_flags)
Example #11
0
 def setUp(self):
     super(TestPreProvisionedCredentials, self).setUp()
     self.useFixture(fake_config.ConfigFixture())
     self.patchobject(config, 'TempestConfigPrivate',
                      fake_config.FakePrivate)
     self.patch(self.token_client, side_effect=self.identity_response)
     self.useFixture(lockutils_fixtures.ExternalLockFixture())
     self.test_accounts = self._fake_accounts(cfg.CONF.identity.admin_role)
     self.accounts_mock = self.useFixture(
         fixtures.MockPatch(
             'tempest.lib.common.preprov_creds.read_accounts_yaml',
             return_value=self.test_accounts))
     self.useFixture(fixtures.MockPatch('os.path.isfile',
                                        return_value=True))
     # NOTE(andreaf) Ensure config is loaded so service clients are
     # registered in the registry before tests
     config.service_client_config()
Example #12
0
 def setUp(self):
     super(TestAccount, self).setUp()
     self.useFixture(fake_config.ConfigFixture())
     self.stubs.Set(config, 'TempestConfigPrivate', fake_config.FakePrivate)
     self.fake_http = fake_http.fake_httplib2(return_type=200)
     self.stubs.Set(token_client.TokenClientJSON, 'raw_request',
                    fake_identity._fake_v2_response)
     self.useFixture(lockutils_fixtures.ExternalLockFixture())
     self.test_accounts = [
         {'username': '******', 'tenant_name': 'test_tenant1',
          'password': '******'},
         {'username': '******', 'tenant_name': 'test_tenant2',
          'password': '******'},
         {'username': '******', 'tenant_name': 'test_tenant3',
          'password': '******'},
         {'username': '******', 'tenant_name': 'test_tenant4',
          'password': '******'},
         {'username': '******', 'tenant_name': 'test_tenant5',
          'password': '******'},
         {'username': '******', 'tenant_name': 'test_tenant6',
          'password': '******', 'roles': ['role1', 'role2']},
         {'username': '******', 'tenant_name': 'test_tenant7',
          'password': '******', 'roles': ['role2', 'role3']},
         {'username': '******', 'tenant_name': 'test_tenant8',
          'password': '******', 'roles': ['role4', 'role1']},
         {'username': '******', 'tenant_name': 'test_tenant9',
          'password': '******', 'roles': ['role1', 'role2', 'role3', 'role4']},
         {'username': '******', 'tenant_name': 'test_tenant10',
          'password': '******', 'roles': ['role1', 'role2', 'role3', 'role4']},
         {'username': '******', 'tenant_name': 'test_tenant11',
          'password': '******', 'roles': [cfg.CONF.identity.admin_role]},
         {'username': '******', 'tenant_name': 'test_tenant12',
          'password': '******', 'roles': [cfg.CONF.identity.admin_role]},
         {'username': '******', 'tenant_name': 'test_tenant13',
          'password': '******', 'resources': {'network': 'network-1'}},
         {'username': '******', 'tenant_name': 'test_tenant14',
          'password': '******', 'roles': ['role-7', 'role-11'],
          'resources': {'network': 'network-2'}},
     ]
     self.useFixture(mockpatch.Patch(
         'tempest.common.accounts.read_accounts_yaml',
         return_value=self.test_accounts))
     cfg.CONF.set_default('test_accounts_file', 'fake_path', group='auth')
     self.useFixture(mockpatch.Patch('os.path.isfile', return_value=True))
Example #13
0
    def setUp(self):
        super(BaseTestCase, self).setUp()

        self.useFixture(lockutils.ExternalLockFixture())
        self.useFixture(fixture.APIDefinitionFixture())

        config.register_common_config_options()
        cfg.CONF.set_override('state_path', self.get_default_temp_dir().path)

        self.addCleanup(CONF.reset)
        self.useFixture(ProcessMonitorFixture())

        self.useFixture(
            fixtures.MonkeyPatch(
                'neutron_lib.exceptions.NeutronException.use_fatal_exceptions',
                fake_use_fatal_exceptions))

        self.useFixture(
            fixtures.MonkeyPatch(
                'oslo_config.cfg.find_config_files',
                lambda project=None, prog=None, extension=None: []))

        self.useFixture(fixture.RPCFixture())

        self.setup_config()

        self._callback_manager = registry_manager.CallbacksManager()
        self.useFixture(
            fixture.CallbackRegistryFixture(
                callback_manager=self._callback_manager))
        # Give a private copy of the directory to each test.
        self.useFixture(fixture.PluginDirectoryFixture())

        policy.init(suppress_deprecation_warnings=True)
        self.addCleanup(policy.reset)
        self.addCleanup(resource_registry.unregister_all_resources)
        self.addCleanup(db_api.sqla_remove_all)
        self.addCleanup(rpc_consumer_reg.clear)
        self.addCleanup(rpc_producer_reg.clear)
        self.addCleanup(profiler.clean)
Example #14
0
 def setUp(self):
     super(TestAccount, self).setUp()
     self.useFixture(fake_config.ConfigFixture())
     self.stubs.Set(config, 'TempestConfigPrivate', fake_config.FakePrivate)
     self.useFixture(lockutils_fixtures.ExternalLockFixture())
     self.test_accounts = [
         {
             'username': '******',
             'tenant_name': 'test_tenant1',
             'password': '******'
         },
         {
             'username': '******',
             'tenant_name': 'test_tenant2',
             'password': '******'
         },
         {
             'username': '******',
             'tenant_name': 'test_tenant3',
             'password': '******'
         },
         {
             'username': '******',
             'tenant_name': 'test_tenant4',
             'password': '******'
         },
         {
             'username': '******',
             'tenant_name': 'test_tenant5',
             'password': '******'
         },
         {
             'username': '******',
             'tenant_name': 'test_tenant6',
             'password': '******',
             'roles': ['role1', 'role2']
         },
         {
             'username': '******',
             'tenant_name': 'test_tenant7',
             'password': '******',
             'roles': ['role2', 'role3']
         },
         {
             'username': '******',
             'tenant_name': 'test_tenant8',
             'password': '******',
             'roles': ['role4', 'role1']
         },
         {
             'username': '******',
             'tenant_name': 'test_tenant9',
             'password': '******',
             'roles': ['role1', 'role2', 'role3', 'role4']
         },
         {
             'username': '******',
             'tenant_name': 'test_tenant10',
             'password': '******',
             'roles': ['role1', 'role2', 'role3', 'role4']
         },
         {
             'username': '******',
             'tenant_name': 'test_tenant11',
             'password': '******',
             'roles': [cfg.CONF.identity.admin_role]
         },
         {
             'username': '******',
             'tenant_name': 'test_tenant12',
             'password': '******',
             'roles': [cfg.CONF.identity.admin_role]
         },
     ]
     self.useFixture(
         mockpatch.Patch('tempest.common.accounts.read_accounts_yaml',
                         return_value=self.test_accounts))
     cfg.CONF.set_default('test_accounts_file', 'fake_path', group='auth')
     self.useFixture(mockpatch.Patch('os.path.isfile', return_value=True))
Example #15
0
 def setUp(self):
     super(TestPreProvisionedCredentials, self).setUp()
     self.useFixture(fake_config.ConfigFixture())
     self.stubs.Set(config, 'TempestConfigPrivate', fake_config.FakePrivate)
     self.fake_http = fake_http.fake_httplib2(return_type=200)
     self.stubs.Set(token_client.TokenClient, 'raw_request',
                    fake_identity._fake_v2_response)
     self.useFixture(lockutils_fixtures.ExternalLockFixture())
     self.test_accounts = [
         {
             'username': '******',
             'tenant_name': 'test_tenant1',
             'password': '******'
         },
         {
             'username': '******',
             'tenant_name': 'test_tenant2',
             'password': '******'
         },
         {
             'username': '******',
             'tenant_name': 'test_tenant3',
             'password': '******'
         },
         {
             'username': '******',
             'tenant_name': 'test_tenant4',
             'password': '******'
         },
         {
             'username': '******',
             'tenant_name': 'test_tenant5',
             'password': '******'
         },
         {
             'username': '******',
             'tenant_name': 'test_tenant6',
             'password': '******',
             'roles': ['role1', 'role2']
         },
         {
             'username': '******',
             'tenant_name': 'test_tenant7',
             'password': '******',
             'roles': ['role2', 'role3']
         },
         {
             'username': '******',
             'tenant_name': 'test_tenant8',
             'password': '******',
             'roles': ['role4', 'role1']
         },
         {
             'username': '******',
             'tenant_name': 'test_tenant9',
             'password': '******',
             'roles': ['role1', 'role2', 'role3', 'role4']
         },
         {
             'username': '******',
             'tenant_name': 'test_tenant10',
             'password': '******',
             'roles': ['role1', 'role2', 'role3', 'role4']
         },
         {
             'username': '******',
             'tenant_name': 'test_tenant11',
             'password': '******',
             'roles': [cfg.CONF.identity.admin_role]
         },
         {
             'username': '******',
             'tenant_name': 'test_tenant12',
             'password': '******',
             'roles': [cfg.CONF.identity.admin_role]
         },
     ]
     self.accounts_mock = self.useFixture(
         mockpatch.Patch('tempest.common.preprov_creds.read_accounts_yaml',
                         return_value=self.test_accounts))
     self.useFixture(mockpatch.Patch('os.path.isfile', return_value=True))