37bfc888fcbb675b3a5a872fe8f770e3e3ad4c05
[nepi.git] / test / resources / linux / udptest.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 skipIfAnyNotAlive
23
24 import os
25 import time
26 import tempfile
27 import unittest
28
29 class LinuxUdpTestTestCase(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 = "alina"
36         
37         self.target = "nepi5.pl.sophia.inria.fr"
38
39     @skipIfAnyNotAlive
40     def t_rtt(self, user1, host1, user2, host2):
41
42         ec = ExperimentController(exp_id = "test-udptest-rtt")
43         
44         node1 = ec.register_resource("LinuxNode")
45         ec.set(node1, "hostname", host1)
46         ec.set(node1, "username", user1)
47         ec.set(node1, "cleanHome", True)
48         ec.set(node1, "cleanProcesses", True)
49
50         server = ec.register_resource("LinuxUdpTest")
51         ec.set(server, "s", True)
52         ec.register_connection(server, node1)
53  
54         node2 = ec.register_resource("LinuxNode")
55         ec.set(node2, "hostname", host2)
56         ec.set(node2, "username", user2)
57         ec.set(node2, "cleanHome", True)
58         ec.set(node2, "cleanProcesses", True)
59
60         client = ec.register_resource("LinuxUdpTest")
61         ec.set(client, "a", True)
62         ec.set(client, "target", host1)
63         ec.register_connection(client, node2)
64
65         ec.deploy()
66
67         ec.wait_finished(client)
68
69         stdout = ec.trace(client, "stderr")
70         self.assertTrue(stdout.find("10 trials with message size 64 Bytes.") > -1)
71
72         ec.shutdown()
73
74     def test_rtt_fedora(self):
75         self.t_rtt(self.fedora_user, self.fedora_host, self.fedora_user, 
76                 self.target)
77
78     def test_rtt_ubuntu(self):
79         self.t_rtt(self.ubuntu_user, self.ubuntu_host, self.fedora_user,
80                 self.target)
81
82 if __name__ == '__main__':
83     unittest.main()
84