Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CLOUD-2903] - Unable to define datasource properties #190

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ function clearDatasourceEnv() {
unset ${prefix}_TX_ISOLATION
unset ${prefix}_MIN_POOL_SIZE
unset ${prefix}_MAX_POOL_SIZE
unset ${prefix}_SAME_RM_OVERRIDE
unset ${prefix}_NO_TX_SEPARATE_POOL
unset ${prefix}_JTA
unset ${prefix}_NONXA
unset ${prefix}_DRIVER
Expand Down Expand Up @@ -405,7 +407,7 @@ function generate_external_datasource_xml() {
<transaction-isolation>$tx_isolation</transaction-isolation>"
fi

if [ -n "$min_pool_size" ] || [ -n "$max_pool_size" ]; then
if [ -n "$min_pool_size" ] || [ -n "$max_pool_size" ] || [ -n "$same_rm_override" ] || [ -n "$no_tx_separate_pool" ]; then
if [ -n "$NON_XA_DATASOURCE" ] && [ "$NON_XA_DATASOURCE" = "true" ]; then
ds="$ds
<pool>"
Expand All @@ -422,6 +424,16 @@ function generate_external_datasource_xml() {
ds="$ds
<max-pool-size>$max_pool_size</max-pool-size>"
fi
# CLOUD-2903: For Oracle XA Datasources, this configuration is required
if [ -n "$same_rm_override" ]; then
ds="$ds
<is-same-rm-override>$same_rm_override</is-same-rm-override>"
fi
# RHPAM-2261
if [ -n "$no_tx_separate_pool" ]; then
ds="$ds
<no-tx-separate-pools />"
fi
if [ -n "$NON_XA_DATASOURCE" ] && [ "$NON_XA_DATASOURCE" = "true" ]; then
ds="$ds
</pool>"
Expand Down Expand Up @@ -527,6 +539,14 @@ function generate_external_datasource_cli() {
ds_tmp_key_values["max-pool-size"]=$max_pool_size
fi

if [ -n "${same_rm_override}"]; then
ds_tmp_key_values["same_rm_override"]=${same_rm_override}
fi

if [ -n "${no_tx_seperate_pool}" ]; then
ds_tmp_key_values["no-tx-separate-pool"]=${no_tx_seperate_pool}
fi

ds_tmp_key_values["user-name"]="${username}"
ds_tmp_key_values["password"]="${password}"

Expand Down Expand Up @@ -891,6 +911,12 @@ function inject_datasource() {
# max pool size environment variable name format: [NAME]_[DATABASE_TYPE]_MAX_POOL_SIZE
max_pool_size=$(find_env "${prefix}_MAX_POOL_SIZE")

# is same rm override environment variable name format: [PREFIX]_SAME_RM_OVERRIDE
same_rm_override=$(find_env "${prefix}_SAME_RM_OVERRIDE")

# no_tx_separate_pool environment variable name format: [PREFIX]_NO_TX_SEPARATE_POOL
no_tx_separate_pool=$(find_env "${prefix}_NO_TX_SEPARATE_POOL")

# jta environment variable name format: [NAME]_[DATABASE_TYPE]_JTA
jta=$(find_env "${prefix}_JTA" true)

Expand Down
4 changes: 4 additions & 0 deletions jboss/container/wildfly/launch/datasources/module.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,13 @@ envs:
- name: "{PREFIX}_NONXA"
description: "Defines the datasource as a non-XA datasource. Defaults to false."
example: "true"
- name: "{PREFIX}_NO_TX_SEPARATE_POOL"
description: "Whether to create separate sub-pools for each context. This is required for Oracle datasources, which do not allow XA connections to be used both inside and outside of a JTA transaction."
- name: "{PREFIX}_PASSWORD"
description: "Defines the password for the datasource."
example: "password"
- name: "{PREFIX}_SAME_RM_OVERRIDE"
description: "Whether the javax.transaction.xa.XAResource.isSameRM(XAResource) class returns true or false."
- name: "{PREFIX}_TX_ISOLATION"
description: "Defines the java.sql.Connection transaction isolation level for the datasource."
example: "TRANSACTION_READ_UNCOMMITTED"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,8 @@ load common
TEST_CONNECTION_CHECKER="org.jboss.jca.adapters.jdbc.extensions.oracle.OracleValidConnectionChecker"
TEST_EXCEPTION_SORTER="org.jboss.jca.adapters.jdbc.extensions.oracle.OracleExceptionSorter"
TEST_BACKGROUND_VALIDATION="false"
TEST_SAME_RM_OVERRIDE=false
TEST_NO_TX_SEPARATE_POOL=true

run inject_datasources

Expand Down Expand Up @@ -302,6 +304,9 @@ load common
TEST_XA_CONNECTION_PROPERTY_PortNumber="50000"
TEST_XA_CONNECTION_PROPERTY_DatabaseName="ibmdb2db"

TEST_SAME_RM_OVERRIDE=false
TEST_NO_TX_SEPARATE_POOL=true

run inject_datasources

[ "$status" -eq 0 ]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@
<xa-datasource-property name="PortNumber">50000</xa-datasource-property>
<xa-datasource-property name="ServerName">localhost</xa-datasource-property>
<driver>ibmdb2</driver>
<xa-pool>
<is-same-rm-override>false</is-same-rm-override>
<no-tx-separate-pools/>
</xa-pool>
<security>
<user-name>kermit</user-name>
<password>thefrog</password>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
<xa-datasource jndi-name="java:/jboss/datasources/testds" pool-name="test_oracle-TEST" enabled="true" use-java-context="true" statistics-enabled="${wildfly.datasources.statistics-enabled:${wildfly.statistics-enabled:false}}">
<xa-datasource-property name="URL">jdbc:oracle:thin:@oracleHostName:1521:orcl</xa-datasource-property>
<driver>oracle</driver>
<xa-pool>
<is-same-rm-override>false</is-same-rm-override>
<no-tx-separate-pools/>
</xa-pool>
<security>
<user-name>kermit</user-name>
<password>thefrog</password>
Expand Down
2 changes: 1 addition & 1 deletion test-common/xml_utils.bash
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ function assert_xml() {
local xpath=$2
local expected=$3
local xml=$(xmllint --xpath "$xpath" $file)
diff <(echo $xml | xmllint --format -) <(xmllint --format $expected)
diff -ur <(echo $xml | xmllint --format -) <(xmllint --format $expected)
}

function assert_xml_value() {
Expand Down