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

Unified Diff: testing/legion/examples/hello_world/host_test.py

Issue 951673002: Revert "Pull chromium at 2c3ffb2355a27c32f45e508ef861416b820c823b" (Closed) Base URL: git@github.com:domokit/mojo.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 side-by-side diff with in-line comments
Download patch
Index: testing/legion/examples/hello_world/host_test.py
diff --git a/testing/legion/examples/hello_world/host_test.py b/testing/legion/examples/hello_world/host_test.py
new file mode 100755
index 0000000000000000000000000000000000000000..7a7875b7a311d5f6099550777efa8ec5af487f47
--- /dev/null
+++ b/testing/legion/examples/hello_world/host_test.py
@@ -0,0 +1,77 @@
+#!/usr/bin/env python
+# Copyright 2015 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 host test module.
+
+This module runs on the host machine and is responsible for creating 2
+client machines, waiting for them, and running RPC calls on them.
+"""
+
+# Map the legion directory so we can import the host controller.
+import sys
+sys.path.append('../../')
+
+import logging
+import time
+
+import host_controller
+
+
+class ExampleController(host_controller.HostController):
+ """A simple example controller for a test."""
+
+ def __init__(self):
+ super(ExampleController, self).__init__()
+ self.client1 = None
+ self.client2 = None
+
+ def CreateClient(self):
+ """Create a client object and set the proper values."""
+ client = self.NewClient(
+ isolate_file='client_test.isolate',
+ config_vars={'multi_machine': '1'},
+ dimensions={'os': 'legion-linux'}, priority=200,
+ idle_timeout_secs=90, connection_timeout_secs=90,
+ verbosity=logging.INFO)
+ client.Create()
+ return client
+
+ def SetUp(self):
+ """Create the client machines and wait until they connect.
+
+ In this call the actual creation of the client machines is done in parallel
+ by the system. The WaitForConnect calls are performed in series but will
+ return as soon as the clients connect.
+ """
+ self.client1 = self.CreateClient()
+ self.client2 = self.CreateClient()
+ self.client1.WaitForConnection()
+ self.client2.WaitForConnection()
+
+ def Task(self):
+ """Main method to run the task code."""
+ self.CallEcho(self.client1)
+ self.CallEcho(self.client2)
+ self.CallClientTest(self.client1)
+ self.CallClientTest(self.client2)
+
+ def CallEcho(self, client):
+ """Call rpc.Echo on a client."""
+ logging.info('Calling Echo on %s', client.name)
+ logging.info(client.rpc.Echo(client.name))
+
+ def CallClientTest(self, client):
+ """Call client_test.py name on a client."""
+ logging.info('Calling Subprocess to run "./client_test.py %s"', client.name)
+ proc = client.rpc.subprocess.Popen(['./client_test.py', client.name])
+ client.rpc.subprocess.Wait(proc)
+ retcode = client.rpc.subprocess.GetReturncode(proc)
+ stdout = client.rpc.subprocess.ReadStdout(proc)
+ stderr = client.rpc.subprocess.ReadStderr(proc)
+ logging.info('retcode: %s, stdout: %s, stderr: %s', retcode, stdout, stderr)
+
+
+if __name__ == '__main__':
+ ExampleController().RunController()
« no previous file with comments | « testing/legion/examples/hello_world/host_test.isolate ('k') | testing/legion/examples/hello_world/task_test.isolate » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698