diff --git a/src/validation/testcase/base.py b/src/validation/testcase/base.py index e23e2c5..70f8b14 100644 --- a/src/validation/testcase/base.py +++ b/src/validation/testcase/base.py @@ -52,15 +52,19 @@ def run_test(self): opening PR close it. :return: """ - self.run_checks() - if self.failure_msg: - message = f"{self.pr.title} ({self.pr.url}) failed: {self.failure_msg}" + try: + self.run_checks() + if self.failure_msg: + message = f"{self.pr.title} ({self.pr.url}) failed: {self.failure_msg}" - log_failure(message) + log_failure(message) - if self.trigger == Trigger.pr_opened: - self.pr.close() - self.pr_branch_ref.delete() + if self.trigger == Trigger.pr_opened: + self.pr.close() + self.pr_branch_ref.delete() + except Exception as e: + msg = f"Validation test {self.pr.title} ({self.pr.url}) failed: {e}" + logging.error(msg) def trigger_build(self): """ @@ -210,9 +214,10 @@ def check_build_submitted(self): self.deployment.copr_user, self.copr_project_name, ) - except Exception: + except Exception as e: # project does not exist yet - logging.info("Copr project doesn't exist yet") + msg = f"Copr project doesn't exist yet: {e}" + logging.warning(msg) continue if len(new_builds) >= old_build_len + 1: diff --git a/src/validation/testcase/gitlab.py b/src/validation/testcase/gitlab.py index 971c6a6..4f669e7 100644 --- a/src/validation/testcase/gitlab.py +++ b/src/validation/testcase/gitlab.py @@ -20,7 +20,7 @@ def get_status_name(self, status: CommitFlag) -> str: return status.context def construct_copr_project_name(self) -> str: - return f"gitlab.com-packit-service-hello-world-{self.pr.id}" + return f"{self.project.service.hostname}-{self.project.namespace}-hello-world-{self.pr.id}" def create_file_in_new_branch(self, branch: str): self.pr_branch_ref = self.project.gitlab_repo.branches.create( diff --git a/src/validation/tests/base.py b/src/validation/tests/base.py index 5c0f4ea..ee7bca2 100644 --- a/src/validation/tests/base.py +++ b/src/validation/tests/base.py @@ -15,10 +15,15 @@ class Tests: test_case_kls: type def run(self): - logging.info("Run testcases where the build is triggered by a ‹vm-image-build› comment") prs_for_comment = [ pr for pr in self.project.get_pr_list() if pr.title.startswith("Test VM Image builds") ] + if prs_for_comment: + logging.info("Run testcases where the build is triggered by a ‹vm-image-build› comment") + else: + logging.warning( + "No testcases found where the build is triggered by a ‹vm-image-build› comment", + ) for pr in prs_for_comment: self.test_case_kls( project=self.project, @@ -28,10 +33,13 @@ def run(self): comment=DEPLOYMENT.pr_comment_vm_image_build, ).run_test() - logging.info("Run testcases where the build is triggered by a ‹build› comment") prs_for_comment = [ pr for pr in self.project.get_pr_list() if pr.title.startswith("Basic test case:") ] + if prs_for_comment: + logging.info("Run testcases where the build is triggered by a ‹build› comment") + else: + logging.warning("No testcases found where the build is triggered by a ‹build› comment") for pr in prs_for_comment: self.test_case_kls( project=self.project, @@ -40,12 +48,15 @@ def run(self): deployment=DEPLOYMENT, ).run_test() - logging.info("Run testcase where the build is triggered by push") pr_for_push = [ pr for pr in self.project.get_pr_list() if pr.title.startswith(DEPLOYMENT.push_trigger_tests_prefix) ] + if pr_for_push: + logging.info("Run testcase where the build is triggered by push") + else: + logging.warning("No testcase found where the build is triggered by push") if pr_for_push: self.test_case_kls( project=self.project,