self.root_dir = tempfile.mkdtemp()
def tearDown(self):
- shutil.rmtree(self.root_dir)
+ try:
+ shutil.rmtree(self.root_dir)
+ except:
+ # retry
+ time.sleep(0.1)
+ shutil.rmtree(self.root_dir)
def make_instance(self):
testbed_version = "01"
instance = planetlab.TestbedController(testbed_version)
slicename = "inria_nepi12"
+ pl_ssh_key = os.environ.get(
+ "PL_SSH_KEY",
+ "%s/.ssh/id_rsa_planetlab" % (os.environ['HOME'],) )
pl_user, pl_pwd = test_util.pl_auth()
instance.defer_configure("homeDirectory", self.root_dir)
instance.defer_configure("slice", slicename)
- instance.defer_configure("sliceSSHKey", "%s/.ssh/id_rsa_planetlab" % (os.environ['HOME'],))
+ instance.defer_configure("sliceSSHKey", pl_ssh_key)
instance.defer_configure("authUser", pl_user)
instance.defer_configure("authPass", pl_pwd)
pass
@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(self):
+ def _pingtest(self, TunClass, ConnectionProto):
instance = self.make_instance()
instance.defer_create(2, "Node")
instance.defer_create(6, "NodeInterface")
instance.defer_connect(3, "devs", 6, "node")
instance.defer_connect(6, "inet", 5, "devs")
- instance.defer_create(7, "TunInterface")
+ instance.defer_create(7, TunClass)
instance.defer_add_address(7, "192.168.2.2", 24, False)
instance.defer_connect(2, "devs", 7, "node")
- instance.defer_create(8, "TunInterface")
+ instance.defer_create(8, TunClass)
instance.defer_add_address(8, "192.168.2.3", 24, False)
instance.defer_connect(3, "devs", 8, "node")
- instance.defer_connect(7, "tcp", 8, "tcp")
+ instance.defer_connect(7, ConnectionProto, 8, ConnectionProto)
instance.defer_create(9, "Application")
instance.defer_create_set(9, "command", "ping -qc1 {#[GUID-8].addr[0].[Address]#}")
instance.defer_add_trace(9, "stdout")
self.assertTrue(re.match(comp_result, ping_result, re.MULTILINE),
"Unexpected trace:\n" + ping_result)
+ @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(self):
+ self._pingtest("TunInterface", "tcp")
+
+ @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(self):
+ self._pingtest("TunInterface", "udp")
+
+ @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")
+
+ @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(self):
+ self._pingtest("TapInterface", "udp")
+
@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):
instance = self.make_instance()
# asserts at the end, to make sure there's proper cleanup
self.assertEqual(ping_result, "")
+
+ @test_util.skipUnless(test_util.pl_auth() is not None,
+ "Test requires PlanetLab authentication info (PL_USER and PL_PASS environment variables)")
+ @test_util.skipUnless(os.environ.get('NEPI_FULL_TESTS','').lower() in ('1','yes','true','on'),
+ "Test is expensive, requires NEPI_FULL_TESTS=yes")
+ def test_ns3_depends(self):
+ instance = self.make_instance()
+
+ instance.defer_create(2, "Node")
+ instance.defer_create_set(2, "hostname", "onelab11.pl.sophia.inria.fr")
+ instance.defer_create(3, "NodeInterface")
+ instance.defer_connect(2, "devs", 3, "node")
+ instance.defer_create(4, "Internet")
+ instance.defer_connect(3, "inet", 4, "devs")
+ instance.defer_create(5, "NepiDependency")
+ instance.defer_connect(5, "node", 2, "deps")
+ instance.defer_create(6, "NS3Dependency")
+ instance.defer_connect(6, "node", 2, "deps")
+ instance.defer_create(12, "Application")
+ instance.defer_connect(12, "node", 2, "apps")
+ instance.defer_create_set(12, "command", "python -c 'import nepi.testbeds.ns3.execute ; tb = nepi.testbeds.ns3.execute.TestbedController(\"3_9_RC3\") ; mod = tb._load_ns3_module()'")
+ instance.defer_add_trace(12, "stderr")
+
+ try:
+ instance.do_setup()
+ instance.do_create()
+ instance.do_connect_init()
+ instance.do_connect_compl()
+ instance.do_preconfigure()
+ instance.do_configure()
+
+ instance.start()
+ while instance.status(12) != STATUS_FINISHED:
+ time.sleep(0.5)
+ ping_result = (instance.trace(12, "stderr") or "").strip()
+ instance.stop()
+ finally:
+ instance.shutdown()
+
+ # asserts at the end, to make sure there's proper cleanup
+ self.assertEqual(ping_result, "")
if __name__ == '__main__':