#351 Generate Pulp repos in case we are generating extra ODCS compose for unpublished image.
Merged 3 months ago by jkaluza. Opened 3 months ago by jkaluza.
jkaluza/freshmaker spec-fix  into  master

@@ -272,8 +272,13 @@ 

                  db.session.commit()

  

                  if state != ArtifactBuildState.FAILED.value:

-                     # Store odcs pulp compose to build

-                     if image["generate_pulp_repos"]:

+                     # Store odcs pulp compose to build.

+                     # Also generate pulp repos in case the image is unpublished,

+                     # because in this case, we have to generate extra ODCS compose

+                     # with all the RPMs in the image anyway later. And OSBS works

+                     # in a way that we have to pass all the ODCS composes to it or

+                     # no ODCS compose at all.

+                     if image["generate_pulp_repos"] or not image["published"]:

                          # Check if the compose for these content_sets is

                          # already cached and use it in this case.

                          cache_key = " ".join(sorted(image["content_sets"]))

@@ -784,7 +784,7 @@ 

                  "generate_pulp_repos": False,

                  "arches": "x86_64",

                  "odcs_compose_ids": None,

-                 "published": False,

+                 "published": True,

              })]

          ]

  

@@ -800,6 +800,46 @@ 

          self.assertEqual(ArtifactBuildState.PLANNED.value, parent_image.state)

          self.mock_prepare_pulp_repo.assert_not_called()

  

+     def test_record_batches_generate_pulp_repos_when_image_unpublished(self):

+         batches = [

+             [ContainerImage({

+                 "brew": {

+                     "completion_date": "20170420T17:05:37.000-0400",

+                     "build": "rhel-server-docker-7.3-82",

+                     "package": "rhel-server-docker"

+                 },

+                 'parsed_data': {

+                     'layers': [

+                         'sha512:12345678980',

+                         'sha512:10987654321'

+                     ]

+                 },

+                 "parent": None,

+                 "content_sets": ["content-set-1"],

+                 "repository": "repo-1",

+                 "commit": "123456789",

+                 "target": "target-candidate",

+                 "git_branch": "rhel-7",

+                 "error": None,

+                 "generate_pulp_repos": False,

+                 "arches": "x86_64",

+                 "odcs_compose_ids": None,

+                 "published": False,

+             })]

+         ]

+ 

+         handler = RebuildImagesOnRPMAdvisoryChange()

+         handler._record_batches(batches, self.mock_event)

+ 

+         # Check parent image

+         query = db.session.query(ArtifactBuild)

+         parent_image = query.filter(

+             ArtifactBuild.original_nvr == 'rhel-server-docker-7.3-82'

+         ).first()

+         self.assertNotEqual(None, parent_image)

+         self.assertEqual(ArtifactBuildState.PLANNED.value, parent_image.state)

+         self.mock_prepare_pulp_repo.assert_called()

+ 

      def test_pulp_compose_generated_just_once(self):

          batches = [

              [ContainerImage({

In case when image is unpublished, we need to generate an extra ODCS compose with
possibly unpublished RPMs which exist only in Koji so far.

We can pass this extra compose to Koji using "compose_ids" build option.

But the issue is that when "compose_ids" is set, Koji/OSBS completely ignores the
Pulp repos defined in the content_sets.yml file and it overrides it by whathever
we passes to it using compose_ids.

Because of that, we need to generate also the Pulp repos on Freshmaker's side
in this case and pass it together with extra compose in the compose_ids.

The test name states that it should not generate_pulp_repos but the last line of this test checks if prepare_pulp_repo is called. Am I missing something here?

The test name is wrong. It's copy-paste issue from older test. I will rename it.

rebased onto f31238e

3 months ago

Commit fa84258 fixes this pull-request

Pull-Request has been merged by jkaluza

3 months ago

Pull-Request has been merged by jkaluza

3 months ago