[SERVER-31942] Large changes in unreliable tests can prevent test lifecycle update Created: 13/Nov/17  Updated: 30/Oct/23  Resolved: 23/Jan/18

Status: Closed
Project: Core Server
Component/s: Testing Infrastructure
Affects Version/s: None
Fix Version/s: 3.6.3, 3.7.2

Type: Bug Priority: Major - P3
Reporter: Yves Duhem Assignee: Yves Duhem
Resolution: Fixed Votes: 0
Labels: pull-request
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Attachments: PNG File Screen Shot 2018-01-17 at 4.22.17 PM.png     PNG File Screen Shot 2018-01-18 at 4.32.49 PM.png     PNG File Screen Shot 2018-01-18 at 4.34.27 PM.png     PNG File Screen Shot 2018-01-18 at 5.37.40 PM.png     PNG File Screen Shot 2018-01-18 at 5.45.19 PM.png    
Issue Links:
Backports
Depends
Backwards Compatibility: Fully Compatible
Operating System: ALL
Backport Requested:
v3.6
Participants:
Linked BF Score: 0

 Description   

When the update_test_lifecycle task sees changes in unreliable tests, it creates a JIRA issue before committing the changes.
The description of the issue contains the tag changes and if there are many of them the description text size can exceed the allowed limit for the field (32,767 characters).
When that happens the task fails and the changes are not committed.

Instead we should truncate the description when its size exceeds the allowed limit.



 Comments   
Comment by Githook User [ 25/Jan/18 ]

Author:

{'name': 'Chibuikem Amaechi', 'email': 'cramaechi@me.com', 'username': 'cramaechi'}

Message: SERVER-31942 Truncate test lifecycle JIRA issue description
Closes #1204

Signed-off-by: Yves Duhem <yves.duhem@mongodb.com>
(cherry picked from commit ad0ab27807a29e025b36a82ede139c975ad65cfb)
Branch: v3.6
https://github.com/mongodb/mongo/commit/d3ce3de42626fc1e7c779e2d915320c43763ac03

Comment by Githook User [ 23/Jan/18 ]

Author:

{'name': 'Chibuikem Amaechi', 'email': 'cramaechi@me.com', 'username': 'cramaechi'}

Message: SERVER-31942 Truncate test lifecycle JIRA issue description
Closes #1204

Signed-off-by: Yves Duhem <yves.duhem@mongodb.com>
Branch: master
https://github.com/mongodb/mongo/commit/ad0ab27807a29e025b36a82ede139c975ad65cfb

Comment by Kelsey Schubert [ 20/Jan/18 ]

yves.duhem, I've gone ahead and linked the pull request to this ticket. Would you please take a look?

Thanks,
Kelsey

Comment by Chibuikem Amaechi [ 19/Jan/18 ]

Hi Yves,

Thank you for the helpful notes. I will apply the changes and open a pull request.

Best Regards,
Chibuikem. A

Comment by Yves Duhem [ 19/Jan/18 ]

Hi Chibuikem,

Here is some feedback on the changes but feel free to submit a pull request referencing this ticket as it'll be easier to discuss code changes on github.

_truncate_description()


Our convention is to limit the Python lines to 100 characters and line 607 would exceed that. Could you put it on two lines like I did in my example?

_get_jira_description()


On line 633, _truncate_description() needs to be referenced as JiraIssueCreator._truncate_description.
And some trivial style adjustment: could you align the strings on lines 624-629 with the one on line 623?

Unit tests

I would suggest adding a new method test_truncate_description() and do two checks:

  • generate a string of size inferior or equal to the max size (e.g. "a" * JiraIssueCreator._MAX_DESCRIPTION_SIZE) and check that the _truncate_description() method returns the same string
  • generate a string of size strictly superior to the max size (e.g. "a" * (1 + JiraIssueCreator._MAX_DESCRIPTION_SIZE)) and check that the _truncate_description() method returns a string of size inferior or equal to the max size.

Thanks!

Comment by Chibuikem Amaechi [ 19/Jan/18 ]

Hi Yves,

The following changes were made to the JiraIssueCreator class:

The following changes were made to the TestJiraIssueCreator class:

Modified file(s): mongo/buildscripts/update_test_lifecycle.py, mongo/buildscripts/tests/test_update_test_lifecycle.py

Please share your thoughts.

Comment by Chibuikem Amaechi [ 18/Jan/18 ]

Hi Yves,

Sounds good. I will make the improvements and follow up.

Thank you.

Comment by Yves Duhem [ 18/Jan/18 ]

Hi Chibuikem,

After taking a look at the surrounding code, I realized that the method you proposed changing only handles part of the description (for the updated tags).
The whole description is created in the _get_jira_description() method and this is where we should truncate.
I'd suggest adding the truncation code in a new method that we can unit test.

And in order to make it easier to update the code, let's move the max size to a constant. Something like the following:

@staticmethod
def _truncate_description(desc):
    max_size = JiraIssueCreator._MAX_DESCRIPTION_SIZE
    if len(desc) > max_size:
        warning = ("\nDescription truncated: "
                   "exceeded max size of {} characters.").format(max_size)
        truncated_length = max_size - len(warning)
        desc = desc[:truncated_length] + warning
    return desc

Comment by Chibuikem Amaechi [ 18/Jan/18 ]

Hi Yves,

Will the following suffice?

if tags_lines:          
    desc = "\n".join(tags_lines)          
    return desc if len(desc) <= 32767 else desc[:32705] + "\nDescription truncated: exceeded max size of 32767 characters."
else:                   
    return "_None_"

Comment by Chibuikem Amaechi [ 18/Jan/18 ]

Hi Yves!

You're definitely right. Somehow it slipped it my mind that slice indexes are zero-based .

I will make the necessary changes and post again.

Thank you!

Comment by Yves Duhem [ 18/Jan/18 ]

Hi cramaechi,

Thank you for your comment.
In your suggestion, the truncated value desc[:32768] is of size 32768 and still over the limit, it should be desc[:32767] instead.
With that change, it would indeed resolve the issue.
Additionally, we may want to include an indication that the description was truncated by including a message like "... (max size exceeded)" at the end of the description.

Comment by Chibuikem Amaechi [ 17/Jan/18 ]

I believe the code change in the following screenshot should resolve this issue:

Modified file(s): mongo/buildscripts/update_test_lifecycle.py

Please share your thoughts.

Generated at Thu Feb 08 04:28:40 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.