Example #1
0
 def setUp(self):
     super(TestPlacementRequestContext, self).setUp()
     self.ctxt = context.RequestContext(user_id='fake', project_id='fake')
     self.default_target = {
         'user_id': self.ctxt.user_id,
         'project_id': self.ctxt.project_id
     }
Example #2
0
    def setUp(self):
        super(TestCase, self).setUp()

        # Manage required configuration
        conf_fixture = self.useFixture(config_fixture.Config(CONF))
        # The Database fixture will get confused if only one of the databases
        # is configured.
        for group in ('placement_database', 'api_database', 'database'):
            conf_fixture.config(group=group,
                                connection='sqlite://',
                                sqlite_synchronous=False)
        CONF([], default_config_files=[])

        self.useFixture(policy_fixture.PlacementPolicyFixture())

        self.useFixture(capture.Logging())
        self.useFixture(output.CaptureOutput())
        # Filter ignorable warnings during test runs.
        self.useFixture(capture.WarningsFixture())

        self.placement_db = self.useFixture(
            fixtures.Database(database='placement'))
        self._reset_database()
        self.context = context.RequestContext()
        # Do database syncs, such as traits sync.
        deploy.update_database()
        self.addCleanup(self._reset_database)
Example #3
0
    def start_fixture(self):
        # Set up stderr and stdout captures by directly driving the
        # existing nova fixtures that do that. This captures the
        # output that happens outside individual tests (for
        # example database migrations).
        self.standard_logging_fixture = capture.Logging()
        self.standard_logging_fixture.setUp()
        self.output_stream_fixture = output.CaptureOutput()
        self.output_stream_fixture.setUp()
        # Filter ignorable warnings during test runs.
        self.warnings_fixture = capture.WarningsFixture()
        self.warnings_fixture.setUp()

        self.conf_fixture = config_fixture.Config(CONF)
        self.conf_fixture.setUp()
        # The Database fixture will get confused if only one of the databases
        # is configured.
        for group in ('placement_database', 'api_database', 'database'):
            self.conf_fixture.config(
                group=group,
                connection='sqlite://',
                sqlite_synchronous=False)
        self.conf_fixture.config(
            group='api', auth_strategy='noauth2')

        self.context = context.RequestContext()

        # Register CORS opts, but do not set config. This has the
        # effect of exercising the "don't use cors" path in
        # deploy.py. Without setting some config the group will not
        # be present.
        CONF.register_opts(cors.CORS_OPTS, 'cors')
        # Set default policy opts, otherwise the deploy module can
        # NoSuchOptError.
        policy_opts.set_defaults(CONF)

        # Make sure default_config_files is an empty list, not None.
        # If None /etc/nova/nova.conf is read and confuses results.
        CONF([], default_config_files=[])

        self._reset_db_flags()
        self.placement_db_fixture = fixtures.Database('placement')
        self.placement_db_fixture.setUp()
        # Do this now instead of waiting for the WSGI app to start so that
        # fixtures can have traits.
        deploy.update_database()

        os.environ['RP_UUID'] = uuidutils.generate_uuid()
        os.environ['RP_NAME'] = uuidutils.generate_uuid()
        os.environ['CUSTOM_RES_CLASS'] = 'CUSTOM_IRON_NFV'
        os.environ['PROJECT_ID'] = uuidutils.generate_uuid()
        os.environ['USER_ID'] = uuidutils.generate_uuid()
        os.environ['PROJECT_ID_ALT'] = uuidutils.generate_uuid()
        os.environ['USER_ID_ALT'] = uuidutils.generate_uuid()
        os.environ['INSTANCE_UUID'] = uuidutils.generate_uuid()
        os.environ['MIGRATION_UUID'] = uuidutils.generate_uuid()
        os.environ['CONSUMER_UUID'] = uuidutils.generate_uuid()
        os.environ['PARENT_PROVIDER_UUID'] = uuidutils.generate_uuid()
        os.environ['ALT_PARENT_PROVIDER_UUID'] = uuidutils.generate_uuid()
Example #4
0
 def setUp(self):
     super(PlacementDbBaseTestCase, self).setUp()
     self.useFixture(fixtures.Database())
     self.placement_db = self.useFixture(
             fixtures.Database(database='placement'))
     self.ctx = context.RequestContext('fake-user', 'fake-project')
     self.user_obj = user_obj.User(self.ctx, external_id='fake-user')
     self.user_obj.create()
     self.project_obj = project_obj.Project(
         self.ctx, external_id='fake-project')
     self.project_obj.create()
     # Do database syncs, such as traits sync.
     deploy.update_database()
     # For debugging purposes, populated by _create_provider and used by
     # _validate_allocation_requests to make failure results more readable.
     self.rp_uuid_to_name = {}
Example #5
0
    def start_fixture(self):
        # Set up stderr and stdout captures by directly driving the
        # existing nova fixtures that do that. This captures the
        # output that happens outside individual tests (for
        # example database migrations).
        self.standard_logging_fixture = fixtures.StandardLogging()
        self.standard_logging_fixture.setUp()
        self.output_stream_fixture = fixtures.OutputStreamCapture()
        self.output_stream_fixture.setUp()
        # Filter ignorable warnings during test runs.
        self.warnings_fixture = fixtures.WarningsFixture()
        self.warnings_fixture.setUp()

        self.conf = CONF
        self.conf.set_override('auth_strategy', 'noauth2', group='api')
        # Be explicit about all three database connections to avoid
        # potential conflicts with config on disk.
        self.conf.set_override('connection', "sqlite://", group='database')
        self.conf.set_override('connection', "sqlite://", group='api_database')
        self.conf.set_override('connection',
                               "sqlite://",
                               group='placement_database')

        self.context = context.RequestContext()

        # Register CORS opts, but do not set config. This has the
        # effect of exercising the "don't use cors" path in
        # deploy.py. Without setting some config the group will not
        # be present.
        self.conf.register_opts(cors.CORS_OPTS, 'cors')

        # Make sure default_config_files is an empty list, not None.
        # If None /etc/nova/nova.conf is read and confuses results.
        config.parse_args([],
                          default_config_files=[],
                          configure_db=False,
                          init_rpc=False)

        # NOTE(cdent): All three database fixtures need to be
        # managed for database handling to work and not cause
        # conflicts with other tests in the same process.
        self._reset_db_flags()
        self.placement_db_fixture = fixtures.Database('placement')
        self.api_db_fixture = fixtures.Database('api')
        self.main_db_fixture = fixtures.Database('main')
        self.placement_db_fixture.reset()
        self.api_db_fixture.reset()
        self.main_db_fixture.reset()
        # Do this now instead of waiting for the WSGI app to start so that
        # fixtures can have traits.
        deploy.update_database()

        os.environ['RP_UUID'] = uuidutils.generate_uuid()
        os.environ['RP_NAME'] = uuidutils.generate_uuid()
        os.environ['CUSTOM_RES_CLASS'] = 'CUSTOM_IRON_NFV'
        os.environ['PROJECT_ID'] = uuidutils.generate_uuid()
        os.environ['USER_ID'] = uuidutils.generate_uuid()
        os.environ['PROJECT_ID_ALT'] = uuidutils.generate_uuid()
        os.environ['USER_ID_ALT'] = uuidutils.generate_uuid()
        os.environ['INSTANCE_UUID'] = uuidutils.generate_uuid()
        os.environ['MIGRATION_UUID'] = uuidutils.generate_uuid()
        os.environ['CONSUMER_UUID'] = uuidutils.generate_uuid()
        os.environ['PARENT_PROVIDER_UUID'] = uuidutils.generate_uuid()
        os.environ['ALT_PARENT_PROVIDER_UUID'] = uuidutils.generate_uuid()
Example #6
0
 def setUp(self):
     super(PlacementPolicyTestCase, self).setUp()
     self.conf = self.useFixture(conf_fixture.ConfFixture()).conf
     self.ctxt = context.RequestContext(user_id='fake', project_id='fake')
     self.target = {'user_id': 'fake', 'project_id': 'fake'}
Example #7
0
 def setUp(self):
     super(_TestCase, self).setUp()
     self.user_id = 'fake-user'
     self.project_id = 'fake-project'
     self.context = context.RequestContext(self.user_id, self.project_id)
Example #8
0
 def setUp(self):
     super(CreateIncompleteConsumersTestCase, self).setUp()
     self.useFixture(fixtures.Database())
     self.api_db = self.useFixture(fixtures.Database(database='placement'))
     self.ctx = context.RequestContext('fake-user', 'fake-project')