Fixing wrong license
[nepi.git] / test / resources / linux / ccn / ccncat.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.resource import ResourceState, ResourceAction 
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 LinuxCCNPeekTestCase(unittest.TestCase):
30     def setUp(self):
31         #self.fedora_host = "nepi2.pl.sophia.inria.fr"
32         #self.fedora_user = "inria_nepi"
33         self.fedora_identity = "%s/.ssh/id_rsa" % (os.environ['HOME'])
34
35         self.fedora_host = "mimas.inria.fr"
36         self.fedora_user = "aquereil"
37
38     @skipIfAnyNotAlive
39     def test_ccnpeek(self):
40         ec = ExperimentController(exp_id = "test-linux-ccncat")
41         
42         node = ec.register_resource("linux::Node")
43         ec.set(node, "hostname", self.fedora_host)
44         ec.set(node, "username", self.fedora_user)
45         ec.set(node, "identity", self.fedora_identity)
46         #ec.set(node, "cleanProcesses", True)
47         #ec.set(node, "cleanExperiment", True)
48
49         ccnd = ec.register_resource("linux::CCND")
50         ec.register_connection(ccnd, node)
51
52         # REPO file is in test/resources/linux/ns3/ccn/repoFile1
53         repofile = os.path.join(
54             os.path.dirname(os.path.realpath(__file__)),
55             "..", "ns3", "ccn", "repoFile1")
56
57         ## Register a repository in node 1
58         ccnr = ec.register_resource("linux::CCNR")
59         ec.set(ccnr, "repoFile1", repofile)
60         ec.register_connection(ccnr, ccnd)
61
62         ccncat = ec.register_resource("linux::CCNCat")
63         ec.set(ccncat, "contentName", "ccnx:/test/bunny.ts")
64         ec.register_connection(ccncat, ccnd)
65
66         ec.deploy()
67
68         ec.wait_finished(ccncat)
69
70         expected = 2873956
71         stdout = ec.trace(ccncat, "stdout")
72         self.assertTrue(len(stdout) == expected , stdout)
73
74         ec.shutdown()
75
76 if __name__ == '__main__':
77     unittest.main()
78