From 20d61d156c7b5ef0701b866d3baa4da689dccac6 Mon Sep 17 00:00:00 2001 From: Sven Krieger <37476281+svkrieger@users.noreply.github.com> Date: Wed, 30 Oct 2024 16:24:27 +0100 Subject: [PATCH] Make puma default webserver (#485) * Make Puma the default webserver Thin can still be used using the new config flag `cc.temporary_enable_deprecated_thin_webserver` * Change Puma defaults to 2 workers with each 10 threads and 10 DB connections * Enable jemalloc by default and remove feature flag * Re-add `cc.experimental.use_puma_webserver` --- .../templates/bin/cc_deployment_updater.erb | 4 +- .../templates/bin/cloud_controller_clock.erb | 2 - jobs/cloud_controller_ng/spec | 27 ++-- .../templates/bin/cloud_controller_ng.erb | 2 - .../templates/bin/local_worker.erb | 2 - .../cloud_controller_ng/templates/bpm.yml.erb | 10 +- .../templates/cloud_controller_ng.yml.erb | 12 +- .../templates/bin/cloud_controller_worker.erb | 2 - .../templates/bin/run.erb | 4 +- jobs/valkey/monit | 10 +- spec/cloud_controller_ng/bpm_spec.rb | 98 +++++++++++---- .../cloud_controller_ng_spec.rb | 117 ++++++++++++++++-- spec/valkey/monit_spec.rb | 62 +++++++++- 13 files changed, 287 insertions(+), 65 deletions(-) diff --git a/jobs/cc_deployment_updater/templates/bin/cc_deployment_updater.erb b/jobs/cc_deployment_updater/templates/bin/cc_deployment_updater.erb index ea1a6a475c..9f8ec58615 100644 --- a/jobs/cc_deployment_updater/templates/bin/cc_deployment_updater.erb +++ b/jobs/cc_deployment_updater/templates/bin/cc_deployment_updater.erb @@ -7,8 +7,6 @@ cd /var/vcap/packages/cloud_controller_ng/cloud_controller_ng export RUBYOPT='--yjit' <% end %> -<% if link("cloud_controller_internal").p('cc.experimental.use_jemalloc_memory_allocator') %> - export LD_PRELOAD=/var/vcap/packages/jemalloc/lib/libjemalloc.so -<% end %> +export LD_PRELOAD=/var/vcap/packages/jemalloc/lib/libjemalloc.so exec bundle exec rake deployment_updater:start diff --git a/jobs/cloud_controller_clock/templates/bin/cloud_controller_clock.erb b/jobs/cloud_controller_clock/templates/bin/cloud_controller_clock.erb index 12ffb37234..05c7daa5b5 100644 --- a/jobs/cloud_controller_clock/templates/bin/cloud_controller_clock.erb +++ b/jobs/cloud_controller_clock/templates/bin/cloud_controller_clock.erb @@ -7,8 +7,6 @@ cd /var/vcap/packages/cloud_controller_ng/cloud_controller_ng export RUBYOPT='--yjit' <% end %> -<% if link("cloud_controller_internal").p('cc.experimental.use_jemalloc_memory_allocator') %> export LD_PRELOAD=/var/vcap/packages/jemalloc/lib/libjemalloc.so -<% end %> exec bundle exec rake clock:start diff --git a/jobs/cloud_controller_ng/spec b/jobs/cloud_controller_ng/spec index c817d72faf..fc5988cb2a 100644 --- a/jobs/cloud_controller_ng/spec +++ b/jobs/cloud_controller_ng/spec @@ -163,7 +163,6 @@ provides: - cc.external_port - cc.external_protocol - cc.experimental.use_yjit_compiler - - cc.experimental.use_jemalloc_memory_allocator - cc.internal_service_hostname - cc.jobs.enable_dynamic_job_priorities - cc.log_db_queries @@ -229,6 +228,7 @@ provides: - cc.app_log_revision - cc.app_instance_stopping_state - cc.deprecated_stacks + - cc.temporary_enable_deprecated_thin_webserver consumes: - name: database @@ -1253,28 +1253,21 @@ properties: description: "Use Ruby's YJIT compiler when running Cloud Controller API servers and workers. This feature is experimental and not recommended. Please review the drawbacks and benefits of YJIT before enabling." default: false - cc.experimental.use_jemalloc_memory_allocator: - description: "Enables jemalloc rather than malloc for Cloud Controller API servers and workers; however, it's experimental and not typically recommended, so review its pros and cons before use." - default: false - - cc.experimental.use_puma_webserver: - description: "Use Puma in place of Thin as the webserver. This may increase performance as Puma forks Cloud Controller processes to avoid relying on threads" - default: false - cc.experimental.use_redis: description: "Use co-deployed Valkey (Redis fork) for rate limiting and metrics. If the Puma webserver is enabled, Valkey will automatically be used." default: false cc.puma.workers: description: "Number of workers for Puma webserver." - default: 3 + default: 2 cc.puma.max_threads: description: "Maximum number of threads per Puma webserver worker." - default: 2 + default: 10 cc.puma.max_db_connections_per_process: - description: "Maximum database connections for Puma per process (main + Puma workers), if not set the ccng value is used (default)" + description: "Maximum database connections for Puma per process (main + Puma workers)." + default: 10 cc.update_metric_tags_on_rename: description: "Enable sending a Desired LRP update when an app is renamed" @@ -1283,3 +1276,13 @@ properties: cc.legacy_md5_buildpack_paths_enabled: description: "Enable legacy MD5 buildpack paths. If disabled, xxhash64 is used for calculating paths in buildpack image layers." default: false + + cc.temporary_enable_deprecated_thin_webserver: + description: "Use deprecated Thin webserver. Please note that when using Thin instead of Puma you miss out on the following benefits: Better resource utilization, well maintained and more performant. Thin will be removed in a future release. `cc.experimental.use_puma_webserver` takes precedence over this." + default: false + + +# deprecated configuration + + cc.experimental.use_puma_webserver: + description: "Deprecated as Puma is now the default. This config flag will be removed in the future. Currently it takes precedence over `cc.temporary_enable_deprecated_thin_webserver` i.e. when set to false Thin will be used." diff --git a/jobs/cloud_controller_ng/templates/bin/cloud_controller_ng.erb b/jobs/cloud_controller_ng/templates/bin/cloud_controller_ng.erb index c207804091..eccf57c9b6 100644 --- a/jobs/cloud_controller_ng/templates/bin/cloud_controller_ng.erb +++ b/jobs/cloud_controller_ng/templates/bin/cloud_controller_ng.erb @@ -18,9 +18,7 @@ echo 'Finished migrations and seeds' export RUBYOPT='--yjit' <% end %> -<% if p('cc.experimental.use_jemalloc_memory_allocator') %> export LD_PRELOAD=/var/vcap/packages/jemalloc/lib/libjemalloc.so -<% end %> exec /var/vcap/packages/cloud_controller_ng/cloud_controller_ng/bin/cloud_controller \ -c /var/vcap/jobs/cloud_controller_ng/config/cloud_controller_ng.yml diff --git a/jobs/cloud_controller_ng/templates/bin/local_worker.erb b/jobs/cloud_controller_ng/templates/bin/local_worker.erb index 54a34ce580..f7ba28477c 100644 --- a/jobs/cloud_controller_ng/templates/bin/local_worker.erb +++ b/jobs/cloud_controller_ng/templates/bin/local_worker.erb @@ -9,9 +9,7 @@ wait_for_blobstore export RUBYOPT='--yjit' <% end %> -<% if p('cc.experimental.use_jemalloc_memory_allocator') %> export LD_PRELOAD=/var/vcap/packages/jemalloc/lib/libjemalloc.so -<% end %> cd /var/vcap/packages/cloud_controller_ng/cloud_controller_ng exec bundle exec rake "jobs:local[cc_api_worker.<%= spec.job.name %>.<%= spec.index %>.${INDEX}]" diff --git a/jobs/cloud_controller_ng/templates/bpm.yml.erb b/jobs/cloud_controller_ng/templates/bpm.yml.erb index 8f93ef2928..897f9a9802 100644 --- a/jobs/cloud_controller_ng/templates/bpm.yml.erb +++ b/jobs/cloud_controller_ng/templates/bpm.yml.erb @@ -12,8 +12,16 @@ def mount_nfs_volume!(config) end end +def thin_webserver_enabled? + if_p('cc.experimental.use_puma_webserver') do |prop| + return !prop + end + + p('cc.temporary_enable_deprecated_thin_webserver') +end + def mount_valkey_volume!(config) - if p("cc.experimental.use_puma_webserver") || p("cc.experimental.use_redis") + unless thin_webserver_enabled? && !p("cc.experimental.use_redis") config['additional_volumes'] = [] unless config.key?('additional_volumes') config['additional_volumes'] << { "path" => "/var/vcap/data/valkey", diff --git a/jobs/cloud_controller_ng/templates/cloud_controller_ng.yml.erb b/jobs/cloud_controller_ng/templates/cloud_controller_ng.yml.erb index a94dd1ef2a..132a55e70d 100644 --- a/jobs/cloud_controller_ng/templates/cloud_controller_ng.yml.erb +++ b/jobs/cloud_controller_ng/templates/cloud_controller_ng.yml.erb @@ -42,6 +42,14 @@ end raise "Error for database_encryption: #{active_keys.length} were marked active. Only one key may be active" end + + def thin_webserver_enabled? + if_p('cc.experimental.use_puma_webserver') do |prop| + return !prop + end + + p('cc.temporary_enable_deprecated_thin_webserver') +end %> --- #Actually NGX host and port @@ -53,7 +61,7 @@ local_route: <%= p('cc.nginx.ip') %> external_port: <%= p("cc.external_port") %> tls_port: <%= p("cc.tls_port") %> internal_service_hostname: <%= p("cc.internal_service_hostname") %> -webserver: <%= p("cc.experimental.use_puma_webserver") ? 'puma' : 'thin' %> +webserver: <%= thin_webserver_enabled? ? 'thin' : 'puma' %> puma: workers: <%= p("cc.puma.workers") %> max_threads: <%= p("cc.puma.max_threads") %> @@ -490,7 +498,7 @@ rate_limiter_v2_api: temporary_enable_v2: <%= p("cc.temporary_enable_v2") %> -<% if p("cc.experimental.use_puma_webserver") || p("cc.experimental.use_redis") %> +<% unless thin_webserver_enabled? && !p("cc.experimental.use_redis") %> redis: socket: "/var/vcap/data/valkey/valkey.sock" <% end %> diff --git a/jobs/cloud_controller_worker/templates/bin/cloud_controller_worker.erb b/jobs/cloud_controller_worker/templates/bin/cloud_controller_worker.erb index f220aab114..03ae14eff2 100644 --- a/jobs/cloud_controller_worker/templates/bin/cloud_controller_worker.erb +++ b/jobs/cloud_controller_worker/templates/bin/cloud_controller_worker.erb @@ -9,9 +9,7 @@ wait_for_blobstore export RUBYOPT='--yjit' <% end %> -<% if link("cloud_controller_internal").p('cc.experimental.use_jemalloc_memory_allocator') %> export LD_PRELOAD=/var/vcap/packages/jemalloc/lib/libjemalloc.so -<% end %> cd /var/vcap/packages/cloud_controller_ng/cloud_controller_ng diff --git a/jobs/rotate_cc_database_key/templates/bin/run.erb b/jobs/rotate_cc_database_key/templates/bin/run.erb index deef575606..3d4fd03ae9 100644 --- a/jobs/rotate_cc_database_key/templates/bin/run.erb +++ b/jobs/rotate_cc_database_key/templates/bin/run.erb @@ -2,9 +2,7 @@ set -eu -<% if link("cloud_controller_internal").p('cc.experimental.use_jemalloc_memory_allocator') %> - export LD_PRELOAD=/var/vcap/packages/jemalloc/lib/libjemalloc.so -<% end %> +export LD_PRELOAD=/var/vcap/packages/jemalloc/lib/libjemalloc.so rotate() { export CLOUD_CONTROLLER_NG_CONFIG=/var/vcap/jobs/rotate_cc_database_key/config/cloud_controller_ng.yml diff --git a/jobs/valkey/monit b/jobs/valkey/monit index ca00165486..2876fe21e2 100644 --- a/jobs/valkey/monit +++ b/jobs/valkey/monit @@ -1,6 +1,14 @@ <% + def thin_webserver_enabled?(link) + link.if_p('cc.experimental.use_puma_webserver') do |prop| + return !prop + end + + link.p('cc.temporary_enable_deprecated_thin_webserver') + end + cloud_controller_internal = link("cloud_controller_internal") - if cloud_controller_internal.p("cc.experimental.use_puma_webserver") || cloud_controller_internal.p("cc.experimental.use_redis") + unless thin_webserver_enabled?(cloud_controller_internal) && !cloud_controller_internal.p("cc.experimental.use_redis") %> check process valkey diff --git a/spec/cloud_controller_ng/bpm_spec.rb b/spec/cloud_controller_ng/bpm_spec.rb index 51e5991e33..ab98bbc38e 100644 --- a/spec/cloud_controller_ng/bpm_spec.rb +++ b/spec/cloud_controller_ng/bpm_spec.rb @@ -112,33 +112,87 @@ def valkey_volume_mounted?(process) end end - context 'when the puma webserver is used' do - it 'mounts the valkey volume into the ccng job container' do - template_hash = YAML.safe_load(template.render({ 'cc' => { 'experimental' => { 'use_puma_webserver' => true } } }, consumes: {})) - - results = template_hash['processes'].select { |p| p['name'].include?('cloud_controller_ng') } - expect(results.length).to eq(1) - expect(valkey_volume_mounted?(results[0])).to be_truthy + describe 'valkey config' do + context 'when the puma webserver is used by default' do + it 'mounts the valkey volume into the ccng job container' do + template_hash = YAML.safe_load(template.render({}, consumes: {})) + + results = template_hash['processes'].select { |p| p['name'].include?('cloud_controller_ng') } + expect(results.length).to eq(1) + expect(valkey_volume_mounted?(results[0])).to be_truthy + end end - end - - context "when 'cc.experimental.use_redis' is set to 'true'" do - it 'mounts the valkey volume into the ccng job container' do - template_hash = YAML.safe_load(template.render({ 'cc' => { 'experimental' => { 'use_redis' => true } } }, consumes: {})) - results = template_hash['processes'].select { |p| p['name'].include?('cloud_controller_ng') } - expect(results.length).to eq(1) - expect(valkey_volume_mounted?(results[0])).to be_truthy + context 'when the puma webserver is enabled by deprecated config' do + it 'mounts the valkey volume into the ccng job container' do + template_hash = YAML.safe_load(template.render({ 'cc' => { 'experimental' => { 'use_puma_webserver' => true } } }, consumes: {})) + + results = template_hash['processes'].select { |p| p['name'].include?('cloud_controller_ng') } + expect(results.length).to eq(1) + expect(valkey_volume_mounted?(results[0])).to be_truthy + end + + context 'when `cc.temporary_enable_deprecated_thin_webserver` is also enabled' do + it 'still uses Puma and mounts the valkey volume into the ccng job container' do + template_hash = YAML.safe_load(template.render( + { 'cc' => { 'experimental' => { 'use_puma_webserver' => true }, + 'temporary_enable_deprecated_thin_webserver' => true } }, consumes: {} + )) + + results = template_hash['processes'].select { |p| p['name'].include?('cloud_controller_ng') } + expect(results.length).to eq(1) + expect(valkey_volume_mounted?(results[0])).to be_truthy + end + end end - end - context "when neither the puma webserver is used nor 'cc.experimental.use_redis' is set to 'true'" do - it 'does not mount the valkey volume into the ccng job container' do - template_hash = YAML.safe_load(template.render({}, consumes: {})) + context 'when thin webserver is explicitly enabled' do + context "when 'cc.experimental.use_redis' is set to 'true'" do + it 'mounts the valkey volume into the ccng job container' do + template_hash = YAML.safe_load( + template.render({ 'cc' => { 'temporary_enable_deprecated_thin_webserver' => true, + 'experimental' => { 'use_redis' => true } } }, consumes: {}) + ) + + results = template_hash['processes'].select { |p| p['name'].include?('cloud_controller_ng') } + expect(results.length).to eq(1) + expect(valkey_volume_mounted?(results[0])).to be_truthy + end + end + + context "when 'cc.experimental.use_redis' is not set'" do + it 'mounts the valkey volume into the ccng job container' do + template_hash = YAML.safe_load(template.render({ 'cc' => { 'temporary_enable_deprecated_thin_webserver' => true } }, consumes: {})) + + results = template_hash['processes'].select { |p| p['name'].include?('cloud_controller_ng') } + expect(results.length).to eq(1) + expect(valkey_volume_mounted?(results[0])).to be_falsey + end + end + end - results = template_hash['processes'].select { |p| p['name'].include?('cloud_controller_ng') } - expect(results.length).to eq(1) - expect(valkey_volume_mounted?(results[0])).to be_falsey + context 'when thin webserver is implicitly enabled through `cc.experimental.use_puma_webserver` => false' do + context "when 'cc.experimental.use_redis' is set to 'true'" do + it 'mounts the valkey volume into the ccng job container' do + template_hash = YAML.safe_load( + template.render({ 'cc' => { 'experimental' => { 'use_puma_webserver' => false, 'use_redis' => true } } }, consumes: {}) + ) + + results = template_hash['processes'].select { |p| p['name'].include?('cloud_controller_ng') } + expect(results.length).to eq(1) + expect(valkey_volume_mounted?(results[0])).to be_truthy + end + end + + context "when 'cc.experimental.use_redis' is not set'" do + it 'mounts the valkey volume into the ccng job container' do + template_hash = YAML.safe_load(template.render({ 'cc' => { 'temporary_enable_deprecated_thin_webserver' => true } }, consumes: {})) + + results = template_hash['processes'].select { |p| p['name'].include?('cloud_controller_ng') } + expect(results.length).to eq(1) + expect(valkey_volume_mounted?(results[0])).to be_falsey + end + end end end end diff --git a/spec/cloud_controller_ng/cloud_controller_ng_spec.rb b/spec/cloud_controller_ng/cloud_controller_ng_spec.rb index 41792e496e..00cdae7640 100644 --- a/spec/cloud_controller_ng/cloud_controller_ng_spec.rb +++ b/spec/cloud_controller_ng/cloud_controller_ng_spec.rb @@ -53,6 +53,7 @@ module Test 'private_endpoint' => 'https://blobstore.service.cf.internal:4443', 'public_endpoint' => 'https://blobstore.brook-sentry.capi.land', 'username' => 'blobstore-user' } }, + 'experimental' => {}, 'install_buildpacks' => [{ 'name' => 'staticfile_buildpack', 'package' => 'staticfile-buildpack' }, { 'name' => 'java_buildpack', 'package' => 'java-buildpack' }, @@ -586,28 +587,130 @@ module Test end end + describe 'webserver config' do + it 'uses Puma by default' do + template_hash = YAML.safe_load(template.render(merged_manifest_properties, consumes: links)) + expect(template_hash['webserver']).to eq('puma') + end + + context 'when the puma webserver is enabled by deprecated config' do + before do + merged_manifest_properties['cc']['experimental']['use_puma_webserver'] = true + end + + it 'uses Puma' do + template_hash = YAML.safe_load(template.render(merged_manifest_properties, consumes: links)) + expect(template_hash['webserver']).to eq('puma') + end + + context 'when `cc.temporary_enable_deprecated_thin_webserver` is also enabled' do + before do + merged_manifest_properties['cc']['temporary_enable_deprecated_thin_webserver'] = true + end + + it 'uses Puma' do + template_hash = YAML.safe_load(template.render(merged_manifest_properties, consumes: links)) + expect(template_hash['webserver']).to eq('puma') + end + end + end + + context 'when the puma webserver is disabled by deprecated config' do + before do + merged_manifest_properties['cc']['experimental']['use_puma_webserver'] = false + end + + it 'uses Thin' do + template_hash = YAML.safe_load(template.render(merged_manifest_properties, consumes: links)) + expect(template_hash['webserver']).to eq('thin') + end + end + + context 'when `cc.temporary_enable_deprecated_thin_webserver` is enabled' do + before do + merged_manifest_properties['cc']['temporary_enable_deprecated_thin_webserver'] = true + end + + it 'uses Thin' do + template_hash = YAML.safe_load(template.render(merged_manifest_properties, consumes: links)) + expect(template_hash['webserver']).to eq('thin') + end + end + end + describe 'valkey config' do - context 'when the puma webserver is used' do + context 'when the puma webserver is used by default' do it 'renders the valkey socket into the ccng config' do - merged_manifest_properties['cc']['experimental'] = { 'use_puma_webserver' => true } template_hash = YAML.safe_load(template.render(merged_manifest_properties, consumes: links)) expect(template_hash['redis']['socket']).to eq('/var/vcap/data/valkey/valkey.sock') end end - context "when 'cc.experimental.use_redis' is set to 'true'" do - it 'renders the redis socket into the ccng config' do - merged_manifest_properties['cc']['experimental'] = { 'use_redis' => true } + context 'when the puma webserver is enabled by deprecated config' do + before do + merged_manifest_properties['cc']['experimental']['use_puma_webserver'] = true + end + + it 'renders the valkey socket into the ccng config' do template_hash = YAML.safe_load(template.render(merged_manifest_properties, consumes: links)) expect(template_hash['redis']['socket']).to eq('/var/vcap/data/valkey/valkey.sock') end + + context 'when `cc.temporary_enable_deprecated_thin_webserver` is also enabled' do + before do + merged_manifest_properties['cc']['temporary_enable_deprecated_thin_webserver'] = true + end + + it 'still uses Puma and renders the valkey socket into the ccng config' do + template_hash = YAML.safe_load(template.render(merged_manifest_properties, consumes: links)) + expect(template_hash['redis']['socket']).to eq('/var/vcap/data/valkey/valkey.sock') + end + end + end + + context 'when thin webserver is explicitly enabled' do + before do + merged_manifest_properties['cc']['temporary_enable_deprecated_thin_webserver'] = true + end + + it 'does not render the valkey socket into the ccng config' do + template_hash = YAML.safe_load(template.render(merged_manifest_properties, consumes: links)) + expect(template_hash).not_to have_key('redis') + end + + context "when 'cc.experimental.use_redis' is set to 'true'" do + before do + merged_manifest_properties['cc']['experimental']['use_redis'] = true + end + + it 'renders the valkey socket into the ccng config' do + template_hash = YAML.safe_load(template.render(merged_manifest_properties, consumes: links)) + expect(template_hash['redis']['socket']).to eq('/var/vcap/data/valkey/valkey.sock') + end + end end - context "when neither the puma webserver is used nor 'cc.experimental.use_redis' is set to 'true'" do - it 'does not render the redis socket into the ccng config' do + context 'when thin webserver is implicitly enabled through `cc.experimental.use_puma_webserver` => false' do + before do + merged_manifest_properties['cc']['experimental']['use_puma_webserver'] = false + end + + it 'does not render the valkey socket into the ccng config' do + merged_manifest_properties['cc']['experimental']['use_puma_webserver'] = false template_hash = YAML.safe_load(template.render(merged_manifest_properties, consumes: links)) expect(template_hash).not_to have_key('redis') end + + context "when 'cc.experimental.use_redis' is set to 'true'" do + before do + merged_manifest_properties['cc']['experimental']['use_redis'] = true + end + + it 'renders the valkey socket into the ccng config' do + template_hash = YAML.safe_load(template.render(merged_manifest_properties, consumes: links)) + expect(template_hash['redis']['socket']).to eq('/var/vcap/data/valkey/valkey.sock') + end + end end end diff --git a/spec/valkey/monit_spec.rb b/spec/valkey/monit_spec.rb index fbcbe19ac8..7959dab113 100644 --- a/spec/valkey/monit_spec.rb +++ b/spec/valkey/monit_spec.rb @@ -12,33 +12,83 @@ module Test let(:job) { release.job('valkey') } let(:spec) { job.instance_variable_get(:@spec) } let(:job_path) { job.instance_variable_get(:@job_path) } - let(:cc_internal_properties) { { 'cc' => { 'experimental' => { 'use_puma_webserver' => false, 'use_redis' => false } } } } + let(:cc_internal_properties) { { 'cc' => { 'temporary_enable_deprecated_thin_webserver' => false, 'experimental' => { 'use_redis' => false } } } } let(:link) { Link.new(name: 'cloud_controller_internal', properties: cc_internal_properties) } describe 'monit' do let(:template) { Template.new(spec, File.join(job_path, 'monit')) } - context 'when the puma webserver is used' do + context 'when the puma webserver is used by default' do it 'renders the monit directives' do - cc_internal_properties['cc']['experimental']['use_puma_webserver'] = true result = template.render({}, consumes: [link]) expect(result).to include('check process valkey') end end - context "when 'cc.experimental.use_redis' is set to 'true'" do + context 'when the puma webserver is enabled by deprecated config' do + before do + cc_internal_properties['cc']['experimental']['use_puma_webserver'] = true + end + it 'renders the monit directives' do - cc_internal_properties['cc']['experimental']['use_redis'] = true result = template.render({}, consumes: [link]) expect(result).to include('check process valkey') end + + context 'when `cc.temporary_enable_deprecated_thin_webserver` is also enabled' do + before do + cc_internal_properties['cc']['temporary_enable_deprecated_thin_webserver'] = true + end + + it 'renders the monit directives' do + result = template.render({}, consumes: [link]) + expect(result).to include('check process valkey') + end + end end - context "when neither the puma webserver is used nor 'cc.experimental.use_redis' is set to 'true'" do + context 'when the puma webserver is disabled by deprecated config' do + before do + cc_internal_properties['cc']['experimental']['use_puma_webserver'] = false + end + it 'does not render the monit directives' do result = template.render({}, consumes: [link]) expect(result.strip).to eq('') end + + context "when 'cc.experimental.use_redis' is set to 'true'" do + before do + cc_internal_properties['cc']['experimental']['use_redis'] = true + end + + it 'renders the monit directives' do + result = template.render({}, consumes: [link]) + expect(result).to include('check process valkey') + end + end + end + + context 'when `cc.temporary_enable_deprecated_thin_webserver` is enabled' do + before do + cc_internal_properties['cc']['temporary_enable_deprecated_thin_webserver'] = true + end + + it 'does not render the monit directives' do + result = template.render({}, consumes: [link]) + expect(result.strip).to eq('') + end + + context "when 'cc.experimental.use_redis' is set to 'true'" do + before do + cc_internal_properties['cc']['experimental']['use_redis'] = true + end + + it 'renders the monit directives' do + result = template.render({}, consumes: [link]) + expect(result).to include('check process valkey') + end + end end end end