def testParseFlakeSwarmingTaskOutputNoOutput(self): task_data = { 'created_ts': '2018-04-02T18:32:06.538220', 'started_ts': '2018-04-02T19:32:06.538220', 'completed_ts': '2018-04-02T20:32:06.538220', 'task_id': 'task_id' } error = SwarmingTaskError(code=1, message='m') commit_position = 1000 isolate_sha = 'sha1' iterations = 50 timeout_seconds = 1200 parameters = RunFlakeSwarmingTaskInput(builder_name='b', commit_position=commit_position, isolate_sha=isolate_sha, iterations=iterations, master_name='m', reference_build_number=123, step_name='s', test_name='t', timeout_seconds=timeout_seconds) expected_result = FlakeSwarmingTaskOutput( task_id='task_id', started_time=datetime(2018, 4, 2, 19, 32, 6, 538220), completed_time=datetime(2018, 4, 2, 20, 32, 6, 538220), iterations=None, error=error, pass_count=None) self.assertEqual( expected_result, flake_swarming._ParseFlakeSwarmingTaskOutput( task_data, None, error, parameters))
def testParseFlakeSwarmingTaskOutput(self, mocked_pass_fail): iterations = 50 pass_count = 25 task_data = { 'created_ts': '2018-04-02T18:32:06.538220', 'started_ts': '2018-04-02T19:32:06.538220', 'completed_ts': '2018-04-02T20:32:06.538220', 'task_id': 'task_id' } mocked_pass_fail.return_value = (iterations, pass_count) commit_position = 1000 isolate_sha = 'sha1' iterations = 50 timeout_seconds = 1200 parameters = RunFlakeSwarmingTaskInput( builder_name='b', commit_position=commit_position, isolate_sha=isolate_sha, iterations=iterations, master_name='m', reference_build_number=123, step_name='s', test_name='t', timeout_seconds=timeout_seconds) expected_result = FlakeSwarmingTaskOutput( task_id='task_id', started_time=datetime(2018, 4, 2, 19, 32, 6, 538220), completed_time=datetime(2018, 4, 2, 20, 32, 6, 538220), iterations=iterations, error=None, pass_count=pass_count) self.assertEqual( expected_result, flake_swarming._ParseFlakeSwarmingTaskOutput(task_data, 'content', None, parameters))
def testParseFlakeSwarmingTaskOutputConsolidatedResult(self, _): task_data = { 'created_ts': '2018-04-02T18:32:06.538220', 'started_ts': '2018-04-02T19:32:06.538220', 'task_id': 'task_id', 'state': 'COMPLETED', 'failure': False, 'internal_failure': False } commit_position = 1000 isolate_sha = 'sha1' iterations = 50 timeout_seconds = 1200 parameters = RunFlakeSwarmingTaskInput(builder_name='b', commit_position=commit_position, isolate_sha=isolate_sha, iterations=iterations, master_name='m', reference_build_number=123, step_name='s', test_name='t', timeout_seconds=timeout_seconds) expected_result = FlakeSwarmingTaskOutput(task_id='task_id', started_time=datetime( 2018, 4, 2, 19, 32, 6, 538220), completed_time=None, iterations=50, error=None, pass_count=0) self.assertEqual( expected_result, flake_swarming._ParseFlakeSwarmingTaskOutput( task_data, {'bla': 'bla'}, None, parameters))