You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by yx...@apache.org on 2023/03/16 05:31:40 UTC
[shardingsphere] branch master updated: Use E2EContainerComposer to instead of BaseE2EIT (#24639)
This is an automated email from the ASF dual-hosted git repository.
yx9o 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 2ec734df909 Use E2EContainerComposer to instead of BaseE2EIT (#24639)
2ec734df909 is described below
commit 2ec734df909b32651aa1f7aebd8ea169e1c03738
Author: Liang Zhang <zh...@apache.org>
AuthorDate: Thu Mar 16 13:31:32 2023 +0800
Use E2EContainerComposer to instead of BaseE2EIT (#24639)
* Use E2EContainerComposer to instead of BaseE2EIT
* Use E2EContainerComposer to instead of BaseE2EIT
* Use E2EContainerComposer to instead of BaseE2EIT
* Use E2EContainerComposer to instead of BaseE2EIT
---
.../shardingsphere/test/e2e/engine/BatchE2EIT.java | 49 ++++++++++++-------
.../{BaseE2EIT.java => E2EContainerComposer.java} | 56 +++++++---------------
.../test/e2e/engine/SingleE2EIT.java | 25 ++++++++--
.../test/e2e/engine/dal/BaseDALE2EIT.java | 3 +-
.../test/e2e/engine/dal/GeneralDALE2EIT.java | 2 +-
.../test/e2e/engine/dcl/BaseDCLE2EIT.java | 3 +-
.../test/e2e/engine/dcl/GeneralDCLE2EIT.java | 4 +-
.../test/e2e/engine/ddl/BaseDDLE2EIT.java | 16 +++----
.../test/e2e/engine/ddl/GeneralDDLE2EIT.java | 4 +-
.../test/e2e/engine/dml/AdditionalDMLE2EIT.java | 28 +++++------
.../test/e2e/engine/dml/BaseDMLE2EIT.java | 17 ++++---
.../test/e2e/engine/dml/BatchDMLE2EIT.java | 16 ++++---
.../test/e2e/engine/dml/GeneralDMLE2EIT.java | 4 +-
.../test/e2e/engine/dql/AdditionalDQLE2EIT.java | 16 +++----
.../test/e2e/engine/dql/BaseDQLE2EIT.java | 16 +++----
.../test/e2e/engine/dql/GeneralDQLE2EIT.java | 8 ++--
.../test/e2e/engine/ral/BaseRALE2EIT.java | 4 +-
.../test/e2e/engine/ral/GeneralRALE2EIT.java | 2 +-
.../test/e2e/engine/rdl/BaseRDLE2EIT.java | 4 +-
.../test/e2e/engine/rdl/GeneralRDLE2EIT.java | 2 +-
.../test/e2e/engine/rql/GeneralRQLE2EIT.java | 2 +-
21 files changed, 147 insertions(+), 134 deletions(-)
diff --git a/test/e2e/suite/src/test/java/org/apache/shardingsphere/test/e2e/engine/BatchE2EIT.java b/test/e2e/suite/src/test/java/org/apache/shardingsphere/test/e2e/engine/BatchE2EIT.java
index 1cf00035e8b..956086a1cd1 100644
--- a/test/e2e/suite/src/test/java/org/apache/shardingsphere/test/e2e/engine/BatchE2EIT.java
+++ b/test/e2e/suite/src/test/java/org/apache/shardingsphere/test/e2e/engine/BatchE2EIT.java
@@ -17,6 +17,7 @@
package org.apache.shardingsphere.test.e2e.engine;
+import lombok.Getter;
import org.apache.shardingsphere.infra.datanode.DataNode;
import org.apache.shardingsphere.infra.util.expr.InlineExpressionParser;
import org.apache.shardingsphere.test.e2e.cases.assertion.IntegrationTestCaseAssertion;
@@ -29,10 +30,14 @@ import org.apache.shardingsphere.test.e2e.env.DataSetEnvironmentManager;
import org.apache.shardingsphere.test.e2e.env.runtime.scenario.path.ScenarioDataPath;
import org.apache.shardingsphere.test.e2e.env.runtime.scenario.path.ScenarioDataPath.Type;
import org.apache.shardingsphere.test.e2e.framework.param.model.CaseTestParameter;
+import org.apache.shardingsphere.test.e2e.framework.runner.ParallelParameterized;
import org.junit.After;
-import org.junit.Before;
+import org.junit.AfterClass;
+import org.junit.runner.RunWith;
import javax.sql.DataSource;
+import javax.xml.bind.JAXBException;
+import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.sql.Connection;
import java.sql.PreparedStatement;
@@ -40,6 +45,7 @@ import java.sql.ResultSet;
import java.sql.ResultSetMetaData;
import java.sql.SQLException;
import java.sql.Types;
+import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Collection;
import java.util.Comparator;
@@ -51,25 +57,26 @@ import java.util.Set;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
-public abstract class BatchE2EIT extends BaseE2EIT {
+@RunWith(ParallelParameterized.class)
+public abstract class BatchE2EIT {
- private final Collection<DataSet> dataSets = new LinkedList<>();
+ @Getter
+ private final CaseTestParameter testParam;
- private final String parentPath;
+ @Getter
+ private final E2EContainerComposer containerComposer;
- private DataSetEnvironmentManager dataSetEnvironmentManager;
+ private final Collection<DataSet> dataSets = new LinkedList<>();
- public BatchE2EIT(final CaseTestParameter testParam) {
- super(testParam);
- parentPath = testParam.getTestCaseContext().getParentPath();
- }
+ private final DataSetEnvironmentManager dataSetEnvironmentManager;
- @Before
- public void init() throws Exception {
- for (IntegrationTestCaseAssertion each : getItCase().getAssertions()) {
- dataSets.add(DataSetLoader.load(parentPath, getScenario(), getDatabaseType(), getMode(), each.getExpectedDataFile()));
+ public BatchE2EIT(final CaseTestParameter testParam) throws JAXBException, IOException, SQLException, ParseException {
+ this.testParam = testParam;
+ containerComposer = new E2EContainerComposer(testParam);
+ for (IntegrationTestCaseAssertion each : testParam.getTestCaseContext().getTestCase().getAssertions()) {
+ dataSets.add(DataSetLoader.load(testParam.getTestCaseContext().getParentPath(), testParam.getScenario(), testParam.getDatabaseType(), testParam.getMode(), each.getExpectedDataFile()));
}
- dataSetEnvironmentManager = new DataSetEnvironmentManager(new ScenarioDataPath(getScenario()).getDataSetFile(Type.ACTUAL), getActualDataSourceMap());
+ dataSetEnvironmentManager = new DataSetEnvironmentManager(new ScenarioDataPath(testParam.getScenario()).getDataSetFile(Type.ACTUAL), containerComposer.getActualDataSourceMap());
dataSetEnvironmentManager.fillData();
}
@@ -78,13 +85,18 @@ public abstract class BatchE2EIT extends BaseE2EIT {
dataSetEnvironmentManager.cleanData();
}
+ @AfterClass
+ public static void closeContainers() {
+ E2EContainerComposer.closeContainers();
+ }
+
protected final void assertDataSets(final int[] actualUpdateCounts) throws SQLException {
DataSet expected = getDataSet(actualUpdateCounts);
assertThat("Only support single table for DML.", expected.getMetaDataList().size(), is(1));
DataSetMetaData expectedDataSetMetaData = expected.getMetaDataList().get(0);
for (String each : new InlineExpressionParser(expectedDataSetMetaData.getDataNodes()).splitAndEvaluate()) {
DataNode dataNode = new DataNode(each);
- DataSource dataSource = getActualDataSourceMap().get(dataNode.getDataSourceName());
+ DataSource dataSource = containerComposer.getActualDataSourceMap().get(dataNode.getDataSourceName());
try (
Connection connection = dataSource.getConnection();
PreparedStatement preparedStatement = connection.prepareStatement(String.format("SELECT * FROM %s ORDER BY 1", dataNode.getTableName()))) {
@@ -155,10 +167,11 @@ public abstract class BatchE2EIT extends BaseE2EIT {
int columnIndex = 1;
for (String expected : expectedDatSetRows.get(count).splitValues(", ")) {
if (Types.DATE == actual.getMetaData().getColumnType(columnIndex)) {
- if (!NOT_VERIFY_FLAG.equals(expected)) {
+ if (!E2EContainerComposer.NOT_VERIFY_FLAG.equals(expected)) {
assertThat(new SimpleDateFormat("yyyy-MM-dd").format(actual.getDate(columnIndex)), is(expected));
}
- } else if (Types.CHAR == actual.getMetaData().getColumnType(columnIndex) && ("PostgreSQL".equals(getDatabaseType().getType()) || "openGauss".equals(getDatabaseType().getType()))) {
+ } else if (Types.CHAR == actual.getMetaData().getColumnType(columnIndex)
+ && ("PostgreSQL".equals(testParam.getDatabaseType().getType()) || "openGauss".equals(testParam.getDatabaseType().getType()))) {
assertThat(String.valueOf(actual.getObject(columnIndex)).trim(), is(expected));
} else if (isPostgreSQLOrOpenGaussMoney(actual.getMetaData().getColumnTypeName(columnIndex))) {
assertThat(actual.getString(columnIndex), is(expected));
@@ -175,6 +188,6 @@ public abstract class BatchE2EIT extends BaseE2EIT {
}
private boolean isPostgreSQLOrOpenGaussMoney(final String columnTypeName) {
- return "money".equalsIgnoreCase(columnTypeName) && ("PostgreSQL".equals(getDatabaseType().getType()) || "openGauss".equals(getDatabaseType().getType()));
+ return "money".equalsIgnoreCase(columnTypeName) && ("PostgreSQL".equals(testParam.getDatabaseType().getType()) || "openGauss".equals(testParam.getDatabaseType().getType()));
}
}
diff --git a/test/e2e/suite/src/test/java/org/apache/shardingsphere/test/e2e/engine/BaseE2EIT.java b/test/e2e/suite/src/test/java/org/apache/shardingsphere/test/e2e/engine/E2EContainerComposer.java
similarity index 67%
rename from test/e2e/suite/src/test/java/org/apache/shardingsphere/test/e2e/engine/BaseE2EIT.java
rename to test/e2e/suite/src/test/java/org/apache/shardingsphere/test/e2e/engine/E2EContainerComposer.java
index 363ce5da7b3..4241e8411e1 100644
--- a/test/e2e/suite/src/test/java/org/apache/shardingsphere/test/e2e/engine/BaseE2EIT.java
+++ b/test/e2e/suite/src/test/java/org/apache/shardingsphere/test/e2e/engine/E2EContainerComposer.java
@@ -19,18 +19,13 @@ package org.apache.shardingsphere.test.e2e.engine;
import lombok.AccessLevel;
import lombok.Getter;
+import lombok.SneakyThrows;
import org.apache.shardingsphere.infra.database.DefaultDatabase;
-import org.apache.shardingsphere.infra.database.type.DatabaseType;
-import org.apache.shardingsphere.test.e2e.cases.assertion.IntegrationTestCase;
import org.apache.shardingsphere.test.e2e.container.compose.ContainerComposer;
import org.apache.shardingsphere.test.e2e.container.compose.ContainerComposerRegistry;
import org.apache.shardingsphere.test.e2e.env.runtime.scenario.path.ScenarioDataPath;
import org.apache.shardingsphere.test.e2e.framework.param.model.E2ETestParameter;
-import org.apache.shardingsphere.test.e2e.framework.runner.ParallelParameterized;
import org.h2.tools.RunScript;
-import org.junit.AfterClass;
-import org.junit.Before;
-import org.junit.runner.RunWith;
import javax.sql.DataSource;
import java.io.FileReader;
@@ -43,9 +38,8 @@ import java.util.Map;
import java.util.Optional;
import java.util.concurrent.atomic.AtomicInteger;
-@RunWith(ParallelParameterized.class)
-@Getter(AccessLevel.PROTECTED)
-public abstract class BaseE2EIT {
+@Getter
+public final class E2EContainerComposer {
public static final String NOT_VERIFY_FLAG = "NOT_VERIFY";
@@ -57,53 +51,35 @@ public abstract class BaseE2EIT {
private static final Collection<String> INITIALIZED_SUITES = new HashSet<>();
- private final String mode;
-
- private final String scenario;
-
- private final DatabaseType databaseType;
-
- private final String itKey;
-
- private final IntegrationTestCase itCase;
-
@Getter(AccessLevel.NONE)
private final ContainerComposer containerComposer;
- private Map<String, DataSource> actualDataSourceMap;
+ private final Map<String, DataSource> actualDataSourceMap;
- private DataSource targetDataSource;
+ private final DataSource targetDataSource;
- private Map<String, DataSource> expectedDataSourceMap;
+ private final Map<String, DataSource> expectedDataSourceMap;
- public BaseE2EIT(final E2ETestParameter testParam) {
- mode = testParam.getMode();
- scenario = testParam.getScenario();
- databaseType = testParam.getDatabaseType();
- itKey = testParam.getKey();
- itCase = testParam.getTestCaseContext().getTestCase();
+ public E2EContainerComposer(final E2ETestParameter testParam) {
containerComposer = CONTAINER_COMPOSER_REGISTRY.getContainerComposer(testParam);
- }
-
- @Before
- public void setUp() throws SQLException, IOException {
containerComposer.start();
actualDataSourceMap = containerComposer.getActualDataSourceMap();
targetDataSource = containerComposer.getTargetDataSource();
expectedDataSourceMap = containerComposer.getExpectedDataSourceMap();
- executeLogicDatabaseInitSQLFileOnlyOnce(targetDataSource);
+ executeLogicDatabaseInitSQLFileOnlyOnce(testParam, targetDataSource);
}
- private void executeLogicDatabaseInitSQLFileOnlyOnce(final DataSource targetDataSource) throws SQLException, IOException {
- Optional<String> logicDatabaseInitSQLFile = new ScenarioDataPath(getScenario()).findActualDatabaseInitSQLFile(DefaultDatabase.LOGIC_NAME, getDatabaseType());
+ @SneakyThrows({SQLException.class, IOException.class})
+ private void executeLogicDatabaseInitSQLFileOnlyOnce(final E2ETestParameter testParam, final DataSource targetDataSource) {
+ Optional<String> logicDatabaseInitSQLFile = new ScenarioDataPath(testParam.getScenario()).findActualDatabaseInitSQLFile(DefaultDatabase.LOGIC_NAME, testParam.getDatabaseType());
if (!logicDatabaseInitSQLFile.isPresent()) {
return;
}
- if (!INITIALIZED_SUITES.contains(getItKey())) {
+ if (!INITIALIZED_SUITES.contains(testParam.getKey())) {
synchronized (INITIALIZED_SUITES) {
- if (!INITIALIZED_SUITES.contains(getItKey())) {
+ if (!INITIALIZED_SUITES.contains(testParam.getKey())) {
executeInitSQL(targetDataSource, logicDatabaseInitSQLFile.get());
- INITIALIZED_SUITES.add(getItKey());
+ INITIALIZED_SUITES.add(testParam.getKey());
}
}
}
@@ -117,7 +93,9 @@ public abstract class BaseE2EIT {
}
}
- @AfterClass
+ /**
+ * Close containers.
+ */
public static void closeContainers() {
if (COMPLETED_SUITES_COUNT.incrementAndGet() == TOTAL_SUITES_COUNT) {
CONTAINER_COMPOSER_REGISTRY.close();
diff --git a/test/e2e/suite/src/test/java/org/apache/shardingsphere/test/e2e/engine/SingleE2EIT.java b/test/e2e/suite/src/test/java/org/apache/shardingsphere/test/e2e/engine/SingleE2EIT.java
index c831ce1d5ef..8eb60952834 100644
--- a/test/e2e/suite/src/test/java/org/apache/shardingsphere/test/e2e/engine/SingleE2EIT.java
+++ b/test/e2e/suite/src/test/java/org/apache/shardingsphere/test/e2e/engine/SingleE2EIT.java
@@ -25,21 +25,29 @@ import org.apache.shardingsphere.test.e2e.cases.dataset.DataSet;
import org.apache.shardingsphere.test.e2e.cases.dataset.DataSetLoader;
import org.apache.shardingsphere.test.e2e.cases.value.SQLValue;
import org.apache.shardingsphere.test.e2e.framework.param.model.AssertionTestParameter;
+import org.apache.shardingsphere.test.e2e.framework.runner.ParallelParameterized;
import org.apache.shardingsphere.test.e2e.framework.watcher.E2EWatcher;
+import org.junit.AfterClass;
import org.junit.Rule;
+import org.junit.runner.RunWith;
import java.text.ParseException;
import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;
+@RunWith(ParallelParameterized.class)
@Getter(AccessLevel.PROTECTED)
-public abstract class SingleE2EIT extends BaseE2EIT {
+public abstract class SingleE2EIT {
@Rule
@Getter(AccessLevel.NONE)
public E2EWatcher watcher = new E2EWatcher();
+ private final AssertionTestParameter testParam;
+
+ private final E2EContainerComposer containerComposer;
+
private final SQLExecuteType sqlExecuteType;
private final IntegrationTestCaseAssertion assertion;
@@ -49,23 +57,30 @@ public abstract class SingleE2EIT extends BaseE2EIT {
private final DataSet generatedKeyDataSet;
public SingleE2EIT(final AssertionTestParameter testParam) {
- super(testParam);
+ this.testParam = testParam;
+ containerComposer = new E2EContainerComposer(testParam);
sqlExecuteType = testParam.getSqlExecuteType();
assertion = testParam.getAssertion();
dataSet = null == assertion || null == assertion.getExpectedDataFile()
? null
- : DataSetLoader.load(testParam.getTestCaseContext().getParentPath(), getScenario(), getDatabaseType(), getMode(), assertion.getExpectedDataFile());
+ : DataSetLoader.load(testParam.getTestCaseContext().getParentPath(), testParam.getScenario(), testParam.getDatabaseType(), testParam.getMode(), assertion.getExpectedDataFile());
generatedKeyDataSet = null == assertion || null == assertion.getExpectedGeneratedKeyDataFile()
? null
- : DataSetLoader.load(testParam.getTestCaseContext().getParentPath(), getScenario(), getDatabaseType(), getMode(), assertion.getExpectedGeneratedKeyDataFile());
+ : DataSetLoader.load(
+ testParam.getTestCaseContext().getParentPath(), testParam.getScenario(), testParam.getDatabaseType(), testParam.getMode(), assertion.getExpectedGeneratedKeyDataFile());
}
protected final String getSQL() throws ParseException {
- return sqlExecuteType == SQLExecuteType.Literal ? getLiteralSQL(getItCase().getSql()) : getItCase().getSql();
+ return sqlExecuteType == SQLExecuteType.Literal ? getLiteralSQL(testParam.getTestCaseContext().getTestCase().getSql()) : testParam.getTestCaseContext().getTestCase().getSql();
}
private String getLiteralSQL(final String sql) throws ParseException {
List<Object> params = null == assertion ? Collections.emptyList() : assertion.getSQLValues().stream().map(SQLValue::toString).collect(Collectors.toList());
return params.isEmpty() ? sql : String.format(sql.replace("%", "ÿ").replace("?", "%s"), params.toArray()).replace("ÿ", "%").replace("%%", "%").replace("'%'", "'%%'");
}
+
+ @AfterClass
+ public static void closeContainers() {
+ E2EContainerComposer.closeContainers();
+ }
}
diff --git a/test/e2e/suite/src/test/java/org/apache/shardingsphere/test/e2e/engine/dal/BaseDALE2EIT.java b/test/e2e/suite/src/test/java/org/apache/shardingsphere/test/e2e/engine/dal/BaseDALE2EIT.java
index 4bd9e1a9cbe..4f8e218f7e4 100644
--- a/test/e2e/suite/src/test/java/org/apache/shardingsphere/test/e2e/engine/dal/BaseDALE2EIT.java
+++ b/test/e2e/suite/src/test/java/org/apache/shardingsphere/test/e2e/engine/dal/BaseDALE2EIT.java
@@ -20,6 +20,7 @@ package org.apache.shardingsphere.test.e2e.engine.dal;
import org.apache.shardingsphere.test.e2e.cases.dataset.metadata.DataSetColumn;
import org.apache.shardingsphere.test.e2e.cases.dataset.metadata.DataSetMetaData;
import org.apache.shardingsphere.test.e2e.cases.dataset.row.DataSetRow;
+import org.apache.shardingsphere.test.e2e.engine.E2EContainerComposer;
import org.apache.shardingsphere.test.e2e.engine.SingleE2EIT;
import org.apache.shardingsphere.test.e2e.framework.param.model.AssertionTestParameter;
@@ -88,7 +89,7 @@ public abstract class BaseDALE2EIT extends SingleE2EIT {
}
private void assertDateValue(final ResultSet actual, final int columnIndex, final String columnLabel, final String expected) throws SQLException {
- if (NOT_VERIFY_FLAG.equals(expected)) {
+ if (E2EContainerComposer.NOT_VERIFY_FLAG.equals(expected)) {
return;
}
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
diff --git a/test/e2e/suite/src/test/java/org/apache/shardingsphere/test/e2e/engine/dal/GeneralDALE2EIT.java b/test/e2e/suite/src/test/java/org/apache/shardingsphere/test/e2e/engine/dal/GeneralDALE2EIT.java
index db2daee79b9..c55ab33c827 100644
--- a/test/e2e/suite/src/test/java/org/apache/shardingsphere/test/e2e/engine/dal/GeneralDALE2EIT.java
+++ b/test/e2e/suite/src/test/java/org/apache/shardingsphere/test/e2e/engine/dal/GeneralDALE2EIT.java
@@ -46,7 +46,7 @@ public final class GeneralDALE2EIT extends BaseDALE2EIT {
@Test
public void assertExecute() throws SQLException, ParseException {
- try (Connection connection = getTargetDataSource().getConnection()) {
+ try (Connection connection = getContainerComposer().getTargetDataSource().getConnection()) {
try (Statement statement = connection.createStatement()) {
statement.execute(getSQL());
assertExecuteResult(statement);
diff --git a/test/e2e/suite/src/test/java/org/apache/shardingsphere/test/e2e/engine/dcl/BaseDCLE2EIT.java b/test/e2e/suite/src/test/java/org/apache/shardingsphere/test/e2e/engine/dcl/BaseDCLE2EIT.java
index 1e537f1bf31..4bb27f258f7 100644
--- a/test/e2e/suite/src/test/java/org/apache/shardingsphere/test/e2e/engine/dcl/BaseDCLE2EIT.java
+++ b/test/e2e/suite/src/test/java/org/apache/shardingsphere/test/e2e/engine/dcl/BaseDCLE2EIT.java
@@ -34,7 +34,8 @@ public abstract class BaseDCLE2EIT extends SingleE2EIT {
@Before
public final void init() throws Exception {
- authorityEnvironmentManager = new AuthorityEnvironmentManager(new ScenarioCommonPath(getScenario()).getAuthorityFile(), getActualDataSourceMap(), getDatabaseType());
+ authorityEnvironmentManager = new AuthorityEnvironmentManager(
+ new ScenarioCommonPath(getTestParam().getScenario()).getAuthorityFile(), getContainerComposer().getActualDataSourceMap(), getTestParam().getDatabaseType());
authorityEnvironmentManager.initialize();
}
diff --git a/test/e2e/suite/src/test/java/org/apache/shardingsphere/test/e2e/engine/dcl/GeneralDCLE2EIT.java b/test/e2e/suite/src/test/java/org/apache/shardingsphere/test/e2e/engine/dcl/GeneralDCLE2EIT.java
index 55db7bf93fd..a83bacb692a 100644
--- a/test/e2e/suite/src/test/java/org/apache/shardingsphere/test/e2e/engine/dcl/GeneralDCLE2EIT.java
+++ b/test/e2e/suite/src/test/java/org/apache/shardingsphere/test/e2e/engine/dcl/GeneralDCLE2EIT.java
@@ -48,7 +48,7 @@ public final class GeneralDCLE2EIT extends BaseDCLE2EIT {
@Test
public void assertExecuteUpdate() throws SQLException, ParseException {
String sql = getSQL();
- try (Connection connection = getTargetDataSource().getConnection()) {
+ try (Connection connection = getContainerComposer().getTargetDataSource().getConnection()) {
if (SQLExecuteType.Literal == getSqlExecuteType()) {
try (Statement statement = connection.createStatement()) {
statement.executeUpdate(sql);
@@ -64,7 +64,7 @@ public final class GeneralDCLE2EIT extends BaseDCLE2EIT {
@Test
public void assertExecute() throws SQLException, ParseException {
String sql = getSQL();
- try (Connection connection = getTargetDataSource().getConnection()) {
+ try (Connection connection = getContainerComposer().getTargetDataSource().getConnection()) {
if (SQLExecuteType.Literal == getSqlExecuteType()) {
try (Statement statement = connection.createStatement()) {
statement.execute(sql);
diff --git a/test/e2e/suite/src/test/java/org/apache/shardingsphere/test/e2e/engine/ddl/BaseDDLE2EIT.java b/test/e2e/suite/src/test/java/org/apache/shardingsphere/test/e2e/engine/ddl/BaseDDLE2EIT.java
index 9d65c1430d0..31e23a39967 100644
--- a/test/e2e/suite/src/test/java/org/apache/shardingsphere/test/e2e/engine/ddl/BaseDDLE2EIT.java
+++ b/test/e2e/suite/src/test/java/org/apache/shardingsphere/test/e2e/engine/ddl/BaseDDLE2EIT.java
@@ -57,7 +57,7 @@ public abstract class BaseDDLE2EIT extends SingleE2EIT {
public final void init() throws Exception {
assertNotNull(getAssertion().getInitialSQL(), "Init SQL is required");
assertNotNull(getAssertion().getInitialSQL().getAffectedTable(), "Expected affected table is required");
- try (Connection connection = getTargetDataSource().getConnection()) {
+ try (Connection connection = getContainerComposer().getTargetDataSource().getConnection()) {
executeInitSQLs(connection);
}
}
@@ -77,7 +77,7 @@ public abstract class BaseDDLE2EIT extends SingleE2EIT {
@After
public final void tearDown() throws SQLException {
if (null != getAssertion().getDestroySQL()) {
- try (Connection connection = getTargetDataSource().getConnection()) {
+ try (Connection connection = getContainerComposer().getTargetDataSource().getConnection()) {
executeDestroySQLs(connection);
}
}
@@ -113,7 +113,7 @@ public abstract class BaseDDLE2EIT extends SingleE2EIT {
private void assertNotContainsTable(final Collection<DataNode> dataNodes) throws SQLException {
for (DataNode each : dataNodes) {
- try (Connection connection = getActualDataSourceMap().get(each.getDataSourceName()).getConnection()) {
+ try (Connection connection = getContainerComposer().getActualDataSourceMap().get(each.getDataSourceName()).getConnection()) {
assertNotContainsTable(connection, each.getTableName());
}
}
@@ -126,7 +126,7 @@ public abstract class BaseDDLE2EIT extends SingleE2EIT {
private List<DataSetColumn> getActualColumns(final Collection<DataNode> dataNodes) throws SQLException {
Set<DataSetColumn> result = new LinkedHashSet<>();
for (DataNode each : dataNodes) {
- try (Connection connection = getActualDataSourceMap().get(each.getDataSourceName()).getConnection()) {
+ try (Connection connection = getContainerComposer().getActualDataSourceMap().get(each.getDataSourceName()).getConnection()) {
result.addAll(getActualColumns(connection, each.getTableName()));
}
}
@@ -151,7 +151,7 @@ public abstract class BaseDDLE2EIT extends SingleE2EIT {
private List<DataSetIndex> getActualIndexes(final Collection<DataNode> dataNodes) throws SQLException {
Set<DataSetIndex> result = new LinkedHashSet<>();
for (DataNode each : dataNodes) {
- try (Connection connection = getActualDataSourceMap().get(each.getDataSourceName()).getConnection()) {
+ try (Connection connection = getContainerComposer().getActualDataSourceMap().get(each.getDataSourceName()).getConnection()) {
result.addAll(getActualIndexes(connection, each.getTableName()));
}
}
@@ -182,11 +182,11 @@ public abstract class BaseDDLE2EIT extends SingleE2EIT {
private void assertColumnMetaData(final DataSetColumn actual, final DataSetColumn expected) {
assertThat("Mismatched column name.", actual.getName(), is(expected.getName()));
- if ("MySQL".equals(getDatabaseType().getType()) && "integer".equals(expected.getType())) {
+ if ("MySQL".equals(getTestParam().getDatabaseType().getType()) && "integer".equals(expected.getType())) {
assertThat("Mismatched column type.", actual.getType(), is("int"));
- } else if ("PostgreSQL".equals(getDatabaseType().getType()) && "integer".equals(expected.getType())) {
+ } else if ("PostgreSQL".equals(getTestParam().getDatabaseType().getType()) && "integer".equals(expected.getType())) {
assertThat("Mismatched column type.", actual.getType(), is("int4"));
- } else if ("openGauss".equals(getDatabaseType().getType()) && "integer".equals(expected.getType())) {
+ } else if ("openGauss".equals(getTestParam().getDatabaseType().getType()) && "integer".equals(expected.getType())) {
assertThat("Mismatched column type.", actual.getType(), is("int4"));
} else {
assertThat("Mismatched column type.", actual.getType(), is(expected.getType()));
diff --git a/test/e2e/suite/src/test/java/org/apache/shardingsphere/test/e2e/engine/ddl/GeneralDDLE2EIT.java b/test/e2e/suite/src/test/java/org/apache/shardingsphere/test/e2e/engine/ddl/GeneralDDLE2EIT.java
index 520f9263502..b945465dd94 100644
--- a/test/e2e/suite/src/test/java/org/apache/shardingsphere/test/e2e/engine/ddl/GeneralDDLE2EIT.java
+++ b/test/e2e/suite/src/test/java/org/apache/shardingsphere/test/e2e/engine/ddl/GeneralDDLE2EIT.java
@@ -49,7 +49,7 @@ public final class GeneralDDLE2EIT extends BaseDDLE2EIT {
@Test
public void assertExecuteUpdate() throws SQLException, ParseException {
- try (Connection connection = getTargetDataSource().getConnection()) {
+ try (Connection connection = getContainerComposer().getTargetDataSource().getConnection()) {
if (SQLExecuteType.Literal == getSqlExecuteType()) {
executeUpdateForStatement(connection);
} else {
@@ -75,7 +75,7 @@ public final class GeneralDDLE2EIT extends BaseDDLE2EIT {
@Test
public void assertExecute() throws SQLException, ParseException {
- try (Connection connection = getTargetDataSource().getConnection()) {
+ try (Connection connection = getContainerComposer().getTargetDataSource().getConnection()) {
if (SQLExecuteType.Literal == getSqlExecuteType()) {
executeForStatement(connection);
} else {
diff --git a/test/e2e/suite/src/test/java/org/apache/shardingsphere/test/e2e/engine/dml/AdditionalDMLE2EIT.java b/test/e2e/suite/src/test/java/org/apache/shardingsphere/test/e2e/engine/dml/AdditionalDMLE2EIT.java
index f985dbbb0c5..9268973e361 100644
--- a/test/e2e/suite/src/test/java/org/apache/shardingsphere/test/e2e/engine/dml/AdditionalDMLE2EIT.java
+++ b/test/e2e/suite/src/test/java/org/apache/shardingsphere/test/e2e/engine/dml/AdditionalDMLE2EIT.java
@@ -56,11 +56,11 @@ public final class AdditionalDMLE2EIT extends BaseDMLE2EIT {
@Test
public void executeUpdateWithAutoGeneratedKeys() throws SQLException, ParseException {
- if (isPostgreSQLOrOpenGauss(getDatabaseType().getType())) {
+ if (isPostgreSQLOrOpenGauss(getTestParam().getDatabaseType().getType())) {
return;
}
int actualUpdateCount;
- try (Connection connection = getTargetDataSource().getConnection()) {
+ try (Connection connection = getContainerComposer().getTargetDataSource().getConnection()) {
actualUpdateCount = SQLExecuteType.Literal == getSqlExecuteType()
? executeUpdateForStatementWithAutoGeneratedKeys(connection)
: executeUpdateForPreparedStatementWithAutoGeneratedKeys(connection);
@@ -95,11 +95,11 @@ public final class AdditionalDMLE2EIT extends BaseDMLE2EIT {
@Ignore
// TODO support execute update with column indexes in #23626
public void assertExecuteUpdateWithColumnIndexes() throws SQLException, ParseException {
- if (isPostgreSQLOrOpenGauss(getDatabaseType().getType())) {
+ if (isPostgreSQLOrOpenGauss(getTestParam().getDatabaseType().getType())) {
return;
}
int actualUpdateCount;
- try (Connection connection = getTargetDataSource().getConnection()) {
+ try (Connection connection = getContainerComposer().getTargetDataSource().getConnection()) {
actualUpdateCount = SQLExecuteType.Literal == getSqlExecuteType() ? executeUpdateForStatementWithColumnIndexes(connection) : executeUpdateForPreparedStatementWithColumnIndexes(connection);
}
assertDataSet(actualUpdateCount);
@@ -124,11 +124,11 @@ public final class AdditionalDMLE2EIT extends BaseDMLE2EIT {
@Ignore
// TODO support execute update with column names in #23626
public void assertExecuteUpdateWithColumnNames() throws SQLException, ParseException {
- if (isPostgreSQLOrOpenGauss(getDatabaseType().getType())) {
+ if (isPostgreSQLOrOpenGauss(getTestParam().getDatabaseType().getType())) {
return;
}
int actualUpdateCount;
- try (Connection connection = getTargetDataSource().getConnection()) {
+ try (Connection connection = getContainerComposer().getTargetDataSource().getConnection()) {
actualUpdateCount = SQLExecuteType.Literal == getSqlExecuteType() ? executeUpdateForStatementWithColumnNames(connection) : executeUpdateForPreparedStatementWithColumnNames(connection);
}
assertDataSet(actualUpdateCount);
@@ -151,11 +151,11 @@ public final class AdditionalDMLE2EIT extends BaseDMLE2EIT {
@Test
public void assertExecuteWithoutAutoGeneratedKeys() throws SQLException, ParseException {
- if (isPostgreSQLOrOpenGauss(getDatabaseType().getType())) {
+ if (isPostgreSQLOrOpenGauss(getTestParam().getDatabaseType().getType())) {
return;
}
int actualUpdateCount;
- try (Connection connection = getTargetDataSource().getConnection()) {
+ try (Connection connection = getContainerComposer().getTargetDataSource().getConnection()) {
actualUpdateCount = SQLExecuteType.Literal == getSqlExecuteType()
? executeForStatementWithoutAutoGeneratedKeys(connection)
: executeForPreparedStatementWithoutAutoGeneratedKeys(connection);
@@ -182,11 +182,11 @@ public final class AdditionalDMLE2EIT extends BaseDMLE2EIT {
@Test
public void assertExecuteWithAutoGeneratedKeys() throws SQLException, ParseException {
- if (isPostgreSQLOrOpenGauss(getDatabaseType().getType())) {
+ if (isPostgreSQLOrOpenGauss(getTestParam().getDatabaseType().getType())) {
return;
}
int actualUpdateCount;
- try (Connection connection = getTargetDataSource().getConnection()) {
+ try (Connection connection = getContainerComposer().getTargetDataSource().getConnection()) {
actualUpdateCount = SQLExecuteType.Literal == getSqlExecuteType() ? executeForStatementWithAutoGeneratedKeys(connection) : executeForPreparedStatementWithAutoGeneratedKeys(connection);
}
assertDataSet(actualUpdateCount);
@@ -215,11 +215,11 @@ public final class AdditionalDMLE2EIT extends BaseDMLE2EIT {
@Ignore
// TODO support execute with column indexes in #23626
public void assertExecuteWithColumnIndexes() throws SQLException, ParseException {
- if (isPostgreSQLOrOpenGauss(getDatabaseType().getType())) {
+ if (isPostgreSQLOrOpenGauss(getTestParam().getDatabaseType().getType())) {
return;
}
int actualUpdateCount;
- try (Connection connection = getTargetDataSource().getConnection()) {
+ try (Connection connection = getContainerComposer().getTargetDataSource().getConnection()) {
actualUpdateCount = SQLExecuteType.Literal == getSqlExecuteType() ? executeForStatementWithColumnIndexes(connection) : executeForPreparedStatementWithColumnIndexes(connection);
}
assertDataSet(actualUpdateCount);
@@ -246,11 +246,11 @@ public final class AdditionalDMLE2EIT extends BaseDMLE2EIT {
@Ignore
// TODO support execute with column names in #23626
public void assertExecuteWithColumnNames() throws SQLException, ParseException {
- if (isPostgreSQLOrOpenGauss(getDatabaseType().getType())) {
+ if (isPostgreSQLOrOpenGauss(getTestParam().getDatabaseType().getType())) {
return;
}
int actualUpdateCount;
- try (Connection connection = getTargetDataSource().getConnection()) {
+ try (Connection connection = getContainerComposer().getTargetDataSource().getConnection()) {
actualUpdateCount = SQLExecuteType.Literal == getSqlExecuteType() ? executeForStatementWithColumnNames(connection) : executeForPreparedStatementWithColumnNames(connection);
}
assertDataSet(actualUpdateCount);
diff --git a/test/e2e/suite/src/test/java/org/apache/shardingsphere/test/e2e/engine/dml/BaseDMLE2EIT.java b/test/e2e/suite/src/test/java/org/apache/shardingsphere/test/e2e/engine/dml/BaseDMLE2EIT.java
index 43a91e1bd76..d3a4c0d0819 100644
--- a/test/e2e/suite/src/test/java/org/apache/shardingsphere/test/e2e/engine/dml/BaseDMLE2EIT.java
+++ b/test/e2e/suite/src/test/java/org/apache/shardingsphere/test/e2e/engine/dml/BaseDMLE2EIT.java
@@ -22,6 +22,7 @@ import org.apache.shardingsphere.infra.util.expr.InlineExpressionParser;
import org.apache.shardingsphere.test.e2e.cases.dataset.metadata.DataSetColumn;
import org.apache.shardingsphere.test.e2e.cases.dataset.metadata.DataSetMetaData;
import org.apache.shardingsphere.test.e2e.cases.dataset.row.DataSetRow;
+import org.apache.shardingsphere.test.e2e.engine.E2EContainerComposer;
import org.apache.shardingsphere.test.e2e.engine.SingleE2EIT;
import org.apache.shardingsphere.test.e2e.env.DataSetEnvironmentManager;
import org.apache.shardingsphere.test.e2e.env.runtime.scenario.path.ScenarioDataPath;
@@ -60,7 +61,7 @@ public abstract class BaseDMLE2EIT extends SingleE2EIT {
@Before
public final void init() throws Exception {
- dataSetEnvironmentManager = new DataSetEnvironmentManager(new ScenarioDataPath(getScenario()).getDataSetFile(Type.ACTUAL), getActualDataSourceMap());
+ dataSetEnvironmentManager = new DataSetEnvironmentManager(new ScenarioDataPath(getTestParam().getScenario()).getDataSetFile(Type.ACTUAL), getContainerComposer().getActualDataSourceMap());
dataSetEnvironmentManager.fillData();
}
@@ -75,7 +76,7 @@ public abstract class BaseDMLE2EIT extends SingleE2EIT {
DataSetMetaData expectedDataSetMetaData = getDataSet().getMetaDataList().get(0);
for (String each : new InlineExpressionParser(expectedDataSetMetaData.getDataNodes()).splitAndEvaluate()) {
DataNode dataNode = new DataNode(each);
- DataSource dataSource = getActualDataSourceMap().get(dataNode.getDataSourceName());
+ DataSource dataSource = getContainerComposer().getActualDataSourceMap().get(dataNode.getDataSourceName());
try (
Connection connection = dataSource.getConnection();
PreparedStatement preparedStatement = connection.prepareStatement(generateFetchActualDataSQL(dataNode))) {
@@ -92,9 +93,10 @@ public abstract class BaseDMLE2EIT extends SingleE2EIT {
}
private String generateFetchActualDataSQL(final DataNode dataNode) throws SQLException {
- Optional<DatabaseAssertionMetaData> databaseAssertionMetaData = DatabaseAssertionMetaDataFactory.newInstance(getDatabaseType());
+ Optional<DatabaseAssertionMetaData> databaseAssertionMetaData = DatabaseAssertionMetaDataFactory.newInstance(getTestParam().getDatabaseType());
if (databaseAssertionMetaData.isPresent()) {
- String primaryKeyColumnName = databaseAssertionMetaData.get().getPrimaryKeyColumnName(getActualDataSourceMap().get(dataNode.getDataSourceName()), dataNode.getTableName());
+ String primaryKeyColumnName = databaseAssertionMetaData.get().getPrimaryKeyColumnName(
+ getContainerComposer().getActualDataSourceMap().get(dataNode.getDataSourceName()), dataNode.getTableName());
return String.format("SELECT * FROM %s ORDER BY %s ASC", dataNode.getTableName(), primaryKeyColumnName);
}
return String.format("SELECT * FROM %s", dataNode.getTableName());
@@ -123,10 +125,11 @@ public abstract class BaseDMLE2EIT extends SingleE2EIT {
private void assertValue(final ResultSet actual, final int columnIndex, final String expected) throws SQLException {
if (Types.DATE == actual.getMetaData().getColumnType(columnIndex)) {
- if (!NOT_VERIFY_FLAG.equals(expected)) {
+ if (!E2EContainerComposer.NOT_VERIFY_FLAG.equals(expected)) {
assertThat(new SimpleDateFormat("yyyy-MM-dd").format(actual.getDate(columnIndex)), is(expected));
}
- } else if (Types.CHAR == actual.getMetaData().getColumnType(columnIndex) && ("PostgreSQL".equals(getDatabaseType().getType()) || "openGauss".equals(getDatabaseType().getType()))) {
+ } else if (Types.CHAR == actual.getMetaData().getColumnType(columnIndex)
+ && ("PostgreSQL".equals(getTestParam().getDatabaseType().getType()) || "openGauss".equals(getTestParam().getDatabaseType().getType()))) {
assertThat(String.valueOf(actual.getObject(columnIndex)).trim(), is(expected));
} else if (isPostgreSQLOrOpenGaussMoney(actual.getMetaData().getColumnTypeName(columnIndex))) {
assertThat(actual.getString(columnIndex), is(expected));
@@ -138,7 +141,7 @@ public abstract class BaseDMLE2EIT extends SingleE2EIT {
}
private boolean isPostgreSQLOrOpenGaussMoney(final String columnTypeName) {
- return "money".equalsIgnoreCase(columnTypeName) && ("PostgreSQL".equals(getDatabaseType().getType()) || "openGauss".equals(getDatabaseType().getType()));
+ return "money".equalsIgnoreCase(columnTypeName) && ("PostgreSQL".equals(getTestParam().getDatabaseType().getType()) || "openGauss".equals(getTestParam().getDatabaseType().getType()));
}
protected void assertGeneratedKeys(final ResultSet generatedKeys) throws SQLException {
diff --git a/test/e2e/suite/src/test/java/org/apache/shardingsphere/test/e2e/engine/dml/BatchDMLE2EIT.java b/test/e2e/suite/src/test/java/org/apache/shardingsphere/test/e2e/engine/dml/BatchDMLE2EIT.java
index f40ef245a4a..4f6b3d41d5f 100644
--- a/test/e2e/suite/src/test/java/org/apache/shardingsphere/test/e2e/engine/dml/BatchDMLE2EIT.java
+++ b/test/e2e/suite/src/test/java/org/apache/shardingsphere/test/e2e/engine/dml/BatchDMLE2EIT.java
@@ -29,6 +29,8 @@ import org.apache.shardingsphere.test.e2e.framework.runner.ParallelRunningStrate
import org.junit.Test;
import org.junit.runners.Parameterized.Parameters;
+import javax.xml.bind.JAXBException;
+import java.io.IOException;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;
@@ -41,7 +43,7 @@ import static org.hamcrest.MatcherAssert.assertThat;
@ParallelRunningStrategy(ParallelLevel.SCENARIO)
public final class BatchDMLE2EIT extends BatchE2EIT {
- public BatchDMLE2EIT(final CaseTestParameter testParam) {
+ public BatchDMLE2EIT(final CaseTestParameter testParam) throws SQLException, JAXBException, IOException, ParseException {
super(testParam);
}
@@ -53,15 +55,15 @@ public final class BatchDMLE2EIT extends BatchE2EIT {
@Test
public void assertExecuteBatch() throws SQLException, ParseException {
int[] actualUpdateCounts;
- try (Connection connection = getTargetDataSource().getConnection()) {
+ try (Connection connection = getContainerComposer().getTargetDataSource().getConnection()) {
actualUpdateCounts = executeBatchForPreparedStatement(connection);
}
assertDataSets(actualUpdateCounts);
}
private int[] executeBatchForPreparedStatement(final Connection connection) throws SQLException, ParseException {
- try (PreparedStatement preparedStatement = connection.prepareStatement(getItCase().getSql())) {
- for (IntegrationTestCaseAssertion each : getItCase().getAssertions()) {
+ try (PreparedStatement preparedStatement = connection.prepareStatement(getTestParam().getTestCaseContext().getTestCase().getSql())) {
+ for (IntegrationTestCaseAssertion each : getTestParam().getTestCaseContext().getTestCase().getAssertions()) {
addBatch(preparedStatement, each);
}
return preparedStatement.executeBatch();
@@ -78,9 +80,9 @@ public final class BatchDMLE2EIT extends BatchE2EIT {
@Test
public void assertClearBatch() throws SQLException, ParseException {
try (
- Connection connection = getTargetDataSource().getConnection();
- PreparedStatement preparedStatement = connection.prepareStatement(getItCase().getSql())) {
- for (IntegrationTestCaseAssertion each : getItCase().getAssertions()) {
+ Connection connection = getContainerComposer().getTargetDataSource().getConnection();
+ PreparedStatement preparedStatement = connection.prepareStatement(getTestParam().getTestCaseContext().getTestCase().getSql())) {
+ for (IntegrationTestCaseAssertion each : getTestParam().getTestCaseContext().getTestCase().getAssertions()) {
addBatch(preparedStatement, each);
}
preparedStatement.clearBatch();
diff --git a/test/e2e/suite/src/test/java/org/apache/shardingsphere/test/e2e/engine/dml/GeneralDMLE2EIT.java b/test/e2e/suite/src/test/java/org/apache/shardingsphere/test/e2e/engine/dml/GeneralDMLE2EIT.java
index b01fa61178d..84c91f467fc 100644
--- a/test/e2e/suite/src/test/java/org/apache/shardingsphere/test/e2e/engine/dml/GeneralDMLE2EIT.java
+++ b/test/e2e/suite/src/test/java/org/apache/shardingsphere/test/e2e/engine/dml/GeneralDMLE2EIT.java
@@ -51,7 +51,7 @@ public final class GeneralDMLE2EIT extends BaseDMLE2EIT {
@Test
public void assertExecuteUpdate() throws SQLException, ParseException {
int actualUpdateCount;
- try (Connection connection = getTargetDataSource().getConnection()) {
+ try (Connection connection = getContainerComposer().getTargetDataSource().getConnection()) {
actualUpdateCount = SQLExecuteType.Literal == getSqlExecuteType() ? executeUpdateForStatement(connection) : executeUpdateForPreparedStatement(connection);
}
assertDataSet(actualUpdateCount);
@@ -75,7 +75,7 @@ public final class GeneralDMLE2EIT extends BaseDMLE2EIT {
@Test
public void assertExecute() throws SQLException, ParseException {
int actualUpdateCount;
- try (Connection connection = getTargetDataSource().getConnection()) {
+ try (Connection connection = getContainerComposer().getTargetDataSource().getConnection()) {
actualUpdateCount = SQLExecuteType.Literal == getSqlExecuteType() ? executeForStatement(connection) : executeForPreparedStatement(connection);
}
assertDataSet(actualUpdateCount);
diff --git a/test/e2e/suite/src/test/java/org/apache/shardingsphere/test/e2e/engine/dql/AdditionalDQLE2EIT.java b/test/e2e/suite/src/test/java/org/apache/shardingsphere/test/e2e/engine/dql/AdditionalDQLE2EIT.java
index 5d8902f6234..ae24b5ade8c 100644
--- a/test/e2e/suite/src/test/java/org/apache/shardingsphere/test/e2e/engine/dql/AdditionalDQLE2EIT.java
+++ b/test/e2e/suite/src/test/java/org/apache/shardingsphere/test/e2e/engine/dql/AdditionalDQLE2EIT.java
@@ -54,7 +54,7 @@ public final class AdditionalDQLE2EIT extends BaseDQLE2EIT {
@Test
public void assertExecuteQueryWithResultSetTypeAndResultSetConcurrency() throws SQLException, ParseException {
// TODO fix e2e test blocked exception with PostgreSQL or openGuass in #23643
- if (isPostgreSQLOrOpenGauss(getDatabaseType().getType())) {
+ if (isPostgreSQLOrOpenGauss(getTestParam().getDatabaseType().getType())) {
return;
}
if (isUseXMLAsExpectedDataset()) {
@@ -67,7 +67,7 @@ public final class AdditionalDQLE2EIT extends BaseDQLE2EIT {
@Test
public void assertExecuteQueryWithResultSetTypeAndResultSetConcurrencyAndResultSetHoldability() throws SQLException, ParseException {
// TODO fix e2e test blocked exception with PostgreSQL or openGuass in #23643
- if (isPostgreSQLOrOpenGauss(getDatabaseType().getType())) {
+ if (isPostgreSQLOrOpenGauss(getTestParam().getDatabaseType().getType())) {
return;
}
if (isUseXMLAsExpectedDataset()) {
@@ -80,7 +80,7 @@ public final class AdditionalDQLE2EIT extends BaseDQLE2EIT {
@Test
public void assertExecuteWithResultSetTypeAndResultSetConcurrency() throws SQLException, ParseException {
// TODO fix e2e test blocked exception with PostgreSQL or openGuass in #23643
- if (isPostgreSQLOrOpenGauss(getDatabaseType().getType())) {
+ if (isPostgreSQLOrOpenGauss(getTestParam().getDatabaseType().getType())) {
return;
}
if (isUseXMLAsExpectedDataset()) {
@@ -93,7 +93,7 @@ public final class AdditionalDQLE2EIT extends BaseDQLE2EIT {
@Test
public void assertExecuteWithResultSetTypeAndResultSetConcurrencyAndResultSetHoldability() throws SQLException, ParseException {
// TODO fix e2e test blocked exception with PostgreSQL or openGuass in #23643
- if (isPostgreSQLOrOpenGauss(getDatabaseType().getType())) {
+ if (isPostgreSQLOrOpenGauss(getTestParam().getDatabaseType().getType())) {
return;
}
if (isUseXMLAsExpectedDataset()) {
@@ -113,7 +113,7 @@ public final class AdditionalDQLE2EIT extends BaseDQLE2EIT {
return;
}
try (
- Connection connection = getTargetDataSource().getConnection();
+ Connection connection = getContainerComposer().getTargetDataSource().getConnection();
Statement statement = 2 == resultSetTypes.length ? connection.createStatement(resultSetTypes[0], resultSetTypes[1])
: connection.createStatement(resultSetTypes[0], resultSetTypes[1], resultSetTypes[2]);
ResultSet resultSet = statement.executeQuery(getSQL())) {
@@ -123,7 +123,7 @@ public final class AdditionalDQLE2EIT extends BaseDQLE2EIT {
private void assertExecuteQueryWithExpectedDataSource(final int... resultSetTypes) throws SQLException, ParseException {
try (
- Connection actualConnection = getTargetDataSource().getConnection();
+ Connection actualConnection = getContainerComposer().getTargetDataSource().getConnection();
Connection expectedConnection = getExpectedDataSource().getConnection()) {
if (SQLExecuteType.Literal == getSqlExecuteType()) {
assertExecuteQueryForStatementWithResultSetTypes(actualConnection, expectedConnection, resultSetTypes);
@@ -172,7 +172,7 @@ public final class AdditionalDQLE2EIT extends BaseDQLE2EIT {
return;
}
try (
- Connection connection = getTargetDataSource().getConnection();
+ Connection connection = getContainerComposer().getTargetDataSource().getConnection();
Statement statement = 2 == resultSetTypes.length ? connection.createStatement(resultSetTypes[0], resultSetTypes[1])
: connection.createStatement(resultSetTypes[0], resultSetTypes[1], resultSetTypes[2])) {
assertTrue(statement.execute(getSQL()), "Not a query statement.");
@@ -183,7 +183,7 @@ public final class AdditionalDQLE2EIT extends BaseDQLE2EIT {
private void assertExecuteWithExpectedDataSource(final int... resultSetTypes) throws SQLException, ParseException {
try (
- Connection actualConnection = getTargetDataSource().getConnection();
+ Connection actualConnection = getContainerComposer().getTargetDataSource().getConnection();
Connection expectedConnection = getExpectedDataSource().getConnection()) {
if (SQLExecuteType.Literal == getSqlExecuteType()) {
assertExecuteForStatementWithResultSetTypes(actualConnection, expectedConnection, resultSetTypes);
diff --git a/test/e2e/suite/src/test/java/org/apache/shardingsphere/test/e2e/engine/dql/BaseDQLE2EIT.java b/test/e2e/suite/src/test/java/org/apache/shardingsphere/test/e2e/engine/dql/BaseDQLE2EIT.java
index 5c1d1e9a1b0..9e646c3c33a 100644
--- a/test/e2e/suite/src/test/java/org/apache/shardingsphere/test/e2e/engine/dql/BaseDQLE2EIT.java
+++ b/test/e2e/suite/src/test/java/org/apache/shardingsphere/test/e2e/engine/dql/BaseDQLE2EIT.java
@@ -67,19 +67,19 @@ public abstract class BaseDQLE2EIT extends SingleE2EIT {
@Before
public final void init() throws Exception {
fillDataOnlyOnce();
- expectedDataSource = null == getAssertion().getExpectedDataSourceName() || 1 == getExpectedDataSourceMap().size()
- ? getExpectedDataSourceMap().values().iterator().next()
- : getExpectedDataSourceMap().get(getAssertion().getExpectedDataSourceName());
+ expectedDataSource = null == getAssertion().getExpectedDataSourceName() || 1 == getContainerComposer().getExpectedDataSourceMap().size()
+ ? getContainerComposer().getExpectedDataSourceMap().values().iterator().next()
+ : getContainerComposer().getExpectedDataSourceMap().get(getAssertion().getExpectedDataSourceName());
useXMLAsExpectedDataset = null != getAssertion().getExpectedDataFile();
}
private void fillDataOnlyOnce() throws SQLException, ParseException, IOException, JAXBException {
- if (!FILLED_SUITES.contains(getItKey())) {
+ if (!FILLED_SUITES.contains(getTestParam().getKey())) {
synchronized (FILLED_SUITES) {
- if (!FILLED_SUITES.contains(getItKey())) {
- new DataSetEnvironmentManager(new ScenarioDataPath(getScenario()).getDataSetFile(Type.ACTUAL), getActualDataSourceMap()).fillData();
- new DataSetEnvironmentManager(new ScenarioDataPath(getScenario()).getDataSetFile(Type.EXPECTED), getExpectedDataSourceMap()).fillData();
- FILLED_SUITES.add(getItKey());
+ if (!FILLED_SUITES.contains(getTestParam().getKey())) {
+ new DataSetEnvironmentManager(new ScenarioDataPath(getTestParam().getScenario()).getDataSetFile(Type.ACTUAL), getContainerComposer().getActualDataSourceMap()).fillData();
+ new DataSetEnvironmentManager(new ScenarioDataPath(getTestParam().getScenario()).getDataSetFile(Type.EXPECTED), getContainerComposer().getExpectedDataSourceMap()).fillData();
+ FILLED_SUITES.add(getTestParam().getKey());
}
}
}
diff --git a/test/e2e/suite/src/test/java/org/apache/shardingsphere/test/e2e/engine/dql/GeneralDQLE2EIT.java b/test/e2e/suite/src/test/java/org/apache/shardingsphere/test/e2e/engine/dql/GeneralDQLE2EIT.java
index dc924b3402c..fe06807a0a9 100644
--- a/test/e2e/suite/src/test/java/org/apache/shardingsphere/test/e2e/engine/dql/GeneralDQLE2EIT.java
+++ b/test/e2e/suite/src/test/java/org/apache/shardingsphere/test/e2e/engine/dql/GeneralDQLE2EIT.java
@@ -64,7 +64,7 @@ public final class GeneralDQLE2EIT extends BaseDQLE2EIT {
return;
}
try (
- Connection connection = getTargetDataSource().getConnection();
+ Connection connection = getContainerComposer().getTargetDataSource().getConnection();
Statement statement = connection.createStatement();
ResultSet resultSet = statement.executeQuery(getSQL())) {
assertResultSet(resultSet);
@@ -73,7 +73,7 @@ public final class GeneralDQLE2EIT extends BaseDQLE2EIT {
private void assertExecuteQueryWithExpectedDataSource() throws SQLException, ParseException {
try (
- Connection actualConnection = getTargetDataSource().getConnection();
+ Connection actualConnection = getContainerComposer().getTargetDataSource().getConnection();
Connection expectedConnection = getExpectedDataSource().getConnection()) {
if (SQLExecuteType.Literal == getSqlExecuteType()) {
assertExecuteQueryForStatement(actualConnection, expectedConnection);
@@ -124,7 +124,7 @@ public final class GeneralDQLE2EIT extends BaseDQLE2EIT {
return;
}
try (
- Connection connection = getTargetDataSource().getConnection();
+ Connection connection = getContainerComposer().getTargetDataSource().getConnection();
Statement statement = connection.createStatement()) {
assertTrue(statement.execute(getSQL()), "Not a query statement.");
ResultSet resultSet = statement.getResultSet();
@@ -134,7 +134,7 @@ public final class GeneralDQLE2EIT extends BaseDQLE2EIT {
private void assertExecuteWithExpectedDataSource() throws SQLException, ParseException {
try (
- Connection actualConnection = getTargetDataSource().getConnection();
+ Connection actualConnection = getContainerComposer().getTargetDataSource().getConnection();
Connection expectedConnection = getExpectedDataSource().getConnection()) {
if (SQLExecuteType.Literal == getSqlExecuteType()) {
assertExecuteForStatement(actualConnection, expectedConnection);
diff --git a/test/e2e/suite/src/test/java/org/apache/shardingsphere/test/e2e/engine/ral/BaseRALE2EIT.java b/test/e2e/suite/src/test/java/org/apache/shardingsphere/test/e2e/engine/ral/BaseRALE2EIT.java
index 41a0d9da909..e5f259d6866 100644
--- a/test/e2e/suite/src/test/java/org/apache/shardingsphere/test/e2e/engine/ral/BaseRALE2EIT.java
+++ b/test/e2e/suite/src/test/java/org/apache/shardingsphere/test/e2e/engine/ral/BaseRALE2EIT.java
@@ -50,7 +50,7 @@ public abstract class BaseRALE2EIT extends SingleE2EIT {
@Before
public final void init() throws Exception {
if (null != getAssertion().getInitialSQL()) {
- try (Connection connection = getTargetDataSource().getConnection()) {
+ try (Connection connection = getContainerComposer().getTargetDataSource().getConnection()) {
executeInitSQLs(connection);
}
}
@@ -59,7 +59,7 @@ public abstract class BaseRALE2EIT extends SingleE2EIT {
@After
public final void tearDown() throws Exception {
if (null != getAssertion().getDestroySQL()) {
- try (Connection connection = getTargetDataSource().getConnection()) {
+ try (Connection connection = getContainerComposer().getTargetDataSource().getConnection()) {
executeDestroySQLs(connection);
}
}
diff --git a/test/e2e/suite/src/test/java/org/apache/shardingsphere/test/e2e/engine/ral/GeneralRALE2EIT.java b/test/e2e/suite/src/test/java/org/apache/shardingsphere/test/e2e/engine/ral/GeneralRALE2EIT.java
index 87450addd0d..737ef4e5b5d 100644
--- a/test/e2e/suite/src/test/java/org/apache/shardingsphere/test/e2e/engine/ral/GeneralRALE2EIT.java
+++ b/test/e2e/suite/src/test/java/org/apache/shardingsphere/test/e2e/engine/ral/GeneralRALE2EIT.java
@@ -46,7 +46,7 @@ public final class GeneralRALE2EIT extends BaseRALE2EIT {
@Test
public void assertExecute() throws SQLException, ParseException {
- try (Connection connection = getTargetDataSource().getConnection()) {
+ try (Connection connection = getContainerComposer().getTargetDataSource().getConnection()) {
try (
Statement statement = connection.createStatement()) {
assertResultSet(statement);
diff --git a/test/e2e/suite/src/test/java/org/apache/shardingsphere/test/e2e/engine/rdl/BaseRDLE2EIT.java b/test/e2e/suite/src/test/java/org/apache/shardingsphere/test/e2e/engine/rdl/BaseRDLE2EIT.java
index 2df24048cfa..14e439f35c5 100644
--- a/test/e2e/suite/src/test/java/org/apache/shardingsphere/test/e2e/engine/rdl/BaseRDLE2EIT.java
+++ b/test/e2e/suite/src/test/java/org/apache/shardingsphere/test/e2e/engine/rdl/BaseRDLE2EIT.java
@@ -48,7 +48,7 @@ public abstract class BaseRDLE2EIT extends SingleE2EIT {
@Before
public final void init() throws Exception {
- try (Connection connection = getTargetDataSource().getConnection()) {
+ try (Connection connection = getContainerComposer().getTargetDataSource().getConnection()) {
executeInitSQLs(connection);
}
}
@@ -56,7 +56,7 @@ public abstract class BaseRDLE2EIT extends SingleE2EIT {
@After
public final void tearDown() throws Exception {
if (null != getAssertion().getDestroySQL()) {
- try (Connection connection = getTargetDataSource().getConnection()) {
+ try (Connection connection = getContainerComposer().getTargetDataSource().getConnection()) {
executeDestroySQLs(connection);
}
}
diff --git a/test/e2e/suite/src/test/java/org/apache/shardingsphere/test/e2e/engine/rdl/GeneralRDLE2EIT.java b/test/e2e/suite/src/test/java/org/apache/shardingsphere/test/e2e/engine/rdl/GeneralRDLE2EIT.java
index ed2b9b78994..a51b1fdaec1 100644
--- a/test/e2e/suite/src/test/java/org/apache/shardingsphere/test/e2e/engine/rdl/GeneralRDLE2EIT.java
+++ b/test/e2e/suite/src/test/java/org/apache/shardingsphere/test/e2e/engine/rdl/GeneralRDLE2EIT.java
@@ -49,7 +49,7 @@ public final class GeneralRDLE2EIT extends BaseRDLE2EIT {
@Test
public void assertExecute() throws SQLException, ParseException {
assertNotNull(getAssertion().getAssertionSQL(), "Assertion SQL is required");
- try (Connection connection = getTargetDataSource().getConnection()) {
+ try (Connection connection = getContainerComposer().getTargetDataSource().getConnection()) {
try (Statement statement = connection.createStatement()) {
executeSQLCase(statement);
sleep();
diff --git a/test/e2e/suite/src/test/java/org/apache/shardingsphere/test/e2e/engine/rql/GeneralRQLE2EIT.java b/test/e2e/suite/src/test/java/org/apache/shardingsphere/test/e2e/engine/rql/GeneralRQLE2EIT.java
index 7f5b7741c4e..3190e093cd3 100644
--- a/test/e2e/suite/src/test/java/org/apache/shardingsphere/test/e2e/engine/rql/GeneralRQLE2EIT.java
+++ b/test/e2e/suite/src/test/java/org/apache/shardingsphere/test/e2e/engine/rql/GeneralRQLE2EIT.java
@@ -46,7 +46,7 @@ public final class GeneralRQLE2EIT extends BaseRQLE2EIT {
@Test
public void assertExecute() throws SQLException, ParseException {
- try (Connection connection = getTargetDataSource().getConnection()) {
+ try (Connection connection = getContainerComposer().getTargetDataSource().getConnection()) {
try (
Statement statement = connection.createStatement();
ResultSet resultSet = statement.executeQuery(getSQL())) {