예제 #1
0
    def testVersionCache(self):
        versions.thawedVersionCache.clear()
        assert (not versions.thawedVersionCache)
        # test the thawed version cache
        verStr = "/foo.com@spc:bar/1:1.2-3/bang.com@spc:branch/2:2.4-5"
        v1 = ThawVersion(verStr)
        v2 = ThawVersion(verStr)
        assert (id(v1) == id(v2))
        assert (len(versions.thawedVersionCache) == 1)
        del v1
        assert (len(versions.thawedVersionCache) == 1)
        del v2
        assert (not versions.thawedVersionCache)

        versions.stringVersionCache.clear()
        v1 = VersionFromString("/foo.com@spc:bar/1.2-3")
        v2 = VersionFromString("/foo.com@spc:bar/1.2-3", timeStamps=[1.000])
        v3 = VersionFromString("/foo.com@spc:bar/1.2-3")
        v4 = VersionFromString("/foo.com@spc:bar/1.2-3")
        assert (v1.timeStamps() == [0])
        assert (v2.timeStamps() == [1])
        assert (id(v1) != id(v2))
        assert (id(v2) != id(v3))
        assert (id(v1) == id(v3))
        assert (id(v3) == id(v4))
예제 #2
0
    def testLoadInstalledInRoot(self):
        # make sure that we find this autoconf213 trove even though it's
        # been built.  (RMK-371)
        self.openRepository()
        repos = self.openRmakeRepository()

        sourceV = VFS("/localhost@rpl:1//autoconf213/2.13-1.1")
        binV = sourceV.createShadow(versions.Label("rmakehost@rpl:1"))
        binV.incrementBuildCount()

        loadInstalledRecipe = fixtures.loadInstalledRecipe.replace(
            "loadInstalled('loaded')", "loadInstalled('loaded=:autoconf213')"
        )
        self.addComponent("loaded:runtime", str(binV))
        trv = self.addCollection("loaded", str(binV), [":runtime"])
        self.updatePkg("loaded=rmakehost@rpl:1")
        self.addComponent(
            "loaded:source", str(sourceV), [("loaded.recipe", fixtures.loadedRecipe.replace("@@", "2.13"))]
        )
        trv = self.addComponent("loadinstalled:source", "1", [("loadinstalled.recipe", loadInstalledRecipe)])
        n, v, f = trv.getNameVersionFlavor()

        db = self.openDatabase()
        source = recipeutil.RemoveHostSource(db, "rmakehost")
        (loader, recipeClass, localFlags, usedFlags) = recipeutil.loadRecipeClass(
            repos, n, v, f, ignoreInstalled=False, root=self.cfg.root, loadInstalledSource=source
        )
        assert recipeClass.loadedVersion == "2.13"
예제 #3
0
    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())
예제 #4
0
    def testLoadInstalledInRoot(self):
        # make sure that we find this autoconf213 trove even though it's
        # been built.  (RMK-371)
        self.openRepository()
        repos = self.openRmakeRepository()

        sourceV = VFS('/localhost@rpl:1//autoconf213/2.13-1.1')
        binV = sourceV.createShadow(versions.Label('rmakehost@rpl:1'))
        binV.incrementBuildCount()

        loadInstalledRecipe = fixtures.loadInstalledRecipe.replace(
                                "loadInstalled('loaded')",
                                "loadInstalled('loaded=:autoconf213')")
        self.addComponent('loaded:runtime', str(binV))
        trv = self.addCollection('loaded', str(binV), [':runtime'])
        self.updatePkg('loaded=rmakehost@rpl:1')
        self.addComponent('loaded:source', str(sourceV),
                          [('loaded.recipe',
                            fixtures.loadedRecipe.replace('@@', '2.13'))])
        trv = self.addComponent('loadinstalled:source', '1',
                          [('loadinstalled.recipe', loadInstalledRecipe)])
        n,v,f = trv.getNameVersionFlavor()

        db = self.openDatabase()
        source = recipeutil.RemoveHostSource(db, 'rmakehost')
        (loader, recipeClass, localFlags, usedFlags) = \
            recipeutil.loadRecipeClass(repos, n, v, f,
                                       ignoreInstalled=False, 
                                       root=self.cfg.root,
                                       loadInstalledSource=source)
        assert(recipeClass.loadedVersion == '2.13')
예제 #5
0
    def testBreakOnUpdate(self):
        # create a package which provides a file, then update that package to 
        # a version which does not provide that library while installing a 
        # package which requires that file. it should cause a dep failure.
        self.resetRepository()
        self.resetRoot()

        (built, d) = self.buildRecipe(recipes.bashRecipe, "Bash")
        bashVersion = built[0][1]
        (built, d) = self.buildRecipe(recipes.bashMissingRecipe, "Bash")
        noBashVersion = built[0][1]

        (built, d) = self.buildRecipe(recipes.bashUserRecipe, "BashUser")
        userVersion = built[0][1]

        repos = self.openRepository()
        # this changeset updates bash to a trove which removed /bin/bash
        # and installs bashuser, which requies /bin/bash
        cs = repos.createChangeSet([("bash", 
                                     (VersionFromString(bashVersion), deps.parseFlavor('ssl')), 
                                     (VersionFromString(noBashVersion), deps.parseFlavor('ssl')), 
                                    0),
                                    ("bashuser", (None, None),
                                     (VersionFromString(userVersion), 
                                      deps.Flavor()), 
                                    0)
                                  ])

        (fd, fileName) = tempfile.mkstemp()
        os.close(fd)
        cs.writeToFile(fileName)

        try:
            self.updatePkg(self.rootDir, 'bash', version = bashVersion)
            (rc, s) = self.captureOutput(self.updatePkg, self.rootDir, fileName)
        finally:
            os.unlink(fileName)
        expectedStr = """\
The following dependencies would not be met after this update:

  bashuser:runtime=0-1-1 (Would be newly installed) requires:
    file: /bin/bash
  which is provided by:
    bash:runtime=0-1-1 (Would be updated to 1-1-1)
"""
        assert(s == expectedStr)

        # since /bin/bash is still installed, this should work fine
        self.updatePkg(self.rootDir, 'bashuser', version = bashVersion)
예제 #6
0
 def testPrefixDirnames(self):
     self.addComponent("foo:source", "1.0")
     self.addComponent("foo:runtime", "1.0", '',
                       [("/usr/share/foo/bar/baz/file1", "file"),
                        ("/usr/share/foo/bar/baz/file2", "file")])
     self.addComponent("foo:lib", "1.0", '',
                       [("/usr/share/foo/file3", "file3")])
     self.addCollection("foo",
                        "1.0", [":runtime", ":lib"],
                        sourceName="foo:source")
     repos = self.openRepository()
     branch = VersionFromString("/" + str(self.defLabel))
     # get everything we know
     allIds = repos.getPackageBranchPathIds("foo:source", branch)
     self.assertEqual(
         set(allIds.keys()),
         set([
             "/usr/share/foo/bar/baz/file1", "/usr/share/foo/bar/baz/file2",
             "/usr/share/foo/file3"
         ]))
     ret = repos.getPackageBranchPathIds("foo:source", branch,
                                         ["/usr/share/foo"])
     # since protocol 62, dirnames are strictly honored, so ret should only have file3
     self.assertEqual(ret.keys(), ["/usr/share/foo/file3"])
     # protocol 61 will treat the dirlist as prefixes, which should return all files back
     repos.c[branch].setProtocolVersion(61)
     ret61 = repos.getPackageBranchPathIds("foo:source", branch,
                                           ["/usr/share/foo"])
     self.assertEqual(ret61, allIds)
예제 #7
0
    def testDoubleShadowParent(self):
        v = '/c.r.com@rpl:devel//a.r.org@rpl:devel//1/nubb-0.1'
        v = VersionFromString(v)
        assert (v.hasParentVersion())
        assert (v.parentVersion().asString() ==
                '/c.r.com@rpl:devel//a.r.org@rpl:devel/nubb-0.1')

        v = '/c.r.com@rpl:devel//a.r.org@rpl:devel//1/nubb-1'
        v = VersionFromString(v)
        assert (v.hasParentVersion())
        assert (v.parentVersion().asString() ==
                '/c.r.com@rpl:devel//a.r.org@rpl:devel/nubb-1')
예제 #8
0
 def testNew(self):
     v = NewVersion()
     assert (v.asString() == "@NEW@")
     assert (v.freeze() == "@NEW@")
     assert (not v.onLocalLabel())
     assert (not v.onEmergeLabel())
     assert (not v.onLocalCookLabel())
     v = VersionFromString("@NEW@")
     assert (v.asString() == "@NEW@")
     assert (v == NewVersion())
     assert (not v != NewVersion())
     self.assertRaises(AttributeError, v.__setattr__, "foo", 1)
예제 #9
0
    def testFreezeThawScriptsAlreadyRun(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")
        js1 = ("trove1", (None, None), (v1, flv1), True)
        js2 = ("trove2", (v1, flv2), (v2, flv2), True)

        runScripts = set([('preupdate', js1), ('preerase', js2)])
        uJob._jobPreScriptsAlreadyRun = set(runScripts)
        uJob.freeze(self.workDir)

        uJob = database.UpdateJob(db)
        uJob.thaw(self.workDir)
        self.assertEqual(uJob.getTransactionCounter(), 100)
        self.assertEqual(uJob._jobPreScriptsAlreadyRun, set(runScripts))
예제 #10
0
    def testGetSourceVersion(self):
        v = VersionFromString("/conary.rpath.com@rpl:linux/4.3-1-0/autconf213/1")
        assert not v.isBranchedBinary()
        source = v.getSourceVersion()
        assert not source.isBranchedBinary()
        assert source.asString() == "/conary.rpath.com@rpl:linux/4.3-1/autconf213/1"

        # binary branched
        v = VersionFromString("/conary.rpath.com@rpl:linux/4.3-1-1/autconf213/1")
        assert v.isBranchedBinary()
        source = v.getSourceVersion()
        assert not source.isBranchedBinary()
        assert source.asString() == "/conary.rpath.com@rpl:linux/4.3-1"

        # make sure timestamps are removed
        v = ThawVersion("/conary.rpath.com@rpl:linux/1:4.3-1-0/autconf213/2:1")
        source = v.getSourceVersion()
        assert source.timeStamps() == [0, 0]

        v = ThawVersion("/conary.rpath.com@rpl:linux/1:4.3-1-1/autconf213/2:1")
        source = v.getSourceVersion()
        assert source.timeStamps() == [0]
예제 #11
0
    def testVersionTable(self):
        db = self.getDB()
        schema.createIdTables(db)
        tbl = versiontable.VersionTable(db)

        v1 = VersionFromString("/conary.rpath.com@test:trunk/1.2-3")
        v2 = VersionFromString("/conary.rpath.com@test:trunk/1.4-5")

        tbl.addId(v1)
        tbl.addId(v2)
        assert (tbl[v1] == 1)
        assert (tbl[v2] == 2)
        assert (tbl.getBareId(1) == v1)
        assert (tbl.getBareId(2) == v2)
        #assert(tbl.getTimestamp(2) == v2.timeStamp)

        v2.versions[-1].timeStamp += 5
        assert (tbl[v2] == 2)

        assert (tbl.get(v1, "foo") == 1)
        del tbl[v1]
        assert (tbl.get(v1, "foo") == "foo")
        tbl.delId(2)
        self.assertRaises(KeyError, tbl.__getitem__, v2)
예제 #12
0
    def testDoubleShadowParent(self):
        v = "/c.r.com@rpl:devel//a.r.org@rpl:devel//1/nubb-0.1"
        v = VersionFromString(v)
        assert v.hasParentVersion()
        assert v.parentVersion().asString() == "/c.r.com@rpl:devel//a.r.org@rpl:devel/nubb-0.1"

        v = "/c.r.com@rpl:devel//a.r.org@rpl:devel//1/nubb-1"
        v = VersionFromString(v)
        assert v.hasParentVersion()
        assert v.parentVersion().asString() == "/c.r.com@rpl:devel//a.r.org@rpl:devel/nubb-1"
예제 #13
0
    def testUnmodifiedShadowParent(self):
        """
        Shadows of unmodified shadows have parents, too.
        @tests: CNY-2812
        """

        # Shadow of an unmodified shadow
        x = VersionFromString("/c.r.com@rpl:devel//1//p.r.com@rpath:widgets/yarr-1.0.2")
        self.assertTrue(x.hasParentVersion())
        self.assertEqual(x.parentVersion(), VersionFromString("/c.r.com@rpl:devel//1/yarr-1"))

        # Shadow of a shadow that changed upstream version
        y = VersionFromString("/c.r.com@rpl:devel//1//p.r.com@rpath:widgets/yarr-0.1.2")
        self.assertTrue(y.hasParentVersion())
        self.assertEqual(y.parentVersion(), VersionFromString("/c.r.com@rpl:devel//1/yarr-0.1"))

        # Shadow that changed upstream version (no parent)
        z = VersionFromString("/c.r.com@rpl:devel//1//p.r.com@rpath:widgets/yarr-0.0.1")
        self.assertFalse(z.hasParentVersion())
예제 #14
0
    def testFreezeThawCompatClassNoneScripts(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])
        flv1 = parseFlavor("")
        js1 = ("trove1", (None, None), (v1, flv1), True)

        scripts = [
            (js1, '', None, None, 'preupdate'),
        ]

        uJob._jobPreScripts = scripts
        uJob.freeze(self.workDir)

        uJob = database.UpdateJob(db)
        uJob.thaw(self.workDir)
        self.assertEqual(uJob.getTransactionCounter(), 100)
        self.assertEqual(uJob._jobPreScripts, scripts)
예제 #15
0
 def testVersionFromStringOnRollbackLabel(self):
     v = "/localhost@rpl:linux//local@local:ROLLBACK/2-1-1"
     v = VersionFromString(v)
     self.assertTrue(v.onRollbackLabel())
예제 #16
0
 def testVersionFromStringOnRollbackLabel(self):
     v = '/localhost@rpl:linux//local@local:ROLLBACK/2-1-1'
     v = VersionFromString(v)
     self.assertTrue(v.onRollbackLabel())
예제 #17
0
 def testIsInLocalNamespace(self):
     v = VersionFromString('/foo.com@local:linux/1.0-1')
     assert (v.isInLocalNamespace())
예제 #18
0
    def testShadowParenthood(self):
        v = VersionFromString("/foo.com@spc:bar//shadow1/1.0-2.1")
        # should this really have a parent?
        assert (v.hasParentVersion())
        assert (v.parentVersion().asString() == "/foo.com@spc:bar/1.0-2")

        # 1. shadow source. 2. cook on shadow1. 3. shadow binary -> has parent
        v = VersionFromString("/foo.com@spc:bar//shadow1//shadow2/1.0-2.1")
        assert (v.hasParentVersion())
        assert (v.parentVersion().asString() ==
                "/foo.com@spc:bar//shadow1/1.0-2.1")

        # if you change the upstream version for a trove, it doesn't
        # have a parent anymore!
        v = VersionFromString("/foo.com@spc:bar//shadow1/3.0-0.1")
        assert (not v.hasParentVersion())

        # 1. shadow source. 2.change version 3. shadow source -> has parent
        v = VersionFromString("/foo.com@spc:bar//shadow1//shadow2/3.0-0.1.1")
        assert (v.hasParentVersion())
        assert (v.parentVersion().asString() ==
                "/foo.com@spc:bar//shadow1/3.0-0.1")

        v = VersionFromString("/foo.com@spc:bar//shadow1/3.0-1-1")
        assert (v.hasParentVersion())
        v = VersionFromString("/foo.com@spc:bar//shadow1/3.0-1-0.1")
        assert (not v.hasParentVersion())
        v = VersionFromString("/foo.com@spc:bar//shadow1//shadow2/3.0-1-0.1")
        assert (v.hasParentVersion())
예제 #19
0
    def testDatabase1(self):
        db = sqldb.Database(':memory:')

        f1 = files.FileFromFilesystem("/etc/passwd", self.id1)
        f2 = files.FileFromFilesystem("/etc/services", self.id2)
        f3 = files.FileFromFilesystem("/etc/group", self.id3)

        trv = trove.Trove("testcomp", self.v10, self.emptyFlavor, None)
        trv.addFile(self.id1, "/bin/1", self.v10, f1.fileId())
        trv.addFile(self.id2, "/bin/2", self.v10, f2.fileId())
        trv.addFile(self.id3, "/bin/3", self.v10, f3.fileId())
        trv.troveInfo.size.set(1234)
        trv.troveInfo.sourceName.set('thesource')

        req = deps.DependencySet()
        req.addDep(deps.FileDependencies, deps.Dependency("/bin/bash"))
        req.addDep(deps.TroveDependencies, deps.Dependency("foo:runtime"))
        req.addDep(deps.SonameDependencies, deps.Dependency("libtest.so.1"))
        trv.setRequires(req)

        trvInfo = db.addTrove(trv)

        db.addFile(trvInfo,
                   f1.pathId(),
                   "/bin/1",
                   f1.fileId(),
                   self.v10,
                   fileStream=f1.freeze())
        db.addFile(trvInfo,
                   f2.pathId(),
                   "/bin/2",
                   f2.fileId(),
                   self.v10,
                   fileStream=f2.freeze())
        db.addFile(trvInfo,
                   f3.pathId(),
                   "/bin/3",
                   f3.fileId(),
                   self.v10,
                   fileStream=f3.freeze())

        db.addTroveDone(trvInfo)

        dbTrv = db.getTroves([("testcomp", self.v10, self.emptyFlavor)])[0]
        assert (dbTrv == trv)
        assert (dbTrv.__class__ == trove.Trove)
        assert (db.trovesArePinned([("testcomp", self.v10, self.emptyFlavor)
                                    ]) == [False])
        dbTrv = db.getTroves([("testcomp", self.v10, self.emptyFlavor)],
                             withFileObjects=True)[0]
        assert (dbTrv == trv)
        assert (dbTrv.__class__ == trove.TroveWithFileObjects)
        for f in (f1, f2, f3):
            assert (dbTrv.getFileObject(f.fileId()) == f)

        trv2 = trove.Trove("testpkg", self.v10, self.emptyFlavor, None)
        ti = trv2.addTrove(trv.getName(), self.v10, trv.getFlavor())
        trv2.addTrove("weakref", self.v10, trv.getFlavor(), weakRef=True)
        ti = db.addTrove(trv2, pin=True)
        db.addTroveDone(ti)
        assert (db.trovesArePinned([("testpkg", self.v10, self.emptyFlavor)
                                    ]) == [True])
        assert (db.getTroves([("testpkg", self.v10, self.emptyFlavor)
                              ])[0] == trv2)
        assert (db.getTroves([
            ("testpkg", self.v10, self.emptyFlavor)
        ])[0].getVersion().timeStamps() == trv2.getVersion().timeStamps())

        assert (db.getTroves([("testpkg", self.v10, self.emptyFlavor),
                              ("testcomp", self.v10, self.emptyFlavor),
                              ("testitem", self.v10, self.emptyFlavor)],
                             True) == [trv2, trv, None])

        assert (db.getTroves([("testpkg", self.v10, self.emptyFlavor),
                              ("testcomp", self.v10, req)],
                             True) == [trv2, None])

        assert (db.findTroveContainers(["testpkg",
                                        "testcomp"]) == [[],
                                                         [("testpkg", self.v10,
                                                           self.emptyFlavor)]])

        assert (db.getTroveContainers([
            ("testpkg", self.v10, self.emptyFlavor),
            ("testcomp", self.v10, self.emptyFlavor)
        ]) == [[], [("testpkg", self.v10, self.emptyFlavor)]])

        res = db.findTroveReferences(["testpkg", "testcomp"])

        assert (db.findTroveReferences(["testpkg", "testcomp"
                                        ]) == [[],
                                               [("testcomp", self.v10,
                                                 self.emptyFlavor)]])

        v10new = VersionFromString("/conary.rpath.com@test:trunk/1.2-10")
        assert (db.getTroves([("testpkg", v10new, self.emptyFlavor)
                              ])[0] == trv2)
        assert (db.getTroves([
            ("testpkg", v10new, self.emptyFlavor)
        ])[0].getVersion().timeStamps() == trv2.getVersion().timeStamps())

        assert (set(db.findByNames(['testpkg', 'testcomp'])) == set([
            ("testpkg", self.v10, self.emptyFlavor),
            ("testcomp", self.v10, self.emptyFlavor)
        ]))

        db.eraseTrove("testcomp", self.v10, None)
        assert (db.getTroves([("testpkg", self.v10, self.emptyFlavor)
                              ])[0] == trv2)

        trv.computePathHashes()
        trvInfo = db.addTrove(trv)
        db.addFile(trvInfo,
                   f1.pathId(),
                   "/bin/1",
                   f1.fileId(),
                   self.v10,
                   fileStream=f1.freeze())
        db.addFile(trvInfo,
                   f2.pathId(),
                   "/bin/2",
                   f2.fileId(),
                   self.v10,
                   fileStream=f1.freeze())
        db.addFile(trvInfo,
                   f3.pathId(),
                   "/bin/3",
                   f3.fileId(),
                   self.v10,
                   fileStream=f1.freeze())
        db.addTroveDone(trvInfo)

        assert (db.getTroves([("testcomp", self.v10, self.emptyFlavor)
                              ])[0] == trv)
        db.removeFileFromTrove(trv, "/bin/1")
        changedTrv = db.getTroves([trv.getNameVersionFlavor()],
                                  pristine=False)[0]
        otherChangedTrv = db.getTroves([trv.getNameVersionFlavor()],
                                       withFiles=False,
                                       pristine=False)[0]
        assert (len(changedTrv.idMap) + 1 == len(trv.idMap))
        assert (len(changedTrv.troveInfo.pathHashes) + 1 == len(
            trv.troveInfo.pathHashes))
        assert (changedTrv.troveInfo.pathHashes ==
                otherChangedTrv.troveInfo.pathHashes)
        assert (len(otherChangedTrv.idMap) == 0)
        changedTrv.addFile(self.id1, "/bin/1", self.v10, f1.fileId())
        assert (changedTrv.idMap == trv.idMap)
        changedTrv.computePathHashes()
        assert (changedTrv.troveInfo.pathHashes == trv.troveInfo.pathHashes)

        assert (db.getTroves([("testcomp", self.v10, self.emptyFlavor)],
                             pristine=True)[0] == trv)
        db.eraseTrove("testpkg", self.v10, None)
        assert (db.getTroves([("testpkg", self.v10, self.emptyFlavor)
                              ]) == [None])
        self.assertRaises(KeyError, db.instances.getVersion, 100)

        db.eraseTrove("testcomp", self.v10, None)
        db.commit()
        cu = db.db.cursor()

        # make sure the versions got removed; the None entry is still there
        cu.execute("SELECT count(*) FROM Versions")
        assert (cu.next()[0] == 1)

        # make sure the dependency table got cleaned up
        cu.execute("SELECT count(*) FROM Dependencies")
        assert (cu.next()[0] == 0)

        # make sure the instances table got cleaned up
        cu.execute("SELECT count(*) FROM Instances")
        assert (cu.next()[0] == 0)

        # make sure the troveInfo table got cleaned up
        cu.execute("SELECT count(*) FROM TroveInfo")
        assert (cu.next()[0] == 0)
예제 #20
0
 def doTestAbbrev(self, fullStr, abbrevStr):
     full = VersionFromString(fullStr)
     abbrev = VersionFromString(abbrevStr)
     assert full.asString() == abbrevStr
     assert abbrev.asString() == abbrevStr
     assert full == abbrev
예제 #21
0
    def testShadowParenthood(self):
        v = VersionFromString("/foo.com@spc:bar//shadow1/1.0-2.1")
        # should this really have a parent?
        assert v.hasParentVersion()
        assert v.parentVersion().asString() == "/foo.com@spc:bar/1.0-2"

        # 1. shadow source. 2. cook on shadow1. 3. shadow binary -> has parent
        v = VersionFromString("/foo.com@spc:bar//shadow1//shadow2/1.0-2.1")
        assert v.hasParentVersion()
        assert v.parentVersion().asString() == "/foo.com@spc:bar//shadow1/1.0-2.1"

        # if you change the upstream version for a trove, it doesn't
        # have a parent anymore!
        v = VersionFromString("/foo.com@spc:bar//shadow1/3.0-0.1")
        assert not v.hasParentVersion()

        # 1. shadow source. 2.change version 3. shadow source -> has parent
        v = VersionFromString("/foo.com@spc:bar//shadow1//shadow2/3.0-0.1.1")
        assert v.hasParentVersion()
        assert v.parentVersion().asString() == "/foo.com@spc:bar//shadow1/3.0-0.1"

        v = VersionFromString("/foo.com@spc:bar//shadow1/3.0-1-1")
        assert v.hasParentVersion()
        v = VersionFromString("/foo.com@spc:bar//shadow1/3.0-1-0.1")
        assert not v.hasParentVersion()
        v = VersionFromString("/foo.com@spc:bar//shadow1//shadow2/3.0-1-0.1")
        assert v.hasParentVersion()
예제 #22
0
    def testVersion(self):
        self.assertRaises(ParseError, VersionFromString, '0.50.1')

        verStr = "/foo.com@spc:bar/1.000:1.2-3/bang.com@spc:branch/10.000:2.4-5"
        verStr2 = "/foo.com@spc:bar/1.000:1.2-3/bang.com@spc:branch/15.000:2.4-6"
        v = ThawVersion(verStr)
        assert (v.freeze() == verStr)
        assert (v.asString(VersionFromString("/foo.com@spc:bar")) ==
                "1.2-3/bang.com@spc:branch/2.4-5")
        assert (v.timeStamps() == [1, 10])
        v = v.copy()
        v.incrementSourceCount()
        assert (v.asString() == ThawVersion(verStr2).asString())
        assert (v.getHost() == 'bang.com')

        # test that cPickle works on a Version object (the changeset cache
        # database pickles versions)
        vpickled = cPickle.dumps(v)
        vunpickled = cPickle.loads(vpickled)
        assert (vunpickled.asString() == v.asString())

        v2 = VersionFromString(
            "/foo.com@spc:bar/1.2-3/bang.com@spc:branch/2.4-5",
            timeStamps=[1.000, 10.000])
        assert (v2.freeze() == verStr)
        assert ([x.asString() for x in v2.iterLabels()
                 ] == ['foo.com@spc:bar', 'bang.com@spc:branch'])

        last = v.trailingRevision()
        assert (last.asString() == "2.4-6")
        assert (not v.onLocalLabel())
        assert (not v.isInLocalNamespace())
        assert (not v.onEmergeLabel())
        assert (not v.onLocalCookLabel())
        assert (v2.getHost() == 'bang.com')

        assert (v.trailingLabel() == Label('bang.com@spc:branch'))

        branch = v.branch()
        assert (branch.getHost() == 'bang.com')
        strrep = branch.asString()
        assert (strrep == "/foo.com@spc:bar/1.2-3/bang.com@spc:branch")
        branch2 = VersionFromString(branch.asString())
        assert (branch == branch2)

        frozen = branch.freeze()
        branch2 = ThawVersion(frozen)
        assert (branch2 == branch)

        newVer = branch2.createVersion(Revision("1.1-2"))
        assert (newVer.asString() ==
                "/foo.com@spc:bar/1.2-3/bang.com@spc:branch/1.1-2")
        assert (not newVer.onLocalLabel())
        assert (not newVer.isInLocalNamespace())
        assert (not newVer.onEmergeLabel())
        assert (not newVer.onLocalCookLabel())
        assert (not newVer.isOnLocalHost())

        assert (newVer.canonicalVersion() == newVer)
        assert (v.hasParentVersion())
        parent = v.parentVersion()
        assert (not parent.hasParentVersion())
        assert (parent.asString() == "/foo.com@spc:bar/1.2-3")

        # check emerge label
        emerge = parent.createBranch(EmergeLabel(), withVerRel=1)
        assert (emerge.getHost() == 'local')
        assert (
            emerge.asString() == "/foo.com@spc:bar/1.2-3/local@local:EMERGE/3")
        assert (not emerge.onLocalLabel())
        assert (emerge.onEmergeLabel())
        assert (not emerge.onRollbackLabel())
        assert (not emerge.onLocalCookLabel())
        assert (emerge.isOnLocalHost())
        assert (emerge.isInLocalNamespace())

        # check local cook label
        cook = parent.createBranch(CookLabel(), withVerRel=1)
        assert (cook.asString() == "/foo.com@spc:bar/1.2-3/local@local:COOK/3")
        assert (not cook.onLocalLabel())
        assert (not cook.onEmergeLabel())
        assert (not cook.onRollbackLabel())
        assert (cook.onLocalCookLabel())
        assert (cook.isOnLocalHost())
        assert (cook.isInLocalNamespace())

        # check local rollback label
        branch2 = parent.createBranch(RollbackLabel(), withVerRel=1)
        assert (branch2.asString() ==
                "/foo.com@spc:bar/1.2-3/local@local:ROLLBACK/3")
        assert (not branch2.onLocalLabel())
        assert (not branch2.onEmergeLabel())
        assert (branch2.onRollbackLabel())
        assert (not branch2.onLocalCookLabel())
        assert (branch2.isOnLocalHost())
        assert (branch2.isInLocalNamespace())

        # check local branch label
        branch2 = parent.createBranch(LocalLabel(), withVerRel=1)
        assert (
            branch2.asString() == "/foo.com@spc:bar/1.2-3/local@local:LOCAL/3")
        assert (branch2.onLocalLabel())
        assert (not branch2.onEmergeLabel())
        assert (not branch2.onRollbackLabel())
        assert (not branch2.onLocalCookLabel())
        assert (branch2.isOnLocalHost())
        assert (branch2.isInLocalNamespace())

        branch3 = VersionFromString(branch2.asString())
        assert (branch2 == branch3)

        branch2 = branch2.branch()
        assert (
            branch2.asString() == "/foo.com@spc:bar/1.2-3/local@local:LOCAL")

        parent = v.parentVersion()
        assert (parent.asString() == "/foo.com@spc:bar/1.2-3")
        branch2 = parent.createBranch(LocalLabel())
        assert (
            branch2.asString() == "/foo.com@spc:bar/1.2-3/local@local:LOCAL")

        shadow = parent.branch().createShadow(Label('foo.com@spc:shadow'))
        assert (shadow.asString() == "/foo.com@spc:bar//shadow")
        assert (shadow.getHost() == 'foo.com')

        branch = VersionFromString("/foo.com@spc:bar")
        v = VersionFromString("1.2-3", branch)
        assert (v.asString() == "/foo.com@spc:bar/1.2-3")

        # test getBinaryVersion and getSourceVersion
        v = ThawVersion(verStr)
        b = v.getBinaryVersion()
        assert (b.asString() ==
                "/foo.com@spc:bar/1.2-3-0/bang.com@spc:branch/2.4-5")

        # make sure slots are working
        v = ThawVersion("/foo.com@spec:bar/10:1.2-3")
        self.assertRaises(AttributeError, v.__setattr__, "foo", 1)
        v = ThawVersion(v.freeze())
        self.assertRaises(AttributeError, v.__setattr__, "foo", 1)

        v = VersionFromString('/localhost@rpl:linux/1.0-1-0/'
                              'local@local:EMERGE/1/COOK/2')
        assert (VersionFromString(v.asString()) == v)
예제 #23
0
    def testVersion(self):
        self.assertRaises(ParseError, VersionFromString, "0.50.1")

        verStr = "/foo.com@spc:bar/1.000:1.2-3/bang.com@spc:branch/10.000:2.4-5"
        verStr2 = "/foo.com@spc:bar/1.000:1.2-3/bang.com@spc:branch/15.000:2.4-6"
        v = ThawVersion(verStr)
        assert v.freeze() == verStr
        assert v.asString(VersionFromString("/foo.com@spc:bar")) == "1.2-3/bang.com@spc:branch/2.4-5"
        assert v.timeStamps() == [1, 10]
        v = v.copy()
        v.incrementSourceCount()
        assert v.asString() == ThawVersion(verStr2).asString()
        assert v.getHost() == "bang.com"

        # test that cPickle works on a Version object (the changeset cache
        # database pickles versions)
        vpickled = cPickle.dumps(v)
        vunpickled = cPickle.loads(vpickled)
        assert vunpickled.asString() == v.asString()

        v2 = VersionFromString("/foo.com@spc:bar/1.2-3/bang.com@spc:branch/2.4-5", timeStamps=[1.000, 10.000])
        assert v2.freeze() == verStr
        assert [x.asString() for x in v2.iterLabels()] == ["foo.com@spc:bar", "bang.com@spc:branch"]

        last = v.trailingRevision()
        assert last.asString() == "2.4-6"
        assert not v.onLocalLabel()
        assert not v.isInLocalNamespace()
        assert not v.onEmergeLabel()
        assert not v.onLocalCookLabel()
        assert v2.getHost() == "bang.com"

        assert v.trailingLabel() == Label("bang.com@spc:branch")

        branch = v.branch()
        assert branch.getHost() == "bang.com"
        strrep = branch.asString()
        assert strrep == "/foo.com@spc:bar/1.2-3/bang.com@spc:branch"
        branch2 = VersionFromString(branch.asString())
        assert branch == branch2

        frozen = branch.freeze()
        branch2 = ThawVersion(frozen)
        assert branch2 == branch

        newVer = branch2.createVersion(Revision("1.1-2"))
        assert newVer.asString() == "/foo.com@spc:bar/1.2-3/bang.com@spc:branch/1.1-2"
        assert not newVer.onLocalLabel()
        assert not newVer.isInLocalNamespace()
        assert not newVer.onEmergeLabel()
        assert not newVer.onLocalCookLabel()
        assert not newVer.isOnLocalHost()

        assert newVer.canonicalVersion() == newVer
        assert v.hasParentVersion()
        parent = v.parentVersion()
        assert not parent.hasParentVersion()
        assert parent.asString() == "/foo.com@spc:bar/1.2-3"

        # check emerge label
        emerge = parent.createBranch(EmergeLabel(), withVerRel=1)
        assert emerge.getHost() == "local"
        assert emerge.asString() == "/foo.com@spc:bar/1.2-3/local@local:EMERGE/3"
        assert not emerge.onLocalLabel()
        assert emerge.onEmergeLabel()
        assert not emerge.onRollbackLabel()
        assert not emerge.onLocalCookLabel()
        assert emerge.isOnLocalHost()
        assert emerge.isInLocalNamespace()

        # check local cook label
        cook = parent.createBranch(CookLabel(), withVerRel=1)
        assert cook.asString() == "/foo.com@spc:bar/1.2-3/local@local:COOK/3"
        assert not cook.onLocalLabel()
        assert not cook.onEmergeLabel()
        assert not cook.onRollbackLabel()
        assert cook.onLocalCookLabel()
        assert cook.isOnLocalHost()
        assert cook.isInLocalNamespace()

        # check local rollback label
        branch2 = parent.createBranch(RollbackLabel(), withVerRel=1)
        assert branch2.asString() == "/foo.com@spc:bar/1.2-3/local@local:ROLLBACK/3"
        assert not branch2.onLocalLabel()
        assert not branch2.onEmergeLabel()
        assert branch2.onRollbackLabel()
        assert not branch2.onLocalCookLabel()
        assert branch2.isOnLocalHost()
        assert branch2.isInLocalNamespace()

        # check local branch label
        branch2 = parent.createBranch(LocalLabel(), withVerRel=1)
        assert branch2.asString() == "/foo.com@spc:bar/1.2-3/local@local:LOCAL/3"
        assert branch2.onLocalLabel()
        assert not branch2.onEmergeLabel()
        assert not branch2.onRollbackLabel()
        assert not branch2.onLocalCookLabel()
        assert branch2.isOnLocalHost()
        assert branch2.isInLocalNamespace()

        branch3 = VersionFromString(branch2.asString())
        assert branch2 == branch3

        branch2 = branch2.branch()
        assert branch2.asString() == "/foo.com@spc:bar/1.2-3/local@local:LOCAL"

        parent = v.parentVersion()
        assert parent.asString() == "/foo.com@spc:bar/1.2-3"
        branch2 = parent.createBranch(LocalLabel())
        assert branch2.asString() == "/foo.com@spc:bar/1.2-3/local@local:LOCAL"

        shadow = parent.branch().createShadow(Label("foo.com@spc:shadow"))
        assert shadow.asString() == "/foo.com@spc:bar//shadow"
        assert shadow.getHost() == "foo.com"

        branch = VersionFromString("/foo.com@spc:bar")
        v = VersionFromString("1.2-3", branch)
        assert v.asString() == "/foo.com@spc:bar/1.2-3"

        # test getBinaryVersion and getSourceVersion
        v = ThawVersion(verStr)
        b = v.getBinaryVersion()
        assert b.asString() == "/foo.com@spc:bar/1.2-3-0/bang.com@spc:branch/2.4-5"

        # make sure slots are working
        v = ThawVersion("/foo.com@spec:bar/10:1.2-3")
        self.assertRaises(AttributeError, v.__setattr__, "foo", 1)
        v = ThawVersion(v.freeze())
        self.assertRaises(AttributeError, v.__setattr__, "foo", 1)

        v = VersionFromString("/localhost@rpl:linux/1.0-1-0/" "local@local:EMERGE/1/COOK/2")
        assert VersionFromString(v.asString()) == v
예제 #24
0
    def testGetSourceVersion(self):
        v = VersionFromString(
            '/conary.rpath.com@rpl:linux/4.3-1-0/autconf213/1')
        assert (not v.isBranchedBinary())
        source = v.getSourceVersion()
        assert (not source.isBranchedBinary())
        assert (source.asString() ==
                '/conary.rpath.com@rpl:linux/4.3-1/autconf213/1')

        # binary branched
        v = VersionFromString(
            '/conary.rpath.com@rpl:linux/4.3-1-1/autconf213/1')
        assert (v.isBranchedBinary())
        source = v.getSourceVersion()
        assert (not source.isBranchedBinary())
        assert (source.asString() == '/conary.rpath.com@rpl:linux/4.3-1')

        # make sure timestamps are removed
        v = ThawVersion('/conary.rpath.com@rpl:linux/1:4.3-1-0/autconf213/2:1')
        source = v.getSourceVersion()
        assert (source.timeStamps() == [0, 0])

        v = ThawVersion('/conary.rpath.com@rpl:linux/1:4.3-1-1/autconf213/2:1')
        source = v.getSourceVersion()
        assert (source.timeStamps() == [0])
예제 #25
0
    def testShadows(self):
        self.doTestVersion('/foo@spc:linux//shadow/1-1.2')
        self.doTestVersion('/foo@spc:linux//shadow/1-1-1.2')
        self.doTestVersion('/foo@spc:linux//shadow/1-1-1/branch//shadow2/1.1')
        self.doTestVersion('/foo@spc:linux//shadow/1-1-1/branch//shadow2/'
                           '/shadow3/1.1.1')

        self.assertRaises(ParseError, VersionFromString,
                          '/foo@spc:linux//shadow/1-1.2.3')
        self.assertRaises(ParseError, VersionFromString,
                          '/foo@spc:linux//shadow/1-1-1.2.3')
        self.assertRaises(ParseError, VersionFromString,
                          '/foo@spc:linux//shadow/1-1-1/branch/1.1')
        self.assertRaises(
            ParseError, VersionFromString,
            '/foo@spc:linux//shadow/1-1-1/branch//shadow2/1.1.1')
        self.assertRaises(
            ParseError, VersionFromString,
            '/foo@spc:linux//shadow/1-1-1/branch//shadow2/'
            '/shadow3/1.1.1.1')

        trunk = VersionFromString('/foo@spc:linux')
        assert (not trunk.isShadow())
        assert (not trunk.hasParentBranch())
        shadow = trunk.createShadow(Label('foo@spc:shadow'))
        assert (shadow.isShadow())
        assert (shadow.asString() == '/foo@spc:linux//shadow')
        assert (shadow.hasParentBranch())
        assert (shadow.parentBranch() == trunk)
        version = shadow.createVersion(Revision('1.1-1'))
        assert (version.isShadow())
        assert (not version.isModifiedShadow())
        assert (version.asString() == '/foo@spc:linux//shadow/1.1-1')
        assert (
            version.canonicalVersion().asString() == '/foo@spc:linux/1.1-1')
        assert (version.shadowLength() == 1)
        newVer = version.createShadow(Label("foo@spc:shadow2"))
        assert (newVer.asString() == '/foo@spc:linux//shadow//shadow2/1.1-1')
        assert (newVer.shadowLength() == 2)
        assert (newVer.parentVersion().asString() ==
                '/foo@spc:linux//shadow/1.1-1')
        assert (newVer.parentVersion().parentVersion().asString() ==
                '/foo@spc:linux/1.1-1')
        assert (newVer.canonicalVersion().asString() == '/foo@spc:linux/1.1-1')
        assert (newVer.isShadow())
        assert (not newVer.canonicalVersion().isShadow())
        assert (not newVer.canonicalVersion().isModifiedShadow())

        self.assertRaises(AssertionError, newVer.createBranch,
                          Label("foo@spc:shadow2"))
        self.assertRaises(VersionStringError, newVer.createShadow,
                          Label("foo@spc:shadow2"))

        branch = newVer.createBranch(Label("foo@spc:branch"))
        assert (branch.asString() ==
                '/foo@spc:linux//shadow//shadow2/1.1-1/branch')

        branchVer = newVer.createBranch(Label("foo@spc:branch"),
                                        withVerRel=True)
        assert (branchVer.asString() ==
                '/foo@spc:linux//shadow//shadow2/1.1-1/branch/1')
        assert (branchVer.shadowLength() == 0)
        assert (not branchVer.isShadow())

        newVer.incrementSourceCount()
        assert (
            newVer.asString() == '/foo@spc:linux//shadow//shadow2/1.1-1.0.1')
        assert (newVer.isModifiedShadow())
        branchVer.incrementSourceCount()
        assert (branchVer.asString() ==
                '/foo@spc:linux//shadow//shadow2/1.1-1/branch/2')
        assert (ThawVersion(branchVer.freeze()) == branchVer)

        newShadow = branchVer.createShadow(Label('foo@spc:shadow3'))
        assert (newShadow.asString() ==
                '/foo@spc:linux//shadow//shadow2/1.1-1/branch//shadow3/2')
        assert (newShadow.parentVersion().asString() ==
                '/foo@spc:linux//shadow//shadow2/1.1-1/branch/2')
        assert (newShadow.parentVersion().parentVersion().asString() ==
                '/foo@spc:linux//shadow//shadow2/1.1-1')
        assert (newShadow.parentVersion().parentVersion().parentVersion().
                asString() == '/foo@spc:linux//shadow/1.1-1')
        assert (newShadow.parentVersion().parentVersion().parentVersion().
                parentVersion().asString() == '/foo@spc:linux/1.1-1')
        assert (newShadow.canonicalVersion().asString() ==
                '/foo@spc:linux//shadow//shadow2/1.1-1/branch/2')

        # shadowed binary has a parent version
        v = VersionFromString("/foo@spc:linux//shadow/1.2-1-1")
        assert (v.hasParentVersion())
        # shadowed source has a parent version
        v = VersionFromString("/foo@spc:linux//shadow/1.2-1")
        assert (v.hasParentVersion())
        # cooked shadowed binary doesn't has a parent version
        v = VersionFromString("/foo@spc:linux//shadow/1.2-1-0.1")
        assert (not v.hasParentVersion())

        v = VersionFromString("/foo@spc:linux//shadow/1.2-1").copy()
        assert (v.hasParentVersion())
        v.incrementBuildCount()
        assert (v.asString() == "/foo@spc:linux//shadow/1.2-1-0.1")
        assert (not v.hasParentVersion())
        v2 = v.createBranch(LocalLabel(), withVerRel=True)
        assert (v2.asString() ==
                "/foo@spc:linux//shadow/1.2-1-0.1/local@local:LOCAL/1")

        v = VersionFromString("/foo@spc:linux//shadow/1.2-1.1").copy()
        v.incrementBuildCount()
        assert (v.asString() == "/foo@spc:linux//shadow/1.2-1.1-1")
        assert (not v.hasParentVersion())

        # test to make sure versions don't count -0 having a build count
        v = VersionFromString('/a@b:c/4.1.25-18-0/d//e/22.3-1')
        assert (not v.hasParentVersion())

        # If you create a pristine shadow of a modified shadow,
        # that version should NOT be a modifiedShadow
        v = VersionFromString("/foo@spc:linux//shadow//shadow2/1.2-1.1")
        assert (v.isShadow() and not v.isModifiedShadow())
        v = v.parentVersion()
        assert (v.isShadow() and v.isModifiedShadow())

        v = VersionFromString("/foo@spc:linux//shadow//shadow2/1.2-1.0.1")
        assert (v.isShadow() and v.isModifiedShadow())
예제 #26
0
    def testUnmodifiedShadowParent(self):
        '''
        Shadows of unmodified shadows have parents, too.
        @tests: CNY-2812
        '''

        # Shadow of an unmodified shadow
        x = VersionFromString(
            '/c.r.com@rpl:devel//1//p.r.com@rpath:widgets/yarr-1.0.2')
        self.assertTrue(x.hasParentVersion())
        self.assertEqual(x.parentVersion(),
                         VersionFromString('/c.r.com@rpl:devel//1/yarr-1'))

        # Shadow of a shadow that changed upstream version
        y = VersionFromString(
            '/c.r.com@rpl:devel//1//p.r.com@rpath:widgets/yarr-0.1.2')
        self.assertTrue(y.hasParentVersion())
        self.assertEqual(y.parentVersion(),
                         VersionFromString('/c.r.com@rpl:devel//1/yarr-0.1'))

        # Shadow that changed upstream version (no parent)
        z = VersionFromString(
            '/c.r.com@rpl:devel//1//p.r.com@rpath:widgets/yarr-0.0.1')
        self.assertFalse(z.hasParentVersion())
예제 #27
0
    def testCommitChangesetByDefaultExcluded(self):
        # this test creates two changesets.  The first includes
        # test=1.0-1-1, test:foo=1.0-1-1 and a reference to 
        # test:bar-1.0-1-1 (but not included).  This gets committed
        # to the database.
        # The next version of the test package no longer has a test:bar
        # component.  A changeset is generated between test=1.0-1-1 and
        # test=1.1-1-1.  The resulting changeset is committed to the
        # database

        cl = conaryclient.ConaryClient(self.cfg)

        versionPrefix = '/' + self.cfg.buildLabel.asString() + '/'
        flavor = parseFlavor('')

        # create an absolute changeset
        cs = changeset.ChangeSet()
        # add a pkg diff
        v1 = VersionFromString(versionPrefix + '1.0-1-1',
                              timeStamps=[1.000])
        old = trove.Trove('test', v1, flavor, None)
        old.addTrove('test:foo', v1, flavor, byDefault=True)
        old.addTrove('test:bar', v1, flavor, byDefault=False)
        old.setIsCollection(True)
        old.computeDigests()

        # add the 'test' package
        diff = old.diff(None)[0]
        cs.newTrove(diff)
        cs.addPrimaryTrove('test', v1, flavor)

        # add the test:foo component
        oldfoo = trove.Trove('test:foo', v1, flavor, None)
        oldfoo.computeDigests()
        diff = oldfoo.diff(None)[0]
        cs.newTrove(diff)

        # note that we do not add a test:bar diff to the
        # changeset.  this is because it's not included by default
        # (byDefault=False)

        # commit the first changeset to the database
        cs.writeToFile(self.workDir + '/first.ccs')
        cs = changeset.ChangeSetFromFile(self.workDir + '/first.ccs')
        cs = cl.updateChangeSet([ ("test", (None, None), (v1, flavor), True) ], 
                                fromChangesets = [cs])[0]
        cl.applyUpdate(cs)

        # create a relative changeset
        cs = changeset.ChangeSet()
        v2 = VersionFromString(versionPrefix + '1.1-1-1',
                              timeStamps=[2.000])
        new = trove.Trove('test', v2, flavor, None)
        new.addTrove('test:foo', v2, flavor, byDefault=True)
        new.setIsCollection(True)
        new.computeDigests()

        # add the new 'test' package
        diff = new.diff(old)[0]
        cs.newTrove(diff)
        cs.addPrimaryTrove('test', v2, flavor)

        # add new test:foo component
        newfoo = trove.Trove('test:foo', v2, flavor, None)
        newfoo.computeDigests()
        diff = newfoo.diff(oldfoo)[0]
        cs.newTrove(diff)

        # mark test:bar as being removed
        cs.oldTrove('test:bar', v1, flavor)
        
        cs.writeToFile(self.workDir + '/second.ccs')
        cs = changeset.ChangeSetFromFile(self.workDir + '/second.ccs')
        cs = cl.updateChangeSet([ ('test', (None, None), (v2, flavor), True) ],
                                fromChangesets = [cs])[0]

        # commit the second changeset to the database
        cl.applyUpdate(cs)
        db = cl.db
        e = [('test', v2, flavor)]
        assert(db.findTrove(None, ('test', '1.1-1-1', None)) == e)
        e = [('test:foo', v2, flavor)]
        assert(db.findTrove(None, ('test:foo', '1.1-1-1', None)) == e)
예제 #28
0
 def doTestAbbrev(self, fullStr, abbrevStr):
     full = VersionFromString(fullStr)
     abbrev = VersionFromString(abbrevStr)
     assert (full.asString() == abbrevStr)
     assert (abbrev.asString() == abbrevStr)
     assert (full == abbrev)
예제 #29
0
 def doTestVersion(self, abbrevStr):
     abbrev = VersionFromString(abbrevStr)
     assert abbrev.asString() == abbrevStr
예제 #30
0
    def testVersion20Migration(self):
        dbfile = os.path.join(resources.get_archive(), 'conarydbs',
                              'conarydb-version-19')
        fd, fn = tempfile.mkstemp()
        os.close(fd)
        shutil.copyfile(dbfile, fn)
        # get a list of tables
        db = dbstore.connect(fn, driver='sqlite')
        db.loadSchema()
        cu = db.cursor()
        tableCounts = dict.fromkeys(db.tables.keys())
        for table in tableCounts.keys():
            tableCounts[table] = cu.execute('select count(*) from %s' %
                                            table).fetchall()[0][0]
        # DBInstances is gone...
        tableCounts.pop('DBInstances')
        # we have a VersionId 0 entry now
        tableCounts['Versions'] += 1
        # new table added
        tableCounts['DatabaseAttributes'] = 1

        # do the migration
        db, str = self.captureOutput(sqldb.Database, fn)
        cu = db.db.cursor()

        # make sure we have all the tables
        db2 = dbstore.connect(fn, driver='sqlite')
        db2.loadSchema()
        cu = db2.cursor()
        tableCounts2 = dict.fromkeys(db2.tables.keys())
        for table in tableCounts2.keys():
            tableCounts2[table] = cu.execute('select count(*) from %s' %
                                             table).fetchall()[0][0]
        self.assertEqual(tableCounts, tableCounts2)

        # check to make sure that we fixed our broken deps and troveinfo
        cu.execute("select count(*) from troveinfo where infoType=3 "
                   "and hex(data) == '31'")
        assert (cu.next()[0] == 0)
        cu.execute("select count(*) from dependencies where "
                   "name like 'conary:%' and flag='1'")
        assert (cu.next()[0] == 0)

        # verify the conary:runtime trove
        v = VersionFromString('/conary.rpath.com@rpl:devel//1/1.0-2-0.1')
        f = deps.parseFlavor('~!bootstrap is: x86')
        t = db.getTroves([('conary:runtime', v, f)])[0]
        t.verifyDigitalSignatures()

        # verify that we can insert a '1.0' into deps and troveinfo
        cu.execute("insert into Dependencies values (NULL, 4, 'test', '1.0')")
        cu.execute("select flag from Dependencies where name='test'")
        assert (cu.next()[0] == '1.0')

        cu.execute("insert into TroveInfo values (300, 3, '1.0')")
        cu.execute("select data from TroveInfo where instanceId=300 and "
                   "infotype=3")
        assert (cu.next()[0] == '1.0')

        db.close()
        db2.close()

        # make sure the addition of DatabaseAttributes happens correctly
        db = dbstore.connect(fn, driver='sqlite')
        db.loadSchema()
        self.assertTrue('DatabaseAttributes' in db.tables)
        cu = db.cursor()
        cu.execute("DROP TABLE DatabaseAttributes")
        db.commit()
        db.close()

        sdb = sqldb.Database(fn)
        self.assertTrue('DatabaseAttributes' in sdb.db.tables)
        del sdb

        os.unlink(fn)
예제 #31
0
 def doTestVersion(self, abbrevStr):
     abbrev = VersionFromString(abbrevStr)
     assert (abbrev.asString() == abbrevStr)
예제 #32
0
    def testShadows(self):
        self.doTestVersion("/foo@spc:linux//shadow/1-1.2")
        self.doTestVersion("/foo@spc:linux//shadow/1-1-1.2")
        self.doTestVersion("/foo@spc:linux//shadow/1-1-1/branch//shadow2/1.1")
        self.doTestVersion("/foo@spc:linux//shadow/1-1-1/branch//shadow2/" "/shadow3/1.1.1")

        self.assertRaises(ParseError, VersionFromString, "/foo@spc:linux//shadow/1-1.2.3")
        self.assertRaises(ParseError, VersionFromString, "/foo@spc:linux//shadow/1-1-1.2.3")
        self.assertRaises(ParseError, VersionFromString, "/foo@spc:linux//shadow/1-1-1/branch/1.1")
        self.assertRaises(ParseError, VersionFromString, "/foo@spc:linux//shadow/1-1-1/branch//shadow2/1.1.1")
        self.assertRaises(
            ParseError, VersionFromString, "/foo@spc:linux//shadow/1-1-1/branch//shadow2/" "/shadow3/1.1.1.1"
        )

        trunk = VersionFromString("/foo@spc:linux")
        assert not trunk.isShadow()
        assert not trunk.hasParentBranch()
        shadow = trunk.createShadow(Label("foo@spc:shadow"))
        assert shadow.isShadow()
        assert shadow.asString() == "/foo@spc:linux//shadow"
        assert shadow.hasParentBranch()
        assert shadow.parentBranch() == trunk
        version = shadow.createVersion(Revision("1.1-1"))
        assert version.isShadow()
        assert not version.isModifiedShadow()
        assert version.asString() == "/foo@spc:linux//shadow/1.1-1"
        assert version.canonicalVersion().asString() == "/foo@spc:linux/1.1-1"
        assert version.shadowLength() == 1
        newVer = version.createShadow(Label("foo@spc:shadow2"))
        assert newVer.asString() == "/foo@spc:linux//shadow//shadow2/1.1-1"
        assert newVer.shadowLength() == 2
        assert newVer.parentVersion().asString() == "/foo@spc:linux//shadow/1.1-1"
        assert newVer.parentVersion().parentVersion().asString() == "/foo@spc:linux/1.1-1"
        assert newVer.canonicalVersion().asString() == "/foo@spc:linux/1.1-1"
        assert newVer.isShadow()
        assert not newVer.canonicalVersion().isShadow()
        assert not newVer.canonicalVersion().isModifiedShadow()

        self.assertRaises(AssertionError, newVer.createBranch, Label("foo@spc:shadow2"))
        self.assertRaises(VersionStringError, newVer.createShadow, Label("foo@spc:shadow2"))

        branch = newVer.createBranch(Label("foo@spc:branch"))
        assert branch.asString() == "/foo@spc:linux//shadow//shadow2/1.1-1/branch"

        branchVer = newVer.createBranch(Label("foo@spc:branch"), withVerRel=True)
        assert branchVer.asString() == "/foo@spc:linux//shadow//shadow2/1.1-1/branch/1"
        assert branchVer.shadowLength() == 0
        assert not branchVer.isShadow()

        newVer.incrementSourceCount()
        assert newVer.asString() == "/foo@spc:linux//shadow//shadow2/1.1-1.0.1"
        assert newVer.isModifiedShadow()
        branchVer.incrementSourceCount()
        assert branchVer.asString() == "/foo@spc:linux//shadow//shadow2/1.1-1/branch/2"
        assert ThawVersion(branchVer.freeze()) == branchVer

        newShadow = branchVer.createShadow(Label("foo@spc:shadow3"))
        assert newShadow.asString() == "/foo@spc:linux//shadow//shadow2/1.1-1/branch//shadow3/2"
        assert newShadow.parentVersion().asString() == "/foo@spc:linux//shadow//shadow2/1.1-1/branch/2"
        assert newShadow.parentVersion().parentVersion().asString() == "/foo@spc:linux//shadow//shadow2/1.1-1"
        assert newShadow.parentVersion().parentVersion().parentVersion().asString() == "/foo@spc:linux//shadow/1.1-1"
        assert (
            newShadow.parentVersion().parentVersion().parentVersion().parentVersion().asString()
            == "/foo@spc:linux/1.1-1"
        )
        assert newShadow.canonicalVersion().asString() == "/foo@spc:linux//shadow//shadow2/1.1-1/branch/2"

        # shadowed binary has a parent version
        v = VersionFromString("/foo@spc:linux//shadow/1.2-1-1")
        assert v.hasParentVersion()
        # shadowed source has a parent version
        v = VersionFromString("/foo@spc:linux//shadow/1.2-1")
        assert v.hasParentVersion()
        # cooked shadowed binary doesn't has a parent version
        v = VersionFromString("/foo@spc:linux//shadow/1.2-1-0.1")
        assert not v.hasParentVersion()

        v = VersionFromString("/foo@spc:linux//shadow/1.2-1").copy()
        assert v.hasParentVersion()
        v.incrementBuildCount()
        assert v.asString() == "/foo@spc:linux//shadow/1.2-1-0.1"
        assert not v.hasParentVersion()
        v2 = v.createBranch(LocalLabel(), withVerRel=True)
        assert v2.asString() == "/foo@spc:linux//shadow/1.2-1-0.1/local@local:LOCAL/1"

        v = VersionFromString("/foo@spc:linux//shadow/1.2-1.1").copy()
        v.incrementBuildCount()
        assert v.asString() == "/foo@spc:linux//shadow/1.2-1.1-1"
        assert not v.hasParentVersion()

        # test to make sure versions don't count -0 having a build count
        v = VersionFromString("/a@b:c/4.1.25-18-0/d//e/22.3-1")
        assert not v.hasParentVersion()

        # If you create a pristine shadow of a modified shadow,
        # that version should NOT be a modifiedShadow
        v = VersionFromString("/foo@spc:linux//shadow//shadow2/1.2-1.1")
        assert v.isShadow() and not v.isModifiedShadow()
        v = v.parentVersion()
        assert v.isShadow() and v.isModifiedShadow()

        v = VersionFromString("/foo@spc:linux//shadow//shadow2/1.2-1.0.1")
        assert v.isShadow() and v.isModifiedShadow()
예제 #33
0
 def _cl(first, second):
     f = VersionFromString(first)
     s = VersionFromString(second)
     c = f.closeness(s)
     return c
예제 #34
0
 def testIsInLocalNamespace(self):
     v = VersionFromString("/foo.com@local:linux/1.0-1")
     assert v.isInLocalNamespace()
예제 #35
0
 def _cl(first, second):
     f = VersionFromString(first)
     s = VersionFromString(second)
     c = f.closeness(s)
     return c