Salome HOME
Copyright update 2022
[modules/yacs.git] / src / yacsloader_swig / Test / testWorkloadManager.py
index 334dcd2af604110ef90388c7c5b37180060ae05e..d1f299b06f05ce1edffda9a228fa2139462dcd18 100755 (executable)
@@ -1,5 +1,5 @@
 #!/usr/bin/env python3
-# Copyright (C) 2006-2020  CEA/DEN, EDF R&D
+# Copyright (C) 2006-2022  CEA/DEN, EDF R&D
 #
 # This library is free software; you can redistribute it and/or
 # modify it under the terms of the GNU Lesser General Public
@@ -27,7 +27,7 @@ import tempfile
 import os
 import salome
 
-NB_NODE=16
+NB_NODE=15
 class TestEdit(unittest.TestCase):
 
     def setUp(self):
@@ -36,12 +36,13 @@ class TestEdit(unittest.TestCase):
         self.l = loader.YACSLoader()
         self.e = pilot.ExecutorSwig()
         # We need a catalog which contains only one resource named "localhost"
-        # with 16 cores. The modifications made here are not saved to the
+        # with NB_NODE cores. The modifications made here are not saved to the
         # catalog file.
         salome.salome_init()
         resourceManager = salome.lcc.getResourcesManager()
         resource_definition = resourceManager.GetResourceDefinition("localhost")
         resource_definition.nb_node = NB_NODE
+        resource_definition.nb_proc_per_node = 1
         resourceManager.AddResource(resource_definition, False, "")
         resource_required = salome.ResourceParameters()
         resource_required.can_run_containers = True
@@ -51,6 +52,7 @@ class TestEdit(unittest.TestCase):
             resourceManager.RemoveResource(r, False, "")
         resource_definition = resourceManager.GetResourceDefinition("localhost")
         self.assertEqual(resource_definition.nb_node, NB_NODE)
+        self.assertEqual(resource_definition.nb_proc_per_node, 1)
 
     def tearDown(self):
         cm = salome.lcc.getContainerManager()
@@ -71,7 +73,7 @@ class TestEdit(unittest.TestCase):
         # The containers may need some time to be launched.
         # We need some delay to add to the 15s.
         msg = "Execution time is too long : {}s".format(execution_time)
-        self.assertTrue(execution_time < 25, msg)
+        self.assertTrue(execution_time < 20, msg)
 
     def test2(self):
         """ Two parallel foreach-s with different containers and python nodes
@@ -91,7 +93,7 @@ class TestEdit(unittest.TestCase):
         # The containers may need some time to be launched.
         # We need some delay to add to the 16s.
         msg = "Execution time is too long : {}s".format(execution_time)
-        self.assertTrue(execution_time < 26, msg)
+        self.assertTrue(execution_time < 20, msg)
         coeff_cont = proc.getChildByName("End").getOutputPort("coeff_cont").getPyObj()
         msg = "coeff_cont too low:"+str(coeff_cont)
         self.assertTrue(coeff_cont >= NB_NODE, msg)
@@ -109,6 +111,21 @@ class TestEdit(unittest.TestCase):
           err_message = proc.getChildByName("End").getOutputPort("err_message").getPyObj()
           self.fail(err_message)
 
+    def test4(self):
+        """ Verify the execution is stoped if no resource can run a task.
+        """
+        proc = self.l.load("samples/wlm_error.xml")
+        self.e.RunW(proc,0)
+        self.assertEqual(proc.getState(),pilot.FAILED)
+        self.assertEqual(proc.getChildByName("ErrorNode").getState(),pilot.ERROR)
+
+    def test5(self):
+        """ Foreach with 1000 points and several nodes in the block.
+        """
+        proc = self.l.load("samples/wlm_complex_foreach.xml")
+        self.e.RunW(proc,0)
+        self.assertEqual(proc.getState(),pilot.DONE)
+
 if __name__ == '__main__':
   dir_test = tempfile.mkdtemp(suffix=".yacstest")
   file_test = os.path.join(dir_test,"UnitTestsResult")