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 version 2 as
8 # published by the Free Software Foundation;
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with this program. If not, see <http://www.gnu.org/licenses/>.
18 # Author: Alina Quereilhac <alina.quereilhac@inria.fr>
20 from nepi.execution.ec import ExperimentController
22 from test_utils import skipIfNotAlive
28 class PlanetlabTapTestCase(unittest.TestCase):
30 self.host = "planetlab2.upc.es"
31 self.user = "inria_nepi"
32 self.identity = "%s/.ssh/id_rsa_planetlab" % (os.environ['HOME'])
33 self.netblock = "192.168.3"
34 #self.host = "nepi2.pl.sophia.inria.fr"
35 #self.user = "inria_nepi"
37 #self.netblock = "192.168.1"
40 def t_tap_create(self, host, user, identity):
41 ec = ExperimentController(exp_id="test-tap-create")
43 node = ec.register_resource("planetlab::Node")
44 ec.set(node, "hostname", host)
45 ec.set(node, "username", user)
46 ec.set(node, "identity", identity)
47 ec.set(node, "cleanExperiment", True)
48 ec.set(node, "cleanProcesses", True)
50 tap = ec.register_resource("planetlab::Tap")
51 ec.set(tap, "ip", "%s.1" % self.netblock)
52 ec.set(tap, "prefix", "24")
53 ec.register_connection(tap, node)
55 app = ec.register_resource("linux::Application")
56 cmd = "ping -c3 %s.1" % self.netblock
57 ec.set(app, "command", cmd)
58 ec.register_connection(app, node)
64 ping = ec.trace(app, "stdout")
65 expected = """3 packets transmitted, 3 received, 0% packet loss"""
66 self.assertTrue(ping.find(expected) > -1)
68 if_name = ec.get(tap, "deviceName")
69 self.assertTrue(if_name.startswith("tap"))
73 def test_tap_create(self):
74 self.t_tap_create(self.host, self.user, self.identity)
76 if __name__ == '__main__':