Esempio n. 1
0
    def testGetTrovesToBuildWithRecipeAndRPM(self):
        recipePath = self.workDir + '/local.recipe'
        self.writeFile(recipePath, localSourceRecipe)
        self.writeFile(self.workDir + '/foo', 'Contents\n')
        shutil.copyfile(resources.get_archive('/tmpwatch-2.9.0-2.src.rpm'),
                        self.workDir + '/tmpwatch-2.9.0-2.src.rpm')

        self.openRepository()
        self.openRmakeRepository()
        helper = self.getRmakeHelper()

        self.logFilter.add()
        v = buildcmd.getTrovesToBuild(self.buildCfg, helper.getConaryClient(),
                                      [recipePath])[0][1]
        assert (v.trailingLabel().getHost() == self.rmakeCfg.reposName)

        self.writeFile(recipePath, localSourceRecipe + '\n')

        v2 = buildcmd.getTrovesToBuild(self.buildCfg, helper.getConaryClient(),
                                       [recipePath])[0][1]
        assert (v2.trailingLabel().getHost() == self.rmakeCfg.reposName)
        assert (v2 != v)

        self.writeFile(recipePath, localSourceRecipe + '\n')
        v3 = buildcmd.getTrovesToBuild(self.buildCfg, helper.getConaryClient(),
                                       [recipePath])[0][1]
        assert (v3.trailingLabel().getHost() == self.rmakeCfg.reposName)
        assert (v3 == v2)
Esempio n. 2
0
 def testGetTrovesToBuildNoPackageWithTemplate(self):
     repos = self.openRepository()
     self.openRmakeRepository()
     helper = self.getRmakeHelper()
     templateDir = resources.get_archive('recipeTemplates')
     oldRTD = self.cfg.recipeTemplateDirs
     oldTemplate = self.cfg.recipeTemplate
     self.buildCfg.recipeTemplateDirs = [templateDir]
     self.buildCfg.recipeTemplate = 'test'
     os.chdir(self.workDir)
     self.writeFile('simple.recipe',
                    recipes.simpleRecipe + '\tr.Create("/bar")\n')
     v = buildcmd.getTrovesToBuild(self.buildCfg,
                                   helper.getConaryClient(),
                                   ['simple.recipe'],
                                   message='foo')[0][1]
     assert (v.trailingLabel().getHost() == self.rmakeCfg.reposName)
     assert (len(list(v.iterLabels())) == 2)
     assert (str(v.branch().parentBranch()) == '/localhost@rpl:linux')
     fileList = repos.iterFilesInTrove('simple:source',
                                       v,
                                       deps.parseFlavor(''),
                                       withFiles=True)
     for item in fileList:
         assert (item[4].flags.isConfig())
Esempio n. 3
0
    def testGetTrovesToBuildWithRecipeAndRPM(self):
        recipePath = self.workDir + '/local.recipe'
        self.writeFile(recipePath, localSourceRecipe)
        self.writeFile(self.workDir + '/foo', 'Contents\n')
        shutil.copyfile(resources.get_archive('/tmpwatch-2.9.0-2.src.rpm'),
                        self.workDir + '/tmpwatch-2.9.0-2.src.rpm')

        self.openRepository()
        self.openRmakeRepository()
        helper = self.getRmakeHelper()

        self.logFilter.add()
        v = buildcmd.getTrovesToBuild(self.buildCfg, helper.getConaryClient(), 
                                      [recipePath])[0][1]
        assert(v.trailingLabel().getHost() == self.rmakeCfg.reposName)

        self.writeFile(recipePath, localSourceRecipe + '\n')

        v2 = buildcmd.getTrovesToBuild(self.buildCfg, helper.getConaryClient(),
                                       [recipePath])[0][1]
        assert(v2.trailingLabel().getHost() == self.rmakeCfg.reposName)
        assert(v2 != v)

        self.writeFile(recipePath, localSourceRecipe + '\n')
        v3 = buildcmd.getTrovesToBuild(self.buildCfg, helper.getConaryClient(),
                                       [recipePath])[0][1]
        assert(v3.trailingLabel().getHost() == self.rmakeCfg.reposName)
        assert(v3 == v2)
Esempio n. 4
0
    def testFailToCommitLocalRecipe(self):
        # We've cooked a local recipe that's not on a branch - there's
        #    nowhere to commit it to!
        self.openRmakeRepository()
        repos = self.openRepository()
        client = self.startRmakeServer()
        helper = self.getRmakeHelper(client.uri)

        localSourceRecipe = """\
class LocalSource(PackageRecipe):
    name = 'local'
    version = '1.0'
    clearBuildReqs()

    def setup(r):
        r.addArchive('tmpwatch-2.9.0.tar.gz', rpm='tmpwatch-2.9.0-2.src.rpm')
        r.addSource('dc_client.init', rpm='distcache-1.4.5-2.src.rpm')
        r.addSource('foo', dest='/')
"""

        recipePath = self.workDir + '/local.recipe'
        self.writeFile(recipePath, localSourceRecipe)
        self.writeFile(self.workDir + '/foo', 'Contents\n')
        shutil.copyfile(resources.get_archive('tmpwatch-2.9.0-2.src.rpm'),
                        self.workDir + '/tmpwatch-2.9.0-2.src.rpm')
        self.logFilter.add(
        )  # this message correct, conary can't guess the type
        # of this file.
        jobId = self.discardOutput(helper.buildTroves,
                                   [self.workDir + '/local.recipe'])
        helper.waitForJob(jobId)
        assert (not client.getJob(jobId, withTroves=False).isFailed())
        helper = self.getRmakeHelper(client.uri)
        self.logFilter.add()
        m = self.getMonitor(client,
                            showTroveLogs=False,
                            showBuildLogs=False,
                            jobId=jobId)
        passed, txt = self.commitJob(helper, jobId)
        assert (passed)
        assert (txt == """
Committed job 1:
    local:source=/localhost@rpl:linux//rmakehost@local:linux/1.0-0.1[%s] ->
       local=/localhost@rpl:linux/1.0-1-1[]
       local:source=/localhost@rpl:linux/1.0-1[]

""" % self.getArchFlavor())
        self._check(m, [
            '[TIME] [1] - State: Committing\n',
            '[TIME] [1] - State: Committed\n'
        ])
        job = client.getJob(jobId)
        assert (job.isCommitted())
        assert (job.isFinished())
Esempio n. 5
0
 def testMigrateAll(self):
     dbPath = self.workDir + '/jobs.db'
     shutil.copyfile(resources.get_archive('jobs.db.v1'))
     db = dbstore.connect(dbPath, driver = "sqlite", timeout=10000)
     db.loadSchema()
     cu = db.cursor()
     assert(cu.execute('select state from Jobs where jobId=1').next()[0] == -1)
     assert(cu.execute('select state from Jobs where jobId=3').next()[0] == 99)
     mgr = schema.SchemaManager(db)
     m = schema.Migrator(db, mgr)
     m.migrate(1, schema.SCHEMA_VERSION)
     db.loadSchema()
     assert(cu.execute('select state from Jobs where jobId=1').next()[0] == 1)
     assert(cu.execute('select state from Jobs where jobId=3').next()[0] == 5)
Esempio n. 6
0
    def testFailToCommitLocalRecipe(self):
        # We've cooked a local recipe that's not on a branch - there's
        #    nowhere to commit it to!
        self.openRmakeRepository()
        repos = self.openRepository()
        client = self.startRmakeServer()
        helper = self.getRmakeHelper(client.uri)

        localSourceRecipe = """\
class LocalSource(PackageRecipe):
    name = 'local'
    version = '1.0'
    clearBuildReqs()

    def setup(r):
        r.addArchive('tmpwatch-2.9.0.tar.gz', rpm='tmpwatch-2.9.0-2.src.rpm')
        r.addSource('dc_client.init', rpm='distcache-1.4.5-2.src.rpm')
        r.addSource('foo', dest='/')
"""

        recipePath = self.workDir + '/local.recipe'
        self.writeFile(recipePath, localSourceRecipe)
        self.writeFile(self.workDir + '/foo', 'Contents\n')
        shutil.copyfile(resources.get_archive('tmpwatch-2.9.0-2.src.rpm'),
                        self.workDir + '/tmpwatch-2.9.0-2.src.rpm')
        self.logFilter.add() # this message correct, conary can't guess the type
                             # of this file.
        jobId = self.discardOutput(helper.buildTroves,
                                   [self.workDir + '/local.recipe'])
        helper.waitForJob(jobId)
        assert(not client.getJob(jobId, withTroves=False).isFailed())
        helper = self.getRmakeHelper(client.uri)
        self.logFilter.add()
        m = self.getMonitor(client, showTroveLogs=False,
                                    showBuildLogs=False, jobId=jobId)
        passed, txt = self.commitJob(helper, jobId)
        assert(passed)
        assert(txt == """
Committed job 1:
    local:source=/localhost@rpl:linux//rmakehost@local:linux/1.0-0.1[%s] ->
       local=/localhost@rpl:linux/1.0-1-1[]
       local:source=/localhost@rpl:linux/1.0-1[]

""" % self.getArchFlavor())
        self._check(m, ['[TIME] [1] - State: Committing\n',
                        '[TIME] [1] - State: Committed\n'])
        job = client.getJob(jobId)
        assert(job.isCommitted())
        assert(job.isFinished())
Esempio n. 7
0
 def testMigrateAll(self):
     dbPath = self.workDir + '/jobs.db'
     shutil.copyfile(resources.get_archive('jobs.db.v1'))
     db = dbstore.connect(dbPath, driver="sqlite", timeout=10000)
     db.loadSchema()
     cu = db.cursor()
     assert (
         cu.execute('select state from Jobs where jobId=1').next()[0] == -1)
     assert (
         cu.execute('select state from Jobs where jobId=3').next()[0] == 99)
     mgr = schema.SchemaManager(db)
     m = schema.Migrator(db, mgr)
     m.migrate(1, schema.SCHEMA_VERSION)
     db.loadSchema()
     assert (
         cu.execute('select state from Jobs where jobId=1').next()[0] == 1)
     assert (
         cu.execute('select state from Jobs where jobId=3').next()[0] == 5)
Esempio n. 8
0
 def testGetTrovesToBuildNoPackage(self):
     repos = self.openRepository()
     self.openRmakeRepository()
     helper = self.getRmakeHelper()
     templateDir = resources.get_archive('recipeTemplates')
     os.chdir(self.workDir)
     self.writeFile('simple.recipe', 
                     recipes.simpleRecipe + '\tr.Create("/bar")\n')
     v = buildcmd.getTrovesToBuild(self.buildCfg,
                                 helper.getConaryClient(),
                                ['simple.recipe'], message='foo')[0][1]
     assert(v.trailingLabel().getHost() == self.rmakeCfg.reposName)
     assert(len(list(v.iterLabels())) == 2)
     assert(str(v.branch().parentBranch()) == '/localhost@rpl:linux')
     fileList = repos.iterFilesInTrove('simple:source', v, 
                          deps.parseFlavor(''), withFiles=True)
     for item  in fileList:
         assert(item[4].flags.isConfig())
Esempio n. 9
0
    def _setupSignature(self, repos, fingerprint):
        # supply the pass phrase for our private key
        keyCache = openpgpkey.getKeyCache()
        keyCache.getPrivateKey(fingerprint, '111111')

        # get the public key
        keyRing = open(resources.get_archive('pubring.gpg'))
        if hasattr(openpgpfile, 'readKeyData'):
            keyData = openpgpfile.readKeyData(keyRing, fingerprint)
        else:
            keyData = openpgpfile.exportKey(fingerprint, keyRing)
            keyData.seek(0)
            keyData = keyData.read()

        # upload the public key
        repos = self.openRepository()
        repos.addNewPGPKey(self.cfg.buildLabel, 'test', keyData)
        self.buildCfg.signatureKey = fingerprint
Esempio n. 10
0
    def _setupSignature(self, repos, fingerprint):
        # supply the pass phrase for our private key
        keyCache = openpgpkey.getKeyCache()
        keyCache.getPrivateKey(fingerprint, '111111')

        # get the public key
        keyRing = open(resources.get_archive('pubring.gpg'))
        if hasattr(openpgpfile, 'readKeyData'):
            keyData = openpgpfile.readKeyData(keyRing, fingerprint)
        else:
            keyData = openpgpfile.exportKey(fingerprint, keyRing)
            keyData.seek(0)
            keyData = keyData.read()

        # upload the public key
        repos = self.openRepository()
        repos.addNewPGPKey(self.cfg.buildLabel, 'test', keyData)
        self.buildCfg.signatureKey = fingerprint
Esempio n. 11
0
    def testCopyInPolicy(self):
        trv = self.addComponent('testcase:source', '1.0-1', '',
                                [('testcase.recipe', workingRecipe)])
        self.openRmakeRepository()

        troveList = [ trv.getNameVersionFlavor() ]
        db = self.openRmakeDatabase()
        buildCfg = copy.deepcopy(self.buildCfg)
        buildCfg.strictMode = False
        buildCfg.copyInConary = True
        fakePolicyPath = resources.get_archive('policy')
        buildCfg.policyDirs = buildCfg.policyDirs + [ fakePolicyPath ]

        job = self.newJob(buildConfig=buildCfg, *troveList)
        b = builder.Builder(self.rmakeCfg, job)
        self.logFilter.add()
        logFile = logfile.LogFile(self.workDir + '/buildlog')
        logFile.redirectOutput()
        b.build()
        logFile.restoreOutput()
        trove = b.job.troves.values()[0]
        assert(str(trove.getFailureReason()).endswith(
                                        'This fake policy always breaks.'))
Esempio n. 12
0
 def testMigrateDatabase(self):
     dbPath = self.workDir + '/jobs.db'
     shutil.copyfile(resources.get_archive('jobs.db.v5'))
     db = database.Database(('sqlite', dbPath), self.workDir + '/contents')
Esempio n. 13
0
 def testMigrateDatabase(self):
     dbPath = self.workDir + '/jobs.db'
     shutil.copyfile(resources.get_archive('jobs.db.v5'))
     db = database.Database(('sqlite', dbPath), self.workDir + '/contents')