def setUp(self): super(DatabaseFixture, self).setUp() db_url = os.environ.get("RALLY_UNITTEST_DB_URL", "sqlite://") db.engine_reset() self.conf.set_default("connection", db_url, group="database") db.schema_cleanup() db.schema_create()
def recreate(self): """Drop and create Rally database. This will delete all existing data. """ db.schema_cleanup() db.schema_create() envutils.clear_env()
def ensure(self, api): """Creates Rally database if it doesn't exists.""" print("Ensuring database exists: ", end="") self.show(api, True) if not db.schema_revision(): db.schema_create() print("Database created successfully") else: print("Database already exists, nothing to do")
def recreate(self, api): """Drop and create Rally database. This will delete all existing data. """ print("Recreating database: ", end="") self.show(api, True) db.schema_cleanup() print("Database deleted successfully") db.schema_create() print("Database created successfully") envutils.clear_env()
def create(self): """Create Rally database.""" db.schema_create()
def create(self, api): """Create Rally database.""" print("Creating database: ", end="") self.show(api, True) db.schema_create() print("Database created successfully")
def __init__(self, observer, openrc, inventory, **params): super(RallyLoader, self).__init__(observer, openrc, inventory, **params) self.scenario_file = os.path.abspath( os.path.join(RallyLoader.scenarios_path, params['scenario_file'])) # TODO (dratushnyy) fallback to default path only if file not found self.scenario_args_file = params.get('scenario_args_file', None) if self.scenario_args_file: self.scenario_args_file = os.path.abspath( os.path.join(RallyLoader.scenarios_path, self.scenario_args_file)) self.start_delay = params['start_delay'] self.deployment_name = params['deployment_name'] self.deployment_config = { "type": "ExistingCloud", "admin": { "username": openrc["username"], "password": openrc["password"], "tenant_name": openrc["tenant_name"] }, "auth_url": openrc["auth_url"], "region_name": openrc["region_name"], "https_insecure": openrc['https_insecure'], "https_cacert": openrc["https_cacert"] } self.scenario_args = params.get('scenario_args', None) # Need to be set to None to avoid exception in stop() method self.rally_task = None load_rally_plugins() if params.get('db'): db_connection = RallyLoader.conn_template.format( user=params["db"]["user"], passwd=params["db"]["pass"], host=params["db"]["host"], db_name=params["db"]["name"]) db_options.set_defaults(CONF, connection=db_connection) try: rally_api.Deployment.get(self.deployment_name) except DBNonExistentTable as e: db.schema_create() except DeploymentNotFound as e: try: rally_api.Deployment.create(config=self.deployment_config, name=self.deployment_name) except ValidationError as e: LOGGER.exception(e) raise e except OperationalError as e: LOGGER.exception(e) raise e # Since there is no api method to do this - using cli deployment_cli.DeploymentCommands().use(self.deployment_name) # Using rally task cli to load and validate task # TODO check is API support this? try: self.scenario_config = task_cli.TaskCommands().\ _load_and_validate_task(self.scenario_file, json.dumps(self.scenario_args), self.scenario_args_file, self.deployment_name) except Exception as e: LOGGER.exception(e) raise e
def __init__(self, observer, openrc, inventory, **params): super(RallyLoader, self).__init__(observer, openrc, inventory, **params) self.scenario_file = os.path.abspath(os.path.join( RallyLoader.scenarios_path, params['scenario_file'])) # TODO (dratushnyy) fallback to default path only if file not found self.scenario_args_file = params.get('scenario_args_file', None) if self.scenario_args_file: self.scenario_args_file = os.path.abspath(os.path.join( RallyLoader.scenarios_path, self.scenario_args_file)) self.start_delay = params['start_delay'] self.deployment_name = params['deployment_name'] self.deployment_config = { "type": "ExistingCloud", "admin": { "username": openrc["username"], "password": openrc["password"], "tenant_name": openrc["tenant_name"] }, "auth_url": openrc["auth_url"], "region_name": openrc["region_name"], "https_insecure": openrc['https_insecure'], "https_cacert": openrc["https_cacert"] } self.scenario_args = params.get('scenario_args', None) # Need to be set to None to avoid exception in stop() method self.rally_task = None load_rally_plugins() if params.get('db'): db_connection = RallyLoader.conn_template.format( user=params["db"]["user"], passwd=params["db"]["pass"], host=params["db"]["host"], db_name=params["db"]["name"]) db_options.set_defaults(CONF, connection=db_connection) try: rally_api.Deployment.get(self.deployment_name) except DBNonExistentTable as e: db.schema_create() except DeploymentNotFound as e: try: rally_api.Deployment.create(config=self.deployment_config, name=self.deployment_name) except ValidationError as e: LOGGER.exception(e) raise e except OperationalError as e: LOGGER.exception(e) raise e # Since there is no api method to do this - using cli deployment_cli.DeploymentCommands().use(self.deployment_name) # Using rally task cli to load and validate task # TODO check is API support this? try: self.scenario_config = task_cli.TaskCommands().\ _load_and_validate_task(self.scenario_file, json.dumps(self.scenario_args), self.scenario_args_file, self.deployment_name) except Exception as e: LOGGER.exception(e) raise e