Exemple #1
0
 def setUp(self):
     TestCase.setUp(self)
     if self.isIndividual():
         self.workDir = "/tmp/%s%s" % (self.testDirName, os_utils.effectiveUser)
     else:
         from testrunner import testhelp
         self.workDir = testhelp.getTempDir(self.testDirName)
     from conary.lib import util
     util.rmtree(self.workDir, ignore_errors = True)
     util.mkdirChain(self.workDir)
Exemple #2
0
def getHarness(driver, topdir = None, dbClass = RepositoryDatabase):
    global _harness

    h = _harness.get(driver, None)
    if h:
        # check that we're not expected to show up in a different
        # place if called with an explicit topdir
        if topdir:
            sqldir = os.path.join(topdir, driver)
            if h.path != sqldir:
                raise RuntimeError("BUG IN TESTSUITE SQL Harness handling: "
                                   "Harness directory should not change during the testrun")
        return h
    # need to create a new harness - start with a clean tree
    if topdir:
        sqldir = os.path.join(topdir, driver)
    else:
        sqldir = testhelp.getTempDir("conarytest-%s-" % driver)
    if os.path.exists(sqldir):
        shutil.rmtree(sqldir)
    os.mkdir(sqldir, 0700)

    if driver == 'sqlite':
        h = SqliteServer(sqldir, dbClass)
    elif driver == 'mysql':
        h = MySQLServer(sqldir, dbClass)
    elif driver == 'postgresql':
        h = PostgreSQLServer(sqldir, dbClass)
    elif driver == 'pgpool':
        h = PgpoolServer(sqldir, dbClass)
    elif driver == 'psycopg2':
        h = PsycoServer(sqldir, dbClass)
    else:
        raise RuntimeError("Unknown database type specified: %s" % driver)
    _harness[driver] = h
    return h