Skip to content

Commit

Permalink
Add info about failed MG to email report
Browse files Browse the repository at this point in the history
Signed-off-by: Petr Balogh <[email protected]>
  • Loading branch information
petr-balogh committed Jan 21, 2025
1 parent 996d8d2 commit 2b07848
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 20 deletions.
8 changes: 4 additions & 4 deletions ocs_ci/framework/pytest_customization/ocscilib.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
)
from ocs_ci.ocs.cluster import check_clusters
from ocs_ci.ocs.resources.ocs import get_version_info
from ocs_ci.ocs.utils import collect_ocs_logs, collect_prometheus_metrics, mg_fail_count
from ocs_ci.ocs import utils
from ocs_ci.utility.utils import (
dump_config_to_file,
get_ceph_version,
Expand Down Expand Up @@ -759,15 +759,15 @@ def pytest_runtest_makereport(item, call):
"purple_squad",
}
# For every failure in MG we are trying to extend next attempt by 20 minutes
adjusted_timeout = mg_fail_count * 1200
adjusted_timeout = utils.mg_fail_count * 1200
timeout = ocsci_config.REPORTING.get(
"must_gather_timeout", 3600 + adjusted_timeout
)
log.info(f"Adjusted timeout for MG is {timeout} seconds")
mcg_logs_collection = bool(mcg_markers_to_collect & item_markers)
try:
if not ocsci_config.RUN.get("is_ocp_deployment_failed"):
collect_ocs_logs(
utils.collect_ocs_logs(
dir_name=test_case_name,
ocp=ocp_logs_collection,
ocs=ocs_logs_collection,
Expand All @@ -789,7 +789,7 @@ def pytest_runtest_makereport(item, call):
metrics = item.get_closest_marker("gather_metrics_on_fail").args
try:
threading_lock = call.getfixturevalue("threading_lock")
collect_prometheus_metrics(
utils.collect_prometheus_metrics(
metrics,
f"{item.name}-{call.when}",
call.start,
Expand Down
10 changes: 10 additions & 0 deletions ocs_ci/utility/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -1722,6 +1722,16 @@ def parse_html_for_email(soup):
skipped[0].string.replace_with(
f"{skipped_number} skipped ({skips_ceph_health_ratio * 100}% on Ceph health)"
)
from ocs import utils

if utils.mg_fail_count:
failed_mg_text = soup.new_tag("b")
failed_mg_text.string = (
f"In this execution Must Gather collection has failed: {utils.mg_fail_count} times!"
" Please check why this has happened!"
)
main_header = soup.find("h1")
main_header.insert_after(failed_mg_text)

main_header = soup.find("h1")
main_header.string.replace_with("OCS-CI RESULTS")
Expand Down
25 changes: 9 additions & 16 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,15 +79,7 @@
from ocs_ci.ocs.resources.mcg_replication_policy import AwsLogBasedReplicationPolicy
from ocs_ci.ocs.resources.mockup_bucket_logger import MockupBucketLogger
from ocs_ci.ocs.scale_lib import FioPodScale
from ocs_ci.ocs.utils import (
setup_ceph_toolbox,
collect_ocs_logs,
collect_pod_container_rpm_package,
get_dr_operator_versions,
mg_collected_types,
mg_collected_logs,
mg_fail_count,
)
from ocs_ci.ocs import utils
from ocs_ci.ocs.resources.deployment import Deployment
from ocs_ci.ocs.resources.job import get_job_obj
from ocs_ci.ocs.resources.backingstore import (
Expand Down Expand Up @@ -1755,7 +1747,7 @@ def additional_testsuite_properties(record_testsuite_property, pytestconfig):
# add markers as separated property
markers = ocsci_config.RUN["cli_params"].get("-m", "").replace(" ", "-")
record_testsuite_property("rp_markers", markers)
dr_operator_versions = get_dr_operator_versions()
dr_operator_versions = utils.get_dr_operator_versions()
for dr_operator_name, dr_operator_version in dr_operator_versions.items():
record_testsuite_property(f"rp_{dr_operator_name}", dr_operator_version)

Expand Down Expand Up @@ -4068,7 +4060,7 @@ def ceph_toolbox(request):
):
try:
# Creating toolbox pod
setup_ceph_toolbox()
utils.setup_ceph_toolbox()
except CommandFailed:
log.info("Failed to create toolbox")

Expand Down Expand Up @@ -4623,10 +4615,11 @@ def finalizer():
for mg_target in ["ocs", "ocp"]:
try:
if (
mg_collected_logs
and mg_target in mg_collected_types
utils.mg_collected_logs
and mg_target in utils.mg_collected_types
and (
mg_fail_count < config.REPORTING["max_mg_fail_attempts"]
utils.mg_fail_count
< config.REPORTING["max_mg_fail_attempts"]
)
):
log.info(
Expand All @@ -4637,7 +4630,7 @@ def finalizer():
if mg_target == "ocs":
timeout = 7200
log.info("Collecting OCP logs on Success run!")
collect_ocs_logs(
utils.collect_ocs_logs(
"testcases",
ocs="ocs" == mg_target,
ocp="ocp" == mg_target,
Expand All @@ -4650,7 +4643,7 @@ def finalizer():
failure_in_mg.append((mg_target, ex))
log.error(f"Failure in {mg_target}, {ex}")
try:
collect_pod_container_rpm_package("testcases")
utils.collect_pod_container_rpm_package("testcases")
except Exception as ex:
failure_in_mg.append(("rpm_package_info", ex))
log.error(f"Failure in {mg_target}, {ex}")
Expand Down

0 comments on commit 2b07848

Please sign in to comment.