Changeset 11969 for main/waeup.kofa/trunk/src
- Timestamp:
- 16 Nov 2014, 13:06:34 (10 years ago)
- Location:
- main/waeup.kofa/trunk/src/waeup/kofa/utils
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.kofa/trunk/src/waeup/kofa/utils/tests/test_utils.py
r11821 r11969 29 29 30 30 def setUp(self): 31 self.max_pmem = psutil.phymem_usage().total32 31 self.max_vmem = psutil.virtual_memory().total 33 32 self.max_smem = psutil.swap_memory().total … … 124 123 utils.SYSTEM_MAX_LOAD['virt-mem'] = -(sys.maxint) # negative int 125 124 assert utils.expensive_actions_allowed() == False 126 127 def test_expensive_actions_allowed_physmem_none(self):128 # unset physmem maximum values make KofUtils ignore physmem values129 utils = self.get_cleared_util()130 utils.SYSTEM_MAX_LOAD['phys-mem'] = None131 assert utils.expensive_actions_allowed() == True132 # even not-set values won't block us133 del utils.SYSTEM_MAX_LOAD['phys-mem']134 assert utils.expensive_actions_allowed() == True135 136 @unittest.skipIf(137 psutil.phymem_usage().percent >= 99.99,138 reason="System physmem use over 99%. Cannot set higher allowed value.")139 def test_expensive_actions_allowed_physmem_ok(self):140 # We can react to high physmem values141 max_mem = psutil.phymem_usage().total142 utils = self.get_cleared_util()143 utils.SYSTEM_MAX_LOAD['phys-mem'] = 99.99 # positive float144 assert utils.expensive_actions_allowed() == True145 utils.SYSTEM_MAX_LOAD['phys-mem'] = -0.01 # negative float146 assert utils.expensive_actions_allowed() == True147 utils.SYSTEM_MAX_LOAD['phys-mem'] = max_mem # positive int148 assert utils.expensive_actions_allowed() == True149 utils.SYSTEM_MAX_LOAD['phys-mem'] = -1 # negative int150 assert utils.expensive_actions_allowed() == True151 152 @unittest.skipIf(153 not psutil.phymem_usage().percent,154 reason="Can test physmem behavior only if actually using some")155 def test_expensive_actions_allowed_physmem_too_much(self):156 # We can react if too much physmem is used157 max_mem = psutil.phymem_usage().total158 utils = self.get_cleared_util()159 utils.SYSTEM_MAX_LOAD['phys-mem'] = 0.0 # positive float160 assert utils.expensive_actions_allowed() == False161 utils.SYSTEM_MAX_LOAD['phys-mem'] = -100.0 # negative float162 assert utils.expensive_actions_allowed() == False163 utils.SYSTEM_MAX_LOAD['phys-mem'] = 0 # positive int164 assert utils.expensive_actions_allowed() == False165 utils.SYSTEM_MAX_LOAD['phys-mem'] = -(max_mem) # negative int166 assert utils.expensive_actions_allowed() == False -
main/waeup.kofa/trunk/src/waeup/kofa/utils/utils.py
r11821 r11969 199 199 #: value. `cpu-load`, of course, accepts float values only. 200 200 #: `swap-mem` = Swap Memory, `virt-mem` = Virtual Memory, 201 #: ` phys-mem` = Physical Memory, `cpu-load` = CPU load in percent.201 #: `cpu-load` = CPU load in percent. 202 202 SYSTEM_MAX_LOAD = { 203 203 'swap-mem': None, 204 204 'virt-mem': None, 205 'phys-mem': None,206 205 'cpu-load': 100.0, 207 206 } … … 321 320 ('swap-mem', psutil.swap_memory), 322 321 ('virt-mem', psutil.virtual_memory), 323 ('phys-mem', psutil.phymem_usage),324 322 ): 325 323 max_val = max_values.get(key, None)
Note: See TracChangeset for help on using the changeset viewer.