• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright (c) 2013 The Chromium OS Authors. All rights reserved.
2# Use of this source code is governed by a BSD-style license that can be
3# found in the LICENSE file.
4
5import time
6import uuid
7
8from autotest_lib.client.common_lib import error
9from autotest_lib.server import hosts
10from autotest_lib.server.cros import queue_barrier
11
12AUTHOR = "chromeos-installer@google.com"
13NAME = "p2p_EndToEndTest"
14TIME = "MEDIUM"
15TEST_CATEGORY = "Functional"
16TEST_CLASS = "platform"
17TEST_TYPE = "server"
18BUG_TEMPLATE = {
19    'cc': ['chromeos-installer-alerts@google.com'],
20    'components': ['Internals>Installer'],
21}
22
23DOC = """
24End-to-end test of the peer-to-peer (p2p) file sharing system.
25
26The test runs over a set of N machines generating a random file in one of
27them (called the "master") and sharing it with the rest of the machines. The
28success condition of this test occurs when all the N machines have the same
29generated file before a certain timeout.
30
31To simulate a progressive download of the shared file in the master, the
32file becomes available in two parts. The first part of the file is available
33at the beginning of the test, while the second part appears later.
34"""
35
36def run(machine):
37    dut = hosts.create_host(machine)
38
39    job.run_test('p2p_EndToEndTest',
40                 dut=dut,
41                 file_id=file_id,
42                 is_master=(machine == master),
43                 peers=machines,
44                 barrier=barrier)
45
46if len(machines) < 2:
47    raise error.TestError('At least two machines are needed for this test')
48
49# The file ID shared among all test machines.
50file_id = "%s-%s" % (time.strftime("%Y%m%d-%H%M"), uuid.uuid4())
51
52# Create the shared QueueBarrier to synchronize the processes.
53barrier = queue_barrier.QueueBarrier(len(machines)-1)
54
55# Pick any DUT as the master.
56master = machines[0]
57
58job.parallel_simple(run, machines)
59