Exemple #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)
Exemple #2
0
    def testSimple(self):
        r1 = self.addComponent('test:runtime', '1.0-1-1', fileContents = [], requires='trove: test:doc')
        r2 = self.addComponent('test:runtime', '2.0-1-1', fileContents = [], requires='soname: ELF32/foo.so.0(a b c) trove: test:doc')
        d1 = self.addComponent('test:doc', '1.0-1-1', filePrimer = 1)
        l1 = self.addComponent('test:lib', '1.0-1-1', filePrimer = 2,
                               provides='soname: ELF32/foo.so.0(a b c d)')

        db = database.Database(':memory:', ':memory:')
        db.addTrove(r1)

        repos = self.openRepository()
        relCs = repos.createChangeSet([ 
                    ('test:runtime', (r1.getVersion(), r1.getFlavor()),
                                     (r2.getVersion(), r2.getFlavor()),
                     False) ])

        absCs = repos.createChangeSet([ 
                    ('test:doc',     (None, None),
                                     (d1.getVersion(), d1.getFlavor()),
                     False),
                    ('test:lib',     (None, None),
                                     (l1.getVersion(), l1.getFlavor()),
                     False) ])

        trvSrc = ChangesetFilesTroveSource(db, storeDeps=True)
        trvSrc.addChangeSet(relCs)
        trvSrc.addChangeSet(absCs)

        for trv in (r2, d1, l1):
            [ otherTrv ] = trvSrc.getTroves([ (trv.getName(), trv.getVersion(),
                                               trv.getFlavor()) ], 
                                            withFiles = False)
            assert(trv == otherTrv)

        suggMap = trvSrc.resolveDependencies(None, [r2.getRequires(),
                                                    r1.getRequires()])
        assert(suggMap[r1.getRequires()] == [[(d1.getName(), d1.getVersion(), 
                                              d1.getFlavor())]])
        suggs = suggMap[r2.getRequires()]
        assert([(d1.getName(), d1.getVersion(), d1.getFlavor())] in suggs)
        assert([(l1.getName(), l1.getVersion(), l1.getFlavor())] in suggs)
Exemple #3
0
    def testUselessRelChangeset(self):
        # don't consider a new version of a trove 'present' if it requires
        # that a relative changeset be applied to a trove that we don't
        # have installed.
        r1 = self.addCollection('foo', '1', [':run'], createComps=True)
        r2 = self.addCollection('foo', '2', [':run'], createComps=True)

        db = database.Database(':memory:', ':memory:')
        db.addTrove(r1) # this doesn't add foo:run to the db!



        chg = ('foo', (r1.getVersion(), r1.getFlavor()),
                      (r2.getVersion(), r2.getFlavor()), False)
        repos = self.openRepository()
        relCs = repos.createChangeSet([chg], recurse=True)

        trvSrc = ChangesetFilesTroveSource(db, storeDeps=True)
        trvSrc.addChangeSet(relCs)
        fooRun = ('foo:run', r2.getVersion(), r2.getFlavor())
        assert(trvSrc.hasTroves([fooRun]) == [False])
        assert(trvSrc.hasTroves([r2.getNameVersionFlavor()]) == [True])
Exemple #4
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)
Exemple #5
0
    def testSimple(self):
        r1 = self.addComponent('test:runtime',
                               '1.0-1-1',
                               fileContents=[],
                               requires='trove: test:doc')
        r2 = self.addComponent(
            'test:runtime',
            '2.0-1-1',
            fileContents=[],
            requires='soname: ELF32/foo.so.0(a b c) trove: test:doc')
        d1 = self.addComponent('test:doc', '1.0-1-1', filePrimer=1)
        l1 = self.addComponent('test:lib',
                               '1.0-1-1',
                               filePrimer=2,
                               provides='soname: ELF32/foo.so.0(a b c d)')

        db = database.Database(':memory:', ':memory:')
        db.addTrove(r1)

        repos = self.openRepository()
        relCs = repos.createChangeSet([
            ('test:runtime', (r1.getVersion(), r1.getFlavor()),
             (r2.getVersion(), r2.getFlavor()), False)
        ])

        absCs = repos.createChangeSet([
            ('test:doc', (None, None), (d1.getVersion(), d1.getFlavor()),
             False),
            ('test:lib', (None, None), (l1.getVersion(), l1.getFlavor()),
             False)
        ])

        trvSrc = ChangesetFilesTroveSource(db, storeDeps=True)
        trvSrc.addChangeSet(relCs)
        trvSrc.addChangeSet(absCs)

        for trv in (r2, d1, l1):
            [otherTrv] = trvSrc.getTroves(
                [(trv.getName(), trv.getVersion(), trv.getFlavor())],
                withFiles=False)
            assert (trv == otherTrv)

        suggMap = trvSrc.resolveDependencies(
            None, [r2.getRequires(), r1.getRequires()])
        assert (suggMap[r1.getRequires()] == [[(d1.getName(), d1.getVersion(),
                                                d1.getFlavor())]])
        suggs = suggMap[r2.getRequires()]
        assert ([(d1.getName(), d1.getVersion(), d1.getFlavor())] in suggs)
        assert ([(l1.getName(), l1.getVersion(), l1.getFlavor())] in suggs)
Exemple #6
0
    def testUselessRelChangeset(self):
        # don't consider a new version of a trove 'present' if it requires
        # that a relative changeset be applied to a trove that we don't
        # have installed.
        r1 = self.addCollection('foo', '1', [':run'], createComps=True)
        r2 = self.addCollection('foo', '2', [':run'], createComps=True)

        db = database.Database(':memory:', ':memory:')
        db.addTrove(r1)  # this doesn't add foo:run to the db!

        chg = ('foo', (r1.getVersion(), r1.getFlavor()),
               (r2.getVersion(), r2.getFlavor()), False)
        repos = self.openRepository()
        relCs = repos.createChangeSet([chg], recurse=True)

        trvSrc = ChangesetFilesTroveSource(db, storeDeps=True)
        trvSrc.addChangeSet(relCs)
        fooRun = ('foo:run', r2.getVersion(), r2.getFlavor())
        assert (trvSrc.hasTroves([fooRun]) == [False])
        assert (trvSrc.hasTroves([r2.getNameVersionFlavor()]) == [True])
Exemple #7
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)
Exemple #8
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)