1 #!/usr/bin/env python
\r
3 # NEPI, a framework to manage network experiments
\r
4 # Copyright (C) 2013 INRIA
\r
6 # This program is free software: you can redistribute it and/or modify
\r
7 # it under the terms of the GNU General Public License version 2 as
\r
8 # published by the Free Software Foundation;
\r
10 # This program is distributed in the hope that it will be useful,
\r
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
\r
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
\r
13 # GNU General Public License for more details.
\r
15 # You should have received a copy of the GNU General Public License
\r
16 # along with this program. If not, see <http://www.gnu.org/licenses/>.
\r
18 # Author: Damien Saucez <damien.saucez@inria.fr>
\r
19 # Alina Quereilhac <alina.quereilhac@inria.fr>
\r
22 from experiment imptort Experiment
\r
23 from nepi.execution.ec import ExperimentController
\r
24 from nepi.execution.resource import ResourceState, ResourceManager
\r
26 # Experiment parameters
\r
27 experiment_id = "case_a"
\r
29 netblock = "10.0.1.0"
\r
31 # number of nodes to test
\r
34 # list of hosts for running the experiment on
\r
36 {"hostname":"onelab4.warsaw.rd.tp.pl",
\r
37 "username":"inria_nepi",
\r
38 "identity": "%s/.ssh/id_rsa_planetlab" % (os.environ['HOME'])}]
\r
41 os.environ["NEPI_NTHREADS"] = "1"
\r
42 ResourceManager._reschedule_delay = "0s"
\r
44 # == Experimentation setup ====================================================
\r
46 # Prepare the ExperimentController
\r
47 ec = ExperimentController(exp_id = experiment_id)
\r
49 # run experimentation as long as there is something to do
\r
50 while len(parameters) > 0:
\r
51 # Collection of application being processed
\r
54 # Collection of experiments launched
\r
57 # Push a job on each node in the cluster
\r
58 for node in node_info:
\r
59 # Stop if nothing else to do
\r
60 if len(parameters) == 0:
\r
63 # Determine what network size to test
\r
64 nb_nodes = parameters.pop(0)
\r
66 # Create the simulated network
\r
67 xp = Experiment(ec, node, nb_nodes, False)
\r
68 xp.build_topology(netblock, prefix, agent)
\r
70 # Remember the experiments just created
\r
73 # Remember the applications to be executed
\r
76 # Let's run the experiment
\r
78 ec.wait_finished(jobs)
\r
80 # Check if everything went well for each experiment
\r
82 # and see the output
\r
83 stdout = ec.trace(xp.apps[0], "stdout")
\r
84 print "[", stdout, "]"
\r
85 # check if one transmitter failed (if everything goes well, all trasmitters
\r
86 # must have stopped properly) (ignore the agent)
\r
87 for app in xp.apps[1:len(xp.apps)]:
\r
88 if ec.state(app, hr=False) != ResourceState.STOPPED:
\r
89 raise Exception("Crashed at size %d" % xp.nb_nodes)
\r