Home | History | Annotate | Download | only in samples
      1 AUTHOR = 'Ashwin Ganti (aganti (a] google.com)'
      2 TIME ='SHORT'
      3 DEPENDENCIES = 'STANDARD'
      4 NAME = 'Parallel Sleeptest'
      5 TEST_TYPE = 'server'
      6 TEST_CATEGORY = 'Functional'
      7 DOC = """\
      8 This control file executes multiple sleeptest tests on a machine
      9 starting at the same time. Multiple machines can also be specified
     10 wherein the specified set of tests are executed in parallel
     11 on each of the machines.
     12 
     13 To run a different set of tests do the following:
     14 1. Replace the sleeptest control files with the required test control files
     15 2. Give tag names for each of the tests
     16 3. Run the control file through autoserv using
     17    server/autoserv <this control file path> -m <machines> -r <subdir to contain the run results>
     18 """
     19 
     20 from autotest_lib.client.common_lib import utils
     21 
     22 # Specify the path to the client control files and the tag names
     23 # for the respective jobs here.
     24 tests = [("client/tests/sleeptest/control", "sleeptag0"),
     25          ("client/tests/sleeptest/control", "sleeptag1"),
     26          ]
     27 
     28 def run_client(at, machine_name, machine_num, instance):
     29     control = open(os.path.join(job.autodir,tests[instance][0])).read()
     30     '''
     31     The get_sync_control_file method basically does the setup of the barriers
     32     required to start these multiple tests at the same time and returns the
     33     modified control file (that contains the barrier code added to it)
     34     Check client/common_lib/utils.py for detailed documentation of how this
     35     method sets up the barriers.
     36     '''
     37     control_new = utils.get_sync_control_file(control, machine_name,
     38                                     machine_num, instance, len(tests))
     39     '''
     40     This control file is now simply passed in to the run method along with
     41     a tag name of the test and a 'parallel_flag' that identifies this scenario
     42     of running multiple tests on the same machine at the same time.
     43     '''
     44     at.run(control_new, tag='%s' % tests[instance][1], parallel_flag=True)
     45 
     46 def main(machine_name, machine_num):
     47     host = hosts.create_host(machine_name)
     48     at = autotest.Autotest(host)
     49     at.install()
     50 
     51     parallel([subcommand(run_client, [at, machine_name, machine_num, i])
     52               for i in range(len(tests))])
     53 
     54 parallel([subcommand(main, [machines[i], i], machines[i])
     55           for i in range(len(machines))])
     56