Skip to content

Commit 07dec34

Browse files
committed
chore: Add redis persistent test support
1 parent ff64f36 commit 07dec34

File tree

3 files changed

+29
-0
lines changed

3 files changed

+29
-0
lines changed

contract-tests/Gemfile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,6 @@ gem 'json'
1111
gem 'rubocop', '~> 1.37', group: 'development'
1212
gem 'rubocop-performance', '~> 1.15', group: 'development'
1313
gem 'thin', :platforms => :ruby
14+
15+
gem "redis", "~> 5.3"
16+
gem "connection_pool", "~> 2.4"

contract-tests/client_entity.rb

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,31 @@ def initialize(log, config)
2525
opts[:base_uri] = polling[:baseUri] unless polling[:baseUri].nil?
2626
opts[:payload_filter_key] = polling[:filter] unless polling[:filter].nil?
2727
opts[:poll_interval] = polling[:pollIntervalMs] / 1_000.0 unless polling[:pollIntervalMs].nil?
28+
else
29+
opts[:use_ldd] = true
30+
end
31+
32+
if config[:persistentDataStore]
33+
store_config = {}
34+
store_config[:prefix] = config[:persistentDataStore][:store][:prefix] if config[:persistentDataStore][:store][:prefix]
35+
36+
case config[:persistentDataStore][:cache][:mode]
37+
when 'off'
38+
store_config[:expiration] = 0
39+
when 'infinite'
40+
# NOTE: We don't actually support infinite cache mode, so we'll just set it to nil for now. This uses a default
41+
# 15 second expiration time in the SDK, which is long enough to pass any test.
42+
store_config[:expiration] = nil
43+
when 'ttl'
44+
store_config[:expiration] = config[:persistentDataStore][:cache][:ttl]
45+
end
46+
47+
case config[:persistentDataStore][:store][:type]
48+
when 'redis'
49+
store_config[:redis_url] = config[:persistentDataStore][:store][:dsn]
50+
store = LaunchDarkly::Integrations::Redis.new_feature_store(store_config)
51+
opts[:feature_store] = store
52+
end
2853
end
2954

3055
if config[:events]

contract-tests/service.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
'evaluation-hooks',
4646
'omit-anonymous-contexts',
4747
'client-prereq-events',
48+
'persistent-data-store-redis',
4849
],
4950
}.to_json
5051
end

0 commit comments

Comments
 (0)