-
Notifications
You must be signed in to change notification settings - Fork 116
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a252904
commit cd4f759
Showing
9 changed files
with
57 additions
and
51 deletions.
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
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 |
---|---|---|
@@ -1,24 +1,36 @@ | ||
import unittest | ||
import time | ||
|
||
from pubnub.managers import TelemetryManager | ||
from pubnub.pubnub import NativeTelemetryManager | ||
from pubnub.enums import PNOperationType | ||
|
||
|
||
class TestTelemetryManager(unittest.TestCase): # pylint: disable=W0612 | ||
@classmethod | ||
def test_clean_up(cls): | ||
manager = TelemetryManager() | ||
manager.MAXIMUM_LATENCY_DATA_AGE = 1 | ||
def test_cleaning_up_latency_data(): | ||
manager = TelemetryManager() | ||
manager.MAXIMUM_LATENCY_DATA_AGE = 1 | ||
|
||
for i in range(0, 10): | ||
manager.store_latency(i, PNOperationType.PNPublishOperation) | ||
for i in range(0, 10): | ||
manager.store_latency(i, PNOperationType.PNPublishOperation) | ||
|
||
# await for store timestamp expired | ||
time.sleep(2) | ||
# await for store timestamp expired | ||
time.sleep(2) | ||
|
||
manager.clean_up_telemetry_data() | ||
print(manager.latencies) | ||
manager.clean_up_telemetry_data() | ||
print(manager.latencies) | ||
|
||
if not 0 == len(manager.operation_latencies()): | ||
raise AssertionError() | ||
assert len(manager.operation_latencies()) == 0 | ||
|
||
|
||
def test_native_telemetry_cleanup(): | ||
manager = NativeTelemetryManager() | ||
manager.MAXIMUM_LATENCY_DATA_AGE = 1 | ||
|
||
for i in range(1, 10): | ||
manager.store_latency(i, PNOperationType.PNPublishOperation) | ||
|
||
time.sleep(2) | ||
|
||
for i in range(1, 10): # Latency = 0 is not being stored! | ||
manager.store_latency(i, PNOperationType.PNPublishOperation) | ||
|
||
assert len(manager.latencies["pub"]) == 9 |
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