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

Side by Side Diff: testing/legion/examples/hello_world/host_test.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 #!/usr/bin/env python
2 # Copyright 2015 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file.
5
6 # Map the legion directory so we can import the host controller.
7 import sys
8 sys.path.append('../../')
9
10 import logging
11 import time
12
13 import host_controller
14
15
16 class ExampleController(host_controller.HostController):
17 """A simple example controller for a test."""
18
19 def __init__(self):
20 super(ExampleController, self).__init__()
21 self.client1 = None
22 self.client2 = None
23
24 def CreateClient(self):
25 """Create a client object and set the proper values."""
26 client = self.NewClient('client_test.isolate')
27 client.AddConfigVars('os', 'Linux')
28 client.AddConfigVars('multi_machine', '1')
29 client.AddDimension('os', 'Linux')
30 client.SetPriority(0)
31 client.SetRPCTimeout(120)
32 client.SetVerbose()
33 client.Create()
34 return client
35
36 def SetUp(self):
37 """Create the client machines and wait until they connect.
38
39 In this call the actual creation of the client machines is done in parallel
40 by the system. The WaitForConnect calls are performed in series but will
41 return as soon as the client connects.
42 """
43 self.client1 = self.CreateClient()
44 self.client2 = self.CreateClient()
45 self.client1.WaitForConnection(120)
46 self.client2.WaitForConnection(120)
47
48 def Test(self):
49 """Run the actual test."""
50 self.CallEcho(self.client1)
51 self.CallEcho(self.client2)
52 self.CallClientTest(self.client1)
53 self.CallClientTest(self.client2)
54
55 def CallEcho(self, client):
56 """Call rpc.Echo on a client."""
57 logging.info('Calling Echo on %s', client.name)
58 logging.info(self.client1.rpc.Echo(client.name))
59
60 def CallClientTest(self, client):
61 """Call client_test.py name on a client."""
62 logging.info('Calling Subprocess on %s to run "client_test.py %s"',
63 client.name, client.name)
64 retcode, stdout, stderr = client.rpc.Subprocess(
65 ['./client_test.py', client.name])
66 logging.info('retcode: %s, stdout: %s, stderr: %s', retcode, stdout, stderr)
67
68
69 if __name__ == '__main__':
70 ExampleController().RunController()
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698