diff --git a/daily_tests/daily_nightly_tests_report.py b/daily_tests/daily_nightly_tests_report.py index c02a5cb..29277a8 100755 --- a/daily_tests/daily_nightly_tests_report.py +++ b/daily_tests/daily_nightly_tests_report.py @@ -36,7 +36,7 @@ "lholmqui@redhat.com", "cpapasta@redhat.com", "nodeshiftcore@redhat.com", - "jprokop@redhat.com" + "jprokop@redhat.com", ], } @@ -99,6 +99,8 @@ # The default directory used for nightly build RESULTS_DIR = "/var/tmp/daily_reports_dir" +# The default directory used for running build +SCLORG_DIR = "/var/tmp/daily_scl_tests" class NightlyTestsReport(object): @@ -154,6 +156,16 @@ def prepare(self) -> bool: self.log_dir = self.args.log_dir return True + def get_pastebin_url(self, log_name: str) -> str: + with open(log_name, "r") as f: + lines = f.read() + + for line in lines.split("\n"): + if not line.startswith("Link:"): + continue + return line.replace("Link:", "").strip() + return "" + def collect_data(self): # Collect data to class dictionary # self.data_dict['tmt'] item is used for Testing Farm errors per each OS and test case @@ -171,10 +183,19 @@ def collect_data(self): path_dir = Path(RESULTS_DIR) / test_case if not path_dir.is_dir(): print(f"The test case {path_dir} does not exists that is weird") - self.data_dict["tmt"]["msg"].append( + self.data_dict["tmt"]["logs"].append( f"Nightly build tests for {test_case} is not finished or did not run. " f"Check nightly build machine for logs." ) + for sclorg in ["S2I", "NOS2I"]: + name = f"{test_case}-{sclorg}" + self.data_dict["tmt"]["logs"].append( + ( + name, + Path(SCLORG_DIR) / f"{test_case}-{sclorg}" / "log.txt", + f"{name}.txt", + ) + ) failed_tests = True continue # It looks like TMT is still running for long time @@ -227,17 +248,10 @@ def collect_data(self): continue print(f"Failed containers are for {test_case} are: {failed_containers}") failed_tests = True - for cont in failed_containers: - mime_name = f"{test_case}-{cont.name}" - attach = MIMEApplication(open(cont, "r").read(), Name=mime_name) - attach.add_header( - "Content-Disposition", 'attachment; filename="{}"'.format(mime_name) - ) - self.mime_msg.attach(attach) + self.data_dict[test_case] = [ (str(f), str(f.name)) for f in failed_containers ] - print(failed_tests) if not failed_tests: self.full_success = True print(f"collect data: {self.data_dict}") @@ -252,13 +266,11 @@ def generate_email_body(self): body_failure = "Nightly builds Testing Farm failures:
" body_success = "These nightly builds were completely successful:
" # Function for generation mail body - if self.data_dict["tmt"]["msg"]: - tmt_failures = "
".join(self.data_dict["tmt"]["msg"]) + if self.data_dict["tmt"]["logs"]: self.body += ( f"{body_failure}\n" f"Tests were not successful because Testing Farm failures. " f"Please contact phracek@redhat.com to analyse it.

" - f"{tmt_failures}

" ) self.generate_tmt_logs_containers() if self.data_dict["SUCCESS"]: @@ -281,10 +293,15 @@ def generate_failed_containers(self): for test_case, plan, msg in self.available_test_case: if test_case not in self.data_dict: continue - print(f"generate_email_body: {self.data_dict[test_case]}") + print( + f"generate_email_body_for_failed_containers: {self.data_dict[test_case]}" + ) self.body += f"
{msg}
List of failed containers:
" - for _, name in self.data_dict[test_case]: - self.body += f"{name}
" + for full_log_name, name in self.data_dict[test_case]: + self.body += ( + f"{name}" + f"
" + ) def generate_success_containers(self): for test_case, cont_path, log_name in self.data_dict["SUCCESS_DATA"]: @@ -298,13 +315,12 @@ def generate_success_containers(self): def generate_tmt_logs_containers(self): for test_case, cont_path, log_name in self.data_dict["tmt"]["logs"]: - mime_name = f"{test_case}-{log_name}" + print(cont_path, log_name) if os.path.exists(cont_path): - attach = MIMEApplication(open(cont_path, "r").read(), Name=mime_name) - attach.add_header( - "Content-Disposition", 'attachment; filename="{}"'.format(mime_name) + self.body += ( + f"{test_case}" + f"

" ) - self.mime_msg.attach(attach) def generate_emails(self): for test_case, plan, _ in self.available_test_case: diff --git a/daily_tests/daily_scl_tests.sh b/daily_tests/daily_scl_tests.sh index 3230368..58bdf9e 100755 --- a/daily_tests/daily_scl_tests.sh +++ b/daily_tests/daily_scl_tests.sh @@ -41,6 +41,8 @@ TMP_DIR="${TMT_PLAN_DATA}" RESULT_DIR="${TMP_DIR}/results/" KUBECONFIG=/root/.kube/config KUBEPASSWD=/root/.kube/ocp-kube +PBINCLI=/usr/local/bin/pbincli +PBINCLI_OPTS="--server https://privatebin.corp.redhat.com --expire 1week --no-insecure-warning --no-check-certificate --format plaintext" mkdir -p "${RESULT_DIR}" @@ -94,7 +96,7 @@ function iterate_over_all_containers() { make "${TESTS}" TARGET="${TARGET}" > "${log_name}" 2>&1 if [[ $? -ne 0 ]]; then echo "Tests for container $repo has failed." - cp "${log_name}" "${RESULT_DIR}/" + $PBINCLI send $PBINCLI_OPTS < "${log_name}" > "${RESULT_DIR}/${log_name}.txt" 2>&1 echo "Show the last 100 lines from file: ${RESULT_DIR}/${repo}.log" tail -100 "${RESULT_DIR}/${repo}.log" fi