From 63e3ad916bff04639b7824178fc8345fda37c5a7 Mon Sep 17 00:00:00 2001 From: Filippe Spolti Date: Wed, 16 Oct 2019 13:51:10 -0300 Subject: [PATCH 1/2] [CLOUD-2903] - Unable to define datasource properties Signed-off-by: Filippe Spolti --- .../added/launch/datasource-common.sh | 20 ++++++++++++++++++- .../test/datasource/configure.bats | 5 +++++ .../expectations/prefix_ibmdb2_xa.xml | 4 ++++ .../expectations/prefix_oracle_xa.xml | 4 ++++ 4 files changed, 32 insertions(+), 1 deletion(-) diff --git a/jboss/container/wildfly/launch/datasources/added/launch/datasource-common.sh b/jboss/container/wildfly/launch/datasources/added/launch/datasource-common.sh index e97358d4..427cf91e 100644 --- a/jboss/container/wildfly/launch/datasources/added/launch/datasource-common.sh +++ b/jboss/container/wildfly/launch/datasources/added/launch/datasource-common.sh @@ -40,6 +40,8 @@ function clearDatasourceEnv() { unset ${prefix}_TX_ISOLATION unset ${prefix}_MIN_POOL_SIZE unset ${prefix}_MAX_POOL_SIZE + unset ${prefix}_IS_SAME_RM_OVERRIDE + unset ${prefix}_NO_TX_SEPARATE_POOLS unset ${prefix}_JTA unset ${prefix}_NONXA unset ${prefix}_DRIVER @@ -405,7 +407,7 @@ function generate_external_datasource_xml() { $tx_isolation" fi - if [ -n "$min_pool_size" ] || [ -n "$max_pool_size" ]; then + if [ -n "$min_pool_size" ] || [ -n "$max_pool_size" ] || [ -n "$is_same_rm_override" ] || [ -n "$no_tx_separate_pools" ]; then if [ -n "$NON_XA_DATASOURCE" ] && [ "$NON_XA_DATASOURCE" = "true" ]; then ds="$ds " @@ -422,6 +424,16 @@ function generate_external_datasource_xml() { ds="$ds $max_pool_size" fi + # CLOUD-2903: For Oracle XA Datasources, this configuration is required + if [ -n "$is_same_rm_override" ]; then + ds="$ds + $is_same_rm_override" + fi + # RHPAM-2261 + if [ -n "$no_tx_separate_pools" ]; then + ds="$ds + " + fi if [ -n "$NON_XA_DATASOURCE" ] && [ "$NON_XA_DATASOURCE" = "true" ]; then ds="$ds " @@ -891,6 +903,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]_IS_SAME_RM_OVERRIDE + is_same_rm_override=$(find_env "${prefix}_IS_SAME_RM_OVERRIDE") + + # no_tx_separate_pools environment variable name format: [PREFIX]_NO_TX_SEPARATE_POOLS + no_tx_separate_pools=$(find_env "${prefix}_NO_TX_SEPARATE_POOLS") + # jta environment variable name format: [NAME]_[DATABASE_TYPE]_JTA jta=$(find_env "${prefix}_JTA" true) diff --git a/jboss/container/wildfly/launch/datasources/test/datasource/configure.bats b/jboss/container/wildfly/launch/datasources/test/datasource/configure.bats index 85a21c84..f40e668d 100644 --- a/jboss/container/wildfly/launch/datasources/test/datasource/configure.bats +++ b/jboss/container/wildfly/launch/datasources/test/datasource/configure.bats @@ -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_IS_SAME_RM_OVERRIDE=false + TEST_NO_TX_SEPARATE_POOLS=true run inject_datasources @@ -302,6 +304,9 @@ load common TEST_XA_CONNECTION_PROPERTY_PortNumber="50000" TEST_XA_CONNECTION_PROPERTY_DatabaseName="ibmdb2db" + TEST_IS_SAME_RM_OVERRIDE=false + TEST_NO_TX_SEPARATE_POOLS=true + run inject_datasources [ "$status" -eq 0 ] diff --git a/jboss/container/wildfly/launch/datasources/test/datasource/expectations/prefix_ibmdb2_xa.xml b/jboss/container/wildfly/launch/datasources/test/datasource/expectations/prefix_ibmdb2_xa.xml index 72060ecc..2ad0c0bd 100644 --- a/jboss/container/wildfly/launch/datasources/test/datasource/expectations/prefix_ibmdb2_xa.xml +++ b/jboss/container/wildfly/launch/datasources/test/datasource/expectations/prefix_ibmdb2_xa.xml @@ -9,6 +9,10 @@ kermit thefrog + + false" + + diff --git a/jboss/container/wildfly/launch/datasources/test/datasource/expectations/prefix_oracle_xa.xml b/jboss/container/wildfly/launch/datasources/test/datasource/expectations/prefix_oracle_xa.xml index 037069f6..c9774cda 100644 --- a/jboss/container/wildfly/launch/datasources/test/datasource/expectations/prefix_oracle_xa.xml +++ b/jboss/container/wildfly/launch/datasources/test/datasource/expectations/prefix_oracle_xa.xml @@ -13,6 +13,10 @@ + + false" + + From 177a7e46fbc895531acb3e14babb7bbbea327cc0 Mon Sep 17 00:00:00 2001 From: Ken Wills Date: Mon, 13 Jul 2020 17:52:59 -0500 Subject: [PATCH 2/2] CLOUD-2903 - Update vars to match management model --- .../added/launch/datasource-common.sh | 28 ++++++++++++------- .../wildfly/launch/datasources/module.yaml | 4 +++ .../test/datasource/configure.bats | 8 +++--- .../expectations/prefix_ibmdb2_xa.xml | 8 +++--- .../expectations/prefix_oracle_xa.xml | 8 +++--- test-common/xml_utils.bash | 2 +- 6 files changed, 35 insertions(+), 23 deletions(-) diff --git a/jboss/container/wildfly/launch/datasources/added/launch/datasource-common.sh b/jboss/container/wildfly/launch/datasources/added/launch/datasource-common.sh index 427cf91e..9bc36b8e 100644 --- a/jboss/container/wildfly/launch/datasources/added/launch/datasource-common.sh +++ b/jboss/container/wildfly/launch/datasources/added/launch/datasource-common.sh @@ -40,8 +40,8 @@ function clearDatasourceEnv() { unset ${prefix}_TX_ISOLATION unset ${prefix}_MIN_POOL_SIZE unset ${prefix}_MAX_POOL_SIZE - unset ${prefix}_IS_SAME_RM_OVERRIDE - unset ${prefix}_NO_TX_SEPARATE_POOLS + unset ${prefix}_SAME_RM_OVERRIDE + unset ${prefix}_NO_TX_SEPARATE_POOL unset ${prefix}_JTA unset ${prefix}_NONXA unset ${prefix}_DRIVER @@ -407,7 +407,7 @@ function generate_external_datasource_xml() { $tx_isolation" fi - if [ -n "$min_pool_size" ] || [ -n "$max_pool_size" ] || [ -n "$is_same_rm_override" ] || [ -n "$no_tx_separate_pools" ]; 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 " @@ -425,12 +425,12 @@ function generate_external_datasource_xml() { $max_pool_size" fi # CLOUD-2903: For Oracle XA Datasources, this configuration is required - if [ -n "$is_same_rm_override" ]; then + if [ -n "$same_rm_override" ]; then ds="$ds - $is_same_rm_override" + $same_rm_override" fi # RHPAM-2261 - if [ -n "$no_tx_separate_pools" ]; then + if [ -n "$no_tx_separate_pool" ]; then ds="$ds " fi @@ -539,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}" @@ -903,11 +911,11 @@ 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]_IS_SAME_RM_OVERRIDE - is_same_rm_override=$(find_env "${prefix}_IS_SAME_RM_OVERRIDE") + # is same rm override environment variable name format: [PREFIX]_SAME_RM_OVERRIDE + same_rm_override=$(find_env "${prefix}_SAME_RM_OVERRIDE") - # no_tx_separate_pools environment variable name format: [PREFIX]_NO_TX_SEPARATE_POOLS - no_tx_separate_pools=$(find_env "${prefix}_NO_TX_SEPARATE_POOLS") + # 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) diff --git a/jboss/container/wildfly/launch/datasources/module.yaml b/jboss/container/wildfly/launch/datasources/module.yaml index 6134f2d3..643a0c01 100644 --- a/jboss/container/wildfly/launch/datasources/module.yaml +++ b/jboss/container/wildfly/launch/datasources/module.yaml @@ -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" diff --git a/jboss/container/wildfly/launch/datasources/test/datasource/configure.bats b/jboss/container/wildfly/launch/datasources/test/datasource/configure.bats index f40e668d..adde17f8 100644 --- a/jboss/container/wildfly/launch/datasources/test/datasource/configure.bats +++ b/jboss/container/wildfly/launch/datasources/test/datasource/configure.bats @@ -267,8 +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_IS_SAME_RM_OVERRIDE=false - TEST_NO_TX_SEPARATE_POOLS=true + TEST_SAME_RM_OVERRIDE=false + TEST_NO_TX_SEPARATE_POOL=true run inject_datasources @@ -304,8 +304,8 @@ load common TEST_XA_CONNECTION_PROPERTY_PortNumber="50000" TEST_XA_CONNECTION_PROPERTY_DatabaseName="ibmdb2db" - TEST_IS_SAME_RM_OVERRIDE=false - TEST_NO_TX_SEPARATE_POOLS=true + TEST_SAME_RM_OVERRIDE=false + TEST_NO_TX_SEPARATE_POOL=true run inject_datasources diff --git a/jboss/container/wildfly/launch/datasources/test/datasource/expectations/prefix_ibmdb2_xa.xml b/jboss/container/wildfly/launch/datasources/test/datasource/expectations/prefix_ibmdb2_xa.xml index 2ad0c0bd..52d51630 100644 --- a/jboss/container/wildfly/launch/datasources/test/datasource/expectations/prefix_ibmdb2_xa.xml +++ b/jboss/container/wildfly/launch/datasources/test/datasource/expectations/prefix_ibmdb2_xa.xml @@ -5,14 +5,14 @@ 50000 localhost ibmdb2 + + false + + kermit thefrog - - false" - - diff --git a/jboss/container/wildfly/launch/datasources/test/datasource/expectations/prefix_oracle_xa.xml b/jboss/container/wildfly/launch/datasources/test/datasource/expectations/prefix_oracle_xa.xml index c9774cda..4cbfb71f 100644 --- a/jboss/container/wildfly/launch/datasources/test/datasource/expectations/prefix_oracle_xa.xml +++ b/jboss/container/wildfly/launch/datasources/test/datasource/expectations/prefix_oracle_xa.xml @@ -3,6 +3,10 @@ jdbc:oracle:thin:@oracleHostName:1521:orcl oracle + + false + + kermit thefrog @@ -13,10 +17,6 @@ - - false" - - diff --git a/test-common/xml_utils.bash b/test-common/xml_utils.bash index 62ab9ab1..3230fee1 100644 --- a/test-common/xml_utils.bash +++ b/test-common/xml_utils.bash @@ -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() {