#2181 frontend: fix get-build-task for PR directories
Merged 4 months ago by praiskup. Opened 4 months ago by praiskup.
copr/ praiskup/copr dirname-fix  into  main

@@ -15,6 +15,7 @@ 

  #DATABASE = './tmp/copr.db' # when executing >1 test instances use different db

  #DATABASE = os.path.join(LOCAL_TMP_DIR, 'copr.db')

  

+ DIST_GIT_CLONE_URL = "http://copr-dist-git-dev.fedorainfracloud.org/git"

  

  OPENID_STORE = os.path.join(LOCAL_TMP_DIR, 'openid_store')

  WHOOSHEE_DIR = os.path.join(LOCAL_TMP_DIR, 'whooshee')

@@ -2003,6 +2003,16 @@ 

              built_packages.append(result_dict)

          return {"packages": built_packages}

  

+     @property

+     def distgit_clone_url(self):

+         """

+         Considering self.build.copr_dir and self.build.package is correctly set,

+         return the dist git clone url for that package.  We can not use

+         self.build.package.dist_git_clone_url because of issue#617.

+         """

+         dirname = self.build.copr_dir.full_name

+         package = self.build.package.name

+         return "{}/{}/{}".format(app.config["DIST_GIT_CLONE_URL"], dirname, package)

  

  

  class BuildChrootResult(db.Model, helpers.Serializer):

@@ -141,7 +141,7 @@ 

              "memory_reqs": task.build.memory_reqs,

              "timeout": task.build.timeout,

              "enable_net": task.build.enable_net,

-             "git_repo": task.build.package.dist_git_clone_url,

+             "git_repo": task.distgit_clone_url,

              "git_hash": task.git_hash,

              "package_name": task.build.package.name,

              "package_version": task.build.pkg_version,

@@ -96,3 +96,30 @@ 

          assert action.action_type == 11

          assert set(json.loads(action.data)) == set(["user1/test-pr-dirs:pr:2",

                                                      "user1/test-pr-dirs:pr:3"])

+ 

+     @TransactionDecorator("u1")

+     @new_app_context

+     @pytest.mark.usefixtures("f_users", "f_mock_chroots", "f_users_api", "f_db")

+     def test_coprdir_build_normal_then_pr(self):

+         chroot = "fedora-17-i386"

+         self.api3.new_project("test-pr-dirs", [chroot])

+         self.api3.create_distgit_package("test-pr-dirs", "tar", {"webhook_rebuild": True})

+         self.api3.rebuild_package("test-pr-dirs", "tar")

+         self.backend.finish_build(1, package_name="tar")

+         assert models.Build.query.count() == 1

+ 

+         url = "/backend/get-build-task/1-{}".format(chroot)

+         response = self.test_client.get(url)

+         assert response.status_code == 200

+         result_dict = json.loads(response.data)

+ 

+         repo_url = "http://copr-dist-git-dev.fedorainfracloud.org/git/user1/{}/tar"

+         assert result_dict["git_repo"] == repo_url.format("test-pr-dirs")

+ 

+         self.pr_trigger.build_package_with_args("test-pr-dirs", "tar", 1)

+ 

+         url = "/backend/get-build-task/2-{}".format(chroot)

+         response = self.test_client.get(url)

+         assert response.status_code == 200

+         result_dict = json.loads(response.data)

+         assert result_dict["git_repo"] == repo_url.format("test-pr-dirs:pr:1")

@@ -18,6 +18,7 @@ 

          r = self.tc.get("/backend/get-build-task/" + str(self.b2.id) + "-fedora-18-x86_64", headers=self.auth_header).data

          data = json.loads(r.decode("utf-8"))

          assert 'modules' not in data

+         assert data["git_repo"] == "http://copr-dist-git-dev.fedorainfracloud.org/git/user1/foocopr/hello-world"

  

      def test_module_name_enable(self, f_users, f_coprs, f_mock_chroots, f_builds, f_db):

          self.c1.copr_chroots[0].module_toggle = "XXX"

Because we have the database design problem #617, we need to be more
precise when selecting the build-related CoprDir instance
(the build.package.copr_dirname != build.copr_dirname).

Build failed. More information on how to proceed and troubleshoot errors available at https://fedoraproject.org/wiki/Zuul-based-ci

rebased onto 43f0d3d

4 months ago

Build succeeded.

Per @frostyx's ack, hot-fixed in prod.

Commit d13ada0 fixes this pull-request

Pull-Request has been merged by praiskup

4 months ago