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 version 2 as
8 # published by the Free Software Foundation;
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.
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/>.
18 # Author: Alina Quereilhac <alina.quereilhac@inria.fr>
20 from __future__ import print_function
22 from nepi.execution.resource import ResourceState, ResourceAction
23 from nepi.execution.ec import ExperimentController
24 from test_utils import skipIfAnyNotAlive
31 class LinuxCCNPeekTestCase(unittest.TestCase):
33 #self.fedora_host = "nepi2.pl.sophia.inria.fr"
34 #self.fedora_user = "inria_nepi"
35 self.fedora_identity = "%s/.ssh/id_rsa" % (os.environ['HOME'])
37 self.fedora_host = "mimas.inria.fr"
38 self.fedora_user = "aquereil"
41 def test_ccnpeek(self):
42 ec = ExperimentController(exp_id = "test-linux-ccnpeek")
44 node = ec.register_resource("linux::Node")
45 ec.set(node, "hostname", self.fedora_host)
46 ec.set(node, "username", self.fedora_user)
47 ec.set(node, "identity", self.fedora_identity)
48 #ec.set(node, "cleanProcesses", True)
49 #ec.set(node, "cleanExperiment", True)
51 ccnd = ec.register_resource("linux::CCND")
52 ec.register_connection(ccnd, node)
54 peek = ec.register_resource("linux::CCNPeek")
55 ec.set(peek, "contentName", "ccnx:/chunk0")
56 ec.register_connection(peek, ccnd)
58 poke = ec.register_resource("linux::CCNPoke")
59 ec.set(poke, "contentName", "ccnx:/chunk0")
60 ec.set(poke, "content", "DATA")
61 ec.register_connection(poke, ccnd)
63 ec.register_condition(peek, ResourceAction.START, poke,
64 ResourceState.STARTED)
68 ec.wait_finished(peek)
70 stdout = ec.trace(peek, "stdout")
73 self.assertTrue(stdout.find(expected) > -1)
77 if __name__ == '__main__':