From: Alina Quereilhac Date: Tue, 5 Nov 2013 18:20:52 +0000 (+0100) Subject: Fixing tickets http://newyans.pl.sophia.inria.fr/trac/ticket/37 and http://newyans... X-Git-Tag: nepi-3.0.0~19 X-Git-Url: http://git.onelab.eu/?a=commitdiff_plain;h=914bb8e91ae1ab342a2c4b5d9b33a7ef2b46d63f;p=nepi.git Fixing tickets newyans.pl.sophia.inria.fr/trac/ticket/37 and http://newyans.pl.sophia.inria.fr/trac/ticket/39 --- diff --git a/examples/linux/ccn/ccncat_extended_ring_topo.py b/examples/linux/ccn/ccncat_extended_ring_topo.py index 06f5ac66..a67075b3 100755 --- a/examples/linux/ccn/ccncat_extended_ring_topo.py +++ b/examples/linux/ccn/ccncat_extended_ring_topo.py @@ -212,7 +212,7 @@ if __name__ == '__main__': app, ResourceState.STARTED, time = "10s") ec.register_condition(l5d, ResourceAction.STOP, app, ResourceState.STARTED, time = "10s") - + # Register a collector to automatically collect traces collector = add_collector(ec, "stderr", results_dir) for ccnd in ccnds.values(): diff --git a/src/nepi/execution/ec.py b/src/nepi/execution/ec.py index 7fe523d1..fe110e73 100644 --- a/src/nepi/execution/ec.py +++ b/src/nepi/execution/ec.py @@ -325,8 +325,9 @@ class ExperimentController(object): if rstate >= state: guids.remove(guid) - self.logger.debug(" guid %d DONE - state is %s, required is >= %s " % ( - guid, hrrstate, hrstate)) + rm = self.get_resource(guid) + self.logger.debug(" %s guid %d DONE - state is %s, required is >= %s " % ( + rm.rtype(), guid, hrrstate, hrstate)) else: # Debug... self.logger.debug(" WAITING FOR guid %d - state is %s, required is >= %s " % ( diff --git a/src/nepi/execution/resource.py b/src/nepi/execution/resource.py index 397dab46..c782416b 100644 --- a/src/nepi/execution/resource.py +++ b/src/nepi/execution/resource.py @@ -962,6 +962,11 @@ class ResourceManager(Logger): pass def do_finish(self): + # In case the RM passed from STARTED directly to FINISHED, + # we set the stop_time for consistency + if self.stop_time == None: + self.set_stopped() + self.set_finished() def do_fail(self): diff --git a/src/nepi/resources/linux/application.py b/src/nepi/resources/linux/application.py index 22ca769e..c1de5432 100644 --- a/src/nepi/resources/linux/application.py +++ b/src/nepi/resources/linux/application.py @@ -633,10 +633,10 @@ class LinuxApplication(ResourceManager): msg = " Failed to execute command '%s'" % self.get("command") err = self._proc.stderr.read() self.error(msg, out, err) - self.fail() + self.do_fail() elif retcode == 0: - self.finish() + self.do_finish() else: # We need to query the status of the command we launched in # background. In order to avoid overwhelming the remote host and @@ -658,9 +658,9 @@ class LinuxApplication(ResourceManager): msg = "Failed to execute command '%s'" % \ self.get("command") self.error(msg, out, err) - self.fail() + self.do_fail() else: - self.finish() + self.do_finish() self._last_state_check = tnow() diff --git a/test/execution/resource.py b/test/execution/resource.py index f820f686..d6398eb4 100755 --- a/test/execution/resource.py +++ b/test/execution/resource.py @@ -349,13 +349,67 @@ class ResourceManagerTestCase(unittest.TestCase): self.assertEquals(ec._fm._failure_level, FailureLevel.OK) - def ztest_start_with_condition(self): - # TODO!!! - pass - - def ztest_stop_with_condition(self): - # TODO!!! - pass + def test_start_with_condition(self): + from nepi.execution.resource import ResourceFactory + + ResourceFactory.register_type(Application) + ResourceFactory.register_type(Node) + ResourceFactory.register_type(Interface) + + ec = ExperimentController() + + node = ec.register_resource("Node") + + app1 = ec.register_resource("Application") + ec.register_connection(app1, node) + + app2 = ec.register_resource("Application") + ec.register_connection(app2, node) + + ec.register_condition(app2, ResourceAction.START, app1, + ResourceState.STARTED, time = "5s") + + ec.deploy() + + ec.wait_finished([app1, app2]) + + rmapp1 = ec.get_resource(app1) + rmapp2 = ec.get_resource(app2) + + self.assertTrue(rmapp2.start_time > rmapp1.start_time) + + ec.shutdown() + + def test_stop_with_condition(self): + from nepi.execution.resource import ResourceFactory + + ResourceFactory.register_type(Application) + ResourceFactory.register_type(Node) + ResourceFactory.register_type(Interface) + + ec = ExperimentController() + + node = ec.register_resource("Node") + + app1 = ec.register_resource("Application") + ec.register_connection(app1, node) + + app2 = ec.register_resource("Application") + ec.register_connection(app2, node) + + ec.register_condition(app2, ResourceAction.START, app1, + ResourceState.STOPPED) + + ec.deploy() + + ec.wait_finished([app1, app2]) + + rmapp1 = ec.get_resource(app1) + rmapp2 = ec.get_resource(app2) + + self.assertTrue(rmapp2.start_time > rmapp1.stop_time) + + ec.shutdown() def ztest_set_with_condition(self): # TODO!!!