Home | History | Annotate | Download | only in p2p_EndToEndTest
      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 
      5 import time
      6 import uuid
      7 
      8 from autotest_lib.client.common_lib import error
      9 from autotest_lib.server import hosts
     10 from autotest_lib.server.cros import queue_barrier
     11 
     12 AUTHOR = "chromeos-installer (a] google.com"
     13 NAME = "p2p_EndToEndTest"
     14 TIME = "MEDIUM"
     15 TEST_CATEGORY = "Functional"
     16 TEST_CLASS = "platform"
     17 TEST_TYPE = "server"
     18 BUG_TEMPLATE = {
     19     'cc': ['chromeos-installer-alerts (a] google.com'],
     20     'components': ['Internals>Installer'],
     21 }
     22 
     23 DOC = """
     24 End-to-end test of the peer-to-peer (p2p) file sharing system.
     25 
     26 The test runs over a set of N machines generating a random file in one of
     27 them (called the "master") and sharing it with the rest of the machines. The
     28 success condition of this test occurs when all the N machines have the same
     29 generated file before a certain timeout.
     30 
     31 To simulate a progressive download of the shared file in the master, the
     32 file becomes available in two parts. The first part of the file is available
     33 at the beginning of the test, while the second part appears later.
     34 """
     35 
     36 def 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 
     46 if 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.
     50 file_id = "%s-%s" % (time.strftime("%Y%m%d-%H%M"), uuid.uuid4())
     51 
     52 # Create the shared QueueBarrier to synchronize the processes.
     53 barrier = queue_barrier.QueueBarrier(len(machines)-1)
     54 
     55 # Pick any DUT as the master.
     56 master = machines[0]
     57 
     58 job.parallel_simple(run, machines)
     59