3 # NEPI, a framework to manage network experiments
4 # Copyright (C) 2013 INRIA
6 # This program is free software: you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation, either version 3 of the License, or
9 # (at your option) any later version.
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License
17 # along with this program. If not, see <http://www.gnu.org/licenses/>.
19 # Author: Alina Quereilhac <alina.quereilhac@inria.fr>
21 from nepi.execution.ec import ExperimentController
23 from test_utils import skipIfNotAlive
29 class PlanetlabTunTestCase(unittest.TestCase):
31 self.host = "planetlab1.informatik.uni-erlangen.de"
32 self.user = "inria_nepi"
33 self.identity = "%s/.ssh/id_rsa_planetlab" % (os.environ['HOME'])
34 self.netblock = "192.168.3"
35 #self.host = "nepi2.pl.sophia.inria.fr"
36 #self.user = "inria_nepi"
38 #self.netblock = "192.168.1"
41 def t_tun_create(self, host, user, identity):
43 ec = ExperimentController(exp_id = "test-un-create")
45 node = ec.register_resource("PlanetlabNode")
46 ec.set(node, "hostname", host)
47 ec.set(node, "username", user)
48 ec.set(node, "identity", identity)
49 ec.set(node, "cleanHome", True)
50 ec.set(node, "cleanProcesses", True)
52 tun = ec.register_resource("PlanetlabTun")
53 ec.set(tun, "ip4", "%s.1" % self.netblock)
54 ec.set(tun, "prefix4", 24)
55 ec.register_connection(tun, node)
57 app = ec.register_resource("LinuxApplication")
58 cmd = "ping -c3 %s.1" % self.netblock
59 ec.set(app, "command", cmd)
60 ec.register_connection(app, node)
66 ping = ec.trace(app, 'stdout')
67 expected = """3 packets transmitted, 3 received, 0% packet loss"""
68 self.assertTrue(ping.find(expected) > -1)
70 if_name = ec.get(tun, "deviceName")
71 self.assertTrue(if_name.startswith("tun"))
75 def test_tun_create(self):
76 self.t_tun_create(self.host, self.user, self.identity)
78 if __name__ == '__main__':