s/dedicatedSlice/cleanProc/g
[nepi.git] / test / testbeds / planetlab / execute.py
index 54330f9..557425f 100755 (executable)
@@ -5,13 +5,13 @@ import getpass
 from nepi.util.constants import ApplicationStatus as AS
 from nepi.testbeds import planetlab
 import os
+import re
 import shutil
+import sys
 import tempfile
+import test_util
 import time
 import unittest
-import re
-import test_util
-import sys
 
 class PlanetLabExecuteTestCase(unittest.TestCase):
     testbed_id = "planetlab"
@@ -35,6 +35,10 @@ class PlanetLabExecuteTestCase(unittest.TestCase):
         os.path.dirname(planetlab.__file__), 
         'scripts',
         'tosqueue.py')
+    CLS_PY = os.path.join(
+        os.path.dirname(planetlab.__file__), 
+        'scripts',
+        'classqueue.py')
     
     def setUp(self):
         self.root_dir = tempfile.mkdtemp()
@@ -70,7 +74,7 @@ class PlanetLabExecuteTestCase(unittest.TestCase):
         instance.defer_configure("plcHost", plchost)
         instance.defer_configure("tapPortBase", self.port_base)
         instance.defer_configure("p2pDeployment", False) # it's interactive, we don't want it in tests
-        instance.defer_configure("dedicatedSlice", True)
+        instance.defer_configure("cleanProc", True)
         
         # Hack, but we need vsys_vnet
         instance.do_setup()
@@ -352,7 +356,7 @@ echo 'OKIDOKI'
         self.assertTrue(netpipe_stats, "Unavailable netpipe stats")
 
     @test_util.skipUnless(test_util.pl_auth() is not None, "Test requires PlanetLab authentication info (PL_USER and PL_PASS environment variables)")
-    def _pingtest(self, TunClass, ConnectionProto, Cipher, Filter1=None, Filter2=None, Filter1args=None, Filter2args=None):
+    def _pingtest(self, TunClass, ConnectionProto, Cipher, Filter1=None, Filter2=None, Filter1args=None, Filter2args=None, PLREX=None, flood=False):
         instance = self.make_instance()
         
         instance.defer_create(2, "Node")
@@ -370,6 +374,8 @@ echo 'OKIDOKI'
         instance.defer_create_set(7, "tun_cipher", Cipher)
         instance.defer_add_trace(7, "packets")
         instance.defer_add_address(7, self.net_prefix+".2", 24, False)
+        if flood:
+            instance.defer_create_set(7, "bwlimit", 128)
         instance.defer_connect(2, "devs", 7, "node")
         instance.defer_create(8, TunClass)
         instance.defer_create_set(8, "tun_cipher", Cipher)
@@ -377,7 +383,10 @@ echo 'OKIDOKI'
         instance.defer_add_address(8, self.net_prefix+".3", 24, False)
         instance.defer_connect(3, "devs", 8, "node")
         instance.defer_create(9, "Application")
-        instance.defer_create_set(9, "command", "ping -qc10 {#[GUID-8].addr[0].[Address]#}")
+        if flood:
+            instance.defer_create_set(9, "command", "sudo -S ping -s 1000 -l 1000 -qfc1000 {#[GUID-8].addr[0].[Address]#} ; sleep 20 ; ping -qc10 {#[GUID-8].addr[0].[Address]#}")
+        else:
+            instance.defer_create_set(9, "command", "ping -qc10 {#[GUID-8].addr[0].[Address]#}")
         instance.defer_add_trace(9, "stdout")
         instance.defer_add_trace(9, "stderr")
         instance.defer_connect(9, "node", 2, "apps")
@@ -396,12 +405,15 @@ echo 'OKIDOKI'
                 instance.defer_create_set(11, "args", Filter2args)
             instance.defer_connect(8, "fd->", 11, "->fd")
 
-        if Filter1 and Filter2:
-            plr = "[5-9][0-9]"
-        elif Filter1 or Filter2:
-            plr = "[3-9][0-9]"
+        if PLREX is None:
+            if Filter1 and Filter2:
+                plr = "[5-9][0-9]"
+            elif Filter1 or Filter2:
+                plr = "[3-9][0-9]"
+            else:
+                plr = "0"
         else:
-            plr = "0"
+            plr = PLREX
        
         instance.defer_connect(
             (10 if Filter1 else 7), ConnectionProto, 
@@ -412,6 +424,8 @@ echo 'OKIDOKI'
 --- .* ping statistics ---
 10 packets transmitted, [0-9]+ received,.* %s%% packet loss, time \d*ms.*
 """ % (plr,)
+        if flood:
+            comp_result = ".*" + comp_result
 
         try:
             instance.do_setup()
@@ -444,7 +458,7 @@ echo 'OKIDOKI'
                 pass
 
         # asserts at the end, to make sure there's proper cleanup
-        self.assertTrue(re.match(comp_result, ping_result, re.MULTILINE),
+        self.assertTrue(re.match(comp_result, ping_result, re.MULTILINE|re.DOTALL),
             "Unexpected trace:\n%s\nPackets @ source:\n%s\nPackets @ target:\n%s" % (
                 ping_result,
                 packets1,
@@ -462,6 +476,14 @@ echo 'OKIDOKI'
     def test_tun_ping_gre(self):
         self._pingtest("TunInterface", "gre", "PLAIN")
 
+    @test_util.skipUnless(test_util.pl_auth() is not None, "Test requires PlanetLab authentication info (PL_USER and PL_PASS environment variables)")
+    def test_tun_ping_flood(self):
+        self._pingtest("TunInterface", "tcp", "PLAIN", flood = True)
+
+    @test_util.skipUnless(test_util.pl_auth() is not None, "Test requires PlanetLab authentication info (PL_USER and PL_PASS environment variables)")
+    def test_tun_ping_flood_udp(self):
+        self._pingtest("TunInterface", "udp", "PLAIN", flood = True)
+
     @test_util.skipUnless(test_util.pl_auth() is not None, "Test requires PlanetLab authentication info (PL_USER and PL_PASS environment variables)")
     def test_tap_ping(self):
         self._pingtest("TapInterface", "tcp", "AES")
@@ -480,7 +502,7 @@ echo 'OKIDOKI'
 
     @test_util.skipUnless(test_util.pl_auth() is not None, "Test requires PlanetLab authentication info (PL_USER and PL_PASS environment variables)")
     def test_tap_ping_udp_loss2_py(self):
-        self._pingtest("TapInterface", "udp", "AES", self.PLR50_PY, self.PLR50_PY, "plr=50", "plr=50")
+        self._pingtest("TapInterface", "udp", "AES", self.PLR50_PY, self.PLR50_PY, "plr=40", "plr=40")
 
     @test_util.skipUnless(test_util.pl_auth() is not None, "Test requires PlanetLab authentication info (PL_USER and PL_PASS environment variables)")
     def test_tap_ping_udp_loss1_c(self):
@@ -488,11 +510,15 @@ echo 'OKIDOKI'
 
     @test_util.skipUnless(test_util.pl_auth() is not None, "Test requires PlanetLab authentication info (PL_USER and PL_PASS environment variables)")
     def test_tap_ping_udp_loss2_c(self):
-        self._pingtest("TapInterface", "udp", "AES", self.PLR50_C, self.PLR50_C, "plr=50", "plr=50")
+        self._pingtest("TapInterface", "udp", "AES", self.PLR50_C, self.PLR50_C, "plr=40", "plr=40")
+
+    @test_util.skipUnless(test_util.pl_auth() is not None, "Test requires PlanetLab authentication info (PL_USER and PL_PASS environment variables)")
+    def test_tun_ping_udp_tos(self):
+        self._pingtest("TunInterface", "udp", "AES", self.TOS_PY, self.TOS_PY, "size=1000", "size=1000", "0")
 
     @test_util.skipUnless(test_util.pl_auth() is not None, "Test requires PlanetLab authentication info (PL_USER and PL_PASS environment variables)")
-    def test_tap_ping_udp_tos(self):
-        self._pingtest("TapInterface", "udp", "AES", self.TOS_PY, self.TOS_PY, "size=1000", "size=1000")
+    def test_tun_ping_udp_class(self):
+        self._pingtest("TunInterface", "udp", "AES", self.CLS_PY, self.CLS_PY, "size=10", "size=10", "0")
 
     @test_util.skipUnless(test_util.pl_auth() is not None, "Test requires PlanetLab authentication info (PL_USER and PL_PASS environment variables)")
     def test_nepi_depends(self):