blob: 4068364d8f4722ce2b58ab07e6bec21587989ebc [file] [log] [blame]
Xixuan Wu865fa282017-09-05 15:23:19 -07001# Copyright 2017 The Chromium OS 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"""Module for tests for handlers."""
6
Craig Bergstrom3212fb42018-04-17 19:24:15 -06007import config_reader
8import file_getter
Xixuan Wu865fa282017-09-05 15:23:19 -07009import swarming_lib
10
11import webapp2
12
13
Xixuan Wua17e3282018-08-21 16:11:11 -070014class TestAFESwarmingAPI(webapp2.RequestHandler):
Xixuan Wu865fa282017-09-05 15:23:19 -070015
16 def get(self):
Craig Bergstrom3212fb42018-04-17 19:24:15 -060017 lab_config = config_reader.LabConfig(config_reader.ConfigReader(
18 file_getter.LAB_CONFIG_FILE))
19 afe_server = lab_config.get_dedicated_afe()
Xixuan Wu5d700dc2018-08-21 15:13:10 -070020 swarming_runner = swarming_lib.SwarmingRunner(
21 afe_server,
22 swarming_lib.CHROME_STAGING_SWARMING_SERVER)
Xixuan Wua17e3282018-08-21 16:11:11 -070023 afe_response = swarming_runner.dummy_run()
24 afe_swarming_task_info = swarming_runner.query_task(afe_response['task_id'])
25 self.response.write(afe_swarming_task_info.name)
26
27
28class TestSkylabSwarmingAPI(webapp2.RequestHandler):
29
30 def get(self):
31 lab_config = config_reader.LabConfig(config_reader.ConfigReader(
32 file_getter.LAB_CONFIG_FILE))
33 afe_server = lab_config.get_dedicated_afe()
34 swarming_runner = swarming_lib.SwarmingRunner(
35 afe_server,
36 swarming_lib.CHROME_STAGING_SWARMING_SERVER)
37 skylab_response = swarming_runner.dummy_run(is_skylab=True)
38 skylab_swarming_task_info = swarming_runner.query_task(
39 skylab_response['task_id'], is_skylab=True)
40 self.response.write(skylab_swarming_task_info.name)
Xixuan Wu865fa282017-09-05 15:23:19 -070041
42
43app = webapp2.WSGIApplication([
Xixuan Wua17e3282018-08-21 16:11:11 -070044 ('/test_push/afe_swarming', TestAFESwarmingAPI),
45 ('/test_push/skylab_swarming', TestSkylabSwarmingAPI),
Xixuan Wu865fa282017-09-05 15:23:19 -070046 ], debug=True)