• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1AUTHOR = "gps@google.com (Gregory P. Smith)"
2TIME = "SHORT"
3NAME = "barrier_2client"
4TEST_CATEGORY = "Functional"
5TEST_CLASS = 'Network'
6TEST_TYPE = "Server"
7SYNC_COUNT = 2
8DOC = """
9A functional test of autotest's Barrier mechanisms for synchronizing
10events between two clients without the help of the server.
11"""
12
13from autotest_lib.server import utils
14from six.moves import zip
15
16def run(pair):
17    logging.info('Running on %s and %s', pair[0], pair[1])
18    host_objs = [hosts.create_host(machine) for machine in pair]
19    host_at_objs = [autotest.Autotest(host) for host in host_objs]
20
21    client_control_template = """
22import logging, platform, socket, traceback
23try:
24    client_hostnames = %r
25    master_hostname = client_hostnames[0]
26    client_hostname = client_hostnames[1]
27
28    logging.info('Testing hostname only barrier')
29    barrier = job.barrier(platform.node(), 'barriertest_2client', 120)
30    logging.info('rendezvous-ing')
31    barrier.rendezvous(master_hostname, client_hostname)
32    logging.info('done.')
33
34    logging.info('Testing local identifier barrier')
35    barrier = job.barrier(platform.node() + '#id0', 'barriertest_2client', 120)
36    logging.info('rendezvous-ing')
37    barrier.rendezvous(master_hostname + '#id0',
38                       client_hostname + '#id0')
39    logging.info('done.')
40
41    logging.info('Testing IP@ barrier')
42    barrier = job.barrier(socket.gethostbyname(platform.node()),
43                          'barriertest_2client', 120)
44    logging.info('rendezvous-ing')
45    barrier.rendezvous(socket.gethostbyname(master_hostname),
46                       socket.gethostbyname(client_hostname))
47    logging.info('done.')
48
49    logging.info('Testing IP@ barrier with ids')
50    barrier = job.barrier(socket.gethostbyname(platform.node()) + '#42',
51                          'barriertest_2client', 120)
52    logging.info('rendezvous-ing')
53    barrier.rendezvous(socket.gethostbyname(master_hostname) + '#42',
54                       socket.gethostbyname(client_hostname) + '#42')
55    logging.info('done.')
56except:
57    traceback.print_exc()
58    raise
59"""
60    client_controls = [client_control_template % (pair,) for host in host_objs]
61
62    subcommand_list = []
63    for host, host_at, control in zip(host_objs, host_at_objs, client_controls):
64        subcommand_list.append(subcommand(host_at.run,
65                                          (control, host.hostname)))
66
67    parallel(subcommand_list)
68
69
70# grab the pairs (and failures)
71(pairs, failures) = utils.form_ntuples_from_machines(machines, 2)
72
73# log the failures
74for failure in failures:
75    job.record("FAIL", failure[0], "barrier_2client", failure[1])
76
77# now run through each pair and run
78job.parallel_simple(run, pairs, log=False)
79