Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/workflows/update-license-year.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v4
with:
fetch-depth: 0

Expand All @@ -24,7 +24,7 @@ jobs:
run: "echo PREVIOUS=$(($CURRENT-1)) >> $GITHUB_ENV"

- name: Update LICENSE
uses: jacobtomlinson/gha-find-replace@v2
uses: jacobtomlinson/gha-find-replace@v3
with:
find: ${{ env.PREVIOUS }}
replace: ${{ env.CURRENT }}
Expand All @@ -38,7 +38,7 @@ jobs:
git commit -m "Updated License Year" -a

- name: Create Pull Request
uses: peter-evans/create-pull-request@v3
uses: peter-evans/create-pull-request@v5
with:
token: ${{ secrets.GITHUB_TOKEN }}
title: Update License Year
Expand Down
3 changes: 3 additions & 0 deletions CHANGES.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
9.6.1 (Feb 15, 2024)
- Added redisUsername configuration parameter for Redis connection to set the username for accessing redis when not using the default `root` username

9.6.0 (Nov 3, 2023)
- Added support for Flag Sets on the SDK, which enables grouping feature flags and interacting with the group rather than individually (more details in our documentation):
- Added new variations of the get treatment methods to support evaluating flags in given flag set/s.
Expand Down
2 changes: 1 addition & 1 deletion LICENSE.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright © 2023 Split Software, Inc.
Copyright © 2024 Split Software, Inc.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
1 change: 1 addition & 0 deletions splitio/client/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
'redisHost': 'localhost',
'redisPort': 6379,
'redisDb': 0,
'redisUsername': None,
'redisPassword': None,
'redisSocketTimeout': None,
'redisSocketConnectTimeout': None,
Expand Down
4 changes: 2 additions & 2 deletions splitio/client/factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -441,7 +441,7 @@ def _build_redis_factory(api_key, cfg):
cache_enabled = cfg.get('redisLocalCacheEnabled', False)
cache_ttl = cfg.get('redisLocalCacheTTL', 5)
storages = {
'splits': RedisSplitStorage(redis_adapter, cache_enabled, cache_ttl, cfg['flagSetsFilter'] if cfg['flagSetsFilter'] is not None else []),
'splits': RedisSplitStorage(redis_adapter, cache_enabled, cache_ttl, []),
'segments': RedisSegmentStorage(redis_adapter),
'impressions': RedisImpressionsStorage(redis_adapter, sdk_metadata),
'events': RedisEventsStorage(redis_adapter, sdk_metadata),
Expand Down Expand Up @@ -524,7 +524,7 @@ def _build_pluggable_factory(api_key, cfg):
pluggable_adapter = cfg.get('storageWrapper')
storage_prefix = cfg.get('storagePrefix')
storages = {
'splits': PluggableSplitStorage(pluggable_adapter, storage_prefix, cfg['flagSetsFilter'] if cfg['flagSetsFilter'] is not None else []),
'splits': PluggableSplitStorage(pluggable_adapter, storage_prefix, []),
'segments': PluggableSegmentStorage(pluggable_adapter, storage_prefix),
'impressions': PluggableImpressionsStorage(pluggable_adapter, sdk_metadata, storage_prefix),
'events': PluggableEventsStorage(pluggable_adapter, sdk_metadata, storage_prefix),
Expand Down
4 changes: 4 additions & 0 deletions splitio/storage/adapters/redis.py
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,7 @@ def _build_default_client(config): # pylint: disable=too-many-locals
host = config.get('redisHost', 'localhost')
port = config.get('redisPort', 6379)
database = config.get('redisDb', 0)
username = config.get('redisUsername', None)
password = config.get('redisPassword', None)
socket_timeout = config.get('redisSocketTimeout', None)
socket_connect_timeout = config.get('redisSocketConnectTimeout', None)
Expand All @@ -382,6 +383,7 @@ def _build_default_client(config): # pylint: disable=too-many-locals
port=port,
db=database,
password=password,
username=username,
socket_timeout=socket_timeout,
socket_connect_timeout=socket_connect_timeout,
socket_keepalive=socket_keepalive,
Expand Down Expand Up @@ -435,6 +437,7 @@ def _build_sentinel_client(config): # pylint: disable=too-many-locals
raise SentinelConfigurationException('redisMasterService must be specified.')

database = config.get('redisDb', 0)
username = config.get('redisUsername', None)
password = config.get('redisPassword', None)
socket_timeout = config.get('redisSocketTimeout', None)
socket_connect_timeout = config.get('redisSocketConnectTimeout', None)
Expand All @@ -452,6 +455,7 @@ def _build_sentinel_client(config): # pylint: disable=too-many-locals
sentinels,
db=database,
password=password,
username=username,
socket_timeout=socket_timeout,
socket_connect_timeout=socket_connect_timeout,
socket_keepalive=socket_keepalive,
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.6.0'
__version__ = '9.6.1'
9 changes: 8 additions & 1 deletion tests/client/test_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ def test_redis_client_creation(self, mocker):
'redisPort': 1234,
'redisDb': 1,
'redisPassword': 'some_password',
'redisUsername': 'redis_user',
'redisSocketTimeout': 123,
'redisSocketConnectTimeout': 123,
'redisSocketKeepalive': 123,
Expand All @@ -115,13 +116,16 @@ def test_redis_client_creation(self, mocker):
'redisSslCertReqs': 'some_cert_req',
'redisSslCaCerts': 'some_ca_cert',
'redisMaxConnections': 999,
'flagSetsFilter': ['set_1']
}
factory = get_factory('some_api_key', config=config)
assert isinstance(factory._get_storage('splits'), redis.RedisSplitStorage)
assert isinstance(factory._get_storage('segments'), redis.RedisSegmentStorage)
assert isinstance(factory._get_storage('impressions'), redis.RedisImpressionsStorage)
assert isinstance(factory._get_storage('events'), redis.RedisEventsStorage)

assert factory._get_storage('splits').flag_set_filter.flag_sets == set([])

adapter = factory._get_storage('splits')._redis
assert adapter == factory._get_storage('segments')._redis
assert adapter == factory._get_storage('impressions')._redis
Expand All @@ -131,6 +135,7 @@ def test_redis_client_creation(self, mocker):
host='some_host',
port=1234,
db=1,
username='redis_user',
password='some_password',
socket_timeout=123,
socket_connect_timeout=123,
Expand Down Expand Up @@ -569,13 +574,15 @@ def test_pluggable_client_creation(self, mocker):
'labelsEnabled': False,
'impressionListener': 123,
'storageType': 'pluggable',
'storageWrapper': StorageMockAdapter()
'storageWrapper': StorageMockAdapter(),
'flagSetsFilter': ['set_1']
}
factory = get_factory('some_api_key', config=config)
assert isinstance(factory._get_storage('splits'), pluggable.PluggableSplitStorage)
assert isinstance(factory._get_storage('segments'), pluggable.PluggableSegmentStorage)
assert isinstance(factory._get_storage('impressions'), pluggable.PluggableImpressionsStorage)
assert isinstance(factory._get_storage('events'), pluggable.PluggableEventsStorage)
assert factory._get_storage('splits').flag_set_filter.flag_sets == set([])

adapter = factory._get_storage('splits')._pluggable_adapter
assert adapter == factory._get_storage('segments')._pluggable_adapter
Expand Down
12 changes: 9 additions & 3 deletions tests/integration/test_redis_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from splitio.models import splits, impressions, events
from splitio.storage.redis import RedisSplitStorage, RedisSegmentStorage, RedisImpressionsStorage, \
RedisEventsStorage
from splitio.storage.adapters.redis import _build_default_client
from splitio.storage.adapters.redis import _build_default_client, StrictRedis
from splitio.client.config import DEFAULT_CONFIG


Expand All @@ -17,7 +17,11 @@ class SplitStorageTests(object):

def test_put_fetch(self):
"""Test storing and retrieving splits in redis."""
adapter = _build_default_client({})
redis = StrictRedis(host="localhost")
redis.acl_setuser(username='redis_user', enabled=True, passwords=["+split"], categories=["+admin"],
commands=["+@all"], keys=["~*"])
redis.close()
adapter = _build_default_client({'redisUsername': 'redis_user', 'redisPassword': 'split'})
try:
storage = RedisSplitStorage(adapter)
with open(os.path.join(os.path.dirname(__file__), 'files', 'split_changes.json'), 'r') as flo:
Expand Down Expand Up @@ -73,10 +77,12 @@ def test_put_fetch(self):
]
for item in to_delete:
adapter.delete(item)

storage = RedisSplitStorage(adapter)
assert storage.is_valid_traffic_type('user') is False
assert storage.is_valid_traffic_type('account') is False
redis = StrictRedis(host="localhost")
redis.acl_deluser("redis_user")
redis.close()

def test_get_all(self):
"""Test get all names & splits."""
Expand Down
4 changes: 4 additions & 0 deletions tests/storage/adapters/test_redis_adapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ def test_adapter_building(self, mocker):
'redisHost': 'some_host',
'redisPort': 1234,
'redisDb': 0,
'redisUsername': 'redis_user',
'redisPassword': 'some_password',
'redisSocketTimeout': 123,
'redisSocketConnectTimeout': 456,
Expand All @@ -113,6 +114,7 @@ def test_adapter_building(self, mocker):
host='some_host',
port=1234,
db=0,
username='redis_user',
password='some_password',
socket_timeout=123,
socket_connect_timeout=456,
Expand All @@ -137,6 +139,7 @@ def test_adapter_building(self, mocker):
'redisSentinels': [('123.123.123.123', 1), ('456.456.456.456', 2), ('789.789.789.789', 3)],
'redisMasterService': 'some_master',
'redisDb': 0,
'redisUsername': 'redis_user',
'redisPassword': 'some_password',
'redisSocketTimeout': 123,
'redisSocketConnectTimeout': 456,
Expand All @@ -162,6 +165,7 @@ def test_adapter_building(self, mocker):
assert sentinel_mock.mock_calls[0] == mocker.call(
[('123.123.123.123', 1), ('456.456.456.456', 2), ('789.789.789.789', 3)],
db=0,
username='redis_user',
password='some_password',
socket_timeout=123,
socket_connect_timeout=456,
Expand Down