Merged in CLIP-1510-update-db-pool-variable (pull request #119)

CLIP-1510: Update the the c3p0 database properties to hikari

Approved-by: Steve Smith
Approved-by: Nasser Ghazali-Beiklar
Approved-by: Dylan Rathbone
This commit is contained in:
Adam Brokes 2022-08-02 01:01:31 +00:00
commit 0fd4e715b1
2 changed files with 94 additions and 7 deletions

View File

@ -10,7 +10,6 @@
<property name="confluence.database.connection.type">database-type-standard</property>
<property name="webwork.multipart.saveDir">${localHome}/temp</property>
<property name="attachments.dir">${confluenceHome}/attachments</property>
<property name="lucene.index.dir">{{ atl_lucene_index_dir | default('${confluenceHome}/index') }}</property>
{# We need mappings for "oracle12c" and "oracle" to remain backwards compatible with Confluence 7.3.0 and earlier. Oracle 19c support was added in Confluence 7.3.1 and changed the database type name for oracle databases from "oracle12c" to "oracle" #}
@ -30,14 +29,23 @@
<property name="hibernate.connection.driver_class">{{ databases[atl_db_type][0] }}</property>
<property name="hibernate.dialect">com.atlassian.confluence.impl.hibernate.dialect.{{ databases[atl_db_type][1] }}</property>
{# Confluence versions 7.13 and newer #}
{% if (confluence_version.split(".")[0] | int() == 7 and confluence_version.split(".")[1] | int() <= 13) or confluence_version.split(".")[0] | int() < 7 %}
<property name="hibernate.c3p0.min_size">{{ atl_db_poolminsize | default('20') }}</property>
<property name="hibernate.c3p0.max_size">{{ atl_db_poolmaxsize | default('100') }}</property>
<property name="hibernate.c3p0.timeout">{{ atl_db_timeout | default('30') }}</property>
<property name="hibernate.c3p0.idle_test_period">{{ atl_db_idletestperiod | default('100') }}</property>
<property name="hibernate.c3p0.max_statements">{{ atl_db_maxstatements | default('0') }}</property>
<property name="hibernate.c3p0.validate">{{ atl_db_validate | default('false') }}</property>
<property name="hibernate.c3p0.validate">{{ atl_db_validate | default('true') }}</property>
<property name="hibernate.c3p0.acquire_increment">{{ atl_db_acquireincrement | default('1') }}</property>
<property name="hibernate.c3p0.preferredTestQuery">{{ atl_db_validationquery | default('select 1') }}</property>
{% else %}
<property name="hibernate.hikari.idleTimeout">{{ (atl_db_timeout | default(30) | int) * 1000 }}</property>
<property name="hibernate.hikari.maximumPoolSize">{{ atl_db_poolmaxsize | default('100') }}</property>
<property name="hibernate.hikari.minimumIdle">{{ atl_db_poolminsize | default('20') }}</property>
<property name="hibernate.hikari.registerMbeans">true</property>
{% endif %}
{% endif %}
{% if atl_cluster_type is defined %}

View File

@ -242,7 +242,7 @@ def test_conf_init_set(docker_cli, image):
assert init.contains("confluence.home = /tmp/")
def test_confluence_xml_default(docker_cli, image):
def test_confluence_xml_default_c3p0(docker_cli, image):
container = run_image(docker_cli, image)
_jvm = wait_for_proc(container, get_bootstrap_proc(container))
@ -260,13 +260,59 @@ def test_confluence_lucene_index(docker_cli, image):
xml = parse_xml(container, f'{get_app_home(container)}/confluence.cfg.xml')
assert xml.findall('.//property[@name="lucene.index.dir"]')[0].text == '/some/other/dir'
def test_confluence_xml_postgres(docker_cli, image, run_user):
environment = {
'ATL_DB_TYPE': 'postgresql',
'ATL_JDBC_URL': 'atl_jdbc_url',
'ATL_JDBC_USER': 'atl_jdbc_user',
'ATL_JDBC_PASSWORD': 'atl_jdbc_password'
'ATL_JDBC_PASSWORD': 'atl_jdbc_password',
}
container = run_image(docker_cli, image, user=run_user, environment=environment)
_jvm = wait_for_proc(container, get_bootstrap_proc(container))
xml = parse_xml(container, f'{get_app_home(container)}/confluence.cfg.xml')
assert xml.findall('.//property[@name="hibernate.connection.url"]')[0].text == "atl_jdbc_url"
assert xml.findall('.//property[@name="hibernate.connection.username"]')[0].text == "atl_jdbc_user"
assert xml.findall('.//property[@name="hibernate.connection.password"]')[0].text == "atl_jdbc_password"
assert xml.findall('.//property[@name="confluence.database.choice"]')[0].text == "postgresql"
assert xml.findall('.//property[@name="hibernate.dialect"]')[0].text == "com.atlassian.confluence.impl.hibernate.dialect.PostgreSQLDialect"
assert xml.findall('.//property[@name="hibernate.connection.driver_class"]')[0].text == "org.postgresql.Driver"
assert xml.findall('.//property[@name="hibernate.hikari.idleTimeout"]')[0].text == "30000"
assert xml.findall('.//property[@name="hibernate.hikari.maximumPoolSize"]')[0].text == "100"
assert xml.findall('.//property[@name="hibernate.hikari.minimumIdle"]')[0].text == "20"
assert xml.findall('.//property[@name="hibernate.hikari.registerMbeans"]')[0].text == "true"
def test_confluence_xml_postgres_all_set(docker_cli, image, run_user):
environment = {
'ATL_DB_TYPE': 'postgresql',
'ATL_JDBC_URL': 'atl_jdbc_url',
'ATL_JDBC_USER': 'atl_jdbc_user',
'ATL_JDBC_PASSWORD': 'atl_jdbc_password',
'ATL_DB_POOLMAXSIZE': 'x100',
'ATL_DB_POOLMINSIZE': 'x20',
'ATL_DB_TIMEOUT': '40',
}
container = run_image(docker_cli, image, user=run_user, environment=environment)
_jvm = wait_for_proc(container, get_bootstrap_proc(container))
xml = parse_xml(container, f'{get_app_home(container)}/confluence.cfg.xml')
assert xml.findall('.//property[@name="hibernate.connection.driver_class"]')[0].text == "org.postgresql.Driver"
assert xml.findall('.//property[@name="hibernate.dialect"]')[0].text == "com.atlassian.confluence.impl.hibernate.dialect.PostgreSQLDialect"
assert xml.findall('.//property[@name="hibernate.hikari.idleTimeout"]')[0].text == "40000"
assert xml.findall('.//property[@name="hibernate.hikari.maximumPoolSize"]')[0].text == "x100"
assert xml.findall('.//property[@name="hibernate.hikari.minimumIdle"]')[0].text == "x20"
def test_confluence_xml_postgres_c3p0(docker_cli, image, run_user):
environment = {
'CONFLUENCE_VERSION': '7.10.0',
'ATL_DB_TYPE': 'postgresql',
'ATL_JDBC_URL': 'atl_jdbc_url',
'ATL_JDBC_USER': 'atl_jdbc_user',
'ATL_JDBC_PASSWORD': 'atl_jdbc_password',
}
container = run_image(docker_cli, image, user=run_user, environment=environment)
_jvm = wait_for_proc(container, get_bootstrap_proc(container))
@ -284,13 +330,14 @@ def test_confluence_xml_postgres(docker_cli, image, run_user):
assert xml.findall('.//property[@name="hibernate.c3p0.timeout"]')[0].text == "30"
assert xml.findall('.//property[@name="hibernate.c3p0.idle_test_period"]')[0].text == "100"
assert xml.findall('.//property[@name="hibernate.c3p0.max_statements"]')[0].text == "0"
assert xml.findall('.//property[@name="hibernate.c3p0.validate"]')[0].text == "false"
assert xml.findall('.//property[@name="hibernate.c3p0.validate"]')[0].text == "true"
assert xml.findall('.//property[@name="hibernate.c3p0.acquire_increment"]')[0].text == "1"
assert xml.findall('.//property[@name="hibernate.c3p0.preferredTestQuery"]')[0].text == "select 1"
def test_confluence_xml_postgres_all_set(docker_cli, image, run_user):
def test_confluence_xml_postgres_all_set_c3p0(docker_cli, image, run_user):
environment = {
'CONFLUENCE_VERSION': '7.10.0',
'ATL_DB_TYPE': 'postgresql',
'ATL_JDBC_URL': 'atl_jdbc_url',
'ATL_JDBC_USER': 'atl_jdbc_user',
@ -496,3 +543,35 @@ def test_confluence_xml_force_overwrite(docker_cli, image, run_user):
xml = parse_xml(tihost, cfg)
assert xml.findall('.//property[@name="confluence.webapp.context.path"]')[0].text == "/myconf"
expected_db_properties = {
'hikari': {
'hibernate.hikari.idleTimeout': '30000',
'hibernate.hikari.registerMbeans': 'true',
'hibernate.hikari.maximumPoolSize': '100',
'hibernate.hikari.minimumIdle': '20',
},
'c3p0': {
'hibernate.c3p0.min_size': '20',
'hibernate.c3p0.max_size': '100',
'hibernate.c3p0.timeout': '30',
}
}
@pytest.mark.parametrize("version,db_property", [('7.13.7', 'c3p0'), ('7.17.7', 'hikari'), ('6.9.0', 'c3p0'), ('8.0.0', 'hikari')])
def test_confluence_db_pool_property(docker_cli, image, version, db_property):
environment = {
'CONFLUENCE_VERSION': version,
'ATL_JDBC_URL': 'postgresql:hostname',
'ATL_DB_TYPE': 'postgresql'
}
container = run_image(docker_cli, image, environment=environment)
xml = parse_xml(container, f'{get_app_home(container)}/confluence.cfg.xml')
expected = expected_db_properties[db_property]
for property, expected_value in expected.items():
assert xml.findall(f'.//property[@name="{property}"]')[0].text == expected_value