So I've split the netpipe and netperf control files into separate control
files and a .py file for each one, so that it will be easier to add
additional tests that use the logic of the python scripts without
duplicating code.

I'm also taking advantage of the new added function to get the
platform_label, as in my testbed I have assigned a net_server platform label
for the machines I want to use as the network side of these tests.

Let me know your thoughts on this, as some of you might think the stress
version of these tests belongs in a site_tests directory. But definitely
splitting the code out with the reusable code in a separate python scripts
seems like a good idea.

Regards,

Kelly

-- 
K.D. Lucas
[email protected]
Index: server/tests/netpipe/control.srv
===================================================================
--- server/tests/netpipe/control.srv	(revision 4275)
+++ server/tests/netpipe/control.srv	(working copy)
@@ -1,6 +1,6 @@
-AUTHOR = "[email protected] (Bryce Boe)"
+AUTHOR = "[email protected] (Kelly Lucas)"
 TIME = "SHORT"
-NAME = "Netpipe Multi-machine"
+NAME = "Netpipe Basic"
 TEST_CATEGORY = "Stress"
 TEST_CLASS = 'Hardware'
 TEST_TYPE = "Server"
@@ -10,16 +10,13 @@
 incrementing buffer sizes.
 
 Arguments to run_test:
-server_ip     - the ip of the server (automatically filled in)
-client_ip     - the ip of the client (automatically filled in)
-role          - specifies either client or server (automatically filled in)
 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)
-perturbation_size -  NetPIPE chooses the message sizes at regular intervals,
+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
@@ -30,31 +27,14 @@
 
 from autotest_lib.server import utils
 
+buffer_size = 1048576
+upper_bound = 1048576
+variance = 17
 
 def run(pair):
-    print "running on %s and %s\n" % (pair[0], pair[1])
-    server = hosts.create_host(pair[0])
-    client = hosts.create_host(pair[1])
+    job.run_test('netpipe', pair=pair, buffer=buffer_size,
+                 upper_bound=upper_bound, variance=variance)
 
-    server_at = autotest.Autotest(server)
-    client_at = autotest.Autotest(client)
-
-    template = ''.join(["job.run_test('netpipe', server_ip='%s', client_ip=",
-                        "'%s', role='%s', bidirectional=True,",
-                        "buffer_size=1048576, upper_bound=1048576,"
-                        "perturbation_size=17)"])
-
-    server_control_file = template % (server.ip, client.ip, 'server')
-    client_control_file = template % (server.ip, client.ip, 'client')
-
-    server_command = subcommand(server_at.run,
-                                [server_control_file, server.hostname])
-    client_command = subcommand(client_at.run,
-                                [client_control_file, client.hostname])
-
-    parallel([server_command, client_command])
-
-
 # grab the pairs (and failures)
 (pairs, failures) = utils.form_ntuples_from_machines(machines, 2)
 
Index: server/tests/netpipe/control.stress.srv
===================================================================
--- server/tests/netpipe/control.stress.srv	(revision 0)
+++ server/tests/netpipe/control.stress.srv	(revision 0)
@@ -0,0 +1,63 @@
+AUTHOR = "[email protected] (Kelly Lucas)"
+TIME = "MEDIUM"
+NAME = "Netpipe Stress"
+TEST_CATEGORY = "Stress"
+TEST_CLASS = 'Network'
+TEST_TYPE = "Server"
+SYNC_COUNT = 2
+DOC = """
+netpipe_stress is a test which produces bandwidth and latency values for
+incrementing buffer sizes. This stress test will run for approximately 1 hour.
+If you need to adjust the run time, change the value of cycles in the run
+function.
+
+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)
+cycles        - Number of times to repeat each test. Each cycle takes about 6
+                minutes to complete.
+"""
+
+from autotest_lib.server import utils
+
+# Buffer sizes should not be less than 131072, as this will cause netpipe
+# to hang. 
+buffer_sizes = {131072: 'small',
+                262144: 'medium',
+                524288: 'large',
+                1048576: 'huge',
+               }
+cycles = 10
+upper_bound = 1048576
+variance = 17
+
+def run(pair):
+    for x in xrange(cycles):
+        for b in buffer_sizes:
+            tag = 'netpipe' + buffer_sizes[b] + str(x)
+            job.run_test('netpipe', tag=tag, pair=pair, buffer=b,
+                         upper_bound=upper_bound, variance=variance)
+
+
+# grab the pairs (and failures)
+print "Machines = %s" % machines
+(pairs, failures) = utils.form_ntuples_from_machines(machines, 2)
+print "pairs = %s" % pairs
+
+# 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)
Index: server/tests/netpipe/netpipe.py
===================================================================
--- server/tests/netpipe/netpipe.py	(revision 0)
+++ server/tests/netpipe/netpipe.py	(revision 0)
@@ -0,0 +1,50 @@
+from autotest_lib.server import autotest, hosts, subcommand, test
+from autotest_lib.server import utils
+
+class netpipe(test.test):
+    version = 2
+
+    def run_once(self, pair, buffer, upper_bound, variance):
+        print "running on %s and %s\n" % (pair[0], pair[1])
+
+        # We may want to run the server side test on specific servers, if they
+        # area available. If not, then we'll revert to randomly selecting the
+        # client and the server.
+        server_label = 'net_server'
+        # These iptable commands are needed when ip filtering is being used.
+        iptable_cmds = '%s\n%s\n%s\n' % (
+            "utils.system('/sbin/iptables -P INPUT ACCEPT')",
+            "utils.system('/sbin/iptables -P FORWARD ACCEPT')",
+            "utils.system('/sbin/iptables -P OUTPUT ACCEPT')")
+        server = hosts.create_host(pair[0])
+        client = hosts.create_host(pair[1])
+
+        # If client has the server_label, then swap server and client.
+        platform_label = client.get_platform_label()
+        if platform_label == server_label:
+            (server, client) = (client, server)
+
+        server_at = autotest.Autotest(server)
+        client_at = autotest.Autotest(client)
+
+        template = ''.join(["job.run_test('netpipe', server_ip='%s', ",
+                            "client_ip='%s', role='%s', bidirectional=True, ",
+                            "buffer_size=%d, upper_bound=%d,"
+                            "perturbation_size=%d)"])
+
+        server_control_file = template % (server.ip, client.ip, 'server',
+                                          buffer, upper_bound, variance)
+        client_control_file = template % (server.ip, client.ip, 'client',
+                                          buffer, upper_bound, variance)
+
+        # Include iptable commands in case devices are running ip filtering.
+        # This should not cause issues if ip filtering is not in use.
+        server_control_file = iptable_cmds + server_control_file
+        client_control_file = iptable_cmds + client_control_file
+
+        server_command = subcommand.subcommand(server_at.run,
+                                    [server_control_file, server.hostname])
+        client_command = subcommand.subcommand(client_at.run,
+                                    [client_control_file, client.hostname])
+
+        subcommand.parallel([server_command, client_command])
Index: server/tests/netperf2/control.srv
===================================================================
--- server/tests/netperf2/control.srv	(revision 4275)
+++ server/tests/netperf2/control.srv	(working copy)
@@ -1,19 +1,16 @@
-AUTHOR = "[email protected] (Martin Bligh) and [email protected] (Bryce Boe)"
+AUTHOR = "[email protected] (K.D. Lucas)"
 TIME = "SHORT"
-NAME = "Netperf Multi-machine"
-TEST_CATEGORY = "Stress"
-TEST_CLASS = 'Hardware'
+NAME = "Netperf Basic"
+TEST_CATEGORY = "Benchmark"
+TEST_CLASS = 'Network'
 TEST_TYPE = "Server"
 SYNC_COUNT = 2
 DOC = """
-netperf_test is a 2 machine test (server/client) that measures the performance
+netperf2 is a 2 machine test (server/client) that measures the performance
 of various network attributes.
 
 Arguments to run_test:
 
-server_ip     - the ip of the server (automatically filled in)
-client_ip     - the ip of the client (automatically filled in)
-role          - specifies either client or server (automatically filled in)
 test          - the list of valid netperf tests that can be run
                 This currently is:
                   TCP_STREAM, TCP_SENDFILE, TCP_RR, TCP_CRR, UDP_STREAM, UDP_RR
@@ -22,34 +19,16 @@
                 the list is [1,10,100] then the test will run 3 times. If
                 bidirectional is set then there will be the specified number of
                 bidirectional streams.
+cycles        - The number of times to run each test.
 """
 
 from autotest_lib.server import utils
 
 
 def run(pair):
-    print "running on %s and %s\n" % (pair[0], pair[1])
-    server = hosts.create_host(pair[0])
-    client = hosts.create_host(pair[1])
+    job.run_test('netperf2', pair=pair, test='TCP_STREAM', time=10,
+                 stream_list=[1], cycles=1)
 
-    server_at = autotest.Autotest(server)
-    client_at = autotest.Autotest(client)
-
-    template = ''.join(["job.run_test('netperf2', server_ip='%s', client_ip=",
-                        "'%s', role='%s', test='TCP_STREAM', test_time=10,",
-                        "stream_list=[1,10])"])
-
-    server_control_file = template % (server.ip, client.ip, 'server')
-    client_control_file = template % (server.ip, client.ip, 'client')
-
-    server_command = subcommand(server_at.run,
-                                [server_control_file, server.hostname])
-    client_command = subcommand(client_at.run,
-                                [client_control_file, client.hostname])
-
-    parallel([server_command, client_command])
-
-
 # grab the pairs (and failures)
 (pairs, failures) = utils.form_ntuples_from_machines(machines, 2)
 
Index: server/tests/netperf2/control.stress.srv
===================================================================
--- server/tests/netperf2/control.stress.srv	(revision 0)
+++ server/tests/netperf2/control.stress.srv	(revision 0)
@@ -0,0 +1,49 @@
+AUTHOR = "[email protected] (Kelly Lucas)"
+TIME = "MEDIUM"
+NAME = "Netperf Stress"
+TEST_CATEGORY = "Stress"
+TEST_CLASS = 'Network'
+TEST_TYPE = "Server"
+SYNC_COUNT = 2
+DOC = """
+netperf_stress is a 2 machine test (server/client) that measures the performance
+of various network attributes. This test will cycle through the various types
+of supported tests and streams, and will take about 1 hour to run. 
+You can adjust the streams by changing the values of the streams list in the
+run function.
+
+Arguments to run_test:
+
+test          - the list of valid netperf tests that can be run
+                This currently is:
+                  TCP_STREAM, TCP_SENDFILE, TCP_RR, TCP_CRR, UDP_STREAM, UDP_RR
+test_time     - Specifies how long each iteration of the test should run for.
+stream_list   - A list containing the number of streams to run the test for. If
+                the list is [1,10,100] then the test will run 3 times. If
+                bidirectional is set then there will be the specified number of
+                bidirectional streams.
+"""
+
+from autotest_lib.server import utils
+
+
+def run(pair):
+    """
+    Run netperf with various parameter settings.
+    """
+    streams = [1, 10, 20, 40, 60, 80, 100, 200]
+    for t in ['TCP_STREAM', 'TCP_MAERTS', 'TCP_RR', 'TCP_CRR', 'UDP_RR']:
+        tag = 'netprerf2' + t
+        job.run_test('netperf2', tag=tag, pair=pair, test=t, time=60,
+                     stream_list=streams, cycles=1)
+
+
+# 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], "netperf2", failure[1])
+
+# now run through each pair and run
+job.parallel_simple(run, pairs, log=False)
Index: server/tests/netperf2/netperf2.py
===================================================================
--- server/tests/netperf2/netperf2.py	(revision 0)
+++ server/tests/netperf2/netperf2.py	(revision 0)
@@ -0,0 +1,48 @@
+from autotest_lib.server import autotest, hosts, subcommand, test
+from autotest_lib.server import utils
+
+class netperf2(test.test):
+    version = 2
+
+    def run_once(self, pair, test, time, stream_list, cycles):
+        print "running on %s and %s\n" % (pair[0], pair[1])
+
+        # Ensure the server side test gets run on a designated server.
+        server_label = 'net_server'
+        # iptable commands are needed when using two Chrome OS devices.
+        iptable_cmds = '%s\n%s\n%s\n' % (
+            "utils.system('/sbin/iptables -P INPUT ACCEPT')",
+            "utils.system('/sbin/iptables -P FORWARD ACCEPT')",
+            "utils.system('/sbin/iptables -P OUTPUT ACCEPT')")
+        server = hosts.create_host(pair[0])
+        client = hosts.create_host(pair[1])
+
+        # If client has the server_label, then swap server and client.
+        platform_label = client.get_platform_label()
+        if platform_label == server_label:
+            (server, client) = (client, server)
+
+        server_at = autotest.Autotest(server)
+        client_at = autotest.Autotest(client)
+
+        template = ''.join(["job.run_test('netperf2', server_ip='%s', ",
+                            "client_ip='%s', role='%s', test='%s', ",
+                            "test_time=%d, stream_list=%s, tag='%s', ",
+                            "iterations=%d)"])
+
+        server_control_file = template % (server.ip, client.ip, 'server', test, 
+                                          time, stream_list, test, cycles)
+        client_control_file = template % (server.ip, client.ip, 'client', test,
+                                          time, stream_list, test, cycles)
+
+        # Include iptable commands in case devices are running ip filtering.
+        # This should not cause issues if ip filtering is not in use.
+        server_control_file = iptable_cmds + server_control_file
+        client_control_file = iptable_cmds + client_control_file
+
+        server_command = subcommand.subcommand(server_at.run,
+                                    [server_control_file, server.hostname])
+        client_command = subcommand.subcommand(client_at.run,
+                                    [client_control_file, client.hostname])
+
+        subcommand.parallel([server_command, client_command])
_______________________________________________
Autotest mailing list
[email protected]
http://test.kernel.org/cgi-bin/mailman/listinfo/autotest

Reply via email to