3 # NEPI, a framework to manage network experiments
4 # Copyright (C) 2013 INRIA
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.
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.
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/>.
19 # Author: Alina Quereilhac <alina.quereilhac@inria.fr>
21 from nepi.execution.resource import ResourceState, ResourceAction
22 from nepi.execution.ec import ExperimentController
23 from test_utils import skipIfAnyNotAlive
30 class LinuxCCNPeekTestCase(unittest.TestCase):
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'])
36 self.fedora_host = "mimas.inria.fr"
37 self.fedora_user = "aquereil"
40 def test_ccnpeek(self):
41 ec = ExperimentController(exp_id = "test-linux-ccnpeek")
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)
50 ccnd = ec.register_resource("linux::CCND")
51 ec.register_connection(ccnd, node)
53 peek = ec.register_resource("linux::CCNPeek")
54 ec.set(peek, "contentName", "ccnx:/chunk0")
55 ec.register_connection(peek, ccnd)
57 poke = ec.register_resource("linux::CCNPoke")
58 ec.set(poke, "contentName", "ccnx:/chunk0")
59 ec.set(poke, "content", "DATA")
60 ec.register_connection(poke, ccnd)
62 ec.register_condition(peek, ResourceAction.START, poke,
63 ResourceState.STARTED)
67 ec.wait_finished(peek)
69 stdout = ec.trace(peek, "stdout")
72 self.assertTrue(stdout.find(expected) > -1)
76 if __name__ == '__main__':