From: Alina Quereilhac Date: Thu, 31 Oct 2013 08:54:26 +0000 (+0100) Subject: Adding unit test for RM 'critical' attribute X-Git-Tag: nepi-3.0.0~22 X-Git-Url: http://git.onelab.eu/?a=commitdiff_plain;h=5f52b47aee711cb3b6581829c337666cbd8df65f;p=nepi.git Adding unit test for RM 'critical' attribute --- diff --git a/src/nepi/execution/ec.py b/src/nepi/execution/ec.py index c5978dea..7fe523d1 100644 --- a/src/nepi/execution/ec.py +++ b/src/nepi/execution/ec.py @@ -307,6 +307,9 @@ class ExperimentController(object): if isinstance(guids, int): guids = [guids] + # Make a copy to avoid modifying the original guids list + guids = list(guids) + while True: # If there are no more guids to wait for # or the quit function returns True, exit the loop diff --git a/test/execution/resource.py b/test/execution/resource.py index 2aaa4b97..f820f686 100755 --- a/test/execution/resource.py +++ b/test/execution/resource.py @@ -292,7 +292,6 @@ class ResourceManagerTestCase(unittest.TestCase): ResourceFactory.register_type(ErrorApplication) ResourceFactory.register_type(Node) ResourceFactory.register_type(Interface) - ResourceFactory.register_type(Channel) ec = ExperimentController() @@ -307,8 +306,48 @@ class ResourceManagerTestCase(unittest.TestCase): ec.shutdown() - self.assertTrue(ec._fm._failure_level == FailureLevel.RM_FAILURE) + self.assertEquals(ec._fm._failure_level, FailureLevel.RM_FAILURE) + + def test_critical(self): + from nepi.execution.resource import ResourceFactory + + ResourceFactory.register_type(ErrorApplication) + ResourceFactory.register_type(Application) + ResourceFactory.register_type(Node) + ResourceFactory.register_type(Interface) + + ec = ExperimentController() + + node = ec.register_resource("Node") + + apps = list() + + eapp = ec.register_resource("ErrorApplication") + ec.set(eapp, "critical", False) + ec.register_connection(eapp, node) + apps.append(eapp) + + for i in xrange(10): + app = ec.register_resource("Application") + ec.register_connection(app, node) + apps.append(app) + + ec.deploy() + + ec.wait_finished(apps) + + state = ec.state(eapp) + self.assertEquals(state, ResourceState.FAILED) + + apps.remove(eapp) + + for app in apps: + state = ec.state(app) + self.assertEquals(state, ResourceState.FINISHED) + + ec.shutdown() + self.assertEquals(ec._fm._failure_level, FailureLevel.OK) def ztest_start_with_condition(self): # TODO!!!