# -*- coding: iso-8859-1 -*-
-# Copyright (C) 2007-2021 CEA/DEN, EDF R&D, OPEN CASCADE
+# Copyright (C) 2007-2023 CEA, EDF, OPEN CASCADE
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
self.assertTrue(0.0 <= load <= 1.0)
def test1(self):
- # Check loadOfCPUCores
- cont = self.getContainer("test_container_1")
- loads1 = cont.loadOfCPUCores()
- self.checkLoads(cont, loads1)
- sleep(1)
- 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")
import multiprocessing as mp
- ref_load = [max(0.1*(i+1),1.0) for i in range(mp.cpu_count())]
+ ref_load = [min(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, ref_load)
self.checkLoads(cont, loads2)
cont.Shutdown()
- def test3(self):
+ def test2(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):
+ def test3(self):
# check memory sizes
cont = self.getContainer("test_container_4")
memory_total = cont.getTotalPhysicalMemory()
self.assertGreater(memory_in_use, memory_by_me)
cont.Shutdown()
- def test5(self):
+ def test4(self):
"""
Test checking memory consumption of container
"""
psn.execute([],pickle.dumps(((),{})))
memory_by_me_end = cont.getTotalPhysicalMemoryInUseByMe()
self.assertGreater(memory_by_me_end,memory_by_me_start)
- self.assertIn(memory_by_me_end-memory_by_me_start,[10,11,12])# test elevation of memory
+ self.assertIn(memory_by_me_end-memory_by_me_start,[9,10,11,12])# test elevation of memory
cont.Shutdown()
if __name__ == '__main__':