Skip to content

Commit

Permalink
Merge pull request #373 from sap-contributions/override-max-conn-rota…
Browse files Browse the repository at this point in the history
…te-cc-database-key-errand

Add config attribute to override max_con for rotate-cc-database-key errand
  • Loading branch information
philippthun authored Jan 22, 2024
2 parents 1d734e1 + 89d51ee commit 83e9fcf
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 1 deletion.
2 changes: 2 additions & 0 deletions jobs/rotate_cc_database_key/spec
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,5 @@ properties:
cc.stdout_logging_enabled:
default: true
description: "Enable logging to stdout"
ccdb.max_connections:
description: "If provided, overrides ccdb.max_connections from cloud_controller_db link"
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ db: &db
user: <%= db_role["name"] %>
password: <%= yaml_escape(db_role["password"]) %>
database: <%= db["name"] %>
max_connections: <%= link("cloud_controller_db").p("ccdb.max_connections") %>
max_connections: <%= p("ccdb.max_connections", link("cloud_controller_db").p("ccdb.max_connections")) %>
pool_timeout: <%= link("cloud_controller_db").p("ccdb.pool_timeout") %>
log_level: "<%= p("cc.db_logging_level", link("cloud_controller_internal").p("cc.db_logging_level")) %>"
log_db_queries: <%= p("cc.log_db_queries", link("cloud_controller_internal").p("cc.log_db_queries")) %>
Expand Down
21 changes: 21 additions & 0 deletions spec/rotate_cc_database_key/rotate_cc_database_key_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ module Test
{
'cc' => {
'db_logging_level' => 100
},
'ccdb' => {
'max_connections' => 100
}
}
end
Expand Down Expand Up @@ -181,6 +184,24 @@ module Test
end
end
end

describe 'max_connections from cloud_controller_db' do
it 'overrides max_connections when value is set' do
template_hash = YAML.safe_load(template.render(manifest_properties, consumes: links))
expect(template_hash['db']['max_connections']).to eq(100)
end

context 'when max_connections is not overriden' do
before do
manifest_properties['ccdb'].delete('max_connections')
end

it 'sets the default value' do
template_hash = YAML.safe_load(template.render(manifest_properties, consumes: links))
expect(template_hash['db']['max_connections']).to eq('foo2')
end
end
end
end
end
end
Expand Down

0 comments on commit 83e9fcf

Please sign in to comment.