1# Copyright 2017 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
5
6# TODO(borenet): This module was copied from build.git and heavily modified to
7# remove dependencies on other modules in build.git.  It belongs in a different
8# repo. Remove this once it has been moved.
9
10
11from recipe_engine import recipe_test_api
12
13import state
14
15class SwarmingTestApi(recipe_test_api.RecipeTestApi):
16
17  @recipe_test_api.placeholder_step_data
18  def summary(self, data):
19    return self.m.json.output(data)
20
21  def canned_summary_output(
22      self, shards=1, failure=False, internal_failure=False):
23    return self.summary({
24      'shards': [
25        {
26          'abandoned_ts': None,
27          'bot_id': 'vm30',
28          'completed_ts': '2014-09-25T01:42:00.123',
29          'created_ts': '2014-09-25T01:41:00.123',
30          'durations': [5.7, 31.5],
31          'exit_codes': [0, 0],
32          'failure': failure,
33          'id': '148aa78d7aa%02d00' % i,
34          'internal_failure': internal_failure,
35          'isolated_out': {
36            'isolated': 'abc123',
37            'isolatedserver': 'https://isolateserver.appspot.com',
38            'namespace': 'default-gzip',
39            'view_url': 'blah',
40          },
41          'modified_ts': '2014-09-25 01:42:00',
42          'name': 'heartbeat-canary-2014-09-25_01:41:55-os=Windows',
43          'outputs': [
44            'Heart beat succeeded on win32.\n',
45            'Foo',
46          ],
47          'outputs_ref': {
48            'view_url': 'blah',
49          },
50          'started_ts': '2014-09-25T01:42:11.123',
51          'state': state.State.COMPLETED,
52          'try_number': 1,
53          'user': 'unknown',
54        } for i in xrange(shards)
55      ],
56    })
57