Skip to content

Commit

Permalink
add test
Browse files Browse the repository at this point in the history
  • Loading branch information
kathap committed Dec 12, 2024
1 parent a5e6c89 commit ae69a9e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
4 changes: 2 additions & 2 deletions jobs/cloud_controller_ng/templates/shutdown_drain.rb.erb
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ require 'cloud_controller/drain'
@drain.shutdown_nginx('/var/vcap/sys/run/bpm/cloud_controller_ng/nginx.pid', <%= p("cc.nginx_drain_timeout") %>)
@drain.shutdown_cc('/var/vcap/sys/run/bpm/cloud_controller_ng/cloud_controller_ng.pid')
@threads = []
@grace_period_in_seconds = <%= p("cc.jobs.local.local_worker_grace_period_seconds") %>
@local_worker_grace_period_seconds = <%= p("cc.jobs.local.local_worker_grace_period_seconds") %>
(1..<%= p("cc.jobs.local.number_of_workers") %>).each do |i|
@threads << Thread.new { @drain.shutdown_delayed_worker("/var/vcap/sys/run/bpm/cloud_controller_ng/local_worker_#{i}.pid", @grace_period_in_seconds.to_i) }
@threads << Thread.new { @drain.shutdown_delayed_worker("/var/vcap/sys/run/bpm/cloud_controller_ng/local_worker_#{i}.pid", @local_worker_grace_period_seconds.to_i) }
end

@threads.each(&:join)
7 changes: 7 additions & 0 deletions spec/cloud_controller_ng/drain_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,13 @@ module Test
expect(rendered_file).to include("@drain.shutdown_nginx('/var/vcap/sys/run/bpm/cloud_controller_ng/nginx.pid', 30)")
end

context "when 'local_worker_grace_period_seconds' is provided" do
it 'renders the provided value' do
rendered_file = template.render({ 'cc' => { 'jobs' => { 'local' => { 'worker_grace_period_seconds' => 300 } } } }, consumes: {})
expect(rendered_file).to include('@local_worker_grace_period_seconds = 300')
end
end

context 'when nginx timeout is provided' do
it 'renders the provided value' do
rendered_file = template.render({ 'cc' => { 'nginx_drain_timeout' => 60 } }, consumes: {})
Expand Down

0 comments on commit ae69a9e

Please sign in to comment.