This is an automated email from the ASF dual-hosted git repository.
terrymanu pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shardingsphere.git
The following commit(s) were added to refs/heads/master by this push:
new 1fe05cfe09b align JDBC and Proxy SQL E2E coverage (#40215)
1fe05cfe09b is described below
commit 1fe05cfe09b8407e8e056c42ad3198cabcc6cd08
Author: Liang Zhang <[email protected]>
AuthorDate: Sun Oct 18 14:27:20 2026 +0800
align JDBC and Proxy SQL E2E coverage (#40215)
* align JDBC and Proxy SQL E2E coverage
* Fix SQL E2E mode isolation and RAL assertions
* Close JDBC Cluster data sources in SQL E2E environments
---
.../scripts/e2e-sql/generate-e2e-sql-matrix.sh | 16 +++--
.../e2e-sql/test-generate-e2e-sql-matrix.sh | 72 ++++++++++++++++++----
.../impl/ShardingSphereJdbcEmbeddedContainer.java | 59 +++++++++++++++---
.../compose/ContainerComposerRegistry.java | 14 ++---
.../JdbcStandaloneTestParameterGenerator.java | 14 ++---
.../framework/param/model/E2ETestParameter.java | 2 +-
.../shardingsphere/test/e2e/sql/it/SQLE2EIT.java | 34 +++++++++-
.../test/e2e/sql/it/distsql/ral/RALE2EIT.java | 4 +-
.../cluster/show_compute_node_info_jdbc.xml | 29 +++++++++
.../cluster/show_compute_nodes_jdbc.xml | 31 ++++++++++
10 files changed, 223 insertions(+), 52 deletions(-)
diff --git
a/.github/workflows/resources/scripts/e2e-sql/generate-e2e-sql-matrix.sh
b/.github/workflows/resources/scripts/e2e-sql/generate-e2e-sql-matrix.sh
index 1e82658c702..762e31962c8 100755
--- a/.github/workflows/resources/scripts/e2e-sql/generate-e2e-sql-matrix.sh
+++ b/.github/workflows/resources/scripts/e2e-sql/generate-e2e-sql-matrix.sh
@@ -59,7 +59,7 @@ ALL_MODES='["Standalone","Cluster"]'
ALL_DATABASES='["MySQL","PostgreSQL"]'
SMOKE_SCENARIOS='["db","tbl"]'
-# Build matrix JSON from dimension arrays and scenarios, applying
exclude/include rules
+# Build matrix JSON from dimension arrays and scenarios, applying include rules
build_matrix() {
local adapters="$1"
local modes="$2"
@@ -74,18 +74,11 @@ build_matrix() {
--argjson scenarios "$scenarios" \
--argjson include_extra_job "$include_extra_job" \
'
- def should_exclude(adapter; mode; scenario):
- (adapter == "jdbc" and scenario == "passthrough") or
- (adapter == "jdbc" and mode == "Cluster") or
- (adapter == "proxy" and mode == "Standalone" and
- (scenario == "empty_rules" or scenario == "distsql_rdl" or scenario ==
"passthrough"));
-
[
$adapters[] as $adapter |
$modes[] as $mode |
$databases[] as $database |
$scenarios[] as $scenario |
- select(should_exclude($adapter; $mode; $scenario) | not) |
{adapter: $adapter, mode: $mode, database: $database, scenario:
$scenario, "additional-options": ""}
] as $base_jobs |
@@ -103,7 +96,12 @@ build_matrix() {
else []
end) as $distsql_bootstrap_job |
- {include: ($base_jobs + $extra_job + $distsql_bootstrap_job)}
+ (if $include_extra_job and ($modes | index("Cluster")) != null and
($scenarios | index("encrypt")) != null
+ then [$adapters[] | {adapter: ., mode: "Cluster", database: "openGauss",
scenario: "encrypt", "additional-options": ""}]
+ else []
+ end) as $opengauss_encrypt_jobs |
+
+ {include: ($base_jobs + $extra_job + $distsql_bootstrap_job +
$opengauss_encrypt_jobs)}
'
}
diff --git
a/.github/workflows/resources/scripts/e2e-sql/test-generate-e2e-sql-matrix.sh
b/.github/workflows/resources/scripts/e2e-sql/test-generate-e2e-sql-matrix.sh
index c0fe02a4f44..25a4eaff9c8 100644
---
a/.github/workflows/resources/scripts/e2e-sql/test-generate-e2e-sql-matrix.sh
+++
b/.github/workflows/resources/scripts/e2e-sql/test-generate-e2e-sql-matrix.sh
@@ -104,18 +104,36 @@ assert_scenarios() {
assert_eq "$desc" "$expected" "$actual"
}
-assert_no_excludes() {
+assert_opengauss_scope() {
local desc="$1" matrix_json="$2"
local count
count=$(echo "$matrix_json" | jq '[.include[] | select(
- (.adapter == "jdbc" and .scenario == "passthrough") or
- (.adapter == "jdbc" and .mode == "Cluster") or
- (.adapter == "proxy" and .mode == "Standalone" and
- (.scenario == "empty_rules" or .scenario == "distsql_rdl" or .scenario
== "passthrough"))
+ (.database == "openGauss" and
+ (.mode != "Cluster" or .scenario != "encrypt" or .["additional-options"]
!= ""))
)] | length')
assert_eq "$desc" "0" "$count"
}
+assert_adapter_parity() {
+ local desc="$1" matrix_json="$2"
+ local count
+ count=$(echo "$matrix_json" | jq '[
+ .include[] | select(.database != "H2" and .["additional-options"] == "")
+ ] | group_by([.mode, .database, .scenario]) |
+ map(select([.[].adapter] | sort != ["jdbc", "proxy"])) | length')
+ assert_eq "$desc" "0" "$count"
+}
+
+assert_cluster_encrypt_jobs() {
+ local desc="$1" matrix_json="$2" expected_json="$3"
+ local expected actual
+ expected=$(echo "$expected_json" | jq -c 'sort')
+ actual=$(echo "$matrix_json" | jq -c '[.include[] | select(
+ .mode == "Cluster" and .scenario == "encrypt" and .["additional-options"]
== ""
+ ) | [.adapter, .database]] | sort')
+ assert_eq "$desc" "$expected" "$actual"
+}
+
assert_extra_passthrough_job() {
local desc="$1" matrix_json="$2"
local count
@@ -191,7 +209,7 @@ assert_full_trigger() {
target_matrix=$(get_output "$outputs" "target-matrix")
assert_all_scenarios "$label: target-matrix has all 22 scenarios"
"$target_matrix"
assert_distsql_bootstrap_job "$label: target-matrix" "$target_matrix" "1"
- assert_no_excludes "$label: target-matrix has no excluded combinations"
"$target_matrix"
+ assert_opengauss_scope "$label: openGauss is limited to Cluster encrypt"
"$target_matrix"
assert_extra_passthrough_job "$label: target-matrix has extra passthrough
job" "$target_matrix"
assert_not_empty "$label: target-smoke-overlap-count exists" "$(get_output
"$outputs" "target-smoke-overlap-count")"
assert_not_empty "$label: estimated-remaining-tests-jobs exists"
"$(get_output "$outputs" "estimated-remaining-tests-jobs")"
@@ -212,6 +230,8 @@ if [ ! -f "$TARGET_SCRIPT" ]; then
exit 1
fi
+eval "$(sed -n '/^build_matrix() {/,/^}/p' "$TARGET_SCRIPT")"
+
echo "Running tests for generate-e2e-sql-matrix.sh"
echo ""
@@ -229,19 +249,19 @@ echo ""
echo "--- #2: core_infra=true ---"
outputs=$(run_script "$(build_filters core_infra=true)")
assert_full_trigger "#2" "$outputs" "pairwise"
-assert_less_than "#2: pairwise target-matrix is reduced" "$(echo "$(get_output
"$outputs" "target-matrix")" | jq '.include | length')" "119"
+assert_less_than "#2: pairwise target-matrix is reduced" "$(echo "$(get_output
"$outputs" "target-matrix")" | jq '.include | length')" "172"
echo ""
echo "--- #3: test_framework=true ---"
outputs=$(run_script "$(build_filters test_framework=true)")
assert_full_trigger "#3" "$outputs" "pairwise"
-assert_less_than "#3: pairwise target-matrix is reduced" "$(echo "$(get_output
"$outputs" "target-matrix")" | jq '.include | length')" "119"
+assert_less_than "#3: pairwise target-matrix is reduced" "$(echo "$(get_output
"$outputs" "target-matrix")" | jq '.include | length')" "172"
echo ""
echo "--- #4: pom_changes=true ---"
outputs=$(run_script "$(build_filters pom_changes=true)")
assert_full_trigger "#4" "$outputs" "pairwise"
-assert_less_than "#4: pairwise target-matrix is reduced" "$(echo "$(get_output
"$outputs" "target-matrix")" | jq '.include | length')" "119"
+assert_less_than "#4: pairwise target-matrix is reduced" "$(echo "$(get_output
"$outputs" "target-matrix")" | jq '.include | length')" "172"
# ============================================================
# B. workflow_dispatch
@@ -253,12 +273,21 @@ echo ""
echo "--- #5: workflow_dispatch ---"
outputs=$(run_script "$(build_filters)" "workflow_dispatch")
assert_full_trigger "#5" "$outputs" "cartesian"
+manual_full=$(get_output "$outputs" "target-matrix")
+manual_smoke=$(get_output "$outputs" "smoke-matrix")
+expected_cluster_encrypt='[["proxy","MySQL"],["proxy","PostgreSQL"],["proxy","openGauss"],["jdbc","MySQL"],["jdbc","PostgreSQL"],["jdbc","openGauss"]]'
+assert_cluster_encrypt_jobs "#5: all six Cluster encrypt jobs occur once"
"$manual_full" "$expected_cluster_encrypt"
+assert_eq "#5: complete candidate count" "172" "$(echo "$manual_full" | jq
'.include | length')"
+assert_eq "#5: no duplicate candidates" "0" "$(echo "$manual_full" | jq
'.include | length - (unique | length)')"
+assert_eq "#5: Smoke covers both adapters in both modes" "16" "$(echo
"$manual_smoke" | jq '.include | length')"
+assert_adapter_parity "#5: full candidates have matching adapter coverage"
"$manual_full"
+assert_adapter_parity "#5: Smoke has matching adapter coverage" "$manual_smoke"
echo ""
echo "--- #6: workflow_dispatch with pairwise ---"
outputs=$(run_script "$(build_filters)" "workflow_dispatch" "pairwise")
assert_full_trigger "#6" "$outputs" "pairwise"
-assert_less_than "#6: workflow_dispatch pairwise target-matrix is reduced"
"$(echo "$(get_output "$outputs" "target-matrix")" | jq '.include | length')"
"119"
+assert_less_than "#6: workflow_dispatch pairwise target-matrix is reduced"
"$(echo "$(get_output "$outputs" "target-matrix")" | jq '.include | length')"
"172"
echo ""
echo "--- #7: workflow_dispatch with invalid algorithm falls back to
auto(cartesian) ---"
@@ -337,10 +366,11 @@ echo "--- #16: feature_encrypt ---"
outputs=$(run_script "$(build_filters feature_encrypt=true)")
smoke=$(get_output "$outputs" "smoke-matrix")
assert_scenarios "#16: encrypt smoke scenarios" "$smoke" '["encrypt"]'
+assert_eq "#16: Smoke includes both adapters without openGauss extras" "8"
"$(echo "$smoke" | jq '.include | length')"
target=$(get_output "$outputs" "target-matrix")
expected_encrypt='["encrypt","dbtbl_with_readwrite_splitting_and_encrypt","sharding_and_encrypt","encrypt_and_readwrite_splitting","encrypt_shadow","sharding_encrypt_shadow","mask_encrypt","mask_encrypt_sharding"]'
assert_scenarios "#16: encrypt scenarios" "$target" "$expected_encrypt"
-assert_all_dimensions "#16" "$target"
+assert_all_dimensions "#16" "$target" "3"
assert_eq "#16: target-matrix-algorithm" "pairwise" "$(get_output "$outputs"
"target-matrix-algorithm")"
echo ""
@@ -449,6 +479,26 @@ remaining=$(get_output "$(cat "$output_file")" "matrix")
rm -f "$output_file"
assert_distsql_bootstrap_job "#26: remaining-matrix" "$remaining" "1"
+echo ""
+echo "--- #27: Cluster encrypt additions remain in Remaining Tests ---"
+output_file=$(mktemp)
+GITHUB_OUTPUT="$output_file" bash "$SCRIPT_DIR/generate-remaining-matrix.sh"
"$(build_filters)" "$manual_full" "$manual_smoke"
+remaining=$(get_output "$(cat "$output_file")" "matrix")
+rm -f "$output_file"
+assert_eq "#27: Remaining Tests is exactly full minus Smoke" \
+ "$(jq -cn --argjson full "$manual_full" --argjson smoke "$manual_smoke"
'{include: ($full.include - $smoke.include)}')" "$remaining"
+
+echo ""
+echo "--- #28: Cluster encrypt includes follow effective dimensions ---"
+matrix=$(build_matrix '["proxy"]' '["Cluster"]' '["PostgreSQL"]' '["encrypt"]')
+assert_cluster_encrypt_jobs "#28: proxy respects database selection and adds
openGauss" "$matrix" '[["proxy","PostgreSQL"],["proxy","openGauss"]]'
+matrix=$(build_matrix '["jdbc"]' '["Cluster"]' '["MySQL"]' '["encrypt"]')
+assert_cluster_encrypt_jobs "#28: JDBC respects MySQL selection and adds
openGauss" "$matrix" '[["jdbc","MySQL"],["jdbc","openGauss"]]'
+matrix=$(build_matrix '["jdbc"]' '["Cluster"]' '["PostgreSQL"]' '["encrypt"]')
+assert_cluster_encrypt_jobs "#28: JDBC respects PostgreSQL selection and adds
openGauss" "$matrix" '[["jdbc","PostgreSQL"],["jdbc","openGauss"]]'
+matrix=$(build_matrix '["proxy","jdbc"]' '["Standalone"]'
'["MySQL","PostgreSQL"]' '["encrypt"]')
+assert_eq "#28: Standalone encrypt has only four original jobs" "4" "$(echo
"$matrix" | jq '.include | length')"
+
# ============================================================
# Summary
# ============================================================
diff --git
a/test/e2e/env/src/test/java/org/apache/shardingsphere/test/e2e/env/container/adapter/impl/ShardingSphereJdbcEmbeddedContainer.java
b/test/e2e/env/src/test/java/org/apache/shardingsphere/test/e2e/env/container/adapter/impl/ShardingSphereJdbcEmbeddedContainer.java
index 0f42e53a610..321313e4d5d 100644
---
a/test/e2e/env/src/test/java/org/apache/shardingsphere/test/e2e/env/container/adapter/impl/ShardingSphereJdbcEmbeddedContainer.java
+++
b/test/e2e/env/src/test/java/org/apache/shardingsphere/test/e2e/env/container/adapter/impl/ShardingSphereJdbcEmbeddedContainer.java
@@ -21,10 +21,17 @@ import com.google.common.base.Strings;
import com.zaxxer.hikari.HikariDataSource;
import lombok.RequiredArgsConstructor;
import lombok.SneakyThrows;
+import
org.apache.shardingsphere.driver.api.yaml.YamlShardingSphereDataSourceFactory;
+import
org.apache.shardingsphere.driver.jdbc.core.datasource.ShardingSphereDataSource;
+import org.apache.shardingsphere.driver.yaml.YamlJDBCConfiguration;
+import org.apache.shardingsphere.infra.util.yaml.YamlEngine;
+import
org.apache.shardingsphere.infra.yaml.config.pojo.mode.YamlModeConfiguration;
+import
org.apache.shardingsphere.infra.yaml.config.pojo.mode.YamlPersistRepositoryConfiguration;
import org.apache.shardingsphere.test.e2e.env.container.EmbeddedE2EContainer;
import
org.apache.shardingsphere.test.e2e.env.container.adapter.AdapterContainer;
import
org.apache.shardingsphere.test.e2e.env.container.storage.StorageContainer;
+import javax.annotation.Nullable;
import javax.sql.DataSource;
import java.io.File;
import java.io.FileWriter;
@@ -32,6 +39,7 @@ import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
+import java.sql.SQLException;
import java.util.Collection;
import java.util.Map;
import java.util.Map.Entry;
@@ -53,6 +61,20 @@ public final class ShardingSphereJdbcEmbeddedContainer
implements EmbeddedE2ECon
public void start() {
}
+ @Override
+ @SneakyThrows(SQLException.class)
+ public void stop() {
+ for (Entry<String, DataSource> entry : targetDataSources.entrySet()) {
+ HikariDataSource targetDataSource = (HikariDataSource)
entry.getValue();
+ DataSource dataSource = targetDataSource.getDataSource();
+ if (null != dataSource) {
+ targetDataSource.close();
+ ((ShardingSphereDataSource) dataSource).close();
+ targetDataSources.remove(entry.getKey());
+ }
+ }
+ }
+
@Override
public DataSource getTargetDataSource(final String serverLists) {
return getTargetDataSource(serverLists, configPath);
@@ -61,18 +83,18 @@ public final class ShardingSphereJdbcEmbeddedContainer
implements EmbeddedE2ECon
@Override
public DataSource getTargetDataSource(final String serverLists, final
String dataSourceName) {
String effectiveDataSourceName = Strings.isNullOrEmpty(dataSourceName)
? configPath : dataSourceName;
- return targetDataSources.computeIfAbsent(effectiveDataSourceName,
this::createTargetDataSource);
- }
-
- @Override
- public Collection<DataSource> getTargetDataSources() {
- return targetDataSources.values();
+ return targetDataSources.computeIfAbsent(effectiveDataSourceName,
unused -> createTargetDataSource(serverLists));
}
- private DataSource createTargetDataSource(final String dataSourceName) {
+ @SneakyThrows({IOException.class, SQLException.class})
+ private DataSource createTargetDataSource(@Nullable final String
serverLists) {
HikariDataSource result = new HikariDataSource();
-
result.setDriverClassName("org.apache.shardingsphere.driver.ShardingSphereDriver");
- result.setJdbcUrl("jdbc:shardingsphere:absolutepath:" +
processFile(configPath, storageContainer.getLinkReplacements()));
+ if (Strings.isNullOrEmpty(serverLists)) {
+
result.setDriverClassName("org.apache.shardingsphere.driver.ShardingSphereDriver");
+ result.setJdbcUrl("jdbc:shardingsphere:absolutepath:" +
processFile(configPath, storageContainer.getLinkReplacements(), serverLists));
+ } else {
+
result.setDataSource(YamlShardingSphereDataSourceFactory.createDataSource(new
File(processFile(configPath, storageContainer.getLinkReplacements(),
serverLists))));
+ }
result.setMaximumPoolSize(2);
result.setTransactionIsolation("TRANSACTION_READ_COMMITTED");
result.setLeakDetectionThreshold(10000L);
@@ -80,12 +102,24 @@ public final class ShardingSphereJdbcEmbeddedContainer
implements EmbeddedE2ECon
}
@SneakyThrows(IOException.class)
- private String processFile(final String filePath, final Map<String,
String> replacements) {
+ private String processFile(final String filePath, final Map<String,
String> replacements, @Nullable final String serverLists) {
Path path = Paths.get(filePath);
String content = new String(Files.readAllBytes(path));
for (Entry<String, String> entry : replacements.entrySet()) {
content = content.replace(entry.getKey(), entry.getValue());
}
+ if (!Strings.isNullOrEmpty(serverLists)) {
+ YamlJDBCConfiguration config = YamlEngine.unmarshal(content,
YamlJDBCConfiguration.class);
+ YamlPersistRepositoryConfiguration repository = new
YamlPersistRepositoryConfiguration();
+ repository.setType("ZooKeeper");
+ repository.getProps().setProperty("namespace", "e2e_db");
+ repository.getProps().setProperty("server-lists", serverLists);
+ YamlModeConfiguration modeConfig = new YamlModeConfiguration();
+ modeConfig.setType("Cluster");
+ modeConfig.setRepository(repository);
+ config.setMode(modeConfig);
+ content = YamlEngine.marshal(config);
+ }
File tempFile =
File.createTempFile("shardingsphere_e2e_jdbc_tmp_config_", null);
tempFile.deleteOnExit();
try (FileWriter writer = new FileWriter(tempFile)) {
@@ -94,6 +128,11 @@ public final class ShardingSphereJdbcEmbeddedContainer
implements EmbeddedE2ECon
return tempFile.getAbsolutePath();
}
+ @Override
+ public Collection<DataSource> getTargetDataSources() {
+ return targetDataSources.values();
+ }
+
@Override
public String getAbbreviation() {
return "jdbc";
diff --git
a/test/e2e/sql/src/test/java/org/apache/shardingsphere/test/e2e/sql/env/container/compose/ContainerComposerRegistry.java
b/test/e2e/sql/src/test/java/org/apache/shardingsphere/test/e2e/sql/env/container/compose/ContainerComposerRegistry.java
index 30fc49c54da..fa8dca271ec 100644
---
a/test/e2e/sql/src/test/java/org/apache/shardingsphere/test/e2e/sql/env/container/compose/ContainerComposerRegistry.java
+++
b/test/e2e/sql/src/test/java/org/apache/shardingsphere/test/e2e/sql/env/container/compose/ContainerComposerRegistry.java
@@ -57,12 +57,16 @@ public final class ContainerComposerRegistry implements
AutoCloseable {
synchronized (containerComposers) {
if (!containerComposers.containsKey(key)) {
close();
- containerComposers.put(key,
createContainerComposer(isClusterMode(mode, adapter), scenario, databaseType,
adapter));
+ containerComposers.put(key,
createContainerComposer(Mode.CLUSTER == mode, scenario, databaseType, adapter));
}
return containerComposers.get(key);
}
}
+ private ContainerComposer createContainerComposer(final boolean
clusterMode, final String scenario, final DatabaseType databaseType, final
Adapter adapter) {
+ return clusterMode ? new ClusterContainerComposer(scenario,
databaseType, adapter) : new StandaloneContainerComposer(scenario,
databaseType, adapter);
+ }
+
/**
* Get target data source.
*
@@ -79,14 +83,6 @@ public final class ContainerComposerRegistry implements
AutoCloseable {
}
}
- private boolean isClusterMode(final Mode mode, final Adapter adapter) {
- return Mode.CLUSTER == mode && Adapter.PROXY == adapter;
- }
-
- private ContainerComposer createContainerComposer(final boolean
clusterMode, final String scenario, final DatabaseType databaseType, final
Adapter adapter) {
- return clusterMode ? new ClusterContainerComposer(scenario,
databaseType, adapter) : new StandaloneContainerComposer(scenario,
databaseType, adapter);
- }
-
@Override
public void close() {
synchronized (containerComposers) {
diff --git
a/test/e2e/sql/src/test/java/org/apache/shardingsphere/test/e2e/sql/framework/param/array/JdbcStandaloneTestParameterGenerator.java
b/test/e2e/sql/src/test/java/org/apache/shardingsphere/test/e2e/sql/framework/param/array/JdbcStandaloneTestParameterGenerator.java
index 7699728b902..b288a6fb02d 100644
---
a/test/e2e/sql/src/test/java/org/apache/shardingsphere/test/e2e/sql/framework/param/array/JdbcStandaloneTestParameterGenerator.java
+++
b/test/e2e/sql/src/test/java/org/apache/shardingsphere/test/e2e/sql/framework/param/array/JdbcStandaloneTestParameterGenerator.java
@@ -20,23 +20,19 @@ package
org.apache.shardingsphere.test.e2e.sql.framework.param.array;
import lombok.AccessLevel;
import lombok.NoArgsConstructor;
import org.apache.shardingsphere.test.e2e.env.runtime.E2ETestEnvironment;
-import
org.apache.shardingsphere.test.e2e.env.runtime.type.ArtifactEnvironment.Adapter;
import
org.apache.shardingsphere.test.e2e.env.runtime.type.ArtifactEnvironment.Mode;
import
org.apache.shardingsphere.test.e2e.sql.framework.param.model.AssertionTestParameter;
import
org.apache.shardingsphere.test.e2e.sql.framework.param.model.E2ETestParameter;
import org.apache.shardingsphere.test.e2e.sql.framework.type.SQLCommandType;
import java.util.Collection;
-import java.util.Collections;
/**
- * JDBC test parameter generator for standalone mode.
+ * SQL test parameter generator for standalone mode.
*/
@NoArgsConstructor(access = AccessLevel.PRIVATE)
public final class JdbcStandaloneTestParameterGenerator {
- private static final Collection<String> ADAPTERS =
Collections.singleton(Adapter.JDBC.getValue());
-
private static final E2ETestEnvironment ENV =
E2ETestEnvironment.getInstance();
/**
@@ -46,8 +42,8 @@ public final class JdbcStandaloneTestParameterGenerator {
* @return assertion test parameter
*/
public static Collection<AssertionTestParameter>
getAssertionTestParameter(final SQLCommandType sqlCommandType) {
- return new E2ETestParameterGenerator(ADAPTERS, ENV.getScenarios(),
Mode.STANDALONE, ENV.getArtifactEnvironment().getDatabaseTypes(),
ENV.getRunEnvironment().isRunSmokeCases())
- .getAssertionTestParameter(sqlCommandType);
+ return new
E2ETestParameterGenerator(ENV.getArtifactEnvironment().getAdapters(),
ENV.getScenarios(), Mode.STANDALONE,
ENV.getArtifactEnvironment().getDatabaseTypes(),
+
ENV.getRunEnvironment().isRunSmokeCases()).getAssertionTestParameter(sqlCommandType);
}
/**
@@ -57,7 +53,7 @@ public final class JdbcStandaloneTestParameterGenerator {
* @return case test parameter
*/
public static Collection<E2ETestParameter> getCaseTestParameter(final
SQLCommandType sqlCommandType) {
- return new E2ETestParameterGenerator(ADAPTERS, ENV.getScenarios(),
Mode.STANDALONE, ENV.getArtifactEnvironment().getDatabaseTypes(),
ENV.getRunEnvironment().isRunSmokeCases())
- .getCaseTestParameter(sqlCommandType);
+ return new
E2ETestParameterGenerator(ENV.getArtifactEnvironment().getAdapters(),
ENV.getScenarios(), Mode.STANDALONE,
ENV.getArtifactEnvironment().getDatabaseTypes(),
+
ENV.getRunEnvironment().isRunSmokeCases()).getCaseTestParameter(sqlCommandType);
}
}
diff --git
a/test/e2e/sql/src/test/java/org/apache/shardingsphere/test/e2e/sql/framework/param/model/E2ETestParameter.java
b/test/e2e/sql/src/test/java/org/apache/shardingsphere/test/e2e/sql/framework/param/model/E2ETestParameter.java
index a1d5822bfad..f7a853ed66c 100644
---
a/test/e2e/sql/src/test/java/org/apache/shardingsphere/test/e2e/sql/framework/param/model/E2ETestParameter.java
+++
b/test/e2e/sql/src/test/java/org/apache/shardingsphere/test/e2e/sql/framework/param/model/E2ETestParameter.java
@@ -75,6 +75,6 @@ public interface E2ETestParameter {
* @return key of test parameter
*/
default String getKey() {
- return String.join("-", getSqlCommandType().toString(), getScenario(),
getAdapter(), getDatabaseType().getType());
+ return String.join("-", getSqlCommandType().toString(), getScenario(),
getAdapter(), getDatabaseType().getType(), getMode().name());
}
}
diff --git
a/test/e2e/sql/src/test/java/org/apache/shardingsphere/test/e2e/sql/it/SQLE2EIT.java
b/test/e2e/sql/src/test/java/org/apache/shardingsphere/test/e2e/sql/it/SQLE2EIT.java
index 3bbf5ae2ab9..97fe6655920 100644
---
a/test/e2e/sql/src/test/java/org/apache/shardingsphere/test/e2e/sql/it/SQLE2EIT.java
+++
b/test/e2e/sql/src/test/java/org/apache/shardingsphere/test/e2e/sql/it/SQLE2EIT.java
@@ -46,22 +46,54 @@ public interface SQLE2EIT {
*/
class SQLE2EITEnvironmentExtension implements InvocationInterceptor {
+ private static final Object ENV_LOCK = new Object();
+
+ private static String currentEnvKey;
+
+ private static int activeInvocations;
+
@Override
public void interceptTestTemplateMethod(final Invocation<Void>
invocation, final ReflectiveInvocationContext<Method> invocationContext,
final ExtensionContext
extensionContext) throws Throwable {
for (Object each : invocationContext.getArguments()) {
if (each instanceof E2ETestParameter) {
E2ETestParameter testParameter = (E2ETestParameter) each;
- setEnvironmentEngine(extensionContext, testParameter);
+ acquireEnvironment(testParameter.getKey());
+ try {
+ setEnvironmentEngine(extensionContext, testParameter);
+ invocation.proceed();
+ } finally {
+ releaseEnvironment();
+ }
+ return;
}
}
invocation.proceed();
}
+ private static void acquireEnvironment(final String key) throws
InterruptedException {
+ synchronized (ENV_LOCK) {
+ while (activeInvocations > 0 && !key.equals(currentEnvKey)) {
+ ENV_LOCK.wait();
+ }
+ currentEnvKey = key;
+ activeInvocations++;
+ }
+ }
+
private void setEnvironmentEngine(final ExtensionContext
extensionContext, final E2ETestParameter testParam) {
SQLE2EEnvironmentEngine environmentEngine = new
SQLE2EEnvironmentEngine(
testParam.getKey(), testParam.getScenario(),
testParam.getDatabaseType(), testParam.getMode(),
Adapter.valueOf(testParam.getAdapter().toUpperCase()));
((SQLE2EIT)
extensionContext.getRequiredTestInstance()).setEnvironmentEngine(environmentEngine);
}
+
+ private static void releaseEnvironment() {
+ synchronized (ENV_LOCK) {
+ activeInvocations--;
+ if (0 == activeInvocations) {
+ ENV_LOCK.notifyAll();
+ }
+ }
+ }
}
}
diff --git
a/test/e2e/sql/src/test/java/org/apache/shardingsphere/test/e2e/sql/it/distsql/ral/RALE2EIT.java
b/test/e2e/sql/src/test/java/org/apache/shardingsphere/test/e2e/sql/it/distsql/ral/RALE2EIT.java
index 456cdb9cc7a..416b80ab6b5 100644
---
a/test/e2e/sql/src/test/java/org/apache/shardingsphere/test/e2e/sql/it/distsql/ral/RALE2EIT.java
+++
b/test/e2e/sql/src/test/java/org/apache/shardingsphere/test/e2e/sql/it/distsql/ral/RALE2EIT.java
@@ -167,8 +167,8 @@ class RALE2EIT implements SQLE2EIT {
private void assertResultSet(final SQLE2EITContext context, final
ResultSet resultSet, final AssertionTestParameter testParam) throws
SQLException, IOException {
assertMetaData(resultSet.getMetaData(), getExpectedColumns(context),
context, testParam);
- if ("jdbc".equals(testParam.getAdapter()) &&
("show_storage_units.xml".equals(context.getAssertion().getExpectedDataFile())
- ||
"show_sharding_table_rule.xml".equals(context.getAssertion().getExpectedDataFile())
|| "show_tables.xml".equals(context.getAssertion().getExpectedDataFile()))) {
+ if
("show_sharding_table_rule.xml".equals(context.getAssertion().getExpectedDataFile())
|| "jdbc".equals(testParam.getAdapter())
+ &&
("show_storage_units.xml".equals(context.getAssertion().getExpectedDataFile())
|| "show_tables.xml".equals(context.getAssertion().getExpectedDataFile()))) {
assertThat(getActualRows(resultSet),
containsInAnyOrder(getExpectedJdbcRows(context, testParam).toArray()));
} else {
assertRows(resultSet, getIgnoreAssertColumns(context),
context.getDataSet().getRows());
diff --git
a/test/e2e/sql/src/test/resources/cases/ral/dataset/empty_rules/cluster/show_compute_node_info_jdbc.xml
b/test/e2e/sql/src/test/resources/cases/ral/dataset/empty_rules/cluster/show_compute_node_info_jdbc.xml
new file mode 100644
index 00000000000..8c8f522f3c0
--- /dev/null
+++
b/test/e2e/sql/src/test/resources/cases/ral/dataset/empty_rules/cluster/show_compute_node_info_jdbc.xml
@@ -0,0 +1,29 @@
+<!--
+ ~ Licensed to the Apache Software Foundation (ASF) under one or more
+ ~ contributor license agreements. See the NOTICE file distributed with
+ ~ this work for additional information regarding copyright ownership.
+ ~ The ASF licenses this file to You under the Apache License, Version 2.0
+ ~ (the "License"); you may not use this file except in compliance with
+ ~ the License. You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing, software
+ ~ distributed under the License is distributed on an "AS IS" BASIS,
+ ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ ~ See the License for the specific language governing permissions and
+ ~ limitations under the License.
+ -->
+
+<dataset>
+ <metadata>
+ <column name="instance_id" ignore-assert-data="true" />
+ <column name="host" ignore-assert-data="true" />
+ <column name="port" />
+ <column name="status" />
+ <column name="mode_type" />
+ <column name="worker_id" />
+ <column name="version" ignore-assert-data="true" />
+ </metadata>
+ <row values=" | | -1| OK| Cluster| 0| " />
+</dataset>
diff --git
a/test/e2e/sql/src/test/resources/cases/ral/dataset/empty_rules/cluster/show_compute_nodes_jdbc.xml
b/test/e2e/sql/src/test/resources/cases/ral/dataset/empty_rules/cluster/show_compute_nodes_jdbc.xml
new file mode 100644
index 00000000000..b83564636ea
--- /dev/null
+++
b/test/e2e/sql/src/test/resources/cases/ral/dataset/empty_rules/cluster/show_compute_nodes_jdbc.xml
@@ -0,0 +1,31 @@
+<!--
+ ~ Licensed to the Apache Software Foundation (ASF) under one or more
+ ~ contributor license agreements. See the NOTICE file distributed with
+ ~ this work for additional information regarding copyright ownership.
+ ~ The ASF licenses this file to You under the Apache License, Version 2.0
+ ~ (the "License"); you may not use this file except in compliance with
+ ~ the License. You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing, software
+ ~ distributed under the License is distributed on an "AS IS" BASIS,
+ ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ ~ See the License for the specific language governing permissions and
+ ~ limitations under the License.
+ -->
+
+<dataset>
+ <metadata>
+ <column name="instance_id" ignore-assert-data="true" />
+ <column name="instance_type" />
+ <column name="host" ignore-assert-data="true" />
+ <column name="port" />
+ <column name="status" />
+ <column name="mode_type" />
+ <column name="worker_id" />
+ <column name="version" ignore-assert-data="true" />
+ <column name="database_name" />
+ </metadata>
+ <row values=" | JDBC| | -1| OK| Cluster| 0| | empty_rules" />
+</dataset>