#1057 Add tests for "Conflicts: module(name)" in MMDResolver.
Merged 6 months ago by mprahl. Opened 6 months ago by jkaluza.
jkaluza/fm-orchestrator solv-stream-conflict  into  master

@@ -332,7 +332,14 @@ 

              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)

  

@@ -260,3 +260,23 @@ 

                         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)

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.

Pull-Request has been merged by mprahl

6 months ago