-
Notifications
You must be signed in to change notification settings - Fork 117
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix snmp agent not-responding issue when high CPU utilization
- Loading branch information
1 parent
6a5c96d
commit 97145ea
Showing
4 changed files
with
117 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
from unittest import TestCase | ||
|
||
from ax_interface.util import get_next_update_interval | ||
|
||
|
||
class TestUtil(TestCase): | ||
# Given: Update is quick, execution time is 0.000001, static interval is 5/10/15s | ||
# When: get next interval | ||
# Then: Return default interval, 5/10/15s | ||
def test_get_interval_quick_finish(self): | ||
for static_interval in [5, 10, 15]: | ||
self.assertEqual(get_next_update_interval(0.000001, static_interval), static_interval) | ||
|
||
# Given: Update is slow, execution time is 0.7666666, static interval is 5 | ||
# When: get next interval | ||
# Then: Return the ceil(0.766666 * 10) = 8 | ||
def test_get_interval_slow_finish(self): | ||
self.assertEqual(get_next_update_interval(0.766666, 5), 8) | ||
|
||
# Given: Update is slow, execution time is 0.766666, static interval is 10 | ||
# When: get next interval | ||
# Then: Return default interval, 10 | ||
def test_get_interval_slow_finish_default_long(self): | ||
self.assertEqual(get_next_update_interval(0.766666, 10), 10) | ||
|
||
# Given: Update is very slow, execution time is 20.2324, static interval is 10 | ||
# When: get next interval | ||
# Then: Return max interval, 60 | ||
def test_get_interval_very_slow(self): | ||
self.assertEqual(get_next_update_interval(20.2324, 10), 60) | ||
|
||
# Given: Get a 0 as the execution time, static interval is 5 | ||
# When: get next interval | ||
# Then: Return default interval, 5 | ||
def test_get_interval_zero(self): | ||
self.assertEqual(get_next_update_interval(0, 5), 5) | ||
|
||
# Given: Get a 0.000000 as the execution time, static interval is 5 | ||
# When: get next interval | ||
# Then: Return default interval, 5 | ||
def test_get_interval_zero_long(self): | ||
self.assertEqual(get_next_update_interval(0.000000, 5), 5) | ||
|
||
# Given: Wrongly get a negative number(-0.000001) as the execution time, static interval is 5 | ||
# When: get next interval | ||
# Then: Return default interval, 5 | ||
def test_get_interval_negative(self): | ||
self.assertEqual(get_next_update_interval(-0.000001, 5), 5) | ||
|
||
# Given: Wrongly get a negative number(-10.000001) as the execution time, static interval is 5 | ||
# When: get next interval | ||
# Then: Return default interval, 5 | ||
def test_get_interval_negative_slow(self): | ||
self.assertEqual(get_next_update_interval(-10.000001, 5), 5) |