Skip to content

Commit

Permalink
Merge pull request splitio#462 from splitio/development
Browse files Browse the repository at this point in the history
Release 9.5.1
  • Loading branch information
chillaq authored Sep 5, 2023
2 parents 523d239 + 980033a commit 703b5cd
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 3 deletions.
4 changes: 4 additions & 0 deletions CHANGES.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
9.5.1 (Sep 5, 2023)
- Exclude tests from when building the package
- Fixed exception when fetching telemetry stats if no SSE Feature flags update events are stored

9.5.0 (Jul 18, 2023)
- Improved streaming architecture implementation to apply feature flag updates from the notification received which is now enhanced, improving efficiency and reliability of the whole update system.

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,5 +53,5 @@
'Programming Language :: Python :: 3',
'Topic :: Software Development :: Libraries'
],
packages=find_packages()
packages=find_packages(exclude=('tests', 'tests.*'))
)
2 changes: 2 additions & 0 deletions splitio/models/telemetry.py
Original file line number Diff line number Diff line change
Expand Up @@ -627,6 +627,8 @@ def pop_update_from_sse(self, event):
:rtype: int
"""
with self._lock:
if self._update_from_sse.get(event.value) is None:
return 0
update_from_sse = self._update_from_sse[event.value]
self._update_from_sse[event.value] = 0
return update_from_sse
Expand Down
2 changes: 1 addition & 1 deletion splitio/version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '9.5.0'
__version__ = '9.5.1'
19 changes: 18 additions & 1 deletion tests/models/test_telemetry_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ def test_storage_type_and_operation_mode(self, mocker):
def test_method_latencies(self, mocker):
method_latencies = MethodLatencies()

method_latencies.pop_all() # should not raise exception
for method in ModelTelemetry.MethodExceptionsAndLatencies:
method_latencies.add_latency(method, 50)
if method.value == 'treatment':
Expand Down Expand Up @@ -87,8 +88,8 @@ def test_method_latencies(self, mocker):
def test_http_latencies(self, mocker):
http_latencies = HTTPLatencies()

http_latencies.pop_all() # should not raise exception
for resource in ModelTelemetry.HTTPExceptionsAndLatencies:
# pytest.set_trace()
if self._get_http_latency(resource, http_latencies) == None:
continue
http_latencies.add_latency(resource, 50)
Expand Down Expand Up @@ -141,6 +142,7 @@ def _get_http_latency(self, resource, storage):
def test_method_exceptions(self, mocker):
method_exception = MethodExceptions()

exceptions = method_exception.pop_all() # should not raise exception
[method_exception.add_exception(ModelTelemetry.MethodExceptionsAndLatencies.TREATMENT) for i in range(2)]
method_exception.add_exception(ModelTelemetry.MethodExceptionsAndLatencies.TREATMENTS)
method_exception.add_exception(ModelTelemetry.MethodExceptionsAndLatencies.TREATMENT_WITH_CONFIG)
Expand All @@ -157,6 +159,7 @@ def test_method_exceptions(self, mocker):

def test_http_errors(self, mocker):
http_error = HTTPErrors()
errors = http_error.pop_all() # should not raise exception
[http_error.add_error(ModelTelemetry.HTTPExceptionsAndLatencies.SEGMENT, str(i)) for i in [500, 501, 502]]
[http_error.add_error(ModelTelemetry.HTTPExceptionsAndLatencies.SPLIT, str(i)) for i in [400, 401, 402]]
http_error.add_error(ModelTelemetry.HTTPExceptionsAndLatencies.IMPRESSION, '502')
Expand All @@ -177,6 +180,7 @@ def test_http_errors(self, mocker):

def test_last_synchronization(self, mocker):
last_synchronization = LastSynchronization()
last_synchronization.get_all() # should not raise exception
last_synchronization.add_latency(ModelTelemetry.HTTPExceptionsAndLatencies.SPLIT, 10)
last_synchronization.add_latency(ModelTelemetry.HTTPExceptionsAndLatencies.IMPRESSION, 20)
last_synchronization.add_latency(ModelTelemetry.HTTPExceptionsAndLatencies.SEGMENT, 40)
Expand All @@ -197,19 +201,27 @@ def test_telemetry_counters(self):
assert(telemetry_counter._token_refreshes == 0)
assert(telemetry_counter._update_from_sse == {})

assert(telemetry_counter.get_session_length() == 0)
telemetry_counter.record_session_length(20)
assert(telemetry_counter.get_session_length() == 20)

assert(telemetry_counter.pop_auth_rejections() == 0)
[telemetry_counter.record_auth_rejections() for i in range(5)]
auth_rejections = telemetry_counter.pop_auth_rejections()
assert(telemetry_counter._auth_rejections == 0)
assert(auth_rejections == 5)

assert(telemetry_counter.pop_token_refreshes() == 0)
[telemetry_counter.record_token_refreshes() for i in range(3)]
token_refreshes = telemetry_counter.pop_token_refreshes()
assert(telemetry_counter._token_refreshes == 0)
assert(token_refreshes == 3)

assert(telemetry_counter.get_counter_stats(ModelTelemetry.CounterConstants.IMPRESSIONS_QUEUED) == 0)
assert(telemetry_counter.get_counter_stats(ModelTelemetry.CounterConstants.IMPRESSIONS_DEDUPED) == 0)
assert(telemetry_counter.get_counter_stats(ModelTelemetry.CounterConstants.IMPRESSIONS_DROPPED) == 0)
assert(telemetry_counter.get_counter_stats(ModelTelemetry.CounterConstants.EVENTS_QUEUED) == 0)
assert(telemetry_counter.get_counter_stats(ModelTelemetry.CounterConstants.EVENTS_DROPPED) == 0)
telemetry_counter.record_impressions_value(ModelTelemetry.CounterConstants.IMPRESSIONS_QUEUED, 10)
assert(telemetry_counter._impressions_queued == 10)
telemetry_counter.record_impressions_value(ModelTelemetry.CounterConstants.IMPRESSIONS_DEDUPED, 14)
Expand All @@ -220,6 +232,7 @@ def test_telemetry_counters(self):
assert(telemetry_counter._events_queued == 30)
telemetry_counter.record_events_value(ModelTelemetry.CounterConstants.EVENTS_DROPPED, 1)
assert(telemetry_counter._events_dropped == 1)
assert(telemetry_counter.pop_update_from_sse(UpdateFromSSE.SPLIT_UPDATE) == 0)
telemetry_counter.record_update_from_sse(UpdateFromSSE.SPLIT_UPDATE)
assert(telemetry_counter._update_from_sse[UpdateFromSSE.SPLIT_UPDATE.value] == 1)
updates = telemetry_counter.pop_update_from_sse(UpdateFromSSE.SPLIT_UPDATE)
Expand All @@ -234,6 +247,7 @@ def test_streaming_event(self, mocker):

def test_streaming_events(self, mocker):
streaming_events = StreamingEvents()
events = streaming_events.pop_streaming_events() # should not raise exception
streaming_events.record_streaming_event((ModelTelemetry.StreamingEventTypes.CONNECTION_ESTABLISHED, 'split', 1234))
streaming_events.record_streaming_event((ModelTelemetry.StreamingEventTypes.STREAMING_STATUS, 'split', 1234))
events = streaming_events.pop_streaming_events()
Expand All @@ -243,6 +257,7 @@ def test_streaming_events(self, mocker):

def test_telemetry_config(self):
telemetry_config = TelemetryConfig()
stats = telemetry_config.get_stats() # should not raise exception
config = {'operationMode': 'standalone',
'streamingEnabled': True,
'impressionsQueueSize': 100,
Expand Down Expand Up @@ -277,9 +292,11 @@ def test_telemetry_config(self):
telemetry_config.record_ready_time(10)
assert(telemetry_config._time_until_ready == 10)

assert(telemetry_config.get_bur_time_outs() == 0)
[telemetry_config.record_bur_time_out() for i in range(2)]
assert(telemetry_config.get_bur_time_outs() == 2)

assert(telemetry_config.get_non_ready_usage() == 0)
[telemetry_config.record_not_ready_usage() for i in range(5)]
assert(telemetry_config.get_non_ready_usage() == 5)

Expand Down

0 comments on commit 703b5cd

Please sign in to comment.