Index: testing/legion/examples/events/controller.py |
diff --git a/testing/legion/examples/hello_world/controller_test.py b/testing/legion/examples/events/controller.py |
similarity index 56% |
copy from testing/legion/examples/hello_world/controller_test.py |
copy to testing/legion/examples/events/controller.py |
index e7d29497b72e3492824f9dcd9285b09c172c736e..4a6a8efc9d859446f0c8932fcaede6d5ff6cd908 100755 |
--- a/testing/legion/examples/hello_world/controller_test.py |
+++ b/testing/legion/examples/events/controller.py |
@@ -22,21 +22,22 @@ TESTING_DIR = os.path.join( |
sys.path.append(TESTING_DIR) |
from legion import legion_test_case |
+from legion.lib import common_lib |
-class ExampleTestController(legion_test_case.TestCase): |
+class EventTestController(legion_test_case.TestCase): |
"""A simple example controller for a test.""" |
@classmethod |
def CreateTestTask(cls): |
"""Create a new task.""" |
parser = argparse.ArgumentParser() |
- parser.add_argument('--task-hash') |
+ parser.add_argument('--task') |
M-A Ruel
2016/01/15 14:07:13
I think it'd be a good idea to have a description
Mike Meade
2016/01/18 20:25:51
Changed to task-hash to be more descriptive and mo
|
parser.add_argument('--os', default='Ubuntu-14.04') |
M-A Ruel
2016/01/15 14:07:13
You should make it a --dimension flag and permits
Mike Meade
2016/01/18 20:25:51
These are defined by the test case author, not the
|
args, _ = parser.parse_known_args() |
task = cls.CreateTask( |
- isolated_hash=args.task_hash, |
+ isolated_hash=args.task, |
dimensions={'os': args.os}, |
idle_timeout_secs=90, |
connection_timeout_secs=90, |
@@ -47,30 +48,23 @@ class ExampleTestController(legion_test_case.TestCase): |
@classmethod |
def setUpClass(cls): |
"""Creates the task machines and waits until they connect.""" |
- cls.task1 = cls.CreateTestTask() |
- cls.task2 = cls.CreateTestTask() |
- cls.task1.WaitForConnection() |
- cls.task2.WaitForConnection() |
+ cls.task = cls.CreateTestTask() |
+ cls.task.WaitForConnection() |
- def testCallEcho(self): |
- """Tests rpc.Echo on a task.""" |
- logging.info('Calling Echo on %s', self.task2.name) |
- self.assertEqual(self.task2.rpc.Echo('foo'), 'echo foo') |
- |
- def testLaunchTaskBinary(self): |
- """Call task_test.py 'name' on the tasks.""" |
- self.VerifyTaskBinaryLaunched(self.task1) |
- self.VerifyTaskBinaryLaunched(self.task2) |
- |
- def VerifyTaskBinaryLaunched(self, task): |
- logging.info( |
- 'Calling Process to run "task_test.py %s"', task.name) |
- proc = task.Process(['python', 'task_test.py', task.name]) |
- proc.Wait() |
- self.assertEqual(proc.GetReturncode(), 0) |
- self.assertIn(task.name, proc.ReadStdout()) |
- self.assertEquals(proc.ReadStderr(), '') |
- proc.Delete() |
+ def testEventTest(self): |
+ cmd = [ |
+ 'python', |
+ 'task.py', |
+ '--address', str(common_lib.MY_IP), |
+ '--port', str(self.event_server.port) |
+ ] |
+ process = self.task.Process(cmd) |
+ process.Wait() |
+ retcode = process.GetReturncode() |
+ if retcode != 0: |
+ logging.info('STDOUT:\n%s', process.ReadStdout()) |
+ logging.info('STDERR:\n%s', process.ReadStderr()) |
+ self.assertEqual(retcode, 0) |
if __name__ == '__main__': |