| Index: appengine/findit/waterfall/test/process_flake_swarming_task_result_pipeline_test.py
|
| diff --git a/appengine/findit/waterfall/test/process_flake_swarming_task_result_pipeline_test.py b/appengine/findit/waterfall/test/process_flake_swarming_task_result_pipeline_test.py
|
| index 48a1da092e6abd4da5ca11149d877c556629124b..b0b9579c480b61a314488ccd68cd16d5d0fc2981 100644
|
| --- a/appengine/findit/waterfall/test/process_flake_swarming_task_result_pipeline_test.py
|
| +++ b/appengine/findit/waterfall/test/process_flake_swarming_task_result_pipeline_test.py
|
| @@ -3,11 +3,17 @@
|
| # found in the LICENSE file.
|
|
|
| import datetime
|
| +import json
|
| +import mock
|
|
|
| from model import analysis_status
|
| from model.flake.flake_swarming_task import FlakeSwarmingTask
|
| from model.flake.master_flake_analysis import MasterFlakeAnalysis
|
| +from model.wf_build import WfBuild
|
| +from waterfall import build_util
|
| from waterfall import swarming_util
|
| +from waterfall import (
|
| + process_flake_swarming_task_result_pipeline as flake_result_pipeline)
|
| from waterfall.process_flake_swarming_task_result_pipeline import (
|
| ProcessFlakeSwarmingTaskResultPipeline)
|
| from waterfall.test import (
|
| @@ -32,7 +38,10 @@ class ProcessFlakeSwarmingTaskResultPipelineTest(wf_testcase.WaterfallTestCase):
|
| self.mock(swarming_util, 'GetSwarmingTaskResultById',
|
| self._MockedGetSwarmingTaskResultById)
|
|
|
| - def testCheckTestsRunStatuses(self):
|
| + @mock.patch.object(flake_result_pipeline,
|
| + '_GetCommitPositionAndGitHash',
|
| + return_value=(12345, 'git_hash'))
|
| + def testCheckTestsRunStatuses(self, _):
|
| analysis = MasterFlakeAnalysis.Create(
|
| self.master_name, self.builder_name,
|
| self.build_number, self.step_name, self.test_name)
|
| @@ -54,7 +63,10 @@ class ProcessFlakeSwarmingTaskResultPipelineTest(wf_testcase.WaterfallTestCase):
|
| base_test._SAMPLE_FAILURE_LOG, *call_params))
|
| self.assertEqual(base_test._EXPECTED_TESTS_STATUS, tests_statuses)
|
|
|
| - def testCheckTestsRunStatusesWhenTestDoesNotExist(self):
|
| + @mock.patch.object(flake_result_pipeline,
|
| + '_GetCommitPositionAndGitHash',
|
| + return_value=(12345, 'git_hash'))
|
| + def testCheckTestsRunStatusesWhenTestDoesNotExist(self, _):
|
| test_name = 'TestSuite1.new_test'
|
| analysis = MasterFlakeAnalysis.Create(
|
| self.master_name, self.builder_name,
|
| @@ -85,14 +97,13 @@ class ProcessFlakeSwarmingTaskResultPipelineTest(wf_testcase.WaterfallTestCase):
|
| self.build_number, self.step_name, test_name, self.version_number)
|
| self.assertTrue(analysis.data_points[-1].pass_rate < 0)
|
|
|
| - def _MockedGetSwarmingTaskFailureLog(self, *_):
|
| - return base_test._SAMPLE_FAILURE_LOG, None
|
| -
|
| - def testProcessFlakeSwarmingTaskResultPipeline(self):
|
| + @mock.patch.object(swarming_util, 'GetSwarmingTaskFailureLog',
|
| + return_value=(base_test._SAMPLE_FAILURE_LOG, None))
|
| + @mock.patch.object(flake_result_pipeline,
|
| + '_GetCommitPositionAndGitHash',
|
| + return_value=(12345, 'git_hash'))
|
| + def testProcessFlakeSwarmingTaskResultPipeline(self, *_):
|
| # End to end test.
|
| - self.mock(swarming_util, 'GetSwarmingTaskFailureLog',
|
| - self._MockedGetSwarmingTaskFailureLog)
|
| -
|
| task = FlakeSwarmingTask.Create(
|
| self.master_name, self.builder_name,
|
| self.build_number, self.step_name, self.test_name)
|
| @@ -126,3 +137,52 @@ class ProcessFlakeSwarmingTaskResultPipelineTest(wf_testcase.WaterfallTestCase):
|
| task.started_time)
|
| self.assertEqual(datetime.datetime(2016, 2, 10, 18, 33, 9),
|
| task.completed_time)
|
| +
|
| + @mock.patch.object(build_util, '_BuildDataNeedUpdating', return_value=False)
|
| + def testGetCommitPositionAndGitHash(self, _):
|
| + build = WfBuild.Create('m', 'b', 123)
|
| + build.data = json.dumps({
|
| + 'properties': [
|
| + ['got_revision', 'a_git_hash'],
|
| + ['got_revision_cp', 'refs/heads/master@{#12345}']
|
| + ],
|
| + })
|
| + build.put()
|
| + self.assertEqual(
|
| + (12345, 'a_git_hash'),
|
| + flake_result_pipeline._GetCommitPositionAndGitHash('m', 'b', 123))
|
| + self.assertEqual(
|
| + (None, None),
|
| + flake_result_pipeline._GetCommitPositionAndGitHash('m', 'b', -1))
|
| +
|
| + @mock.patch.object(build_util, '_BuildDataNeedUpdating', return_value=False)
|
| + def testGetCommitPositionAndGitHashNoBuildDataAvailable(self, _):
|
| + build = WfBuild.Create('m', 'b', 123)
|
| + build.data = {}
|
| + build.put()
|
| +
|
| + self.assertEqual(
|
| + (None, None),
|
| + flake_result_pipeline._GetCommitPositionAndGitHash('m', 'b', 123))
|
| +
|
| + @mock.patch.object(flake_result_pipeline,
|
| + '_GetCommitPositionAndGitHash',
|
| + return_value=(12345, 'git_hash'))
|
| + def testNoGitHashForPreviousBuildNumberIfZero(self, _):
|
| + analysis = MasterFlakeAnalysis.Create(
|
| + self.master_name, self.builder_name, 0, self.step_name, self.test_name)
|
| + analysis.Save()
|
| +
|
| + task = FlakeSwarmingTask.Create(
|
| + self.master_name, self.builder_name, 0, self.step_name, self.test_name)
|
| + task.put()
|
| +
|
| + call_params = ProcessFlakeSwarmingTaskResultPipeline._GetArgs(
|
| + self.pipeline, self.master_name, self.builder_name, 0, self.step_name,
|
| + 0, self.test_name, self.version_number)
|
| +
|
| + ProcessFlakeSwarmingTaskResultPipeline._CheckTestsRunStatuses(
|
| + self.pipeline, base_test._SAMPLE_FAILURE_LOG, *call_params)
|
| +
|
| + self.assertIsNone(analysis.data_points[0].previous_build_commit_position)
|
| + self.assertIsNone(analysis.data_points[0].previous_build_git_hash)
|
|
|