Skip to content

Commit

Permalink
Merge pull request #5394 from h-kataria/workers_default_settings_fixed
Browse files Browse the repository at this point in the history
Fixed display of default memory threshold correctly on new appliance

(cherry picked from commit 4b913ce)

Fixes https://bugzilla.redhat.com/show_bug.cgi?id=1686902
  • Loading branch information
mzazrivec authored and simaishi committed Mar 29, 2019
1 parent b0f0e2b commit 1ca9689
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
12 changes: 6 additions & 6 deletions app/controllers/ops_controller/settings/common.rb
Expand Up @@ -1023,9 +1023,8 @@ def settings_set_form_vars_workers
qwb[:ems_metrics_collector_worker] ||= {}
qwb[:ems_metrics_collector_worker][:defaults] ||= {}
w = qwb[:ems_metrics_collector_worker][:defaults]
raw = get_worker_setting(@edit[:current], MiqEmsMetricsCollectorWorker)
w[:count] = raw[:defaults][:count] || 2
w[:memory_threshold] = raw[:defaults][:memory_threshold] || 400.megabytes
w[:count] = get_worker_setting(@edit[:current], MiqEmsMetricsCollectorWorker, :defaults, :count) || 2
w[:memory_threshold] = get_worker_setting(@edit[:current], MiqEmsMetricsCollectorWorker, :defaults, :memory_threshold) || 400.megabytes
@sb[:ems_metrics_collector_threshold] = []
@sb[:ems_metrics_collector_threshold] = copy_array(@sb[:threshold])

Expand All @@ -1040,6 +1039,7 @@ def settings_set_form_vars_workers
w[:memory_threshold] = get_worker_setting(@edit[:current], MiqSmartProxyWorker, :memory_threshold) || 400.megabytes
@sb[:smart_proxy_threshold] = []
@sb[:smart_proxy_threshold] = copy_array(@sb[:threshold])
(1.gigabytes..2.9.gigabytes).step(0.1.gigabyte) { |x| @sb[:smart_proxy_threshold] << [number_to_human_size(x, :significant => false), x.to_i] }

qwb[:ems_refresh_worker] ||= {}
qwb[:ems_refresh_worker][:defaults] ||= {}
Expand All @@ -1048,22 +1048,22 @@ def settings_set_form_vars_workers
@sb[:ems_refresh_threshold] = []
(200.megabytes...550.megabytes).step(50.megabytes) { |x| @sb[:ems_refresh_threshold] << [number_to_human_size(x, :significant => false), x] }
(600.megabytes..900.megabytes).step(100.megabytes) { |x| @sb[:ems_refresh_threshold] << [number_to_human_size(x, :significant => false), x] }
(1.gigabytes..2.9.gigabytes).step(1.gigabyte / 10) { |x| @sb[:ems_refresh_threshold] << [number_to_human_size(x, :significant => false), x.to_i] }
(1.gigabytes..2.9.gigabytes).step(0.1.gigabyte) { |x| @sb[:ems_refresh_threshold] << [number_to_human_size(x, :significant => false), x.to_i] }
(3.gigabytes..10.gigabytes).step(512.megabytes) { |x| @sb[:ems_refresh_threshold] << [number_to_human_size(x, :significant => false), x.to_i] }

wb = @edit[:current].config[:workers][:worker_base]
w = (wb[:event_catcher] ||= {})
w[:memory_threshold] = get_worker_setting(@edit[:current], MiqEventCatcher, :memory_threshold) || 1.gigabytes
@sb[:event_catcher_threshold] = []
(500.megabytes...1000.megabytes).step(100.megabytes) { |x| @sb[:event_catcher_threshold] << [number_to_human_size(x, :significant => false), x] }
(1.gigabytes..2.9.gigabytes).step(1.gigabyte / 10) { |x| @sb[:event_catcher_threshold] << [number_to_human_size(x, :significant => false), x.to_i] }
(1.gigabytes..2.9.gigabytes).step(0.1.gigabyte) { |x| @sb[:event_catcher_threshold] << [number_to_human_size(x, :significant => false), x.to_i] }
(3.gigabytes..10.gigabytes).step(512.megabytes) { |x| @sb[:event_catcher_threshold] << [number_to_human_size(x, :significant => false), x.to_i] }

w = (wb[:vim_broker_worker] ||= {})
w[:memory_threshold] = get_worker_setting(@edit[:current], MiqVimBrokerWorker, :memory_threshold) || 1.gigabytes
@sb[:vim_broker_threshold] = []
(500.megabytes..900.megabytes).step(100.megabytes) { |x| @sb[:vim_broker_threshold] << [number_to_human_size(x, :significant => false), x] }
(1.gigabytes..2.9.gigabytes).step(1.gigabyte / 10) { |x| @sb[:vim_broker_threshold] << [number_to_human_size(x, :significant => false), x.to_i] }
(1.gigabytes..2.9.gigabytes).step(0.1.gigabyte) { |x| @sb[:vim_broker_threshold] << [number_to_human_size(x, :significant => false), x.to_i] }
(3.gigabytes..10.gigabytes).step(512.megabytes) { |x| @sb[:vim_broker_threshold] << [number_to_human_size(x, :significant => false), x.to_i] }

w = (wb[:ui_worker] ||= {})
Expand Down
8 changes: 8 additions & 0 deletions spec/controllers/ops_controller/settings/common_spec.rb
Expand Up @@ -441,6 +441,7 @@
end

describe '#settings_set_form_vars_workers' do
include ActionView::Helpers::NumberHelper
context "set worker settings for selected server" do
before do
@miq_server = FactoryBot.create(:miq_server)
Expand Down Expand Up @@ -474,6 +475,13 @@
expect(ui_worker_threshold).to eq(600.megabytes)
expect(ui_worker_count).to eq(2)
end

it "gets worker setting and makes sure it exists in threshold array so correct value can be selected in drop down" do
controller.send(:settings_set_form_vars_workers)
proxy_worker_threshold = controller.send(:get_worker_setting, assigns(:edit)[:current], MiqSmartProxyWorker, :memory_threshold)
proxy_worker_threshold_human_size = number_to_human_size(proxy_worker_threshold, :significant => false)
expect(assigns(:sb)[:smart_proxy_threshold]).to include([proxy_worker_threshold_human_size, proxy_worker_threshold])
end
end
end
end
Expand Down

0 comments on commit 1ca9689

Please sign in to comment.