From 22536484c31914ec934e1d67b2b51187901df566 Mon Sep 17 00:00:00 2001 From: Ovidiu Mircescu Date: Mon, 10 May 2021 16:58:16 +0200 Subject: [PATCH 1/1] Improve test stability. --- src/yacsloader/samples/wlm_2foreach.xml | 93 ++++++++++++-- .../samples/wlm_2foreach_with_cache.xml | 115 ++++++++++++++---- src/yacsloader/samples/wlm_8nodes.xml | 72 ++++++++--- src/yacsloader_swig/Test/testSaveLoadRun.py | 4 +- .../Test/testWorkloadManager.py | 6 +- 5 files changed, 233 insertions(+), 57 deletions(-) diff --git a/src/yacsloader/samples/wlm_2foreach.xml b/src/yacsloader/samples/wlm_2foreach.xml index 65f5e8c8f..8225bf3bd 100644 --- a/src/yacsloader/samples/wlm_2foreach.xml +++ b/src/yacsloader/samples/wlm_2foreach.xml @@ -79,30 +79,57 @@ time.sleep(1) + + + + + + + + + + + + + + + + + Begin ForEach1 Begin ForEach2 Begin End + Begin delay ForEach1 End ForEach2 End + delay ForEach1 + Create_c1_containers Create_c2_containers + Create_c2_containers Begin Begin t0 End t0 Begin vals - ForEach1 SmplsCollection + ForEach2 SmplsCollection Begin vals - ForEach2 SmplsCollection + ForEach1 SmplsCollection Begin nbbranches - ForEach2 nbBranches + ForEach1 nbBranches Begin nbbranches - ForEach1 nbBranches + ForEach2 nbBranches ForEach1 evalSamples @@ -112,19 +139,61 @@ time.sleep(1) ForEach2 evalSamples ForEach2.PyScript7 v + + Create_c1_containers evalSamples + Create_c1_containers.wait_c1 x + + + Create_c2_containers evalSamples + Create_c2_containers.PyScript5 x + - ForEach1nbBranches + ForEach2nbBranches 1 - ForEach2nbBranches + Create_c2_containersnbBranches + 3 + + + Create_c2_containersSmplsCollection + +1 +2 +3 + + + + ForEach1nbBranches 1 - - + + Create_c1_containersnbBranches + 8 + + + Create_c1_containersSmplsCollection + +1 +2 +3 +4 +5 +6 +7 +8 + + + - - - - + + + + + + + + + + diff --git a/src/yacsloader/samples/wlm_2foreach_with_cache.xml b/src/yacsloader/samples/wlm_2foreach_with_cache.xml index 4bda1d82c..e70df0c91 100644 --- a/src/yacsloader/samples/wlm_2foreach_with_cache.xml +++ b/src/yacsloader/samples/wlm_2foreach_with_cache.xml @@ -51,6 +51,7 @@ vals = [ i for i in range(40)] nbbranches = len(vals) t0=time.time() ]]> + @@ -62,7 +63,7 @@ total_time=int(tf-t0) ok = True s_expected = sum(vals) - +err_message = "" tr1={} for cont_name, s in r1: if cont_name in tr1.keys(): @@ -75,9 +76,9 @@ for cont_name, s in r1: s1 = sum(tr1.values()) if s_expected != s1: ok = False - print("Error on the first foreach.") - print("Expected sum:", s_expected) - print("Obtained sum:", s1) + err_message += "Error on the first foreach.\n" + err_message += "Expected sum:{}\n".format(s_expected) + err_message += "Obtained sum:{}\n".format(s1) tr2={} for cont_name, s in r2: @@ -91,14 +92,15 @@ for cont_name, s in r2: s2 = sum(tr2.values()) if s_expected != s2: ok = False - print("Error on the second foreach.") - print("Expected sum:", s_expected) - print("Obtained sum:", s2) + err_message += "Error on the second foreach.\n" + err_message += "Expected sum:{}\n".format(s_expected) + err_message += "Obtained sum:{}\n".format(s2) coeff_cont = len(tr1) + ( 4 * len(tr2)) -#print(r1) -#print(r2) +print("total_time:", total_time) +print(err_message) ]]> + @@ -106,6 +108,7 @@ coeff_cont = len(tr1) + ( 4 * len(tr2)) + @@ -141,34 +144,62 @@ time.sleep(1) + + + + + + + + + + + + + + + + + + Begin ForEach1 Begin ForEach2 Begin End + Begin delay ForEach1 End ForEach2 End + Create_C1_containers Create_C2_containers + Create_C2_containers Begin + delay ForEach1 Begin t0 End t0 Begin vals - ForEach2 SmplsCollection + ForEach1 SmplsCollection Begin vals - ForEach1 SmplsCollection + End vals Begin vals - End vals + ForEach2 SmplsCollection Begin nbbranches - ForEach2 nbBranches + ForEach1 nbBranches Begin nbbranches - ForEach1 nbBranches + ForEach2 nbBranches ForEach1 evalSamples @@ -178,6 +209,14 @@ time.sleep(1) ForEach2 evalSamples ForEach2.PyNode2 v + + Create_C1_containers evalSamples + Create_C1_containers.wait_c1 x + + + Create_C2_containers evalSamples + Create_C2_containers.wait_c2 x + ForEach1.PyNode1 result End r1 @@ -187,18 +226,52 @@ time.sleep(1) End r2 - ForEach2nbBranches + ForEach1nbBranches 1 - ForEach1nbBranches + Create_C1_containersnbBranches + 8 + + + Create_C1_containersSmplsCollection + +1 +2 +3 +4 +5 +6 +7 +8 + + + + Create_C2_containersnbBranches + 3 + + + Create_C2_containersSmplsCollection + +1 +2 +3 + + + + ForEach2nbBranches 1 + + + + + + + - - - - - + + + diff --git a/src/yacsloader/samples/wlm_8nodes.xml b/src/yacsloader/samples/wlm_8nodes.xml index 7dfaca767..c178717f4 100644 --- a/src/yacsloader/samples/wlm_8nodes.xml +++ b/src/yacsloader/samples/wlm_8nodes.xml @@ -20,6 +20,7 @@ + @@ -155,6 +156,15 @@ container_name = my_container.name + + + + + + + Begin End Begin n1 Begin n2 @@ -172,37 +182,38 @@ container_name = my_container.name n6 End n7 End n8 End + Create_containers Begin Begin t0 End t0 Begin time_to_sleep - n1 time_to_sleep + End time_to_sleep Begin time_to_sleep - n2 time_to_sleep + n7 time_to_sleep Begin time_to_sleep - End time_to_sleep + n4 time_to_sleep Begin time_to_sleep - n5 time_to_sleep + n6 time_to_sleep Begin time_to_sleep - n4 time_to_sleep + n5 time_to_sleep Begin time_to_sleep - n3 time_to_sleep + n1 time_to_sleep Begin time_to_sleep - n6 time_to_sleep + n2 time_to_sleep Begin time_to_sleep @@ -210,7 +221,7 @@ container_name = my_container.name Begin time_to_sleep - n7 time_to_sleep + n3 time_to_sleep n1 container_name @@ -244,15 +255,38 @@ container_name = my_container.name n8 container_name End n8 - - - - - - - - - - - + + Create_containers evalSamples + Create_containers.wait_container x + + + Create_containersnbBranches + 8 + + + Create_containersSmplsCollection + +1 +2 +3 +4 +5 +6 +7 +8 + + + + + + + + + + + + + + + diff --git a/src/yacsloader_swig/Test/testSaveLoadRun.py b/src/yacsloader_swig/Test/testSaveLoadRun.py index 35f363fda..0479c522f 100755 --- a/src/yacsloader_swig/Test/testSaveLoadRun.py +++ b/src/yacsloader_swig/Test/testSaveLoadRun.py @@ -1528,7 +1528,7 @@ dd=range(10)""") n1.edAddChild(n10) n10.setScript(""" import time -time.sleep(4) +time.sleep(9) o2=2*i1 """) i1=n10.edAddInputPort("i1",ti) @@ -1559,7 +1559,7 @@ o2=2*i1 myRun=threading.Thread(None, ex.RunW, None, (p,0)) myRun.start() import time - time.sleep(7) + time.sleep(15) SALOMERuntime.schemaSaveState(p, ex, xmlStateFileName) a,b,c=n1.getPassedResults(ex) myRun.join() diff --git a/src/yacsloader_swig/Test/testWorkloadManager.py b/src/yacsloader_swig/Test/testWorkloadManager.py index 5c5fe5e67..965283530 100755 --- a/src/yacsloader_swig/Test/testWorkloadManager.py +++ b/src/yacsloader_swig/Test/testWorkloadManager.py @@ -27,7 +27,7 @@ import tempfile import os import salome -NB_NODE=16 +NB_NODE=15 class TestEdit(unittest.TestCase): def setUp(self): @@ -71,7 +71,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 +91,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) -- 2.39.2