• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright 2015 The Chromium Authors. All rights reserved.
2# Use of this source code is governed by a BSD-style license that can be
3# found in the LICENSE file.
4
5import unittest
6
7from dashboard import buildbucket_job
8from dashboard import testing_common
9
10
11class BuildbucketJobTest(testing_common.TestCase):
12
13  def setUp(self):
14    super(BuildbucketJobTest, self).setUp()
15    self._args_base = {
16        'try_job_id': 1,
17        'recipe_tester_name': 'linux_perf_bisect',
18        'good_revision': '1',
19        'bad_revision': '2',
20        'test_command': 'tools/perf/dummy_command',
21        'metric': 'dummy_metric',
22        'repeats': '5',
23        'timeout_minutes': '10',
24        'bug_id': None,
25        'gs_bucket': 'dummy_bucket',
26        'builder_host': None,
27        'builder_port': None,
28    }
29
30  def testCreateJob(self):
31    job = buildbucket_job.BisectJob(**self._args_base)
32    params = job.GetBuildParameters()
33    assert isinstance(params, dict)
34    self.assertIn('builder_name', params)
35    properties = params['properties']
36    assert isinstance(properties, dict)
37    bisect_config = properties['bisect_config']
38    assert isinstance(bisect_config, dict)
39    self.assertIn('test_type', bisect_config)
40    self.assertIn('command', bisect_config)
41    self.assertIn('src', bisect_config['command'])
42    self.assertIn('metric', bisect_config)
43    self.assertIn('good_revision', bisect_config)
44    self.assertIn('bad_revision', bisect_config)
45    self.assertIn('repeat_count', bisect_config)
46    self.assertIn('max_time_minutes', bisect_config)
47
48  def testMissingRequiredArgs(self):
49    self._args_base['test_command'] = None
50    with self.assertRaises(ValueError):
51      job = buildbucket_job.BisectJob(**self._args_base)
52      _ = job.GetBuildParameters()
53
54if __name__ == '__main__':
55  unittest.main()
56