Skip to content
Draft
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
3 changes: 3 additions & 0 deletions contract-tests/Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ gem "puma", "~> 8.0"
gem "rackup", "~> 2.2"
gem 'sinatra', '>= 4.1'

# The file-based override source uses the listen gem for its watching change detection mode.
gem 'listen', '~> 3.3'

gem 'rubocop', '~> 1.37', group: 'development'
gem 'rubocop-performance', '~> 1.15', group: 'development'

Expand Down
22 changes: 22 additions & 0 deletions contract-tests/client_entity.rb
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,12 @@ def initialize(log, config)
opts[:payload_filter_key] = data_system_config[:payloadFilter]
end

# Flag overrides are an option of the FDv2 data system configuration.
data_system.overrides(build_override_source(config[:overrides])) if config[:overrides]

opts[:data_system_config] = data_system.build
elsif config[:overrides]
raise ArgumentError, "flag overrides require the data system to be configured"
elsif config[:streaming]
streaming = config[:streaming]
opts[:stream_uri] = streaming[:baseUri] unless streaming[:baseUri].nil?
Expand Down Expand Up @@ -365,6 +370,23 @@ def close
builder
end

#
# Builds the file-based override source from the `overrides` block of the contract test
# configuration.
#
# @param overrides_config [Hash] the overrides configuration
# @return [Object] a builder for LaunchDarkly::DataSystem::ConfigBuilder#overrides
#
private def build_override_source(overrides_config)
options = { paths: overrides_config[:filePaths] }
if overrides_config[:duplicateKeysHandling]
options[:duplicate_keys_handling] = overrides_config[:duplicateKeysHandling].to_sym
end
options[:change_detection] = overrides_config[:changeDetection].to_sym if overrides_config[:changeDetection]
set_optional_time_prop(overrides_config, :pollIntervalMs, options, :poll_interval)
LaunchDarkly::Integrations::FileData.override_source(options)
end

#
# Builds a persistent data store from the contract test configuration.
#
Expand Down
3 changes: 2 additions & 1 deletion contract-tests/service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
}

set :bind, '0.0.0.0'
set :port, 9000
set :port, (ENV['PORT'] || 9000).to_i
set :logging, false

clients = {}
Expand Down Expand Up @@ -55,6 +55,7 @@
'flag-change-listeners',
'flag-value-change-listeners',
'fdv1-fallback',
'flag-overrides',
],
}.to_json
end
Expand Down
Loading