Skip to content

Commit

Permalink
Bugfix: show compatible for autonomous DB also if it's empty
Browse files Browse the repository at this point in the history
Put empty line after stack trace to distinguish from next
  • Loading branch information
rammpeter committed Sep 18, 2023
1 parent bdd2b49 commit 35d16ba
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 7 deletions.
3 changes: 2 additions & 1 deletion app/models/panorama_connection.rb
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,8 @@ def exec_update(sql, name, binds)

# Config for DB connection for current threads request is stored in Thread.current[:]

MAX_CONNECTION_POOL_SIZE = ENV['MAX_CONNECTION_POOL_SIZE'] || 100 # Number of pooled connections, may be more than max. threads
MAX_CONNECTION_POOL_SIZE = (ENV['MAX_CONNECTION_POOL_SIZE'] || 100).to_i # Number of pooled connections, may be more than max. threads
Panorama::Application.log_env_setting('MAX_CONNECTION_POOL_SIZE', MAX_CONNECTION_POOL_SIZE)

# noinspection RubyClassVariableUsageInspection
class PanoramaConnection
Expand Down
10 changes: 6 additions & 4 deletions app/views/env/_start_page.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,12 @@
end

show_compatible = proc do |rec|
if rec.compatible == rec.version[0, rec.compatible&.length]
"<span class=\"cui-thumb-up\"></span>".html_safe
else
"<span style=\"background-color:lightyellow;\">#{rec.compatible}</span>".html_safe
if rec.compatible
if rec.compatible == rec.version[0, rec.compatible.length]
"<span class=\"cui-thumb-up\"></span>".html_safe
else
"<span style=\"background-color:lightyellow;\">#{rec.compatible}</span>".html_safe
end
end
end

Expand Down
10 changes: 8 additions & 2 deletions config/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@

module Panorama
# VERSION and RELEASE_DATE should have fix syntax and positions because they are parsed from other sites
VERSION = '2.17.10'
RELEASE_DATE = Date.parse('2023-09-15')
VERSION = '2.17.11'
RELEASE_DATE = Date.parse('2023-09-18')

RELEASE_DAY = "%02d" % RELEASE_DATE.day
RELEASE_MONTH = "%02d" % RELEASE_DATE.month
Expand Down Expand Up @@ -114,5 +114,11 @@ class Application < Rails::Application
# It's best enabled when your entire app is migrated and stable on 6.1.
config.action_dispatch.cookies_same_site_protection = :lax

# Log the used settings from environment
# @param [String] setting Name of setting
# @param [Object] used_value Value of setting
def self.log_env_setting(setting, used_value)
Rails.logger.info "Environment setting: #{setting} = #{used_value}"
end
end
end
21 changes: 21 additions & 0 deletions test/models/panorama_connection_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,27 @@ class PanoramaConnectionTest < ActiveSupport::TestCase
@sampler_config = prepare_panorama_sampler_thread_db_config
end

# Ensure that the connection is established with various settings
test "connect to db" do
[
{ 'MAX_CONNECTION_POOL_SIZE' => 10},
{ 'MAX_CONNECTION_POOL_SIZE' => nil},
].each do |env_setting|
env_setting.each do |key, value|
if value.nil?
ENV.delete(key)
else
ENV[key] = value.to_s
end
end
PanoramaConnection.disconnect_aged_connections(-10) # disconnect all existing connections, force creation of new connection in next step
Thread.current[:panorama_connection_connection_object] = nil # Release the relation to current connection object
Object.send(:remove_const, :PanoramaConnection)
load 'panorama_connection.rb'
PanoramaConnection.sql_select_one "SELECT SYSDATE FROM DUAL" # force connect to db
end
end

test "disconnect_aged_connections" do
PanoramaConnection.disconnect_aged_connections(100)
end
Expand Down

0 comments on commit 35d16ba

Please sign in to comment.