1
1
import os
2
2
import unittest
3
3
4
- from hamcrest import *
4
+ from hamcrest import assert_that , is_ , less_than
5
5
from psutil import AccessDenied , process_iter , virtual_memory
6
6
7
7
from utilities .utilities import (
22
22
23
23
24
24
class TestMemoryUsage (unittest .TestCase ):
25
- def setUp (self ):
25
+ def setUp (self ) -> None :
26
26
g .set_instrument (None )
27
27
28
28
setup_simulated_wiring_tables ()
29
29
30
- # all tests that interact with anything but genie should try to load a config to ensure that the configurations
30
+ # all tests that interact with anything but genie should try to load
31
+ # a config to ensure that the configurations
31
32
# in the tests are not broken, e.g. by a schema update
32
33
load_config_if_not_already_loaded (TYPICAL_CONFIG_NAME )
33
34
34
- def get_current_memory_usage (self ):
35
+ def get_current_memory_usage (self ) -> float :
35
36
"""
36
37
Obtains the current system memory usage and returns it in gibibytes
37
38
@@ -60,7 +61,7 @@ def get_current_memory_usage(self):
60
61
61
62
def test_GIVEN_typical_config_with_IOCs_blocks_and_LVDCOM_IOC_WHEN_dae_is_doing_a_run_THEN_memory_usage_stays_under_9point5gb (
62
63
self ,
63
- ):
64
+ ) -> None :
64
65
system_threshold = 9.5
65
66
66
67
g .begin ()
@@ -71,7 +72,7 @@ def test_GIVEN_typical_config_with_IOCs_blocks_and_LVDCOM_IOC_WHEN_dae_is_doing_
71
72
72
73
def test_GIVEN_typical_config_with_IOCs_blocks_and_LVDCOM_IOC_WHEN_dae_is_not_doing_a_run_THEN_memory_usage_stays_under_7point5gb (
73
74
self ,
74
- ):
75
+ ) -> None :
75
76
system_threshold = 8.5
76
77
77
78
memory_used = self .get_current_memory_usage ()
@@ -80,7 +81,7 @@ def test_GIVEN_typical_config_with_IOCs_blocks_and_LVDCOM_IOC_WHEN_dae_is_not_do
80
81
81
82
def get_matching_process_cmdline_substring_from_process_or_none (
82
83
self , process , process_cmdline_substrings
83
- ):
84
+ ) -> str :
84
85
"""
85
86
Get the first substring from process_cmdline_substrings that is contained in the cmdline call for the process
86
87
or None if no substrings match.
@@ -90,7 +91,7 @@ def get_matching_process_cmdline_substring_from_process_or_none(
90
91
if process_cmdline_substring in cmdline :
91
92
return process_cmdline_substring
92
93
93
- def get_commit_sizes_in_kb (self , process_cmdline_substrings ):
94
+ def get_commit_sizes_in_kb (self , process_cmdline_substrings ) -> dict () :
94
95
"""
95
96
Get the commit sizes of the processes that contain the given substrings in their command line call.
96
97
"""
@@ -111,7 +112,7 @@ def get_commit_sizes_in_kb(self, process_cmdline_substrings):
111
112
112
113
def assert_commit_sizes_are_less_than_expected_max_commit_size (
113
114
self , process_cmdline_substrings_and_expected_max_commit_size , commit_sizes_in_kb
114
- ):
115
+ ) -> None :
115
116
assertion_error_occurred = False
116
117
for process_cmdline_substring , commit_size_in_kb in commit_sizes_in_kb .items ():
117
118
try :
@@ -130,7 +131,7 @@ def assert_commit_sizes_are_less_than_expected_max_commit_size(
130
131
f"Expected commit size to be less than values: { process_cmdline_substrings_and_expected_max_commit_size } . Actually got: { commit_sizes_in_kb } "
131
132
)
132
133
133
- def test_GIVEN_standard_setup_THEN_commit_size_of_python_processes_are_reasonable (self ):
134
+ def test_GIVEN_standard_setup_THEN_commit_size_of_python_processes_are_reasonable (self ) -> None :
134
135
process_cmdline_substrings_and_expected_max_commit_size = {
135
136
"block_server.py" : 950000 ,
136
137
"database_server.py" : 950000 ,
0 commit comments