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

Unified Diff: testing/legion/examples/events/controller.py

Issue 1585373003: Adding a cross-task eventing server. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressing reviewer comments Created 4 years, 11 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 side-by-side diff with in-line comments
Download patch
Index: testing/legion/examples/events/controller.py
diff --git a/testing/legion/examples/events/controller.py b/testing/legion/examples/events/controller.py
new file mode 100755
index 0000000000000000000000000000000000000000..cbe246de254669c2991e21b1658e4bda0d6e6829
--- /dev/null
+++ b/testing/legion/examples/events/controller.py
@@ -0,0 +1,73 @@
+#!/usr/bin/env python
+# Copyright 2016 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+"""A simple event server test case.
+
+This test will go through all of the possible event states and ensures their
+return codes are what are expected.
+"""
+
+import argparse
+import logging
+import os
+import sys
+import time
+
+# Map the testing directory so we can import legion.legion_test_case.
+TESTING_DIR = os.path.join(
+ os.path.dirname(os.path.abspath(__file__)),
+ '..', '..', '..', '..', 'testing')
+sys.path.append(TESTING_DIR)
+
+from legion import legion_test_case
+from legion.lib import common_lib
+
+
+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('--os', default='Ubuntu-14.04')
+ args, _ = parser.parse_known_args()
M-A Ruel 2016/01/18 21:57:36 why not parse_args()?
Mike Meade 2016/01/19 21:53:23 Because there can be other flags (i.e. flags for t
+
+ task = cls.CreateTask(
+ isolated_hash=args.task_hash,
+ dimensions={'os': args.os},
+ idle_timeout_secs=90,
+ connection_timeout_secs=90,
+ verbosity=logging.DEBUG)
+ task.Create()
+ return task
+
+ @classmethod
+ def setUpClass(cls):
+ """Creates the task machines and waits until they connect."""
+ cls.task = cls.CreateTestTask()
+ cls.task.WaitForConnection()
+
+ 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)
+ # Add a success logging statement to make the logs a little easier to read.
+ logging.info('Success')
+
+
+if __name__ == '__main__':
+ legion_test_case.main()

Powered by Google App Engine
This is Rietveld 408576698