Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(303)

Side by Side Diff: appengine/findit/waterfall/flake/recursive_flake_pipeline.py

Issue 2391063002: [Findit] Fix flaky tests due to importing pytz. (Closed)
Patch Set: Fix nit. Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 # Copyright 2016 The Chromium Authors. All rights reserved. 1 # Copyright 2016 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 import logging 5 import logging
6 from datetime import timedelta 6 from datetime import timedelta
7 import random 7 import random
8 8
9 from common import appengine_util 9 from common import appengine_util
10 from common import constants 10 from common import constants
(...skipping 30 matching lines...) Expand all
41 manually_triggered (bool): True if the analysis is from manual request, like 41 manually_triggered (bool): True if the analysis is from manual request, like
42 by a Chromium sheriff. 42 by a Chromium sheriff.
43 43
44 Returns: 44 Returns:
45 The ETA as of a UTC datetime.datetime to start the analysis. 45 The ETA as of a UTC datetime.datetime to start the analysis.
46 """ 46 """
47 if manually_triggered: 47 if manually_triggered:
48 # If the analysis is manually triggered, run it right away. 48 # If the analysis is manually triggered, run it right away.
49 return time_util.GetUTCNow() 49 return time_util.GetUTCNow()
50 50
51 now_at_mtv = time_util.GetDatetimeInTimezone( 51 now_at_pst = time_util.GetDatetimeInTimezone(
52 'US/Pacific', time_util.GetUTCNowWithTimezone()) 52 'US/Pacific', time_util.GetUTCNowWithTimezone())
53 if now_at_mtv.weekday() >= 5: # PST Saturday or Sunday. 53 if now_at_pst.weekday() >= 5: # PST Saturday or Sunday.
54 return time_util.GetUTCNow() 54 return time_util.GetUTCNow()
55 55
56 if now_at_mtv.hour < 11 or now_at_mtv.hour >= 18: # Before 11am or after 6pm. 56 if now_at_pst.hour < 11 or now_at_pst.hour >= 18: # Before 11am or after 6pm.
57 return time_util.GetUTCNow() 57 return time_util.GetUTCNow()
58 58
59 # Set ETA time to 6pm, and also with a random latency within 30 minutes to 59 # Set ETA time to 6pm, and also with a random latency within 30 minutes to
60 # avoid sudden burst traffic to Swarming. 60 # avoid sudden burst traffic to Swarming.
61 diff = timedelta(hours=18 - now_at_mtv.hour, 61 diff = timedelta(hours=18 - now_at_pst.hour,
62 minutes=-now_at_mtv.minute, 62 minutes=-now_at_pst.minute,
63 seconds=-now_at_mtv.second + random.randint(0, 30 * 60), 63 seconds=-now_at_pst.second + random.randint(0, 30 * 60),
64 microseconds=-now_at_mtv.microsecond) 64 microseconds=-now_at_pst.microsecond)
65 eta = now_at_mtv + diff 65 eta = now_at_pst + diff
66 66
67 # Convert back to UTC. 67 # Convert back to UTC.
68 return time_util.GetDatetimeInTimezone('UTC', eta) 68 return time_util.GetDatetimeInTimezone('UTC', eta)
69 69
70 70
71 class RecursiveFlakePipeline(BasePipeline): 71 class RecursiveFlakePipeline(BasePipeline):
72 72
73 def __init__(self, *args, **kwargs): 73 def __init__(self, *args, **kwargs):
74 super(RecursiveFlakePipeline, self).__init__(*args, **kwargs) 74 super(RecursiveFlakePipeline, self).__init__(*args, **kwargs)
75 self.manually_triggered = kwargs.get('manually_triggered', False) 75 self.manually_triggered = kwargs.get('manually_triggered', False)
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after
271 flakiness_algorithm_results_dict=flakiness_algorithm_results_dict, 271 flakiness_algorithm_results_dict=flakiness_algorithm_results_dict,
272 manually_triggered=manually_triggered) 272 manually_triggered=manually_triggered)
273 # pylint: disable=W0201 273 # pylint: disable=W0201
274 pipeline_job.target = appengine_util.GetTargetNameForModule( 274 pipeline_job.target = appengine_util.GetTargetNameForModule(
275 constants.WATERFALL_BACKEND) 275 constants.WATERFALL_BACKEND)
276 pipeline_job.StartOffPSTPeakHours( 276 pipeline_job.StartOffPSTPeakHours(
277 queue_name=self.queue_name or constants.DEFAULT_QUEUE) 277 queue_name=self.queue_name or constants.DEFAULT_QUEUE)
278 else: 278 else:
279 _UpdateAnalysisStatusUponCompletion( 279 _UpdateAnalysisStatusUponCompletion(
280 master_flake_analysis, analysis_status.COMPLETED, None) 280 master_flake_analysis, analysis_status.COMPLETED, None)
OLDNEW
« no previous file with comments | « appengine/findit/common/time_util.py ('k') | appengine/findit/waterfall/flake/test/recursive_flake_pipeline_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698