jingshanglu commented on code in PR #19293:
URL: https://github.com/apache/shardingsphere/pull/19293#discussion_r922946226


##########
shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-transaction/pom.xml:
##########
@@ -0,0 +1,159 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  ~ 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.
+  -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0"; 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 
http://maven.apache.org/xsd/maven-4.0.0.xsd";>
+    <modelVersion>4.0.0</modelVersion>
+    <parent>
+        <groupId>org.apache.shardingsphere</groupId>
+        <artifactId>shardingsphere-integration-test</artifactId>
+        <version>5.1.3-SNAPSHOT</version>
+    </parent>
+    <artifactId>shardingsphere-integration-test-transaction</artifactId>
+    <name>${project.artifactId}</name>
+    
+    <properties>
+        <maven.deploy.skip>true</maven.deploy.skip>
+        <atomikos.version>5.0.8</atomikos.version>
+    </properties>
+    
+    <dependencies>
+        <dependency>
+            <groupId>org.apache.shardingsphere</groupId>
+            <artifactId>shardingsphere-proxy-frontend-core</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+        
+        <dependency>
+            <groupId>org.apache.shardingsphere</groupId>
+            <artifactId>shardingsphere-proxy-bootstrap</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+        
+        <dependency>
+            <groupId>org.apache.shardingsphere</groupId>
+            <artifactId>shardingsphere-data-pipeline-core</artifactId>
+            <version>${project.version}</version>
+        </dependency>

Review Comment:
   Why do we need this dependency?



##########
shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-transaction/src/test/java/org/apache/shardingsphere/integration/transaction/engine/opengauss/OpenGaussProxyTransactionIT.java:
##########
@@ -0,0 +1,48 @@
+/*
+ * 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.
+ */
+
+package org.apache.shardingsphere.integration.transaction.engine.opengauss;
+
+import lombok.extern.slf4j.Slf4j;
+import 
org.apache.shardingsphere.integration.transaction.engine.base.BaseTransactionITCase;
+import 
org.apache.shardingsphere.integration.transaction.engine.mysql.MySQLJdbcTransactionIT;
+import 
org.apache.shardingsphere.integration.transaction.framework.param.TransactionParameterized;
+import org.junit.runners.Parameterized.Parameters;
+
+import java.sql.SQLException;
+import java.util.Collection;
+
+/**
+ * OpenGauss general transaction test case with proxy container, includes 
multiple cases.
+ */
+@Slf4j
+// @RunWith(Parameterized.class)

Review Comment:
   Do I need to uncomment here?



##########
shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-transaction/src/test/java/org/apache/shardingsphere/integration/transaction/engine/mysql/MySQLJdbcTransactionIT.java:
##########
@@ -0,0 +1,48 @@
+/*
+ * 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.
+ */
+
+package org.apache.shardingsphere.integration.transaction.engine.mysql;
+
+import lombok.extern.slf4j.Slf4j;
+import 
org.apache.shardingsphere.integration.transaction.engine.base.BaseTransactionITCase;
+import 
org.apache.shardingsphere.integration.transaction.framework.param.TransactionParameterized;
+import org.junit.runners.Parameterized.Parameters;
+
+import java.sql.SQLException;
+import java.util.Collection;
+
+/**
+ * MySQL general transaction test case with JDBC container, includes multiple 
cases.
+ */
+@Slf4j
+// @RunWith(Parameterized.class)

Review Comment:
   Do I need to uncomment here?



##########
shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-transaction/src/test/java/org/apache/shardingsphere/integration/transaction/framework/container/database/OpenGaussContainer.java:
##########
@@ -0,0 +1,81 @@
+/*
+ * 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.
+ */
+
+package 
org.apache.shardingsphere.integration.transaction.framework.container.database;
+
+import org.apache.commons.lang3.StringUtils;
+import org.apache.shardingsphere.infra.database.type.DatabaseType;
+import 
org.apache.shardingsphere.infra.database.type.dialect.OpenGaussDatabaseType;
+import 
org.apache.shardingsphere.integration.transaction.env.IntegrationTestEnvironment;
+import 
org.apache.shardingsphere.integration.transaction.env.enums.TransactionITEnvTypeEnum;
+import org.apache.shardingsphere.test.integration.env.DataSourceEnvironment;
+import 
org.apache.shardingsphere.test.integration.framework.container.wait.JDBCConnectionWaitStrategy;
+import org.testcontainers.containers.BindMode;
+
+import java.sql.DriverManager;
+
+/**
+ * OpenGauss container for Scaling IT.
+ */

Review Comment:
   Transaction?



##########
shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-transaction/pom.xml:
##########
@@ -0,0 +1,159 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  ~ 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.
+  -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0"; 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 
http://maven.apache.org/xsd/maven-4.0.0.xsd";>
+    <modelVersion>4.0.0</modelVersion>
+    <parent>
+        <groupId>org.apache.shardingsphere</groupId>
+        <artifactId>shardingsphere-integration-test</artifactId>
+        <version>5.1.3-SNAPSHOT</version>

Review Comment:
   Maybe `${project.version}` is better.



##########
shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-transaction/src/test/java/org/apache/shardingsphere/integration/transaction/engine/opengauss/OpenGaussJdbcTransactionIT.java:
##########
@@ -0,0 +1,49 @@
+/*
+ * 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.
+ */
+
+package org.apache.shardingsphere.integration.transaction.engine.opengauss;
+
+import lombok.extern.slf4j.Slf4j;
+import 
org.apache.shardingsphere.integration.transaction.engine.base.BaseTransactionITCase;
+import 
org.apache.shardingsphere.integration.transaction.engine.mysql.MySQLJdbcTransactionIT;
+import 
org.apache.shardingsphere.integration.transaction.framework.param.TransactionParameterized;
+import org.junit.runners.Parameterized.Parameters;
+
+import java.sql.SQLException;
+import java.util.Collection;
+
+/**
+ * OpenGauss general transaction test case with JDBC container, includes 
multiple cases.
+ */
+@Slf4j
+// @RunWith(Parameterized.class)

Review Comment:
   Do I need to uncomment here?



##########
shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-transaction/src/test/java/org/apache/shardingsphere/integration/transaction/engine/postgresql/PostgreSQLJdbcTransactionIT.java:
##########
@@ -0,0 +1,49 @@
+/*
+ * 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.
+ */
+
+package org.apache.shardingsphere.integration.transaction.engine.postgresql;
+
+import lombok.extern.slf4j.Slf4j;
+import 
org.apache.shardingsphere.integration.transaction.engine.base.BaseTransactionITCase;
+import 
org.apache.shardingsphere.integration.transaction.engine.mysql.MySQLJdbcTransactionIT;
+import 
org.apache.shardingsphere.integration.transaction.framework.param.TransactionParameterized;
+import org.junit.runners.Parameterized.Parameters;
+
+import java.sql.SQLException;
+import java.util.Collection;
+
+/**
+ * PostgreSQL general transaction test case with JDBC container, includes 
multiple cases.
+ */
+@Slf4j
+// @RunWith(Parameterized.class)

Review Comment:
   Do I need to uncomment here?



##########
shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-transaction/src/test/java/org/apache/shardingsphere/integration/transaction/framework/container/database/DatabaseContainer.java:
##########
@@ -0,0 +1,65 @@
+/*
+ * 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.
+ */
+
+package 
org.apache.shardingsphere.integration.transaction.framework.container.database;
+
+import lombok.Getter;
+import org.apache.shardingsphere.infra.database.type.DatabaseType;
+import 
org.apache.shardingsphere.test.integration.framework.container.atomic.DockerITContainer;
+
+/**
+ * Docker storage container.
+ */
+@Getter
+public abstract class DatabaseContainer extends DockerITContainer {
+    
+    private final DatabaseType databaseType;
+    
+    public DatabaseContainer(final DatabaseType databaseType, final String 
dockerImageName) {
+        super(databaseType.getType().toLowerCase(), dockerImageName);
+        this.databaseType = databaseType;
+    }
+    
+    /**
+     * Get jdbc url.
+     *
+     * @param databaseName database name
+     * @return jdbc url
+     */
+    public abstract String getJdbcUrl(String databaseName);
+    
+    /**
+     * Get database username.
+     *
+     * @return database username
+     */
+    public abstract String getUsername();
+    
+    /**
+     * Get database password.
+     *
+     * @return database username
+     */

Review Comment:
   database password,right?



##########
shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-transaction/src/test/java/org/apache/shardingsphere/integration/transaction/engine/postgresql/PostgreSQLProxyTransactionIT.java:
##########
@@ -0,0 +1,49 @@
+/*
+ * 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.
+ */
+
+package org.apache.shardingsphere.integration.transaction.engine.postgresql;
+
+import lombok.extern.slf4j.Slf4j;
+import 
org.apache.shardingsphere.integration.transaction.engine.base.BaseTransactionITCase;
+import 
org.apache.shardingsphere.integration.transaction.engine.mysql.MySQLJdbcTransactionIT;
+import 
org.apache.shardingsphere.integration.transaction.framework.param.TransactionParameterized;
+import org.junit.runners.Parameterized.Parameters;
+
+import java.sql.SQLException;
+import java.util.Collection;
+
+/**
+ * PostgreSQL general transaction test case with proxy container, includes 
multiple cases.
+ */
+@Slf4j
+// @RunWith(Parameterized.class)

Review Comment:
   Do I need to uncomment here?



##########
shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-transaction/src/test/java/org/apache/shardingsphere/integration/transaction/env/IntegrationTestEnvironment.java:
##########
@@ -0,0 +1,197 @@
+/*
+ * 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.
+ */
+
+package org.apache.shardingsphere.integration.transaction.env;
+
+import lombok.Getter;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.shardingsphere.infra.database.type.DatabaseType;
+import 
org.apache.shardingsphere.infra.database.type.dialect.OpenGaussDatabaseType;
+import 
org.apache.shardingsphere.integration.transaction.engine.entity.JdbcInfoEntity;
+import 
org.apache.shardingsphere.integration.transaction.env.enums.TransactionITEnvTypeEnum;
+import 
org.apache.shardingsphere.integration.transaction.env.enums.TransactionTestCaseRegistry;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+import java.util.stream.Collectors;
+
+@Getter
+@Slf4j
+public final class IntegrationTestEnvironment {
+    
+    private static final IntegrationTestEnvironment INSTANCE = new 
IntegrationTestEnvironment();
+    
+    private final Properties props;
+    
+    private final TransactionITEnvTypeEnum itEnvType;
+    
+    private final List<String> mysqlVersions;
+    
+    private final List<String> postgresVersions;
+    
+    private final List<String> openGaussVersions;
+    
+    private final Map<String, TransactionTestCaseRegistry> 
transactionTestCaseRegistryMap;
+    
+    private IntegrationTestEnvironment() {
+        props = loadProperties();
+        itEnvType = 
TransactionITEnvTypeEnum.valueOf(StringUtils.defaultIfBlank(props.getProperty("transaction.it.env.type").toUpperCase(),
 TransactionITEnvTypeEnum.NONE.name()));
+        mysqlVersions = splitProperty("transaction.it.docker.mysql.version");
+        postgresVersions = 
splitProperty("transaction.it.docker.postgresql.version");
+        openGaussVersions = 
splitProperty("transaction.it.docker.opengauss.version");
+        transactionTestCaseRegistryMap = initTransactionTestCaseRegistryMap();
+    }
+    
+    private Map<String, TransactionTestCaseRegistry> 
initTransactionTestCaseRegistryMap() {
+        final Map<String, TransactionTestCaseRegistry> 
transactionTestCaseRegistryMap;
+        transactionTestCaseRegistryMap = new 
HashMap<>(TransactionTestCaseRegistry.values().length, 1);
+        for (TransactionTestCaseRegistry each : 
TransactionTestCaseRegistry.values()) {
+            
transactionTestCaseRegistryMap.put(each.getTestCaseClass().getName(), each);
+        }
+        return transactionTestCaseRegistryMap;
+    }
+    
+    private List<String> splitProperty(final String key) {
+        return Arrays.stream(props.getOrDefault(key, 
"").toString().split(",")).filter(StringUtils::isNotBlank).collect(Collectors.toList());
+    }
+    
+    private Properties loadProperties() {
+        Properties result = new Properties();
+        try (InputStream inputStream = 
IntegrationTestEnvironment.class.getClassLoader().getResourceAsStream("env/transaction-it-env.properties"))
 {
+            result.load(inputStream);
+        } catch (final IOException ex) {
+            throw new RuntimeException(ex);
+        }
+        for (String each : System.getProperties().stringPropertyNames()) {
+            result.setProperty(each, System.getProperty(each));
+        }
+        return result;
+    }
+    
+    /**
+     * Get actual data source connection.
+     *
+     * @param databaseType database type.
+     * @return jdbc connection
+     */
+    public JdbcInfoEntity getActualDatabaseJdbcInfo(final DatabaseType 
databaseType) {
+        String username;
+        String password;
+        int port;
+        switch (databaseType.getType()) {
+            case "MySQL":
+                username = 
props.getOrDefault("transaction.it.native.mysql.username", "root").toString();
+                password = 
props.getOrDefault("transaction.it.native.mysql.password", "root").toString();
+                port = 
Integer.parseInt(props.getOrDefault("transaction.it.native.mysql.port", 
3307).toString());
+                break;
+            case "PostgreSQL":
+                username = 
props.getOrDefault("transaction.it.native.postgresql.username", 
"postgres").toString();
+                password = 
props.getOrDefault("transaction.it.native.postgresql.password", 
"postgres").toString();
+                port = 
Integer.parseInt(props.getOrDefault("transaction.it.native.postgresql.port", 
5432).toString());
+                break;
+            case "openGauss":
+                username = 
props.getOrDefault("transaction.it.native.opengauss.username", 
"gaussdb").toString();
+                password = 
props.getOrDefault("transaction.it.native.opengauss.password", 
"Root@123").toString();
+                port = 
Integer.parseInt(props.getOrDefault("transaction.it.native.opengauss.port", 
5432).toString());
+                break;
+            default:
+                throw new UnsupportedOperationException("Unsupported database 
type: " + databaseType.getType());
+        }
+        return new JdbcInfoEntity(username, password, port);
+    }
+    
+    /**
+     * Get actual data source default port.
+     *
+     * @param databaseType database type.
+     * @return default port
+     */
+    public int getActualDataSourceDefaultPort(final DatabaseType databaseType) 
{
+        switch (databaseType.getType()) {
+            case "MySQL":
+                return 
Integer.parseInt(props.getOrDefault("transaction.it.native.mysql.port", 
3306).toString());
+            case "PostgreSQL":
+                return 
Integer.parseInt(props.getOrDefault("transaction.it.native.postgresql.port", 
5432).toString());
+            case "openGauss":
+                return 
Integer.parseInt(props.getOrDefault("transaction.it.native.opengauss.port", 
5432).toString());
+            default:
+                throw new IllegalArgumentException("Unsupported database type: 
" + databaseType.getType());
+        }
+    }
+    
+    /**
+     * Get native database type.
+     *
+     * @return native database type
+     */
+    public String getNativeDatabaseType() {
+        return String.valueOf(props.get("transaction.it.native.database"));
+    }
+    
+    /**
+     * Get actual data source username.
+     *
+     * @param databaseType database type.
+     * @return actual data source username
+     */
+    public String getActualDataSourceUsername(final DatabaseType databaseType) 
{
+        String username;
+        if (databaseType instanceof OpenGaussDatabaseType) {
+            username = "gaussdb";
+        } else {
+            username = "root";
+        }

Review Comment:
   Can we put variables in config file?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to