Beispiel #1
0
 def testTwoChangeSetsWithSameTroveAndDiffConfig(self):
     trv = self.addComponent('foo:run=1', [('/etc/config', 'v1\n')])
     trv2 = self.addComponent('foo:run=2', [('/etc/config', 'v2\n')])
     repos = self.openRepository()
     csPath = self.workDir + '/foo.ccs'
     csPath2 = self.workDir + '/foo.ccs'
     self.changeset(repos, 'foo:run=1--2', csPath)
     self.changeset(repos, 'foo:run=1--2', csPath2)
     cs1 = changeset.ChangeSetFromFile(csPath)
     cs2 = changeset.ChangeSetFromFile(csPath2)
     self.updatePkg('foo:run=1')
     db = self.openDatabase()
     source = ChangesetFilesTroveSource(db)
     source.addChangeSets([cs1, cs2], True)
     n, v, f = trv.getNameVersionFlavor()
     v2, f2 = trv2.getNameVersionFlavor()[1:]
     # this used to traceback when there were two changesets that both
     # provided the same trove in the same source, (if the changesets
     # were relative and involved a config file)
     newCs, remainder = source.createChangeSet([(n, (v, f),
                                                 (v2, f2), False)],
                                               withFiles=True,
                                               withFileContents=True,
                                               useDatabase=True)
     assert (not remainder)
Beispiel #2
0
 def testTwoChangeSetsWithSameTroveAndDiffConfig(self):
     trv = self.addComponent('foo:run=1', [('/etc/config', 'v1\n')])
     trv2 = self.addComponent('foo:run=2', [('/etc/config', 'v2\n')])
     repos = self.openRepository()
     csPath = self.workDir + '/foo.ccs'
     csPath2 = self.workDir + '/foo.ccs'
     self.changeset(repos, 'foo:run=1--2', csPath)
     self.changeset(repos, 'foo:run=1--2', csPath2)
     cs1 = changeset.ChangeSetFromFile(csPath)
     cs2 = changeset.ChangeSetFromFile(csPath2)
     self.updatePkg('foo:run=1')
     db = self.openDatabase()
     source = ChangesetFilesTroveSource(db)
     source.addChangeSets([cs1, cs2], True)
     n, v, f = trv.getNameVersionFlavor()
     v2, f2 = trv2.getNameVersionFlavor()[1:]
     # this used to traceback when there were two changesets that both 
     # provided the same trove in the same source, (if the changesets
     # were relative and involved a config file)
     newCs, remainder = source.createChangeSet([(n, (v, f), (v2, f2), False)],
                                      withFiles=True, withFileContents=True,
                                      useDatabase=True)
     assert(not remainder)
Beispiel #3
0
    def testCreateNewChangesetNotInSource(self):
        # Test creating a relative changeset when all we have in the
        # source is absolute changesets, and vice versa.
        r1 = self.addCollection('foo', '1', [':run'], createComps=True)
        self.addComponent('foo:run', '2', filePrimer=2)
        r2 = self.addCollection('foo', '2', [':run'])

        # create two absolute changesets, we want one relative one out
        absChg = [('foo', (None, None), (r1.getVersion(), r1.getFlavor()), True),
               ('foo', (None, None), (r2.getVersion(), r2.getFlavor()), True)]
        repos = self.openRepository()
        absCs = repos.createChangeSet(absChg, recurse=True)

        trvSrc = ChangesetFilesTroveSource(None)
        trvSrc.addChangeSet(absCs)

        relChg = ('foo', (r1.getVersion(), r1.getFlavor()),
                         (r2.getVersion(), r2.getFlavor()), False)
        newCs, remainder = trvSrc.createChangeSet([relChg], recurse=False,
                                       withFiles=False, withFileContents=False)
        assert(not remainder)
        trvCs = newCs.iterNewTroveList().next()
        assert(trvCs.getNewVersion() == r2.getVersion())
        assert(trvCs.getOldVersion() == r1.getVersion())

        # now we'll try to get a relative changeset out when we don't 
        # have the new trove that we'd need to make the relative changeset 
        # work
        badChg = ('foo', (r1.getVersion(), r1.getFlavor()),
                      (r2.getVersion(), deps.parseFlavor('foo')), False)
        newCs, remainder = trvSrc.createChangeSet([badChg], recurse=False,
                                       withFiles=False, withFileContents=False)
        assert(remainder)
        assert(newCs.isEmpty())

        # now we'll try to get a relative changeset out when we don't 
        # have the _old_ trove that we'd need to make the relative changeset 
        # work
        badChg = ('foo', (r1.getVersion(), deps.parseFlavor('foo')),
                      (r2.getVersion(), r2.getFlavor()), False)
        newCs, remainder = trvSrc.createChangeSet([badChg], recurse=False,
                                       withFiles=False, withFileContents=False)
        assert(remainder)
        assert(newCs.isEmpty())

        # Now test getting absolute changesets when the trovesource only has
        # relative ones.  This requires using the database to grab information
        # from the installed system about the old versions of troves.

        # First try creating those absolute changesets when there is
        # no information about the old trove on the system
        relCs = repos.createChangeSet([relChg], recurse=True)
        db = self.openDatabase()
        trvSrc = ChangesetFilesTroveSource(db)
        trvSrc.addChangeSet(relCs)
        newCs, remainder = trvSrc.createChangeSet(absChg, recurse=False,
                                       withFiles=False, withFileContents=False)
        assert(len(remainder) == 2)
        assert(newCs.isEmpty())

        # now create them when the old trove has been installed.
        self.updatePkg(['foo=%s' % r1.getVersion()])
        # FIXME - we need to recreate the changeset files source here -
        # apparently some information pertaining to what is installed is
        # cached
        trvSrc = ChangesetFilesTroveSource(db)
        trvSrc.addChangeSet(relCs)
        newCs, remainder = trvSrc.createChangeSet(absChg, recurse=False,
                                       withFiles=False, withFileContents=False)
        assert(not remainder)
        assert(len(list(newCs.iterNewTroveList())) == 2)
Beispiel #4
0
    def testCreateNewChangesetNotInSource(self):
        # Test creating a relative changeset when all we have in the
        # source is absolute changesets, and vice versa.
        r1 = self.addCollection('foo', '1', [':run'], createComps=True)
        self.addComponent('foo:run', '2', filePrimer=2)
        r2 = self.addCollection('foo', '2', [':run'])

        # create two absolute changesets, we want one relative one out
        absChg = [
            ('foo', (None, None), (r1.getVersion(), r1.getFlavor()), True),
            ('foo', (None, None), (r2.getVersion(), r2.getFlavor()), True)
        ]
        repos = self.openRepository()
        absCs = repos.createChangeSet(absChg, recurse=True)

        trvSrc = ChangesetFilesTroveSource(None)
        trvSrc.addChangeSet(absCs)

        relChg = ('foo', (r1.getVersion(), r1.getFlavor()),
                  (r2.getVersion(), r2.getFlavor()), False)
        newCs, remainder = trvSrc.createChangeSet([relChg],
                                                  recurse=False,
                                                  withFiles=False,
                                                  withFileContents=False)
        assert (not remainder)
        trvCs = newCs.iterNewTroveList().next()
        assert (trvCs.getNewVersion() == r2.getVersion())
        assert (trvCs.getOldVersion() == r1.getVersion())

        # now we'll try to get a relative changeset out when we don't
        # have the new trove that we'd need to make the relative changeset
        # work
        badChg = ('foo', (r1.getVersion(), r1.getFlavor()),
                  (r2.getVersion(), deps.parseFlavor('foo')), False)
        newCs, remainder = trvSrc.createChangeSet([badChg],
                                                  recurse=False,
                                                  withFiles=False,
                                                  withFileContents=False)
        assert (remainder)
        assert (newCs.isEmpty())

        # now we'll try to get a relative changeset out when we don't
        # have the _old_ trove that we'd need to make the relative changeset
        # work
        badChg = ('foo', (r1.getVersion(), deps.parseFlavor('foo')),
                  (r2.getVersion(), r2.getFlavor()), False)
        newCs, remainder = trvSrc.createChangeSet([badChg],
                                                  recurse=False,
                                                  withFiles=False,
                                                  withFileContents=False)
        assert (remainder)
        assert (newCs.isEmpty())

        # Now test getting absolute changesets when the trovesource only has
        # relative ones.  This requires using the database to grab information
        # from the installed system about the old versions of troves.

        # First try creating those absolute changesets when there is
        # no information about the old trove on the system
        relCs = repos.createChangeSet([relChg], recurse=True)
        db = self.openDatabase()
        trvSrc = ChangesetFilesTroveSource(db)
        trvSrc.addChangeSet(relCs)
        newCs, remainder = trvSrc.createChangeSet(absChg,
                                                  recurse=False,
                                                  withFiles=False,
                                                  withFileContents=False)
        assert (len(remainder) == 2)
        assert (newCs.isEmpty())

        # now create them when the old trove has been installed.
        self.updatePkg(['foo=%s' % r1.getVersion()])
        # FIXME - we need to recreate the changeset files source here -
        # apparently some information pertaining to what is installed is
        # cached
        trvSrc = ChangesetFilesTroveSource(db)
        trvSrc.addChangeSet(relCs)
        newCs, remainder = trvSrc.createChangeSet(absChg,
                                                  recurse=False,
                                                  withFiles=False,
                                                  withFileContents=False)
        assert (not remainder)
        assert (len(list(newCs.iterNewTroveList())) == 2)