Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Truncate initial bug description if it is too long. Fixes #374 #379

Merged
merged 3 commits into from
Sep 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions components/bugzilla.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,11 @@ def __init__(self, config):

@logEntryExit
def file_bug(self, library, summary, description, cc_list, needinfo=None, see_also=None, depends_on=None, blocks=None, moco_confidential=False):
if len(description) > 65535:
self.logger.log("New bug description is too long: %s characters; truncating." % (len(description)), level=LogLevel.Warning)
suffix = "\n\nOops - the above comment was too long. I was unable to shrink it nicely, so I had to truncate it to fit Bugzilla's limits."
description = description[0:65533 - len(suffix)] + suffix

try:
bugID = fileBug(self.config['url'], self.config['apikey'], self.config['General']['ff-version'],
library.bugzilla_product, library.bugzilla_component,
Expand Down
7 changes: 5 additions & 2 deletions components/utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,12 +144,15 @@ def decorate(func):
# Retry calling a function `times` times, sleeping between each tries, with an exponential backoff
# This is to be used on API calls, that are likely to fail

RETRY_TIMES = 10

def retry(_func=None, *, times=10, sleep_s=1, exp=2):

def retry(_func=None, *, sleep_s=1, exp=2):
def decorator_retry(func):
@functools.wraps(func)
def wrapper_retry(*args, **kwargs):
retries_try = times
global RETRY_TIMES
retries_try = RETRY_TIMES
sleep_duration = sleep_s
while retries_try > 0:
try:
Expand Down
5 changes: 4 additions & 1 deletion tests/functionality_all_platforms.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@

sys.path.append(".")
sys.path.append("..")
import components.utilities
components.utilities.RETRY_TIMES = 2

from automation import Updatebot

from components.utilities import Struct, raise_, AssertFalse
Expand Down Expand Up @@ -462,7 +465,7 @@ def testTryLockedOutput(self):

def try_output():
nonlocal call_counter
if call_counter < 2:
if call_counter < 1:
call_counter += 1
return (1, TRY_LOCKED_OUTPUT)
return (0, TRY_OUTPUT(expected_values.try_revision_id()))
Expand Down
3 changes: 3 additions & 0 deletions tests/functionality_commitalert.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@

sys.path.append(".")
sys.path.append("..")
import components.utilities
components.utilities.RETRY_TIMES = 2

from automation import Updatebot

from components.utilities import Struct, NeverUseMeClass
Expand Down
6 changes: 5 additions & 1 deletion tests/functionality_two_platforms.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@

sys.path.append(".")
sys.path.append("..")
import components.utilities
components.utilities.RETRY_TIMES = 2

from automation import Updatebot

from components.utilities import Struct, raise_, AssertFalse
Expand All @@ -34,6 +37,7 @@
from tests.mock_treeherder_server import MockTreeherderServerFactory, TYPE_HEALTH
from tests.database import transform_db_config_to_tmp_db


try:
from localconfig import localconfig
except ImportError:
Expand Down Expand Up @@ -439,7 +443,7 @@ def testTryLockedOutput(self):

def try_output():
nonlocal call_counter
if call_counter < 2:
if call_counter < 1:
call_counter += 1
return (1, TRY_LOCKED_OUTPUT)
return (0, TRY_OUTPUT(expected_values.try_revisions_func()[0]))
Expand Down
Loading