From c6febabab7f120e8a396dc0969af49382f63d0ec Mon Sep 17 00:00:00 2001 From: Jeff Ohrstrom Date: Thu, 21 Nov 2024 10:54:22 -0500 Subject: [PATCH] give new env var precedence and fix tests --- apps/dashboard/config/configuration_singleton.rb | 2 +- .../test/config/configuration_singleton_test.rb | 14 +++++++++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/apps/dashboard/config/configuration_singleton.rb b/apps/dashboard/config/configuration_singleton.rb index 71762bc905..9db8aa902c 100644 --- a/apps/dashboard/config/configuration_singleton.rb +++ b/apps/dashboard/config/configuration_singleton.rb @@ -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 diff --git a/apps/dashboard/test/config/configuration_singleton_test.rb b/apps/dashboard/test/config/configuration_singleton_test.rb index 4aa3ccd231..6ec5f3d4e6 100644 --- a/apps/dashboard/test/config/configuration_singleton_test.rb +++ b/apps/dashboard/test/config/configuration_singleton_test.rb @@ -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) @@ -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