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