Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1078)

Side by Side Diff: testing/legion/host_controller.py

Issue 890773003: Adding the initial code for Omnibot multi-machine support (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
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 """The host controller base library.
5
6 This module is the basis on which host controllers are built and executed.
7 """
8 import json
9 import logging
10 import sys
11
12 #pylint: disable=relative-import
13 import client_lib
14 import common_lib
15 import discovery_server
16
17
18 class HostController(object):
19 """The base host controller class."""
20
21 clients = []
22
23 def __init__(self):
24 self._discovery_server = discovery_server.DiscoveryServer()
25
26 def _SetUp(self):
27 """Perform private internal setup operations."""
28 common_lib.InitLogging()
29 common_lib.LogCommandLine()
30 self._discovery_server.Start()
31
32 def SetUp(self):
33 """Setup method used by the subclass."""
34 pass
35
36 def Test(self):
37 """Main test method used by the subclass."""
38 pass
39
40 def TearDown(self):
41 """Teardown method used by the subclass."""
42 pass
43
44 def _TearDown(self):
45 """Private internal teardown method."""
46 self._discovery_server.Shutdown()
47 for client in self.clients:
48 client.Release()
49
50 def NewClient(self, isolate_file):
51 """Creates a new client object given an isolate file.
52
53 Args:
54 isolate_file: The path to an isolate file for the client machine.
55
56 Returns:
57 A new client_lib.Client object.
58 """
59 client = client_lib.Client(isolate_file, self._discovery_server)
60 self.clients.append(client)
61 return client
62
63 def RunController(self):
64 """Main entry point for the controller."""
65 error = None
66 tb = None
67 try:
68 self._SetUp()
69 self.SetUp()
70 self.Test()
71 except Exception, e:
72 # Defer raising exceptions until after TearDown and _TearDown are called.
73 error = e
74 tb = sys.exc_info()[-1]
75 try:
76 self.TearDown()
77 except Exception, e:
78 # Defer raising exceptions until after _TearDown is called.
79 # Note that an error raised here will obscure any errors raised
80 # previously.
81 error = e
82 tb = sys.exc_info()[-1]
83
84 self._TearDown()
85 if error:
86 raise error, None, tb #pylint: disable=raising-bad-type
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698