def testFindTrove(self): db = database.Database(':memory:', ':memory:') self.assertEqual(db.getTransactionCounter(), 0) flavor = deps.parseFlavor('~readline,!foo') v10 = ThawVersion("/conary.rpath.com@test:trunk/10:1.2-10-1") f1 = files.FileFromFilesystem("/etc/passwd", self.id1) trv = trove.Trove("testcomp", v10, flavor, None) trv.addFile(self.id1, "/bin/1", v10, f1.fileId()) trvInfo = db.addTrove(trv) db.addTroveDone(trvInfo) f2 = files.FileFromFilesystem("/etc/group", self.id2) v20 = ThawVersion("/conary.rpath.com@local:blah/20:1.3-2-1") trv = trove.Trove("testcomp", v20, flavor, None) trv.addFile(self.id2, "/bin/2", v20, f2.fileId()) trvInfo = db.addTrove(trv) db.addTroveDone(trvInfo) tup = [('testcomp', v10, flavor)] tup2 = [('testcomp', v10, flavor), ('testcomp', v20, flavor)] assert (db.findTrove(None, ('testcomp', '1.2-10-1', None)) == tup) assert (db.findTrove(None, ('testcomp', '1.2', None)) == tup) assert (set(db.findTrove( None, ('testcomp', None, parseFlavor('!foo')))) == set(tup2)) assert (db.findTrove(None, ('testcomp', ':trunk', None)) == tup) assert (db.findTrove([Label('conary.rpath.com@test:foo')], ('testcomp', ':trunk', None)) == tup) assert (db.findTrove(None, ('testcomp', ':trunk', None)) == tup) assert (db.findTrove(None, ('testcomp', '@test:trunk', None)) == tup) assert (db.findTrove([Label('conary.rpath.com@blah:foo')], ('testcomp', '@test:trunk', None)) == tup) # Transaction counter changes upon commit self.assertEqual(db.getTransactionCounter(), 0) db.commit() self.assertEqual(db.getTransactionCounter(), 1)
def testCookTwoGroups(self): self.addComponent('test:run', '1', '!ssl,~test.foo') self.addComponent('test:run', '1', 'ssl,~test.foo') trv = self.addComponent('group-foo:source', '1', '', [('group-foo.recipe', groupRecipeWithFlags)]) flavorList = [deps.parseFlavor('!ssl'), deps.parseFlavor('ssl')] repos = self.openRepository() logger_ = logger.Logger() targetLabel = versions.Label('localhost@rpl:TARGET') self.cfg.shortenGroupFlavors = True logPath, pid, buildInfo = self.discardOutput(cook.cookTrove, self.cfg, repos, logger_, trv.getName(), trv.getVersion(), flavorList, targetLabel=targetLabel) result = self._wait(buildInfo) assert (result.isBuildSuccess()) cs = changeset.ChangeSetFromFile(result.getChangeSetFile()) newTroves = [ x.getNewNameVersionFlavor() for x in cs.iterNewTroveList() ] assert (len(set([x[1] for x in newTroves]))) flavorList = set([x[2] for x in newTroves]) self.assertEquals(sorted(str(x) for x in flavorList), ['readline,!ssl', 'ssl'])
def testResolveResult(self): trv = self.addComponent('foo:runtime', '1.0', 'ssl') tup = trv.getNameVersionFlavor() job = (tup[0], (None, None), (tup[1], tup[2]), False) r = resolver.ResolveResult() r.troveResolved([job], [], []) r2 = thaw('ResolveResult', freeze('ResolveResult', r)) assert(r2.getBuildReqs() == [ job ]) assert(r2.success) assert(not r2.inCycle) r = resolver.ResolveResult(inCycle=True) r.troveMissingBuildReqs(True, [('foo', None, parseFlavor('ssl'))]) r2 = thaw('ResolveResult', freeze('ResolveResult', r)) assert(not r2.hasMissingDeps()) assert(r2.hasMissingBuildReqs()) assert(r2.getMissingBuildReqs() == [(True, ('foo', '', parseFlavor('ssl')))]) assert(not r2.success) assert(r2.inCycle) r = resolver.ResolveResult(inCycle=True) r.troveMissingDependencies(True, [(trv.getNameVersionFlavor(), parseDep('trove: foo trove: bar'))]) r2 = thaw('ResolveResult', freeze('ResolveResult', r)) assert(r.getMissingDeps() == r2.getMissingDeps()) assert(r2.hasMissingDeps()) assert(not r2.success) assert(r2.inCycle)
def testFreezeThawTroveMap(self): db = database.Database(':memory:', ':memory:') uJob = database.UpdateJob(db) uJob.setTransactionCounter(100) now = 1234567890.0 v1 = VersionFromString('/a@b:c/1.0-1', timeStamps = [ now ]) v2 = VersionFromString('/a@b:c/1.0-2', timeStamps = [ now + 1 ]) flv1 = parseFlavor("") flv2 = parseFlavor("is: x86") trv1 = trove.Trove("trove1", v1, flv1) trv2 = trove.Trove("trove2", v2, flv2) nvf1 = trv1.getNameVersionFlavor() nvf2 = trv2.getNameVersionFlavor() uJob._troveMap[nvf1] = trv1 uJob._troveMap[nvf2] = trv2 expKeys = set([nvf1, nvf2]) uJob.freeze(self.workDir) uJob = database.UpdateJob(db) uJob.thaw(self.workDir) self.assertEqual(uJob.getTransactionCounter(), 100) self.assertEqual(set(uJob._troveMap.keys()), expKeys) self.assertEqual(trv1.diff(None)[0].freeze(), uJob._troveMap[nvf1].diff(None)[0].freeze()) self.assertEqual(trv2.diff(None)[0].freeze(), uJob._troveMap[nvf2].diff(None)[0].freeze())
def testRoleFilters(self): db = self._setupDB() na = netauth.NetworkAuthorization(db, "conary.rpath.com") self._addUserRole(na, "testuser", "testpass") roleId = na._getRoleIdByName('testuser') geoip = { '1.2.3.4': deps.parseFlavor('country.XC'), '5.6.7.8': deps.parseFlavor('country.XB'), } na.geoIp.getFlags = lambda x: geoip[x] na.setRoleFilters({'testuser': ( deps.parseFlavor('!country.XA,!country.XB'), None)}) self.assertEqual(na.getRoleFilters(['testuser']), {'testuser': ( deps.parseFlavor('!country.XA,!country.XB'), deps.Flavor())}) token = AuthToken('testuser', 'testpass', remote_ip='1.2.3.4') self.assertEqual( na.getAuthRoles(db.cursor(), token), set([roleId])) token = AuthToken('testuser', 'testpass', remote_ip='5.6.7.8') level = netauth.log.level netauth.log.setLevel(100) try: self.assertRaises(errors.InsufficientPermission, na.getAuthRoles, db.cursor(), token) finally: netauth.log.setLevel(level)
def testFreezeThawTroveMap(self): db = database.Database(':memory:', ':memory:') uJob = database.UpdateJob(db) uJob.setTransactionCounter(100) now = 1234567890.0 v1 = VersionFromString('/a@b:c/1.0-1', timeStamps=[now]) v2 = VersionFromString('/a@b:c/1.0-2', timeStamps=[now + 1]) flv1 = parseFlavor("") flv2 = parseFlavor("is: x86") trv1 = trove.Trove("trove1", v1, flv1) trv2 = trove.Trove("trove2", v2, flv2) nvf1 = trv1.getNameVersionFlavor() nvf2 = trv2.getNameVersionFlavor() uJob._troveMap[nvf1] = trv1 uJob._troveMap[nvf2] = trv2 expKeys = set([nvf1, nvf2]) uJob.freeze(self.workDir) uJob = database.UpdateJob(db) uJob.thaw(self.workDir) self.assertEqual(uJob.getTransactionCounter(), 100) self.assertEqual(set(uJob._troveMap.keys()), expKeys) self.assertEqual( trv1.diff(None)[0].freeze(), uJob._troveMap[nvf1].diff(None)[0].freeze()) self.assertEqual( trv2.diff(None)[0].freeze(), uJob._troveMap[nvf2].diff(None)[0].freeze())
def testChangedRecipeCook(self): repos = self.openRepository() self.openRmakeRepository() trv = self.addComponent( 'test1:source=/localhost@rpl:linux//rmakehost@LOCAL:linux/1.2-0.1', [('test1.recipe', test1Recipe)]) cookFlavor = deps.parseFlavor('readline,ssl,X') troveTup = trv.getNameVersionFlavor() troveTup = (troveTup[0], troveTup[1], cookFlavor) targetLabel = versions.Label('rmakehost@LOCAL:linux') newTargetLabel = versions.Label('rmakehost@LOCAL:linux') # adding an unknown flavor shouldn't matter with latest conary. self.cfg.buildFlavor = deps.overrideFlavor(self.cfg.buildFlavor, deps.parseFlavor('foobar')) logger_ = logger.Logger() logPath, pid, buildInfo = self.discardOutput(cook.cookTrove, self.cfg, repos, logger_, targetLabel=targetLabel, *troveTup) result = self._wait(buildInfo) assert (result.isBuildSuccess())
def _filterTroveSpecs(self, troveSpecs, useFlags): """ Filter trove specs based on a list of use flags. This is only applicable to groups. @param troveSpecs: iterable of nvf tuples. @type troveSpecs: list(tuple(str, conary.versions.VersionFromString, conary.deps.deps.Flavor), ...) @param useFlags: iterable of valid use flags (x86 and x86_64) @type useFlags: list(str, ...) @return modified list of trove specs @rtype list(tuple(str, conary.versions.VersionFromString, conary.deps.deps.Flavor), ...) """ useMap = { 'x86': deps.parseFlavor('is: x86'), 'x86_64': deps.parseFlavor('is: x86_64'), } specs = set() for n, v, f in troveSpecs: for flag in useFlags: if f.satisfies(useMap[flag]): specs.add((n, v, f)) return list(specs)
def testFindTrovesHandlesDifferentVersionsForX86AndX86_64(self): self.openRmakeRepository() self.openRepository() builtFooRun = self.addComponent('foo:runtime', '/localhost@rpl:linux//rmakehost@local:branch/1.0-1-0.1', 'is:x86') builtFooRun2 = self.addComponent('foo:runtime', '/localhost@rpl:linux//rmakehost@local:branch/1.0-1-0.2', 'is:x86_64') resolveFooRun = self.addComponent('foo:runtime', '/localhost@rpl:linux/1.0-1', 'is:x86_64') builtTroves = [builtFooRun.getNameVersionFlavor(), builtFooRun2.getNameVersionFlavor()] resolveTroves = [ resolveFooRun.getNameVersionFlavor()] self.buildCfg.resolveTroveTups = [resolveTroves] self.buildCfg.resolveTrovesOnly = True self.buildCfg.flavor = [parseFlavor('is:x86_64'), parseFlavor('is:x86 x86_64') ] trv = self.addComponent('bam:source') bt = self.newBuildTrove(1, *trv.getNameVersionFlavor()) bt.setBuildRequirements(['foo:runtime']) resolveJob = dephandler.ResolveJob(bt, self.buildCfg, builtTroves, []) self.logFilter.add() res = resolver.DependencyResolver(log, self.openRepository()) # make sure that we don't grab the foo:lib from the resolveTroves # list even though it's a better match (intraTroveDeps should stop that) result = res.resolve(resolveJob) assert(result.success) buildReqs = result.getBuildReqs() buildReq, = buildReqs assert((buildReq[0], buildReq[2][0], buildReq[2][1]) == builtFooRun2.getNameVersionFlavor())
def testFlavorSetOps(self): a = parseFlavor('foo,bar is: x86') b = parseFlavor('foo,~!bar') x = a & b assert(x.freeze() == '5#use:foo') x = a - b assert(x.freeze() == '1#x86|5#use:bar') x = flavorDifferences((a,b)) assert(x[a].freeze() == '1#x86|5#use:bar') assert(x[b].freeze() == '5#use:~!bar') a = DependencySet() a.addDep(TroveDependencies, Dependency("foo:runtime")) assert(a.copy() & a == a) assert(not (a - a)) x = flavorDifferences((a, a)) assert(not x[a]) #now test non-strict ops a = parseFlavor('foo,bar') b = parseFlavor('~foo,~!bar,bam') assert(str(a.intersection(b, strict=False)) == 'foo') assert(str(a.difference(b, strict=False)) == 'bar') assert(str(flavorDifferences([a, b],strict=False)[a]) == 'bar') assert(str(flavorDifferences([a, b],strict=False)[b]) == 'bam,~!bar') # test empty set assert(flavorDifferences([]) == {})
def testTroveFilterFlavors2(self): recipe = self.getRecipe() filt1 = trovefilter.TroveFilter(recipe, flavor = 'xen,domU is: x86') filt2 = trovefilter.TroveFilter(recipe, flavor = 'xen,domU is: x86_64') filt3 = trovefilter.TroveFilter(recipe, flavor = 'xen,domU is: x86_64 x86') nvf1 = ('foo', versions.VersionFromString( \ '/test.rpath.local@rpl:linux/1-1-1'), deps.parseFlavor('is: x86')) nvf2 = ('foo', versions.VersionFromString( \ '/test.rpath.local@rpl:linux/1-1-1'), deps.parseFlavor('xen,domU is: x86')) nvf3 = ('foo', versions.VersionFromString( \ '/test.rpath.local@rpl:linux/1-1-1'), deps.parseFlavor('xen,domU is: x86_64')) nvf4 = ('foo', versions.VersionFromString( \ '/test.rpath.local@rpl:linux/1-1-1'), deps.parseFlavor('xen,domU is: x86 x86_64')) self.assertEquals(filt1.match((nvf1,)), False) self.assertEquals(filt1.match((nvf2,)), True) self.assertEquals(filt2.match((nvf2,)), False) self.assertEquals(filt2.match((nvf3,)), True) self.assertEquals(filt2.match((nvf4,)), False) self.assertEquals(filt3.match((nvf4,)), True) self.assertEquals(filt3.match((nvf1,)), False) self.assertEquals(filt3.match((nvf2,)), False) self.assertEquals(filt3.match((nvf3,)), False)
def testTroveFilterFlavors2(self): recipe = self.getRecipe() filt1 = trovefilter.TroveFilter(recipe, flavor='xen,domU is: x86') filt2 = trovefilter.TroveFilter(recipe, flavor='xen,domU is: x86_64') filt3 = trovefilter.TroveFilter(recipe, flavor='xen,domU is: x86_64 x86') nvf1 = ('foo', versions.VersionFromString( \ '/test.rpath.local@rpl:linux/1-1-1'), deps.parseFlavor('is: x86')) nvf2 = ('foo', versions.VersionFromString( \ '/test.rpath.local@rpl:linux/1-1-1'), deps.parseFlavor('xen,domU is: x86')) nvf3 = ('foo', versions.VersionFromString( \ '/test.rpath.local@rpl:linux/1-1-1'), deps.parseFlavor('xen,domU is: x86_64')) nvf4 = ('foo', versions.VersionFromString( \ '/test.rpath.local@rpl:linux/1-1-1'), deps.parseFlavor('xen,domU is: x86 x86_64')) self.assertEquals(filt1.match((nvf1, )), False) self.assertEquals(filt1.match((nvf2, )), True) self.assertEquals(filt2.match((nvf2, )), False) self.assertEquals(filt2.match((nvf3, )), True) self.assertEquals(filt2.match((nvf4, )), False) self.assertEquals(filt3.match((nvf4, )), True) self.assertEquals(filt3.match((nvf1, )), False) self.assertEquals(filt3.match((nvf2, )), False) self.assertEquals(filt3.match((nvf3, )), False)
def testBasic(self): trv = self.addComponent('nocross:source', '1.0-1', '', [('nocross.recipe', nocrossRecipe)]) trv2 = self.addComponent('crosstool:source', '1.0-1', '', [('crosstool.recipe', crosstoolRecipe)]) ccRoot = self.rmakeCfg.buildDir + '/chroots/crosscompiled' trv3 = self.addComponent('crosscompiled:source', '1.0-1', '', [('crosscompiled.recipe', crosscompiledRecipe % (ccRoot, ccRoot))]) self.openRmakeRepository() troveList = [ (trv.getName(), trv.getVersion(), deps.parseFlavor('!cross target: x86_64')), (trv2.getName(), trv2.getVersion(), deps.parseFlavor('cross target: x86_64')), (trv3.getName(), trv3.getVersion(), deps.parseFlavor('!cross target: x86_64')) ] db = self.openRmakeDatabase() self.buildCfg.flavor = [deps.overrideFlavor(self.buildCfg.flavor[0], deps.parseFlavor('~cross is:x86 target:x86_64'))] job = self.newJob(*troveList) db.subscribeToJob(job) b = builder.Builder(self.rmakeCfg, job) self.logFilter.add() logFile = logfile.LogFile(self.workDir + '/buildlog') logFile.redirectOutput() try: b.build() except Exception: b.worker.stopAllCommands() raise logFile.restoreOutput() assert(set([x.getName() for x in b.dh.depState.getBuiltTroves()]) == set([trv.getName(), trv2.getName(), trv3.getName()]))
def testTroveFilterVersion(self): recipe = self.getRecipe() filt = trovefilter.TroveFilter(recipe, 'foo', version='test.rpath.local@rpl:linux') filt2 = trovefilter.TroveFilter(recipe, 'bar', version='test.rpath.local@rpl:linux') nvf = ('foo', versions.VersionFromString( \ '/test.rpath.local@rpl:linux/1-1-1'), deps.parseFlavor('')) self.assertEquals(filt.match((nvf, )), True) self.assertEquals(filt2.match((nvf, )), False) filt = trovefilter.TroveFilter(recipe, 'foo', version='/test.rpath.local@rpl:linux') self.assertEquals(filt.match((nvf, )), True) filt = trovefilter.TroveFilter( recipe, 'foo', version='/test.rpath.local@rpl:linux/1-1-1') self.assertEquals(filt.match((nvf, )), True) filt = trovefilter.TroveFilter(recipe, 'foo', version='test.rpath.local@rpl:linux') nvf = ('foo', versions.VersionFromString( \ '/test.rpath.local@rpl:devel/1-1-1'), deps.parseFlavor('')) self.assertEquals(filt.match((nvf, )), False) filt = trovefilter.TroveFilter(recipe, 'foo', version='/test.rpath.local@rpl:linux') self.assertEquals(filt.match((nvf, )), False) filt = trovefilter.TroveFilter( recipe, 'foo', version='/test.rpath.local@rpl:linux/1-1-1') self.assertEquals(filt.match((nvf, )), False)
def createXVA(self, outfile, size): # Read in the stub file infile = file(os.path.join(constants.templateDir, self.templateName), 'rb') # Replace the @DELIMITED@ text with the appropriate values template = infile.read() infile.close() template = template.replace('@TITLE@', self.jobData['project']['name']) template = template.replace('@DESCRIPTION@', 'Created by rPath rBuilder') template = template.replace('@MEMORY@', str(self.getBuildData('vmMemory') * 1024 * 1024)) if self.baseFlavor.satisfies(deps.parseFlavor('!xen')) and \ self.baseFlavor.satisfies(deps.parseFlavor('!domU')): hvm = True else: hvm = False template = template.replace('@HVM@', str(hvm).lower()) vbdLines = '<vbd device="xvda" function="root" mode="w" ' \ 'vdi="vdi_xvda" />' vdiLines = '<vdi name="vdi_xvda" size="%d" ' \ 'source="file://xvda" type="dir-gzipped-chunks" ' \ 'variety="system" />' % size template = template.replace('@VDB_ENTRIES@', vbdLines) template = template.replace('@VDI_ENTRIES@', vdiLines) # write the file to the proper location ofile = file(outfile, 'wb') ofile.write(template) ofile.close()
def testNetworkSearchSource(self): repos = self.openRepository() trv1 = self.addComponent('foo:runtime', '1', 'ssl') trv2 = self.addComponent('foo:runtime', '2', '!ssl') s = searchsource.NetworkSearchSource(repos, self.cfg.installLabelPath, parseFlavor('ssl')) tup = s.findTrove(('foo:runtime', None, None))[0] assert(tup == trv1.getNameVersionFlavor()) tup = s.findTrove(('foo:runtime', None, parseFlavor('!ssl')))[0] assert(tup == trv2.getNameVersionFlavor()) trv = s.getTrove(*tup) assert(trv == trv2) cs = s.createChangeSet([(tup[0], (None, None), (tup[1], tup[2]), True)]) trvCs = cs.getNewTroveVersion(*trv.getNameVersionFlavor()) trv = trove.Trove(trvCs) assert(trv == trv2) assert(list(s.iterFilesInTrove(*trv.getNameVersionFlavor())) == list(repos.iterFilesInTrove(*trv.getNameVersionFlavor()))) # test dep resolution - the resolve source for this should check # the right branch. self.cfg.installLabelPath = [versions.Label('localhost@rpl:branch')] self.addComponent('bar:runtime', ':branch/1', filePrimer=1, requires='trove:foo:runtime') self.checkUpdate('bar:runtime', ['bar:runtime', 'foo:runtime=1'], resolveSource=s.getResolveMethod(), resolve=True)
def _test(flavor, filterList, result): if not isinstance(filterList, (list, tuple)): filterList = [filterList] filterList = [ parseFlavor(x, raiseError=True) for x in filterList] flavor = parseFlavor(flavor, raiseError=True) filteredFlavor = filterFlavor(flavor, filterList) self.assertEquals(str(filteredFlavor), result)
def testTroveFilterVersion(self): recipe = self.getRecipe() filt = trovefilter.TroveFilter(recipe, 'foo', version = 'test.rpath.local@rpl:linux') filt2 = trovefilter.TroveFilter(recipe, 'bar', version = 'test.rpath.local@rpl:linux') nvf = ('foo', versions.VersionFromString( \ '/test.rpath.local@rpl:linux/1-1-1'), deps.parseFlavor('')) self.assertEquals(filt.match((nvf,)), True) self.assertEquals(filt2.match((nvf,)), False) filt = trovefilter.TroveFilter(recipe, 'foo', version = '/test.rpath.local@rpl:linux') self.assertEquals(filt.match((nvf,)), True) filt = trovefilter.TroveFilter(recipe, 'foo', version = '/test.rpath.local@rpl:linux/1-1-1') self.assertEquals(filt.match((nvf,)), True) filt = trovefilter.TroveFilter(recipe, 'foo', version = 'test.rpath.local@rpl:linux') nvf = ('foo', versions.VersionFromString( \ '/test.rpath.local@rpl:devel/1-1-1'), deps.parseFlavor('')) self.assertEquals(filt.match((nvf,)), False) filt = trovefilter.TroveFilter(recipe, 'foo', version = '/test.rpath.local@rpl:linux') self.assertEquals(filt.match((nvf,)), False) filt = trovefilter.TroveFilter(recipe, 'foo', version = '/test.rpath.local@rpl:linux/1-1-1') self.assertEquals(filt.match((nvf,)), False)
def testFindTrove(self): db = database.Database(':memory:', ':memory:') self.assertEqual(db.getTransactionCounter(), 0) flavor = deps.parseFlavor('~readline,!foo') v10 = ThawVersion("/conary.rpath.com@test:trunk/10:1.2-10-1") f1 = files.FileFromFilesystem("/etc/passwd", self.id1) trv = trove.Trove("testcomp", v10, flavor, None) trv.addFile(self.id1, "/bin/1", v10, f1.fileId()) trvInfo = db.addTrove(trv) db.addTroveDone(trvInfo) f2 = files.FileFromFilesystem("/etc/group", self.id2) v20 = ThawVersion("/conary.rpath.com@local:blah/20:1.3-2-1") trv = trove.Trove("testcomp", v20, flavor, None) trv.addFile(self.id2, "/bin/2", v20, f2.fileId()) trvInfo = db.addTrove(trv) db.addTroveDone(trvInfo) tup = [('testcomp', v10, flavor)] tup2 = [('testcomp', v10, flavor), ('testcomp', v20, flavor)] assert(db.findTrove(None, ('testcomp', '1.2-10-1', None)) == tup) assert(db.findTrove(None, ('testcomp', '1.2', None)) == tup) assert(set(db.findTrove(None, ('testcomp', None, parseFlavor('!foo')))) == set(tup2)) assert(db.findTrove(None, ('testcomp', ':trunk', None)) == tup) assert(db.findTrove([Label('conary.rpath.com@test:foo')], ('testcomp', ':trunk', None)) == tup) assert(db.findTrove(None, ('testcomp', ':trunk', None)) == tup) assert(db.findTrove(None, ('testcomp', '@test:trunk', None)) == tup) assert(db.findTrove([Label('conary.rpath.com@blah:foo')], ('testcomp', '@test:trunk', None)) == tup) # Transaction counter changes upon commit self.assertEqual(db.getTransactionCounter(), 0) db.commit() self.assertEqual(db.getTransactionCounter(), 1)
def testParse(self): self.compare('foo', 'foo', 'foo', None, None) self.compare('foo=1.2', 'foo=1.2', 'foo', '1.2', None) self.compare('foo=1.2[asdf]', 'foo=1.2[asdf]', 'foo', '1.2', deps.parseFlavor('asdf')) self.compare('foo[asdf]', 'foo[asdf]', 'foo', None, deps.parseFlavor('asdf'))
def testCook(self): repos = self.openRepository() self.makeSourceTrove('test1', test1Recipe) cookFlavor = deps.parseFlavor('readline,ssl,X') troveTup = repos.findTrove(self.cfg.buildLabel, ('test1:source', None, None), None)[0] troveTup = (troveTup[0], troveTup[1], cookFlavor) targetLabel = versions.Label('localhost@LOCAL:linux') newTargetLabel = versions.Label('localhost@LOCAL:linux') # adding an unknown flavor shouldn't matter with latest conary. self.cfg.buildFlavor = deps.overrideFlavor(self.cfg.buildFlavor, deps.parseFlavor('foobar')) logger_ = logger.Logger() logPath, pid, buildInfo = self.discardOutput(cook.cookTrove, self.cfg, repos, logger_, targetLabel=targetLabel, *troveTup) result = self._wait(buildInfo) assert(result.isBuildSuccess()) repos.commitChangeSetFile(result.getChangeSetFile()) troveTup = repos.findTrove(newTargetLabel, ('test1', None, deps.parseFlavor('readline,ssl')), None)[0] assert(troveTup[1].branch().label() == newTargetLabel) assert(str(troveTup[2]) == 'readline,ssl') self.updatePkg('test1=%s[readline,ssl]' % newTargetLabel, raiseError=True) self.verifyFile(self.rootDir + '/foo/bar', str(self.cfg.buildLabel) + '\n')
def testFindPackageInSearchPaths(self): _, facade = self.prep() repos = mock.MockObject() mock.mockMethod(facade._getRepositoryClient, repos) groupSpecFoo = ('group-foo', 'localhost@rpl:1', deps.parseFlavor('')) groupSpecBar = ('group-bar', 'localhost@rpl:1', deps.parseFlavor('')) groupTup = self.makeTroveTuple('group-foo=localhost@rpl:1/1:1.0-1-1') groupTup2 = self.makeTroveTuple( 'group-foo=localhost@rpl:1/2:2.0-2-1[is:x86]') groupTupBar = self.makeTroveTuple( 'group-bar=localhost@rpl:1/3:1.0-1-1') groupTrv = mock.MockObject(stableReturnValues=True) repos.findTroves._mock.setReturn({groupSpecFoo : [groupTup, groupTup2], groupSpecBar : [groupTupBar]}, None, [groupSpecFoo], allowMissing = True) repos.getTroves._mock.setReturn([groupTrv], [groupTup2], withFiles=False) iterator = mock.MockObject() fooTup = self.makeTroveTuple('foo') iterator._mock._dict[0] = fooTup iterator._mock._dict[1] = self.makeTroveTuple('blah') groupTrv.iterTroveList._mock.setDefaultReturn(iterator) self.assertEquals(facade._findPackageInSearchPaths([groupSpecFoo], 'foo'), [fooTup]) # when no groups are found, return nothing repos.findTroves._mock.setReturn({}, None, [groupSpecFoo], allowMissing = True) self.assertEquals(facade._findPackageInSearchPaths([groupSpecFoo], 'foo'), [])
def testCook(self): repos = self.openRepository() self.makeSourceTrove('test1', test1Recipe) cookFlavor = deps.parseFlavor('readline,ssl,X') troveTup = repos.findTrove(self.cfg.buildLabel, ('test1:source', None, None), None)[0] troveTup = (troveTup[0], troveTup[1], cookFlavor) targetLabel = versions.Label('localhost@LOCAL:linux') newTargetLabel = versions.Label('localhost@LOCAL:linux') # adding an unknown flavor shouldn't matter with latest conary. self.cfg.buildFlavor = deps.overrideFlavor(self.cfg.buildFlavor, deps.parseFlavor('foobar')) logger_ = logger.Logger() logPath, pid, buildInfo = self.discardOutput(cook.cookTrove, self.cfg, repos, logger_, targetLabel=targetLabel, *troveTup) result = self._wait(buildInfo) assert (result.isBuildSuccess()) repos.commitChangeSetFile(result.getChangeSetFile()) troveTup = repos.findTrove( newTargetLabel, ('test1', None, deps.parseFlavor('readline,ssl')), None)[0] assert (troveTup[1].branch().label() == newTargetLabel) assert (str(troveTup[2]) == 'readline,ssl') self.updatePkg('test1=%s[readline,ssl]' % newTargetLabel, raiseError=True) self.verifyFile(self.rootDir + '/foo/bar', str(self.cfg.buildLabel) + '\n')
def testCookTwoGroups(self): self.addComponent('test:run', '1', '!ssl,~test.foo') self.addComponent('test:run', '1', 'ssl,~test.foo') trv = self.addComponent('group-foo:source', '1', '', [('group-foo.recipe', groupRecipeWithFlags)]) flavorList = [deps.parseFlavor('!ssl'), deps.parseFlavor('ssl')] repos = self.openRepository() logger_ = logger.Logger() targetLabel = versions.Label('localhost@rpl:TARGET') self.cfg.shortenGroupFlavors = True logPath, pid, buildInfo = self.discardOutput(cook.cookTrove, self.cfg, repos, logger_, trv.getName(), trv.getVersion(), flavorList, targetLabel=targetLabel) result = self._wait(buildInfo) assert(result.isBuildSuccess()) cs = changeset.ChangeSetFromFile(result.getChangeSetFile()) newTroves = [ x.getNewNameVersionFlavor() for x in cs.iterNewTroveList() ] assert(len(set([x[1] for x in newTroves]))) flavorList = set([ x[2] for x in newTroves ]) self.assertEquals(sorted(str(x) for x in flavorList), ['readline,!ssl', 'ssl'])
def testLoadedTroves(self): # we don't check the output of this test. self.logFilter.add() repos = self.openRepository() header = ''' if Use.%s: foo = '1.0-readline' else: foo = '1.0-noreadline' ''' self.addTestPkg(1, version='1.0', header=header % 'readline') self.addTestPkg(2, header='loadRecipe("test1")' + header % 'ssl') test3Recipe = self.addTestPkg(3, header='loadRecipe("test2")' + header % 'bootstrap') use.track() rldep = deps.parseFlavor('readline') ssldep = deps.parseFlavor('ssl') nobsdep = deps.parseFlavor('~!bootstrap') v1 = versions.VersionFromString('/localhost@rpl:linux/1.0-1') loader = self._testSubload(repos, "loadInstalled('test3')") FooLoaded = loader.getLoadedSpecs() assert (FooLoaded['test3'][0] == ('test3:source', v1, nobsdep)) Test3Loaded = FooLoaded['test3'][1] assert (Test3Loaded['test2'][0] == ('test2:source', v1, ssldep)) Test2Loaded = Test3Loaded['test2'][1] assert (Test2Loaded['test1'][0] == ('test1:source', v1, rldep)) Test1Loaded = Test2Loaded['test1'][1] assert (Test1Loaded == {}) loadedTroves = loader.getLoadedTroves() assert (len(loadedTroves) == 3) assert (loadedTroves[0] == ('test1:source', v1, rldep)) assert (loadedTroves[1] == ('test2:source', v1, ssldep)) assert (loadedTroves[2] == ('test3:source', v1, nobsdep)) # Now reset and load again w/ overrides specified branch = versions.VersionFromString('/localhost@rpl:foo/') oldLoadedSpecs = loader.getLoadedSpecs() # move ILP and buildLabel over to another branch, and use overrides # to load exactly what we want anyway. cfg = copy.copy(self.cfg) cfg.installLabelPath = [versions.Label('localhost@rpl:foo')] cfg.buildLabel = versions.Label('localhost@rpl:foo') self.overrideBuildFlavor('!readline, !ssl') overrides = oldLoadedSpecs loader = self._testSubload(repos, "loadInstalled('test3')", cfg=cfg, overrides=overrides) assert (loadedTroves[0] == ('test1:source', v1, rldep)) assert (loadedTroves[1] == ('test2:source', v1, ssldep)) assert (loadedTroves[2] == ('test3:source', v1, nobsdep))
def testApiRpcParams(self): server = TestServer() client = TestClient(ShimAddress(server)) assert(client.ping(True)) assert(client.ping2(deps.parseFlavor('foo')) == deps.parseFlavor('foo')) self.assertRaises(apirpc.ApiError, client.proxy.ping, True, False) self.assertRaises(apirpc.ApiError, client.proxy.foobar)
def testLoadedTrovesWithAutoLoad(self): self.logFilter.add() repos = self.openRepository() if 'x86_64' not in str(self.cfg.buildFlavor): raise testhelp.SkipTestException('Skip test on x86 arch') self.cfg.autoLoadRecipes.append('other') self.overrideBuildFlavor('is: x86 x86_64') header = ''' if Arch.x86: pass ''' self.addComponent( 'other:recipe=2.0[is:x86 x86_64]', [('simplesuper.recipe', simpleSuperRecipe.replace('1.0', '2.0'))]) self.addCollection('other=2.0[is:x86 x86_64]', [':recipe']) self.addTestPkg(1, version='1.0', header=header) self.addTestPkg(2, header='loadRecipe("test1")') use.track() rldep = deps.parseFlavor('readline') ssldep = deps.parseFlavor('ssl') nobsdep = deps.parseFlavor('~!bootstrap') emptydep = deps.Flavor() x64dep = deps.parseFlavor('is:x86_64') v1 = versions.VersionFromString('/localhost@rpl:linux/1.0-1') loader = self._testSubload(repos, "loadInstalled('test2')") FooLoaded = loader.getLoadedSpecs() assertEq = self.assertEqual assertEq(FooLoaded['test2'][0], ('test2:source', v1, emptydep)) Test2Loaded = FooLoaded['test2'][1] assertEq(Test2Loaded['test1'][0], ('test1:source', v1, x64dep)) Test1Loaded = Test2Loaded['test1'][1] assertEq(Test1Loaded, {}) loadedTroves = loader.getLoadedTroves() assertEq(len(loadedTroves), 2) assertEq(loadedTroves[0], ('test1:source', v1, x64dep)) assertEq(loadedTroves[1], ('test2:source', v1, emptydep)) # Now reset and load again w/ overrides specified branch = versions.VersionFromString('/localhost@rpl:foo/') oldLoadedSpecs = loader.getLoadedSpecs() # move ILP and buildLabel over to another branch, and use overrides # to load exactly what we want anyway. cfg = copy.copy(self.cfg) self.overrideBuildFlavor('!readline, !ssl') overrides = oldLoadedSpecs loader = self._testSubload(repos, "loadInstalled('test2')", cfg=cfg, overrides=overrides) assert (loadedTroves[0] == ('test1:source', v1, x64dep)) assert (loadedTroves[1] == ('test2:source', v1, emptydep))
def testNonRecursiveGroupSigs(self): fingerprint = '95B457D16843B21EA3FC73BBC7C32FC1F94E405E' # supply the pass phrase for our private key keyCache = openpgpkey.getKeyCache() keyCache.getPrivateKey(fingerprint, '111111') # make all components before assigning a key, so all start out blank self.addQuickTestComponent("test:doc", "1.0-1-1") self.makeSourceTrove('testcase', testRecipe) repos = self.openRepository() built = self.cookItem(repos, self.cfg, 'testcase', ignoreDeps=True) group = self.build(testGroup, "GroupTest") group = self.build(outerGroup, "OuterGroup") signatureKey = self.cfg.signatureKey self.cfg.signatureKey = fingerprint self.cfg.quiet = True v = versions.VersionFromString('/localhost@rpl:linux/1.0-1-1') f = deps.parseFlavor('') try: # first sign the outer group trove #signtrove.signTroves(self.cfg, [ "group-outer" ]) cvccmd.sourceCommand(self.cfg, ["sign", "group-outer"], {}) try: t = repos.getTrove('group-outer', v, f) self._checkDigitalSig(t, fingerprint) except openpgpfile.KeyNotFound: self.fail('Group signing failed to cover %s' % t) # check the sig on each trove in the group, since group signing # should be recursive for trvName in ('group-test', 'test:doc', 'testcase', 'testcase:runtime'): try: t = repos.getTrove(trvName, v, f) t.getDigitalSignature(fingerprint) self.fail('Group signing inadvenderntly signed %s' % trvName) except openpgpfile.KeyNotFound: pass # then check that the source trove wasn't signed... it wasn't # explicitly part of the group v = versions.VersionFromString('/localhost@rpl:linux/1.0-1') f = deps.parseFlavor('') t = repos.getTrove('testcase:source', v, f) try: signature = t.getDigitalSignature(fingerprint) self._checkDigitalSig(t, fingerprint) self.fail('signing group inadvendently signed source trove') except openpgpfile.KeyNotFound: pass finally: self.cfg.signatureKey = signatureKey
def testGetMajorArch(self): deplist = deps.parseFlavor('is: x86 x86_64').iterDepsByClass( deps.InstructionSetDependency) self.assertEqual(arch.getMajorArch(deplist).name, 'x86_64') deplist = deps.parseFlavor('is: x86 ppc').iterDepsByClass( deps.InstructionSetDependency) self.assertRaises(arch.IncompatibleInstructionSets, arch.getMajorArch, deplist)
def testTroveFilterBlank(self): recipe = self.getRecipe() filt = trovefilter.TroveFilter(recipe) nvf = ('foo', versions.VersionFromString( \ '/test.rpath.local@rpl:linux/1.1-2-1'), deps.parseFlavor('')) self.assertEquals(filt.match((nvf, )), True) nvf = ('bar', versions.VersionFromString( \ '/test.rpath.local@rpl:devel/1.0-6-4'), deps.parseFlavor('')) self.assertEquals(filt.match((nvf, )), True)
def testApiRpcParams(self): server = TestServer() client = TestClient(ShimAddress(server)) assert (client.ping(True)) assert (client.ping2( deps.parseFlavor('foo')) == deps.parseFlavor('foo')) self.assertRaises(apirpc.ApiError, client.proxy.ping, True, False) self.assertRaises(apirpc.ApiError, client.proxy.foobar)
def testLookup(self): g = geoip.GeoIPLookup([]) g.dbs = [mock.MockObject(), mock.MockObject()] g.dbs[0].country_code_by_addr._mock.setReturn('AA', '1.2.3.4') self.assertEqual(g.getFlags('1.2.3.4'), deps.parseFlavor('country.AA')) g.dbs[0].country_code_by_addr._mock.raiseErrorOnAccess(geoip.GeoIPError) g.dbs[1].country_code_by_addr._mock.setReturn('XX', 'f00::b47') self.assertEqual(g.getFlags('f00::b47'), deps.parseFlavor('country.XX'))
def testTroveFilterBlank(self): recipe = self.getRecipe() filt = trovefilter.TroveFilter(recipe) nvf = ('foo', versions.VersionFromString( \ '/test.rpath.local@rpl:linux/1.1-2-1'), deps.parseFlavor('')) self.assertEquals(filt.match((nvf,)), True) nvf = ('bar', versions.VersionFromString( \ '/test.rpath.local@rpl:devel/1.0-6-4'), deps.parseFlavor('')) self.assertEquals(filt.match((nvf,)), True)
def testGetFlavor(self): _, facade = self.prep() flavorString = '!bootstrap is:x86' flavorObject = deps.parseFlavor(flavorString) assert facade._getFlavor(flavorString) == flavorObject assert facade._getFlavor(flavorObject) == flavorObject flavorObject = deps.parseFlavor('') # same as deps.Flavor() assert facade._getFlavor() == flavorObject assert facade._getFlavor(None, keepNone=True) == None
def testGetArchFlavor(self): f = deps.parseFlavor("use: blah is: x86") self.failUnlessEqual(installable_iso.getArchFlavor(f).freeze(), flavors.pathSearchOrder[1]) f = deps.parseFlavor("use: blah is: x86 x86_64") self.failUnlessEqual(installable_iso.getArchFlavor(f).freeze(), flavors.pathSearchOrder[0]) f = deps.parseFlavor("use: foo") self.failUnlessEqual(installable_iso.getArchFlavor(f), None)
def testLatestByLabel(self): def _build(*specList): for (v, f) in specList: self.addComponent('t:rt', v, flavor=f) v1 = versions.ThawVersion('/localhost@rpl:foo//1/1:1.0-1-1') v2 = versions.ThawVersion('/localhost@rpl:bar//1/2:1.0-1-2') l = v1.trailingLabel() defFlavor = deps.parseFlavor('readline,ssl') noReadLine = deps.parseFlavor('~!readline,ssl') reqNoReadLine = deps.parseFlavor('!readline,ssl') _build((v1, defFlavor), (v2, defFlavor)) repos = self.openRepository() d = repos.getTroveLatestByLabel({'t:rt': {l: None}}) assert (d['t:rt'].keys() == [v2]) d = repos.getTroveLatestByLabel({'t:rt': {l: [defFlavor]}}) assert (d['t:rt'].keys() == [v2]) d = repos.getTroveLatestByLabel({'t:rt': { l: [defFlavor] }}, bestFlavor=True) assert (d['t:rt'].keys() == [v2]) _build((v1, noReadLine)) d = repos.getTroveLatestByLabel({'t:rt': {l: None}}) assert (d['t:rt']) == {v1: [noReadLine], v2: [defFlavor]} d = repos.getTroveLatestByLabel({'t:rt': { l: [noReadLine] }}, bestFlavor=True) assert (d['t:rt']) == {v2: [defFlavor]} d = repos.getTroveLatestByLabel({'t:rt': { l: [reqNoReadLine] }}, bestFlavor=True) assert (d['t:rt']) == {v1: [noReadLine]} d = repos.getTroveLatestByLabel({'t:rt': {l: [noReadLine]}}) assert (d['t:rt']) == {v2: [defFlavor], v1: [noReadLine]} d = repos.getTroveLatestByLabel({'t:rt': {l: [defFlavor, noReadLine]}}) assert (d['t:rt']) == {v2: [defFlavor], v1: [noReadLine]} d = repos.getTroveLatestByLabel( {'t:rt': { l: [defFlavor, reqNoReadLine] }}, bestFlavor=True) assert (d['t:rt']) == {v2: [defFlavor], v1: [noReadLine]}
def testLoadedTrovesWithAutoLoad(self): self.logFilter.add() repos = self.openRepository() if 'x86_64' not in str(self.cfg.buildFlavor): raise testhelp.SkipTestException('Skip test on x86 arch') self.cfg.autoLoadRecipes.append('other') self.overrideBuildFlavor('is: x86 x86_64') header = ''' if Arch.x86: pass ''' self.addComponent('other:recipe=2.0[is:x86 x86_64]', [('simplesuper.recipe', simpleSuperRecipe.replace('1.0', '2.0'))]) self.addCollection('other=2.0[is:x86 x86_64]', [':recipe']) self.addTestPkg(1, version='1.0', header=header) self.addTestPkg(2, header='loadRecipe("test1")') use.track() rldep = deps.parseFlavor('readline') ssldep = deps.parseFlavor('ssl') nobsdep = deps.parseFlavor('~!bootstrap') emptydep = deps.Flavor() x64dep = deps.parseFlavor('is:x86_64') v1 = versions.VersionFromString('/localhost@rpl:linux/1.0-1') loader = self._testSubload(repos, "loadInstalled('test2')") FooLoaded = loader.getLoadedSpecs() assertEq = self.assertEqual assertEq(FooLoaded['test2'][0], ('test2:source', v1, emptydep)) Test2Loaded = FooLoaded['test2'][1] assertEq(Test2Loaded['test1'][0], ('test1:source', v1, x64dep)) Test1Loaded = Test2Loaded['test1'][1] assertEq(Test1Loaded, {}) loadedTroves = loader.getLoadedTroves() assertEq(len(loadedTroves), 2) assertEq(loadedTroves[0], ('test1:source', v1, x64dep)) assertEq(loadedTroves[1], ('test2:source', v1, emptydep)) # Now reset and load again w/ overrides specified branch = versions.VersionFromString('/localhost@rpl:foo/') oldLoadedSpecs = loader.getLoadedSpecs() # move ILP and buildLabel over to another branch, and use overrides # to load exactly what we want anyway. cfg = copy.copy(self.cfg) self.overrideBuildFlavor('!readline, !ssl') overrides = oldLoadedSpecs loader = self._testSubload(repos, "loadInstalled('test2')", cfg = cfg, overrides = overrides) assert(loadedTroves[0] == ('test1:source', v1, x64dep)) assert(loadedTroves[1] == ('test2:source', v1, emptydep))
def testLoadedTroves(self): # we don't check the output of this test. self.logFilter.add() repos = self.openRepository() header = ''' if Use.%s: foo = '1.0-readline' else: foo = '1.0-noreadline' ''' self.addTestPkg(1, version='1.0', header=header % 'readline') self.addTestPkg(2, header='loadRecipe("test1")' + header % 'ssl') test3Recipe = self.addTestPkg(3, header='loadRecipe("test2")' + header % 'bootstrap') use.track() rldep = deps.parseFlavor('readline') ssldep = deps.parseFlavor('ssl') nobsdep = deps.parseFlavor('~!bootstrap') v1 = versions.VersionFromString('/localhost@rpl:linux/1.0-1') loader = self._testSubload(repos, "loadInstalled('test3')") FooLoaded = loader.getLoadedSpecs() assert(FooLoaded['test3'][0] == ('test3:source', v1, nobsdep)) Test3Loaded = FooLoaded['test3'][1] assert(Test3Loaded['test2'][0] == ('test2:source', v1, ssldep)) Test2Loaded = Test3Loaded['test2'][1] assert(Test2Loaded['test1'][0] == ('test1:source', v1, rldep)) Test1Loaded = Test2Loaded['test1'][1] assert(Test1Loaded == {}) loadedTroves = loader.getLoadedTroves() assert(len(loadedTroves) == 3) assert(loadedTroves[0] == ('test1:source', v1, rldep)) assert(loadedTroves[1] == ('test2:source', v1, ssldep)) assert(loadedTroves[2] == ('test3:source', v1, nobsdep)) # Now reset and load again w/ overrides specified branch = versions.VersionFromString('/localhost@rpl:foo/') oldLoadedSpecs = loader.getLoadedSpecs() # move ILP and buildLabel over to another branch, and use overrides # to load exactly what we want anyway. cfg = copy.copy(self.cfg) cfg.installLabelPath = [versions.Label('localhost@rpl:foo')] cfg.buildLabel = versions.Label('localhost@rpl:foo') self.overrideBuildFlavor('!readline, !ssl') overrides = oldLoadedSpecs loader = self._testSubload(repos, "loadInstalled('test3')", cfg = cfg, overrides = overrides) assert(loadedTroves[0] == ('test1:source', v1, rldep)) assert(loadedTroves[1] == ('test2:source', v1, ssldep)) assert(loadedTroves[2] == ('test3:source', v1, nobsdep))
def testGetTrovesToBuild(self): repos = self.openRmakeRepository() helper = self.getRmakeHelper() self.addComponent('simple:source', '1', '', [('simple.recipe', recipes.simpleRecipe), ('foo', 'content\n')]) os.chdir(self.workDir) self.checkout('simple') os.chdir('simple') self.writeFile('simple.recipe', recipes.simpleRecipe + '\tr.AddSource("bar")\n') self.remove('foo') self.writeFile('bar', 'content\n') self.addfile('bar', text=True) os.mkdir('baz') # just make a random dir - rmake should # ignore this. (n, v, f) = buildcmd.getTrovesToBuild(self.buildCfg, helper.getConaryClient(), ['simple.recipe[bam]'], message='foo')[0] assert (f == deps.parseFlavor('bam')) f = deps.parseFlavor('') assert (v.trailingLabel().getHost() == self.rmakeCfg.reposName) # make sure we can commit this uphill assert (len(list(v.iterLabels())) == 2) trove = repos.getTrove(n, v, f, withFiles=True) assert (set(x[1] for x in list(trove.iterFileList())) == set( ['simple.recipe', 'bar'])) # okay now let's do it again, no change this time v2 = buildcmd.getTrovesToBuild(self.buildCfg, helper.getConaryClient(), ['simple.recipe'], message='foo')[0][1] assert (v == v2) # this time, change the config setting for foo self.setSourceFlag('bar', binary=True) v3 = buildcmd.getTrovesToBuild(self.buildCfg, helper.getConaryClient(), ['simple.recipe'], message='foo')[0][1] assert (v3 != v2) # one more time, revert back to original. self.writeFile('simple.recipe', recipes.simpleRecipe) v4 = buildcmd.getTrovesToBuild(self.buildCfg, helper.getConaryClient(), ['simple.recipe'], message='foo')[0][1] assert (v4.trailingLabel().getHost() == self.rmakeCfg.reposName) assert (v4 != v3) assert (helper.buildConfig.buildTroveSpecs == [ (self.workDir + '/simple/simple.recipe', None, deps.parseFlavor('')) ])
def testPrimaryFlavorComesThrough(self): # we specified this flavor at the command line. Even though # it may not be needed for display, it's needed to ensure that the # flavor gets cooked in the right environ. trv = self.addComponent("simple:source", "1", [("simple.recipe", recipes.simpleRecipe)]) flavor = deps.parseFlavor("!ssl,readline") repos = self.openRepository() job = self.newJob((trv.getName(), trv.getVersion(), flavor)) results = recipeutil.getSourceTrovesFromJob(job, repos=repos, reposName=self.rmakeCfg.reposName) self.failUnless(results.values()[0].flavor.stronglySatisfies(deps.parseFlavor("readline,!ssl")))
def _test(flavorStr, expected): flavor = deps.parseFlavor(flavorStr, raiseError=True) result = packagerecipe.getCrossCompileSettings(flavor) if result is None: self.assertEquals(expected, None) return expected = (expected[0], deps.parseFlavor(expected[1], raiseError=True), expected[2]) self.assertEquals(result, expected)
class JobTupleTest(testhelp.TestCase): old = (versions.ThawVersion('/conary.rpath.com@rpl:devel//2/1000000000.000:2.9.10-2-0.1'), deps.parseFlavor('is: x86_64')) new = (versions.ThawVersion('/conary.rpath.com@rpl:devel//2/1200000000.000:3.0.00-1-0.1'), deps.parseFlavor('is: x86_64')) def testNewTuple(self): n = 'tmpwatch' a = self.old b = self.new atup = (n, a[0], a[1]) btup = trovetup.TroveTuple(n, b[0], b[1]) self.assertEqual((n, a, b, False), trovetup.JobTuple((n, a, b, False))) self.assertEqual((n, a, b, False), trovetup.JobTuple(n, a, b, False)) self.assertEqual((n, a, b, False), trovetup.JobTuple(n, a, b)) self.assertEqual((n, a, b, False), trovetup.JobTuple(n, atup, btup)) self.assertEqual((n, (None, None), b, True), trovetup.JobTuple(n, new=b)) self.assertEqual((n, (None, None), b, True), trovetup.JobTuple(n, new=btup)) self.assertEqual((n, a, (None, None), False), trovetup.JobTuple(n, old=a)) self.assertEqual((n, a, (None, None), False), trovetup.JobTuple(n, old=atup)) self.assertEqual((n, (None, None), b, True), btup.asJob()) def testStringify(self): x = trovetup.JobTuple('tmpwatch', new=self.new) self.assertEqual(str(x), "tmpwatch=/conary.rpath.com@rpl:devel//2/3.0.00-1-0.1[is: x86_64]") self.assertEqual(repr(x), "JobTuple('tmpwatch=/conary.rpath.com@rpl:devel//2/1200000000.000:3.0.00-1-0.1[is: x86_64]')") x = x._replace(absolute=False) self.assertEqual(str(x), "tmpwatch=/conary.rpath.com@rpl:devel//2/3.0.00-1-0.1[is: x86_64]") self.assertEqual(repr(x), "JobTuple('tmpwatch=/conary.rpath.com@rpl:devel//2/1200000000.000:3.0.00-1-0.1[is: x86_64]', absolute=False)") x = trovetup.JobTuple('tmpwatch', self.old, self.new) self.assertEqual(str(x), "tmpwatch=/conary.rpath.com@rpl:devel//2/2.9.10-2-0.1[is: x86_64]" "--/conary.rpath.com@rpl:devel//2/3.0.00-1-0.1[is: x86_64]") self.assertEqual(repr(x), "JobTuple('tmpwatch=/conary.rpath.com@rpl:devel//2/1000000000.000:2.9.10-2-0.1[is: x86_64]" "--/conary.rpath.com@rpl:devel//2/1200000000.000:3.0.00-1-0.1[is: x86_64]')") x = x._replace(absolute=True) self.assertEqual(str(x), "tmpwatch=/conary.rpath.com@rpl:devel//2/2.9.10-2-0.1[is: x86_64]" "--/conary.rpath.com@rpl:devel//2/3.0.00-1-0.1[is: x86_64]") self.assertEqual(repr(x), "JobTuple('tmpwatch=/conary.rpath.com@rpl:devel//2/1000000000.000:2.9.10-2-0.1[is: x86_64]" "--/conary.rpath.com@rpl:devel//2/1200000000.000:3.0.00-1-0.1[is: x86_64]', absolute=True)") x = trovetup.JobTuple('tmpwatch', self.old) self.assertEqual(str(x), "tmpwatch=/conary.rpath.com@rpl:devel//2/2.9.10-2-0.1[is: x86_64]--") self.assertEqual(repr(x), "JobTuple('tmpwatch=/conary.rpath.com@rpl:devel//2/1000000000.000:2.9.10-2-0.1[is: x86_64]--')") def testParser(self): p = trovetup.JobTuple self.assertRaises(ParseError, p, u'spam\xFF=foo[bar]') self.assertEqual(p('tmpwatch=/conary.rpath.com@rpl:devel//2/1200000000.000:3.0.00-1-0.1[is: x86_64]'), ('tmpwatch', (None, None), self.new, True)) self.assertEqual(p('tmpwatch=/conary.rpath.com@rpl:devel//2/1000000000.000:2.9.10-2-0.1[is: x86_64]' '--/conary.rpath.com@rpl:devel//2/1200000000.000:3.0.00-1-0.1[is: x86_64]'), ('tmpwatch', self.old, self.new, False)) self.assertEqual(p('tmpwatch=/conary.rpath.com@rpl:devel//2/1000000000.000:2.9.10-2-0.1[is: x86_64]--'), ('tmpwatch', self.old, (None, None), False))
def _checkFlavor2(client, *args, **kw): flavors = client.buildConfig.flavor foo = deps.parseFlavor('foo') x86_64 = deps.parseFlavor('is:x86_64') x86_and_x86_64 = deps.parseFlavor('is:x86 x86_64') assert (len(flavors) == 2) assert (flavors[0].satisfies(foo)) assert (flavors[0].satisfies(x86_64)) assert (not flavors[0].satisfies(x86_and_x86_64)) assert (flavors[1].satisfies(foo)) assert (flavors[1].satisfies(x86_and_x86_64))
def testLookup(self): g = geoip.GeoIPLookup([]) g.dbs = [mock.MockObject(), mock.MockObject()] g.dbs[0].country_code_by_addr._mock.setReturn('AA', '1.2.3.4') self.assertEqual(g.getFlags('1.2.3.4'), deps.parseFlavor('country.AA')) g.dbs[0].country_code_by_addr._mock.raiseErrorOnAccess( geoip.GeoIPError) g.dbs[1].country_code_by_addr._mock.setReturn('XX', 'f00::b47') self.assertEqual(g.getFlags('f00::b47'), deps.parseFlavor('country.XX'))
def _checkFlavor2(client, *args, **kw): flavors = client.buildConfig.flavor foo = deps.parseFlavor('foo') x86_64 = deps.parseFlavor('is:x86_64') x86_and_x86_64 = deps.parseFlavor('is:x86 x86_64') assert(len(flavors) == 2) assert(flavors[0].satisfies(foo)) assert(flavors[0].satisfies(x86_64)) assert(not flavors[0].satisfies(x86_and_x86_64)) assert(flavors[1].satisfies(foo)) assert(flavors[1].satisfies(x86_and_x86_64))
def testFlavorSelection(self): server, sessionClient = self._setupMockDispatcher() mock.mockMethod(server.client._logger.logRPCCall) rpcClient = dispatcher.DispatcherRPCClient(server.getClient().getBusClient(), sessionClient.sessionId) node = self.makeRegisterNodeMessage(buildFlavors=["is:x86 x86_64"]).getNode() # this assigns a command to this node as well. server.nodeRegistered("session1", node) assert server._nodes.getNodeForFlavors([parseFlavor("foo is:x86")]) assert server._nodes.getNodeForFlavors([parseFlavor("bar is:x86_64")]) assert server._nodes.getNodeForFlavors([parseFlavor("bar is:x86 x86_64")]) assert server._nodes.getNodeForFlavors([parseFlavor("")]) assert not server._nodes.getNodeForFlavors([parseFlavor("foo is:ppc")])
def testPullInX86WhenWeHaveX86_64(self): # pull in an x86 flavor of a lib when the x86_64 flavor is already # installed self.addComponent('foo:lib=1[is:x86]', provides='trove:foo:lib(x86)') self.addComponent('foo:lib=1[is:x86_64]', provides='trove:foo:lib(x86_64)', filePrimer=1) self.addComponent('bar:lib', requires='trove:foo:lib(x86)') self.updatePkg('foo:lib[is:x86_64]') self.cfg.flavor = [ deps.parseFlavor('is:x86_64'), deps.parseFlavor('is: x86 x86_64') ] self.checkUpdate('bar:lib', ['foo:lib[is:x86]', 'bar:lib'], resolve=True)
def testPrimaryFlavorComesThrough(self): # we specified this flavor at the command line. Even though # it may not be needed for display, it's needed to ensure that the # flavor gets cooked in the right environ. trv = self.addComponent('simple:source', '1', [('simple.recipe', recipes.simpleRecipe)]) flavor = deps.parseFlavor('!ssl,readline') repos = self.openRepository() job = self.newJob((trv.getName(), trv.getVersion(), flavor)) results = recipeutil.getSourceTrovesFromJob(job, repos=repos, reposName=self.rmakeCfg.reposName) self.failUnless(results.values()[0].flavor.stronglySatisfies( deps.parseFlavor('readline,!ssl')))
def expand_targets(cfg): ''' Accept a target config section and return a list of build flavors. ''' # If no configuration is available, build is: x86 if not cfg or (not cfg.flavor_set and not cfg.flavor): return SETS['rPL 1']['x86'] # Ensure flavor_set and flavor aren't both set # This might be supported later, by recombining flavors from each if cfg.flavor_set and cfg.flavor: raise ValueError('flavor_set and flavor cannot be used together') if cfg.flavor_set: if ':' in cfg.flavor_set: distro, set_name = cfg.flavor_set.split(':', 1) else: distro, set_name = 'rPL 1', cfg.flavor_set try: return SETS[distro][set_name] except KeyError: raise RuntimeError('flavor set "%s" is not defined for ' 'distro "%s"' % (distro, set_name)) else: ret = [] for flavor in cfg.flavor: if '%' in flavor: # Handle "templates" in flavors, e.g. # flavor %rPL 1:x86% xen,dom0,!domU,!vmware match = FLAVOR_TEMPLATE_RE.search(flavor) if not match: raise RuntimeError('Malformed template in flavor') stripped_flavor = FLAVOR_TEMPLATE_RE.sub('', flavor) if '%' in stripped_flavor: raise RuntimeError('Cannot have multiple templates ' 'in flavor') distro_name, arch_name = match.groups() distro = _DISTROS[distro_name] base = distro['base'].copy() base.union(distro['arches'][arch_name][0]) suffix = deps.parseFlavor(stripped_flavor) ret.append(deps.overrideFlavor(base, suffix)) else: ret.append(deps.parseFlavor(flavor)) return ret