Skip to content

Commit

Permalink
give new env var precedence and fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
johrstrom committed Nov 21, 2024
1 parent 8553768 commit c6febab
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
2 changes: 1 addition & 1 deletion apps/dashboard/config/configuration_singleton.rb
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,7 @@ def status_poll_delay
# to update the sessions card information.
# The default and minimum value is 10s = 10_000
def bc_sessions_poll_delay
bc_poll_delay = ENV['POLL_DELAY'] || ENV['OOD_BC_SESSIONS_POLL_DELAY']
bc_poll_delay = ENV['OOD_BC_SESSIONS_POLL_DELAY'] || ENV['POLL_DELAY']
bc_poll_delay_int = bc_poll_delay.nil? ? config.fetch(:bc_sessions_poll_delay, '10000').to_i : bc_poll_delay.to_i
bc_poll_delay_int < 10_000 ? 10_000 : bc_poll_delay_int
end
Expand Down
14 changes: 13 additions & 1 deletion apps/dashboard/test/config/configuration_singleton_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -510,7 +510,7 @@ def no_config_env
test 'bc_sessions_poll_delay reads from config' do
Dir.mktmpdir do |dir|
with_modified_env({ OOD_CONFIG_D_DIRECTORY: dir.to_s }) do
sessions_config = { 'sessions_poll_delay' => '99999' }
sessions_config = { 'bc_sessions_poll_delay' => '99999' }
File.open("#{dir}/sessions_config.yml", 'w+') { |f| f.write(sessions_config.to_yaml) }

assert_equal(99_999, ConfigurationSingleton.new.bc_sessions_poll_delay)
Expand All @@ -523,4 +523,16 @@ def no_config_env
assert_equal(10_000, ConfigurationSingleton.new.bc_sessions_poll_delay)
end
end

test "bc_sessions_poll_delay respnods to new environment variable" do
with_modified_env('OOD_BC_SESSIONS_POLL_DELAY': '30000') do
assert_equal(30_000, ConfigurationSingleton.new.bc_sessions_poll_delay)
end
end

test "bc_sessions_poll_delay's new variable has precedence over the old" do
with_modified_env('OOD_BC_SESSIONS_POLL_DELAY': '30000', POLL_DELAY: '40000') do
assert_equal(30_000, ConfigurationSingleton.new.bc_sessions_poll_delay)
end
end
end

0 comments on commit c6febab

Please sign in to comment.