Add tests for "Conflicts: module(name)" in MMDResolver.

The test tests installation of multiple streams of single module.
For example:
 - "app:1" requires "foo:1" and "gtk:1".
 - "foo:1" requires "bar:1".
 - "gtk:1" requires "bar:2".
"bar:1" and "bar:2" cannot be installed in the same time and therefore
there need to be conflict defined between them.
This commit is contained in:
Jan Kaluza
2018-10-25 16:01:36 +02:00
parent 77ee4b2185
commit 6b496dfde4
2 changed files with 28 additions and 1 deletions

View File

@@ -332,7 +332,14 @@ class MMDResolver(object):
log.debug("Adding module %s with requires: %r", solvable.name, requires)
solvable.add_deparray(solv.SOLVABLE_REQUIRES, requires)
# Add "Conflicts: module(name)", because TODO, ask ignatenko.
# Add "Conflicts: module(name)".
# This is needed to prevent installation of multiple streams of single module.
# For example:
# - "app:1" requires "foo:1" and "gtk:1".
# - "foo:1" requires "bar:1".
# - "gtk:1" requires "bar:2".
# "bar:1" and "bar:2" cannot be installed in the same time and therefore
# there need to be conflict defined between them.
solvable.add_deparray(solv.SOLVABLE_CONFLICTS, pool.Dep("module(%s)" % n))
solvables.append(solvable)

View File

@@ -260,3 +260,23 @@ class TestMMDResolver:
for e in exp)
assert expanded == expected
def test_solve_stream_conflicts(self):
# app requires both gtk:1 and foo:1.
# gtk:1 requires bar:1
# foo:1 requires bar:2.
# We cannot install both bar:1 and bar:2 in the same time.
# Therefore the solving should fail.
modules = (
("platform:f29:0:c0", {}),
('gtk:1:1:c2', {'bar': ['1']}),
('foo:1:1:c2', {'bar': ['2']}),
('bar:1:0:c2', {'platform': ['f29']}),
('bar:2:0:c2', {'platform': ['f29']}),
)
for n, req in modules:
self.mmd_resolver.add_modules(self._make_mmd(n, req))
app = self._make_mmd("app:1:0", {'gtk': '1', 'foo': '1'})
with pytest.raises(RuntimeError):
self.mmd_resolver.solve(app)