Changing ResourceManager naming for platform::ResourceName
[nepi.git] / test / resources / linux / ccn / fibentry.py
1 #!/usr/bin/env python
2 #
3 #    NEPI, a framework to manage network experiments
4 #    Copyright (C) 2013 INRIA
5 #
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.
10 #
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.
15 #
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/>.
18 #
19 # Author: Alina Quereilhac <alina.quereilhac@inria.fr>
20
21 from nepi.execution.ec import ExperimentController 
22 from test_utils import skipIfNotAlive, skipInteractive
23
24 import os
25 import time
26 import tempfile
27 import unittest
28
29 class LinuxFIBEntryTestCase(unittest.TestCase):
30     def setUp(self):
31         self.fedora_host = "nepi2.pl.sophia.inria.fr"
32         self.fedora_user = "inria_nepi"
33
34         self.ubuntu_host = "roseval.pl.sophia.inria.fr"
35         self.ubuntu_user = "nepi"
36         
37         self.target = "nepi5.pl.sophia.inria.fr"
38
39     @skipIfNotAlive
40     def t_traces(self, host, user):
41
42         ec = ExperimentController(exp_id = "test-fib-traces")
43         
44         node1 = ec.register_resource("linux::Node")
45         ec.set(node1, "hostname", host)
46         ec.set(node1, "username", user)
47         ec.set(node1, "cleanExperiment", True)
48         ec.set(node1, "cleanProcesses", True)
49
50         ccnd1 = ec.register_resource("linux::CCND")
51         ec.register_connection(ccnd1, node1)
52
53         entry1 = ec.register_resource("linux::FIBEntry")
54         ec.set(entry1, "host", self.target)
55         ec.enable_trace(entry1, "ping")
56         ec.enable_trace(entry1, "mtr")
57         ec.register_connection(entry1, ccnd1)
58  
59         node2 = ec.register_resource("linux::Node")
60         ec.set(node2, "hostname", self.target)
61         ec.set(node2, "username", self.fedora_user)
62         ec.set(node2, "cleanExperiment", True)
63         ec.set(node2, "cleanProcesses", True)
64
65         ccnd2 = ec.register_resource("linux::CCND")
66         ec.register_connection(ccnd2, node2)
67
68         entry2 = ec.register_resource("linux::FIBEntry")
69         ec.set(entry2, "host", host)
70         ec.register_connection(entry2, ccnd2)
71
72         ec.deploy()
73
74         ec.wait_started([ccnd1, ccnd2])
75
76         stdout = ec.trace(entry1, "ping")
77         expected = "icmp_seq=1" 
78         self.assertTrue(stdout.find(expected) > -1)
79
80         stdout = ec.trace(entry1, "mtr")
81         expected = "1." 
82         self.assertTrue(stdout.find(expected) > -1)
83
84         ec.shutdown()
85
86     def test_traces_fedora(self):
87         self.t_traces(self.fedora_host, self.fedora_user)
88
89     def test_traces_ubuntu(self):
90         self.t_traces(self.ubuntu_host, self.ubuntu_user)
91
92 if __name__ == '__main__':
93     unittest.main()
94