From: Anthony Geay Date: Mon, 11 Oct 2021 13:01:09 +0000 (+0200) Subject: Make the test OK on all hardware config X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=5d4fa044ff10457fe5ee07e3e05f942fae40a5ee;p=modules%2Fkernel.git Make the test OK on all hardware config --- diff --git a/src/Container/Test/CTestTestfileInstall.cmake b/src/Container/Test/CTestTestfileInstall.cmake index 2cddc72c0..33360f185 100644 --- a/src/Container/Test/CTestTestfileInstall.cmake +++ b/src/Container/Test/CTestTestfileInstall.cmake @@ -19,7 +19,7 @@ IF(NOT WIN32) SET(TEST_NAME ${COMPONENT_NAME}_testcontainer) - ADD_TEST(${TEST_NAME} ${SALOME_TEST_DRIVER} ${TIMEOUT} testcontainer.py) + ADD_TEST(${TEST_NAME} ${PYTHON_TEST_DRIVER} ${TIMEOUT} testcontainer.py) SET_TESTS_PROPERTIES(${TEST_NAME} PROPERTIES LABELS "${COMPONENT_NAME}" ENVIRONMENT "LD_LIBRARY_PATH=${KERNEL_TEST_LIB}:$ENV{LD_LIBRARY_PATH}" diff --git a/src/Container/Test/testcontainer.py b/src/Container/Test/testcontainer.py index 2f5d34fe7..3789420ed 100644 --- a/src/Container/Test/testcontainer.py +++ b/src/Container/Test/testcontainer.py @@ -65,22 +65,27 @@ class TestResourceManager(unittest.TestCase): loads2 = cont.loadOfCPUCores() self.checkLoads(cont, loads2) self.assertNotEqual(loads1, loads2) + cont.Shutdown() def test2(self): # Check custom script cont = self.getContainer("test_container_2") - cont.setPyScriptForCPULoad('cpu_loads = [0.1, 0.2, 0.3, 0.4]') + import multiprocessing as mp + ref_load = [max(0.1*(i+1),1.0) for i in range(mp.cpu_count())] + cont.setPyScriptForCPULoad('cpu_loads = {}'.format(ref_load)) loads1 = cont.loadOfCPUCores() - self.assertEqual(loads1, [0.1, 0.2, 0.3, 0.4]) + self.assertEqual(loads1, ref_load) cont.resetScriptForCPULoad() loads2 = cont.loadOfCPUCores() self.checkLoads(cont, loads2) + cont.Shutdown() def test3(self): # Check bad script cont = self.getContainer("test_container_3") cont.setPyScriptForCPULoad("bla-bla-bla") self.assertRaises(Exception, cont.loadOfCPUCores) + cont.Shutdown() def test4(self): # check memory sizes @@ -90,6 +95,7 @@ class TestResourceManager(unittest.TestCase): memory_by_me = cont.getTotalPhysicalMemoryInUseByMe() self.assertGreater(memory_total, memory_in_use) self.assertGreater(memory_in_use, memory_by_me) + cont.Shutdown() if __name__ == '__main__':