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

Side by Side Diff: testing/legion/examples/hello_world/controller_test.py

Issue 943923003: Removing the isolate.py functionality and requiring tasks to be created from an archive hash rather… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Doing a little clean up 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 """A simple host test module.
7
8 This module runs on the host machine and is responsible for creating 2
9 task machines, waiting for them, and running RPC calls on them.
10 """
11
12 # Map the legion directory so we can import the host controller.
13 import sys
14 sys.path.append('../../')
15
16 import argparse
17 import logging
18 import time
19
20 import test_controller
21
22
23 class ExampleTestController(test_controller.TestController):
24 """A simple example controller for a test."""
25
26 def __init__(self):
27 super(ExampleTestController, self).__init__()
28 self.task1 = None
29 self.task2 = None
30
31 def CreateTask(self, isolated_hash):
32 """Create a task object and set the proper values."""
33 task = self.CreateNewTask(
34 isolated_hash=isolated_hash,
35 dimensions={'os': 'legion-linux'}, priority=200,
36 idle_timeout_secs=90, connection_timeout_secs=90,
37 verbosity=logging.INFO,
38 run_id=1)
39 task.Create()
40 return task
41
42 def SetUp(self):
43 """Create the task machines and wait until they connect.
44
45 In this call the actual creation of the task machines is done in parallel
46 by the system. The WaitForConnect calls are performed in series but will
47 return as soon as the tasks connect.
48 """
49 parser = argparse.ArgumentParser()
50 parser.add_argument('--task-hash')
51 args, _ = parser.parse_known_args()
52
53 self.task1 = self.CreateTask(args.task_hash)
54 self.task2 = self.CreateTask(args.task_hash)
M-A Ruel 2015/02/23 23:17:07 Didn't you want to use two different content?
Mike Meade 2015/02/23 23:22:11 No need to as the task file is the same for each.
55 self.task1.WaitForConnection()
56 self.task2.WaitForConnection()
57
58 def RunTest(self):
59 """Main method to run the test code."""
60 self.CallEcho(self.task1)
61 self.CallEcho(self.task2)
62 self.CallTaskTest(self.task1)
63 self.CallTaskTest(self.task2)
64
65 def CallEcho(self, task):
66 """Call rpc.Echo on a task."""
67 logging.info('Calling Echo on %s', task.name)
68 logging.info(task.rpc.Echo(task.name))
69
70 def CallTaskTest(self, task):
71 """Call task_test.py name on a task."""
72 logging.info('Calling Subprocess to run "./task_test.py %s"', task.name)
73 proc = task.rpc.subprocess.Popen(['./task_test.py', task.name])
74 task.rpc.subprocess.Wait(proc)
75 retcode = task.rpc.subprocess.GetReturncode(proc)
76 stdout = task.rpc.subprocess.ReadStdout(proc)
77 stderr = task.rpc.subprocess.ReadStderr(proc)
78 logging.info('retcode: %s, stdout: %s, stderr: %s', retcode, stdout, stderr)
79
80
81 if __name__ == '__main__':
82 ExampleTestController().RunController()
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698