aboutsummaryrefslogtreecommitdiffhomepage
path: root/infra/bots/recipe_modules/swarming/test_api.py
blob: 3066fd6189aa6d407b03a4da8cfc7b027f36f2ad (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# Copyright 2017 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.


# TODO(borenet): This module was copied from build.git and heavily modified to
# remove dependencies on other modules in build.git.  It belongs in a different
# repo. Remove this once it has been moved.


from recipe_engine import recipe_test_api

import state

class SwarmingTestApi(recipe_test_api.RecipeTestApi):

  @recipe_test_api.placeholder_step_data
  def summary(self, data):
    return self.m.json.output(data)

  def canned_summary_output(
      self, shards=1, failure=False, internal_failure=False):
    return self.summary({
      'shards': [
        {
          'abandoned_ts': None,
          'bot_id': 'vm30',
          'completed_ts': '2014-09-25T01:42:00.123',
          'created_ts': '2014-09-25T01:41:00.123',
          'durations': [5.7, 31.5],
          'exit_codes': [0, 0],
          'failure': failure,
          'id': '148aa78d7aa%02d00' % i,
          'internal_failure': internal_failure,
          'isolated_out': {
            'isolated': 'abc123',
            'isolatedserver': 'https://isolateserver.appspot.com',
            'namespace': 'default-gzip',
            'view_url': 'blah',
          },
          'modified_ts': '2014-09-25 01:42:00',
          'name': 'heartbeat-canary-2014-09-25_01:41:55-os=Windows',
          'outputs': [
            'Heart beat succeeded on win32.\n',
            'Foo',
          ],
          'outputs_ref': {
            'view_url': 'blah',
          },
          'started_ts': '2014-09-25T01:42:11.123',
          'state': state.State.COMPLETED,
          'try_number': 1,
          'user': 'unknown',
        } for i in xrange(shards)
      ],
    })