AUTHOR = "kdlucas@google.com (Kelly Lucas)"
TIME = "SHORT"
NAME = "Netpipe Basic"
TEST_CATEGORY = "Stress"
TEST_CLASS = 'Hardware'
TEST_TYPE = "Server"
SYNC_COUNT = 2
DOC = """
netpipe_test is a test which produces bandwidth and latency values for
incrementing buffer sizes.

Arguments to run_test:
bidirectional - indicates whether the test should run simultaneously in both
                directions
buffer_size   - Sets the send and receive TCP buffer sizes (from man NPtcp)
upper_bound   - Specify the upper boundary to the size of message being tested.
                By default, NetPIPE will stop when the time to transmit a block
                exceeds one second. (from man NPtcp)
variance      -  NetPIPE chooses the message sizes at regular intervals,
                increasing them exponentially from the lower boundary to the
                upper boundary. At each point, it also tests perturbations of 3
                bytes above and 3 bytes below (default) each test point to find
                idiosyncrasies in the system. This perturbation  value  can be
                changed using using this option or turned off by setting
                perturbation_size to 0. (from man NPtcp)
"""

from autotest_lib.server import utils

buffer_size = 1048576
upper_bound = 1048576
variance = 17

def run(pair):
    job.run_test('netpipe', pair=pair, buffer=buffer_size,
                 upper_bound=upper_bound, variance=variance)

# grab the pairs (and failures)
(pairs, failures) = utils.form_ntuples_from_machines(machines, 2)

# log the failures
for failure in failures:
    job.record("FAIL", failure[0], "netpipe", failure[1])

# now run through each pair and run
job.parallel_simple(run, pairs, log=False)