@@ -96,9 +96,9 @@ def close_issue_if_invalid(upload_request, attachment_info, description,
9696 return invalid
9797
9898
99- def close_issue_if_not_reproducible (issue ):
100- if issue .status == ISSUETRACKER_ACCEPTED_STATE and filed_one_day_ago (
101- issue .created_time ):
99+ def close_issue_if_not_reproducible (issue , config ):
100+ if issue .status == ISSUETRACKER_ACCEPTED_STATE and filed_n_days_ago (
101+ issue .created_time , config ):
102102 comment_message = ('Clusterfuzz failed to reproduce - '
103103 'please check testcase details for more info.' )
104104 issue .status = ISSUETRACKER_WONTFIX_STATE
@@ -107,10 +107,11 @@ def close_issue_if_not_reproducible(issue):
107107 return False
108108
109109
110- def filed_one_day_ago (issue_created_time_string ):
110+ def filed_n_days_ago (issue_created_time_string , config ):
111111 created_time = datetime .datetime .strptime (issue_created_time_string ,
112112 '%Y-%m-%dT%H:%M:%S.%fZ' )
113- return datetime .datetime .now () - created_time > datetime .timedelta (days = 1 )
113+ return datetime .datetime .now () - created_time > datetime .timedelta (
114+ days = config .get ('submitted-buffer-days' ))
114115
115116
116117def submit_testcase (issue_id , file , filename , filetype , cmds ):
@@ -152,31 +153,41 @@ def submit_testcase(issue_id, file, filename, filetype, cmds):
152153
153154
154155def handle_testcases (tracker , config ):
155- """Fetches and submits testcases from bugs or closes unnecssary bugs."""
156- # TODO(pgrace) remove ID filter once done testing.
157- issues = tracker .find_issues_with_filters (
156+ """Fetches and submits testcases from bugs or closes unnecessary bugs."""
157+
158+ # Handle bugs that were already submitted and still open.
159+ older_issues = tracker .find_issues_with_filters (
158160 keywords = [],
159- query_filters = ['componentid:1600865' , 'id:373893311 ' ],
161+ query_filters = ['componentid:1600865' , 'status:accepted ' ],
160162 only_open = True )
163+ for issue in older_issues :
164+ # Close out older bugs that may have failed to reproduce.
165+ if close_issue_if_not_reproducible (issue , config ):
166+ helpers .log ('Closing issue {issue_id} as it failed to reproduce' ,
167+ issue .id )
161168
169+ # Handle new bugs that may need to be submitted.
170+ issues = tracker .find_issues_with_filters (
171+ keywords = [],
172+ query_filters = ['componentid:1600865' , 'status:new' ],
173+ only_open = True )
162174 if len (issues ) == 0 :
163175 return
164176
165177 # TODO(pgrace) Cache in redis.
166178 vrp_uploaders = get_vrp_uploaders (config )
167179
168- # TODO(pgrace) Implement rudimentary rate limiting.
180+ # Rudimentary rate limiting -
181+ # Process only a certain number of bugs per reporter for each job run.
182+ reporters_map = {}
169183
170184 for issue in issues :
171- # Close out older bugs that may have failed to reproduce.
172- if close_issue_if_not_reproducible (issue ):
173- helpers .log ('Closing issue {issue_id} as it failed to reproduce' ,
174- issue .id )
175- continue
176-
177- # Close out invalid bugs.
178185 attachment_metadata = tracker .get_attachment_metadata (issue .id )
179186 commandline_flags = tracker .get_description (issue .id )
187+ if reporters_map .get (issue .reporter ,
188+ 0 ) > config .get ('max-report-count-per-run' ):
189+ continue
190+ reporters_map [issue .reporter ] = reporters_map .get (issue .reporter , 1 ) + 1
180191 if close_issue_if_invalid (issue , attachment_metadata , commandline_flags ,
181192 vrp_uploaders ):
182193 helpers .log ('Closing issue {issue_id} as it is invalid' , issue .id )
0 commit comments