| # Copyright (c) 2013 The Chromium OS Authors. All rights reserved. |
| # Use of this source code is governed by a BSD-style license that can be |
| # found in the LICENSE file. |
| |
| import time |
| import uuid |
| |
| from autotest_lib.client.common_lib import error |
| from autotest_lib.server import hosts |
| from autotest_lib.server.cros import queue_barrier |
| |
| AUTHOR = "chromeos-installer@google.com" |
| NAME = "p2p_EndToEndTest" |
| TIME = "MEDIUM" |
| TEST_CATEGORY = "Functional" |
| TEST_CLASS = "platform" |
| TEST_TYPE = "server" |
| |
| DOC = """ |
| End-to-end test of the peer-to-peer (p2p) file sharing system. |
| |
| The test runs over a set of N machines generating a random file in one of |
| them (called the "master") and sharing it with the rest of the machines. The |
| success condition of this test occurs when all the N machines have the same |
| generated file before a certain timeout. |
| |
| To simulate a progressive download of the shared file in the master, the |
| file becomes available in two parts. The first part of the file is available |
| at the beginning of the test, while the second part appears later. |
| """ |
| |
| def run(machine): |
| dut = hosts.create_host(machine) |
| |
| job.run_test('p2p_EndToEndTest', |
| dut=dut, |
| file_id=file_id, |
| is_master=(machine == master), |
| peers=machines, |
| barrier=barrier) |
| |
| if len(machines) < 2: |
| raise error.TestError('At least two machines are needed for this test') |
| |
| # The file ID shared among all test machines. |
| file_id = "%s-%s" % (time.strftime("%Y%m%d-%H%M"), uuid.uuid4()) |
| |
| # Create the shared QueueBarrier to synchronize the processes. |
| barrier = queue_barrier.QueueBarrier(len(machines)-1) |
| |
| # Pick any DUT as the master. |
| master = machines[0] |
| |
| job.parallel_simple(run, machines) |