def test_mysql_opportunistically(self): connect_string = oslo_utils.get_connect_string(self.BACKEND, "openstack_citest", user="******", passwd="openstack_citest") engine = session.create_engine(connect_string) config = self._get_alembic_config(connect_string) self.engines["mysqlcitest"] = engine self.test_databases["mysqlcitest"] = connect_string # build a fully populated mysql database with all the tables self._reset_databases() self._walk_versions(config, engine, False, False)
def test_postgresql_opportunistically(self): # add this to the global lists to make reset work with it, it's removed # automatically in tearDown so no need to clean it up here. connect_string = oslo_utils.get_connect_string(self.BACKEND, "openstack_citest", "openstack_citest", "openstack_citest") engine = session.create_engine(connect_string) config = self._get_alembic_config(connect_string) self.engines["postgresqlcitest"] = engine self.test_databases["postgresqlcitest"] = connect_string # build a fully populated postgresql database with all the tables self._reset_databases() self._walk_versions(config, engine, False, False)
def _is_backend_avail(backend, user="******", passwd="openstack_citest", database="openstack_citest"): # is_backend_avail will be soon deprecated from oslo_db # thats why its added here try: connect_uri = oslo_utils.get_connect_string(backend, user=user, passwd=passwd, database=database) engine = session.create_engine(connect_uri) connection = engine.connect() except Exception: # intentionally catch all to handle exceptions even if we don't # have any backend code loaded. return False else: connection.close() engine.dispose() return True
def test_connect_string_host(self): self.full_credentials['host'] = 'myhost' connect_string = utils.get_connect_string(**self.full_credentials) self.assertEqual(connect_string, 'postgresql://*****:*****@myhost/test')
def test_connect_string_sqlite(self): sqlite_credentials = {'backend': 'sqlite', 'database': 'test.db'} connect_string = utils.get_connect_string(**sqlite_credentials) self.assertEqual(connect_string, 'sqlite:///test.db')
def test_connect_string(self): connect_string = utils.get_connect_string(**self.full_credentials) self.assertEqual(connect_string, self.connect_string)