Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # Copyright 2015 The Chromium Authors. All rights reserved. | 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 | 3 # Use of this source code is governed by a BSD-style license that can be |
| 4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
| 5 | 5 |
| 6 """A host test module demonstrating interacting with remote subprocesses.""" | 6 """A host test module demonstrating interacting with remote subprocesses.""" |
| 7 | 7 |
| 8 # Map the legion directory so we can import the host controller. | 8 # Map the legion directory so we can import the host controller. |
| 9 import sys | 9 import sys |
| 10 sys.path.append('../../') | 10 sys.path.append('../../') |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 25 self.task = None | 25 self.task = None |
| 26 | 26 |
| 27 def SetUp(self): | 27 def SetUp(self): |
| 28 """Creates the task machine and waits until it connects.""" | 28 """Creates the task machine and waits until it connects.""" |
| 29 parser = argparse.ArgumentParser() | 29 parser = argparse.ArgumentParser() |
| 30 parser.add_argument('--task-hash') | 30 parser.add_argument('--task-hash') |
| 31 args, _ = parser.parse_known_args() | 31 args, _ = parser.parse_known_args() |
| 32 | 32 |
| 33 self.task = self.CreateNewTask( | 33 self.task = self.CreateNewTask( |
| 34 isolated_hash=args.task_hash, | 34 isolated_hash=args.task_hash, |
| 35 dimensions={'os': 'Ubuntu-14.04', 'pool': 'Legion'}, | 35 dimensions={'os': 'Ubuntu-14.04', 'pool': 'Chromoting'}, |
|
Mike Meade
2015/03/06 17:18:43
We merged the Legion machines in with the Chromoti
| |
| 36 idle_timeout_secs=90, connection_timeout_secs=90, | 36 idle_timeout_secs=90, connection_timeout_secs=90, |
| 37 verbosity=logging.DEBUG) | 37 verbosity=logging.DEBUG) |
| 38 self.task.Create() | 38 self.task.Create() |
| 39 self.task.WaitForConnection() | 39 self.task.WaitForConnection() |
| 40 | 40 |
| 41 def RunTest(self): | 41 def RunTest(self): |
| 42 """Main method to run the test code.""" | 42 """Main method to run the test code.""" |
| 43 self.TestLs() | 43 self.TestLs() |
| 44 self.TestTerminate() | 44 self.TestTerminate() |
| 45 self.TestMultipleProcesses() | 45 self.TestMultipleProcesses() |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 57 self.task.rpc.subprocess.Wait(sleep20) | 57 self.task.rpc.subprocess.Wait(sleep20) |
| 58 elapsed = time.time() - start | 58 elapsed = time.time() - start |
| 59 assert elapsed >= 20 | 59 assert elapsed >= 20 |
| 60 | 60 |
| 61 self.task.rpc.subprocess.Delete(sleep20) | 61 self.task.rpc.subprocess.Delete(sleep20) |
| 62 self.task.rpc.subprocess.Delete(sleep10) | 62 self.task.rpc.subprocess.Delete(sleep10) |
| 63 | 63 |
| 64 def TestTerminate(self): | 64 def TestTerminate(self): |
| 65 start = time.time() | 65 start = time.time() |
| 66 proc = self.task.rpc.subprocess.Popen(['sleep', '20']) | 66 proc = self.task.rpc.subprocess.Popen(['sleep', '20']) |
| 67 self.task.rpc.subprocess.Terminate(proc) # Implicitly deleted | 67 self.task.rpc.subprocess.Terminate(proc) |
| 68 try: | 68 try: |
| 69 self.task.rpc.subprocess.Wait(proc) | 69 self.task.rpc.subprocess.Wait(proc) |
| 70 except xmlrpclib.Fault: | 70 except xmlrpclib.Fault: |
| 71 pass | 71 pass |
| 72 finally: | |
| 73 self.task.rpc.subprocess.Delete(proc) | |
| 72 assert time.time() - start < 20 | 74 assert time.time() - start < 20 |
| 73 | 75 |
| 74 def TestLs(self): | 76 def TestLs(self): |
| 75 proc = self.task.rpc.subprocess.Popen(['ls']) | 77 proc = self.task.rpc.subprocess.Popen(['ls']) |
| 76 self.task.rpc.subprocess.Wait(proc) | 78 self.task.rpc.subprocess.Wait(proc) |
| 77 assert self.task.rpc.subprocess.GetReturncode(proc) == 0 | 79 assert self.task.rpc.subprocess.GetReturncode(proc) == 0 |
| 78 assert 'task.isolate' in self.task.rpc.subprocess.ReadStdout(proc) | 80 assert 'task.isolate' in self.task.rpc.subprocess.ReadStdout(proc) |
| 79 self.task.rpc.subprocess.Delete(proc) | 81 self.task.rpc.subprocess.Delete(proc) |
| 80 | 82 |
| 81 | 83 |
| 82 if __name__ == '__main__': | 84 if __name__ == '__main__': |
| 83 ExampleTestController().RunController() | 85 ExampleTestController().RunController() |
| OLD | NEW |