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

Unified Diff: appengine/findit/waterfall/test/schedule_try_job_pipeline_test.py

Issue 1591003002: [Findit] Modify tryjob pipelines to trigger try jobs for test failure. (Closed) Base URL: https://chromium.googlesource.com/infra/infra.git@master
Patch Set: . Created 4 years, 10 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 side-by-side diff with in-line comments
Download patch
Index: appengine/findit/waterfall/test/schedule_try_job_pipeline_test.py
diff --git a/appengine/findit/waterfall/test/schedule_try_job_pipeline_test.py b/appengine/findit/waterfall/test/schedule_try_job_pipeline_test.py
index 0f8f2515b5aac34a1b63eb2cdd99c98a23778e61..fa35b9f8d31936fe07761c6c2f41453acf22114a 100644
--- a/appengine/findit/waterfall/test/schedule_try_job_pipeline_test.py
+++ b/appengine/findit/waterfall/test/schedule_try_job_pipeline_test.py
@@ -8,18 +8,19 @@ from common import buildbucket_client
from model.wf_try_job import WfTryJob
from waterfall import waterfall_config
from waterfall.schedule_try_job_pipeline import ScheduleTryJobPipeline
+from waterfall.try_job_type import TryJobType
class ScheduleTryjobPipelineTest(testing.AppengineTestCase):
def _Mock_GetTrybotForWaterfallBuilder(self, *_):
- def Mocked_GetTrybotForWaterfallBuilder(*_):
+ def MockedGetTrybotForWaterfallBuilder(*_):
return 'linux_chromium_variable', 'master.tryserver.chromium.linux'
self.mock(waterfall_config, 'GetTrybotForWaterfallBuilder',
- Mocked_GetTrybotForWaterfallBuilder)
+ MockedGetTrybotForWaterfallBuilder)
def _Mock_TriggerTryJobs(self, responses):
- def Mocked_TriggerTryJobs(*_):
+ def MockedTriggerTryJobs(*_):
results = []
for response in responses:
if response.get('error'): # pragma: no cover
@@ -29,16 +30,15 @@ class ScheduleTryjobPipelineTest(testing.AppengineTestCase):
results.append((
None, buildbucket_client.BuildbucketBuild(response['build'])))
return results
- self.mock(buildbucket_client, 'TriggerTryJobs', Mocked_TriggerTryJobs)
+ self.mock(buildbucket_client, 'TriggerTryJobs', MockedTriggerTryJobs)
def testGetBuildPropertiesWithCompileTargets(self):
master_name = 'm'
builder_name = 'b'
- recipe = 'a/b/recipe'
compile_targets = ['a.exe']
expected_properties = {
- 'recipe': recipe,
+ 'recipe': 'findit/chromium/compile',
'good_revision': 1,
'bad_revision': 2,
'target_mastername': master_name,
@@ -46,8 +46,29 @@ class ScheduleTryjobPipelineTest(testing.AppengineTestCase):
'compile_targets': compile_targets
}
try_job_pipeline = ScheduleTryJobPipeline()
- properties = try_job_pipeline._getBuildProperties(
- recipe, master_name, builder_name, 1, 2, compile_targets)
+ properties = try_job_pipeline._GetBuildProperties(
+ master_name, builder_name, 1, 2, TryJobType.COMPILE,
+ compile_targets, None)
+
+ self.assertEqual(properties, expected_properties)
+
+ def testGetBuildPropertiesForTestFailure(self):
+ master_name = 'm'
+ builder_name = 'b'
+ targeted_tests = {'a': []}
+
+ expected_properties = {
+ 'recipe': 'findit/chromium/test',
+ 'good_revision': 1,
+ 'bad_revision': 2,
+ 'target_mastername': master_name,
+ 'target_testername': 'b',
+ 'tests': targeted_tests
+ }
+ try_job_pipeline = ScheduleTryJobPipeline()
+ properties = try_job_pipeline._GetBuildProperties(
+ master_name, builder_name, 1, 2, TryJobType.TEST,
+ None, targeted_tests)
self.assertEqual(properties, expected_properties)
@@ -75,7 +96,7 @@ class ScheduleTryjobPipelineTest(testing.AppengineTestCase):
try_job_pipeline = ScheduleTryJobPipeline()
try_job_id = try_job_pipeline.run(
master_name, builder_name, build_number, good_revision, bad_revision,
- [])
+ TryJobType.COMPILE, None, None)
try_job = WfTryJob.Get(master_name, builder_name, build_number)
expected_try_job_id = '1'
@@ -83,3 +104,34 @@ class ScheduleTryjobPipelineTest(testing.AppengineTestCase):
self.assertEqual(
expected_try_job_id, try_job.compile_results[-1]['try_job_id'])
self.assertTrue(expected_try_job_id in try_job.try_job_ids)
+
+ def testSuccessfullyScheduleNewTryJobForTest(self):
+ master_name = 'm'
+ builder_name = 'b'
+ build_number = 223
+ good_revision = 'rev1'
+ bad_revision = 'rev2'
+ targeted_tests = {'a': ['test1', 'test2']}
+
+ responses = [
+ {
+ 'build': {
+ 'id': '1',
+ 'url': 'url',
+ 'status': 'SCHEDULED',
+ }
+ }
+ ]
+ self._Mock_GetTrybotForWaterfallBuilder(master_name, builder_name)
+ self._Mock_TriggerTryJobs(responses)
+
+ WfTryJob.Create(master_name, builder_name, build_number).put()
+
+ try_job_pipeline = ScheduleTryJobPipeline()
+ try_job_id = try_job_pipeline.run(
+ master_name, builder_name, build_number, good_revision, bad_revision,
+ TryJobType.TEST, None, targeted_tests)
+
+ try_job = WfTryJob.Get(master_name, builder_name, build_number)
+ self.assertEqual('1', try_job_id)
+ self.assertEqual('1', try_job.test_results[-1]['try_job_id'])

Powered by Google App Engine
This is Rietveld 408576698