Fixing wrong license
[nepi.git] / test / resources / linux / nping.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 version 2 as
8 #    published by the Free Software Foundation;
9 #
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.
14 #
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/>.
17 #
18 # Author: Alina Quereilhac <alina.quereilhac@inria.fr>
19
20 from nepi.execution.ec import ExperimentController 
21 from test_utils import skipIfNotAlive, skipInteractive
22
23 import os
24 import time
25 import tempfile
26 import unittest
27
28 class LinuxNPingTestCase(unittest.TestCase):
29     def setUp(self):
30         self.fedora_host = "nepi2.pl.sophia.inria.fr"
31         self.fedora_user = "inria_nepi"
32
33         self.ubuntu_host = "roseval.pl.sophia.inria.fr"
34         self.ubuntu_user = "alina"
35         
36         self.target = "nepi5.pl.sophia.inria.fr"
37
38     @skipIfNotAlive
39     def t_nping(self, host, user):
40
41         ec = ExperimentController(exp_id = "test-nping")
42         
43         node = ec.register_resource("linux::Node")
44         ec.set(node, "hostname", host)
45         ec.set(node, "username", user)
46         ec.set(node, "cleanExperiment", True)
47         ec.set(node, "cleanProcesses", True)
48
49         app = ec.register_resource("linux::NPing")
50         ec.set(app, "c", 1)
51         ec.set(app, "tcp", True)
52         ec.set(app, "p", 80)
53         ec.set(app, "target", self.target)
54         ec.register_connection(app, node)
55
56         ec.deploy()
57
58         ec.wait_finished(app)
59
60         stdout = ec.trace(app, "stdout")
61         self.assertTrue(stdout.find("1 IP address pinged in") > -1)
62
63         ec.shutdown()
64
65     def test_nping_fedora(self):
66         self.t_nping(self.fedora_host, self.fedora_user)
67
68     def test_nping_ubuntu(self):
69         self.t_nping(self.ubuntu_host, self.ubuntu_user)
70
71 if __name__ == '__main__':
72     unittest.main()
73