Skip to content

Commit 67fabc9

Browse files
review comments
Signed-off-by: Stepan Blyschak <[email protected]>
1 parent 23912ef commit 67fabc9

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

scripts/memory_threshold_check.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ def run_check(self):
171171
Returns:
172172
(bool, str)
173173
"""
174-
# don't bother getting stats if availbale threshold is set to 0
174+
# don't bother getting stats if available memory threshold is set to 0
175175
if self.config.memory_available_threshold:
176176
memory_stats = self.stats.get_sys_memory_stats()
177177
memory_free = memory_stats["MemAvailable"]

tests/memory_threshold_check_test.py

+8-8
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
memory_threshold_check = load_module_from_source('memory_threshold_check.py', memory_threshold_check_path)
1515

1616
@pytest.fixture()
17-
def case_1():
17+
def setup_dbs_regular_mem_usage():
1818
cfg_db = dbconnector.dedicated_dbs.get('CONFIG_DB')
1919
state_db = dbconnector.dedicated_dbs.get('STATE_DB')
2020
dbconnector.dedicated_dbs['CONFIG_DB'] = os.path.join(test_path, 'memory_threshold_check', 'config_db')
@@ -25,7 +25,7 @@ def case_1():
2525

2626

2727
@pytest.fixture()
28-
def case_2():
28+
def setup_dbs_telemetry_high_mem_usage():
2929
memory_threshold_check.MemoryStats.get_sys_memory_stats = mock.Mock(return_value={'MemAvailable': 10000000, 'MemTotal': 20000000})
3030
cfg_db = dbconnector.dedicated_dbs.get('CONFIG_DB')
3131
state_db = dbconnector.dedicated_dbs.get('STATE_DB')
@@ -37,7 +37,7 @@ def case_2():
3737

3838

3939
@pytest.fixture()
40-
def case_3():
40+
def setup_dbs_swss_high_mem_usage():
4141
memory_threshold_check.MemoryStats.get_sys_memory_stats = mock.Mock(return_value={'MemAvailable': 10000000, 'MemTotal': 20000000})
4242
cfg_db = dbconnector.dedicated_dbs.get('CONFIG_DB')
4343
state_db = dbconnector.dedicated_dbs.get('STATE_DB')
@@ -48,24 +48,24 @@ def case_3():
4848
dbconnector.dedicated_dbs['STATE_DB'] = state_db
4949

5050

51-
def test_memory_check_host_not_crossed(case_1):
51+
def test_memory_check_host_not_crossed(setup_dbs_regular_mem_usage):
5252
memory_threshold_check.MemoryStats.get_sys_memory_stats = mock.Mock(return_value={'MemAvailable': 1000000, 'MemTotal': 2000000})
5353
assert memory_threshold_check.main() == (memory_threshold_check.EXIT_SUCCESS, '')
5454

5555

56-
def test_memory_check_host_less_then_min_required(case_1):
56+
def test_memory_check_host_less_then_min_required(setup_dbs_regular_mem_usage):
5757
memory_threshold_check.MemoryStats.get_sys_memory_stats = mock.Mock(return_value={'MemAvailable': 1000, 'MemTotal': 2000000})
5858
assert memory_threshold_check.main() == (memory_threshold_check.EXIT_THRESHOLD_CROSSED, '')
5959

6060

61-
def test_memory_check_host_threshold_crossed(case_1):
61+
def test_memory_check_host_threshold_crossed(setup_dbs_regular_mem_usage):
6262
memory_threshold_check.MemoryStats.get_sys_memory_stats = mock.Mock(return_value={'MemAvailable': 2000000, 'MemTotal': 20000000})
6363
assert memory_threshold_check.main() == (memory_threshold_check.EXIT_THRESHOLD_CROSSED, '')
6464

6565

66-
def test_memory_check_telemetry_threshold_crossed(case_2):
66+
def test_memory_check_telemetry_threshold_crossed(setup_dbs_telemetry_high_mem_usage):
6767
assert memory_threshold_check.main() == (memory_threshold_check.EXIT_THRESHOLD_CROSSED, 'telemetry')
6868

6969

70-
def test_memory_check_swss_threshold_crossed(case_3):
70+
def test_memory_check_swss_threshold_crossed(setup_dbs_swss_high_mem_usage):
7171
assert memory_threshold_check.main() == (memory_threshold_check.EXIT_THRESHOLD_CROSSED, 'swss')

0 commit comments

Comments
 (0)