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 = "nepi2.pl.sophia.inria.fr"
32 self.user = "inria_nepi"
35 def t_tun_create(self, host, user):
37 ec = ExperimentController(exp_id = "test-un-create")
39 node = ec.register_resource("PlanetlabNode")
40 ec.set(node, "hostname", host)
41 ec.set(node, "username", user)
42 ec.set(node, "cleanHome", True)
43 ec.set(node, "cleanProcesses", True)
45 tun = ec.register_resource("PlanetlabTun")
46 ec.set(tun, "ip4", "192.168.1.1")
47 ec.set(tun, "prefix4", 24)
48 ec.register_connection(tun, node)
50 app = ec.register_resource("LinuxApplication")
51 cmd = "ping -c3 192.168.1.1"
52 ec.set(app, "command", cmd)
53 ec.register_connection(app, node)
59 ping = ec.trace(app, 'stdout')
60 expected = """3 packets transmitted, 3 received, 0% packet loss"""
61 self.assertTrue(ping.find(expected) > -1)
63 if_name = ec.get(tun, "deviceName")
64 self.assertTrue(if_name.startswith("tun"))
68 def test_tun_create(self):
69 self.t_tun_create(self.host, self.user)
71 if __name__ == '__main__':