From: Claudio-Daniel Freire Date: Tue, 26 Apr 2011 16:31:46 +0000 (+0200) Subject: Ticket #21: support for netpipe stats traces X-Git-Tag: nepi_v2~113 X-Git-Url: http://git.onelab.eu/?a=commitdiff_plain;h=073efe30348390088fc4949f6cb027d35d5f8a7c;p=nepi.git Ticket #21: support for netpipe stats traces --- diff --git a/src/nepi/testbeds/planetlab/interfaces.py b/src/nepi/testbeds/planetlab/interfaces.py index 876e6d0f..c5e23ac9 100644 --- a/src/nepi/testbeds/planetlab/interfaces.py +++ b/src/nepi/testbeds/planetlab/interfaces.py @@ -5,6 +5,9 @@ from constants import TESTBED_ID import nepi.util.ipaddr2 as ipaddr2 import nepi.util.server as server import plcapi +import subprocess +import os +import os.path class NodeIface(object): def __init__(self, api=None): @@ -191,7 +194,6 @@ class NetPipe(object): # set up rule scope, options = self._get_ruledef() command = "sudo -S netconfig config %s %s %s" % (self.mode, scope, options) - print command (out,err),proc = server.popen_ssh_command( command, @@ -249,3 +251,39 @@ class NetPipe(object): self.configured = False + def sync_trace(self, local_dir, whichtrace): + if whichtrace != 'netpipeStats': + raise ValueError, "Unsupported trace %s" % (whichtrace,) + + local_path = os.path.join(local_dir, "netpipe_stats_%s" % (self.mode,)) + + # create parent local folders + proc = subprocess.Popen( + ["mkdir", "-p", os.path.dirname(local_path)], + stdout = open("/dev/null","w"), + stdin = open("/dev/null","r")) + + if proc.wait(): + raise RuntimeError, "Failed to synchronize trace: %s %s" % (out,err,) + + (out,err),proc = server.popen_ssh_command( + "echo 'Rules:' ; sudo -S netconfig show rules ; echo 'Pipes:' ; sudo -S netconfig show pipes", + host = self.node.hostname, + port = None, + user = self.node.slicename, + agent = None, + ident_key = self.node.ident_path, + server_key = self.node.server_key + ) + + if proc.wait(): + raise RuntimeError, "Failed to synchronize trace: %s %s" % (out,err,) + + # dump results to file + f = open(local_path, "wb") + f.write(err or "") + f.write(out or "") + f.close() + + return local_path + diff --git a/src/nepi/testbeds/planetlab/metadata_v01.py b/src/nepi/testbeds/planetlab/metadata_v01.py index faa53795..b0b0c474 100644 --- a/src/nepi/testbeds/planetlab/metadata_v01.py +++ b/src/nepi/testbeds/planetlab/metadata_v01.py @@ -604,6 +604,11 @@ traces = dict({ "name": "buildlog", "help": "Output of the build process", }), + + "netpipe_stats": dict({ + "name": "netpipeStats", + "help": "Information about rule match counters, packets dropped, etc.", + }), }) create_order = [ INTERNET, NODE, NODEIFACE, TUNIFACE, NETPIPE, APPLICATION ] @@ -681,7 +686,7 @@ factories_info = dict({ "bw_in","plr_in","delay_in", "bw_out","plr_out","delay_out"], "connector_types": ["node"], - "traces": ["stdout", "stderr"] + "traces": ["netpipe_stats"] }), }) diff --git a/test/testbeds/planetlab/execute.py b/test/testbeds/planetlab/execute.py index 0156d732..4b67d3d6 100755 --- a/test/testbeds/planetlab/execute.py +++ b/test/testbeds/planetlab/execute.py @@ -222,6 +222,7 @@ echo 'OKIDOKI' instance.defer_create_set(7, "plrIn", 0.001) # 0.1% plr inbound - regular loss instance.defer_create_set(7, "delayOut", int(1500 * 8 / (12.0/1024.0) / 1000)) # tx delay at 12kbps in ms instance.defer_create_set(7, "delayIn", int(1500 * 8 / (64.0/1024.0) / 1000)) # rx delay at 64kbps in ms + instance.defer_add_trace(7, "netpipeStats") instance.defer_connect(2, "pipes", 7, "node") instance.defer_create(8, "Application") instance.defer_create_set(8, "command", "time wget -q -O /dev/null http://www.google.com/") # Fetch ~10kb @@ -246,6 +247,10 @@ echo 'OKIDOKI' minutes = int(match.group("min")) seconds = float(match.group("sec")) self.assertTrue((minutes * 60 + seconds) > 1.0, "Emulation not effective: %s" % (test_result,)) + + netpipe_stats = instance.trace(7, "netpipeStats") + self.assertTrue(netpipe_stats, "Unavailable netpipe stats") + instance.stop() instance.shutdown()