#723 Fix bug log PDC communications and info for modular composes
Merged 6 years ago by dowang. Opened 6 years ago by dowang.
dowang/pungi log-pdc  into  master

file modified
+1
@@ -11,3 +11,4 @@ 

  tests/_composes

  htmlcov/

  .coverage

+ .idea/

@@ -169,15 +169,16 @@ 

              koji_wrapper, compose.conf["sigkeys"], logger=compose._logger,

              arches=all_arches)

          variant_tags[variant] = []

- 

+         pdc_module_file = os.path.join(compose.paths.work.topdir(arch="global"), "pdc-module-%s.json" % variant.uid)

+         pdc_modules = []

          # Find out all modules in every variant and add their compose tags

          # to compose_tags list.

          if session:

              for module in variant.get_modules():

                  pdc_module = get_module(session, module["name"])

+                 pdc_modules.append(pdc_module)

                  mmd = modulemd.ModuleMetadata()

                  mmd.loads(pdc_module["modulemd"])

- 

                  # Add RPMs from PDC response to modulemd, so we can track

                  # what RPM is in which module later in gather phase.

                  for rpm_nevra in pdc_module["rpms"]:
@@ -190,7 +191,8 @@ 

                  variant_tags[variant].append(tag)

                  if tag not in compose_tags:

                      compose_tags.append(tag)

- 

+         if pdc_modules:

+             json.dump(pdc_modules, open(pdc_module_file, 'w'))

          if not variant_tags[variant]:

              variant_tags[variant].extend(force_list(compose.conf["pkgset_koji_tag"]))

  

file modified
+3
@@ -45,6 +45,9 @@ 

          return [v for v in self.variants.values()

                  if (not arch or arch in v.arches) and (not types or v.type in types)]

  

+     def get_modules(self, arch=None, types=None):

+         return []

+ 

  

  class IterableMock(mock.Mock):

      def __iter__(self):

@@ -93,6 +93,7 @@ 

          self.compose.DEBUG = False

          self.koji_wrapper = mock.Mock()

          self.pkgset_path = os.path.join(self.topdir, 'work', 'global', 'pkgset_global.pickle')

+         self.pdc_module_path = os.path.join(self.topdir, 'work', 'global', 'pdc-module-Server.json')

  

      @mock.patch('cPickle.dumps')

      @mock.patch('pungi.phases.pkgset.pkgsets.KojiPackageSet')
@@ -119,6 +120,26 @@ 

  

      @mock.patch('cPickle.dumps')

      @mock.patch('pungi.phases.pkgset.pkgsets.KojiPackageSet')

+     @mock.patch('pungi.phases.pkgset.sources.source_koji.get_module')

+     @mock.patch('pungi.phases.pkgset.sources.source_koji.get_pdc_client_session')

+     @mock.patch('pungi.phases.pkgset.sources.source_koji.modulemd')

+     def test_pdc_log(self, modulemd, get_pdc_client_session, get_module, KojiPackageSet, pickle_dumps):

+ 

+         pickle_dumps.return_value = 'DATA'

+ 

+         get_module.return_value = {'abc': 'def', 'modulemd': 'sth', 'rpms': [], 'koji_tag': 'taggg'}

+         for name, variant in self.compose.variants.iteritems():

+             variant.get_modules = mock.MagicMock()

+             if name == 'Server':

+                 variant.get_modules.return_value = [{'name': 'a'}]

+ 

+         source_koji.populate_global_pkgset(

+             self.compose, self.koji_wrapper, '/prefix', 123456)

+         with open(self.pdc_module_path, 'r') as pdc_f:

+             self.assertEqual(pdc_f.read(), '[{"rpms": [], "abc": "def", "koji_tag": "taggg", "modulemd": "sth"}]')

+ 

+     @mock.patch('cPickle.dumps')

+     @mock.patch('pungi.phases.pkgset.pkgsets.KojiPackageSet')

      def test_populate_with_multiple_koji_tags(self, KojiPackageSet, pickle_dumps):

          self.compose = helpers.DummyCompose(self.topdir, {

              'pkgset_koji_tag': ['f25', 'f25-extra'],

This import seems redundant. Can you remove it?

There should be a space after the first :.

The tests are failing on Jenkins due to pdc-client and modulemd not being installed. I changed the configuration to install them.

Please also shorten the commit message to Log PDC communications and info for modular composes and add a sign-off (git commit -s).

rebased onto 9f0620b

6 years ago

Looks good to me. I'll rebase on current master and merge.

Commit 463fb96 fixes this pull-request

Pull-Request has been merged by dowang@redhat.com

6 years ago