You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by zh...@apache.org on 2022/10/28 08:13:49 UTC

[shardingsphere] branch master updated: Fix create table sql generator IT using mysql 8 (#21815)

This is an automated email from the ASF dual-hosted git repository.

zhonghongsheng 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 b83d70c76a0 Fix create table sql generator IT using mysql 8 (#21815)
b83d70c76a0 is described below

commit b83d70c76a0ef3f7816e1d499c1a331fdd64d2e0
Author: Xinze Guo <10...@users.noreply.github.com>
AuthorDate: Fri Oct 28 16:13:40 2022 +0800

    Fix create table sql generator IT using mysql 8 (#21815)
    
    * Fix create table IT using mysql 8
    
    * add log
    
    * Add more log
---
 .../cases/createtable/CreateTableSQLGeneratorIT.java   | 18 ++++++++++++++++--
 1 file changed, 16 insertions(+), 2 deletions(-)

diff --git a/test/integration-test/scaling/src/test/java/org/apache/shardingsphere/integration/data/pipeline/cases/createtable/CreateTableSQLGeneratorIT.java b/test/integration-test/scaling/src/test/java/org/apache/shardingsphere/integration/data/pipeline/cases/createtable/CreateTableSQLGeneratorIT.java
index a654855c1cf..3158d73ec18 100644
--- a/test/integration-test/scaling/src/test/java/org/apache/shardingsphere/integration/data/pipeline/cases/createtable/CreateTableSQLGeneratorIT.java
+++ b/test/integration-test/scaling/src/test/java/org/apache/shardingsphere/integration/data/pipeline/cases/createtable/CreateTableSQLGeneratorIT.java
@@ -17,7 +17,9 @@
 
 package org.apache.shardingsphere.integration.data.pipeline.cases.createtable;
 
+import lombok.extern.slf4j.Slf4j;
 import org.apache.shardingsphere.data.pipeline.spi.ddlgenerator.CreateTableSQLGeneratorFactory;
+import org.apache.shardingsphere.infra.database.type.DatabaseType;
 import org.apache.shardingsphere.infra.database.type.dialect.MySQLDatabaseType;
 import org.apache.shardingsphere.infra.database.type.dialect.OpenGaussDatabaseType;
 import org.apache.shardingsphere.infra.database.type.dialect.PostgreSQLDatabaseType;
@@ -27,9 +29,14 @@ import org.apache.shardingsphere.integration.data.pipeline.entity.CreateTableSQL
 import org.apache.shardingsphere.integration.data.pipeline.env.IntegrationTestEnvironment;
 import org.apache.shardingsphere.integration.data.pipeline.env.enums.ITEnvTypeEnum;
 import org.apache.shardingsphere.integration.data.pipeline.framework.param.ScalingParameterized;
+import org.apache.shardingsphere.integration.data.pipeline.util.DockerImageVersion;
+import org.apache.shardingsphere.test.integration.env.container.atomic.constants.StorageContainerConstants;
 import org.apache.shardingsphere.test.integration.env.container.atomic.storage.DockerStorageContainer;
 import org.apache.shardingsphere.test.integration.env.container.atomic.storage.StorageContainerFactory;
+import org.apache.shardingsphere.test.integration.env.container.atomic.storage.config.StorageContainerConfiguration;
 import org.apache.shardingsphere.test.integration.env.container.atomic.storage.config.impl.StorageContainerConfigurationFactory;
+import org.apache.shardingsphere.test.integration.env.container.atomic.storage.config.impl.mysql.MySQLContainerConfigurationFactory;
+import org.apache.shardingsphere.test.integration.env.container.atomic.util.DatabaseTypeUtil;
 import org.junit.After;
 import org.junit.Test;
 import org.junit.runner.RunWith;
@@ -42,6 +49,7 @@ import java.sql.Connection;
 import java.sql.SQLException;
 import java.sql.Statement;
 import java.util.Collection;
+import java.util.Collections;
 import java.util.Iterator;
 import java.util.LinkedList;
 import java.util.Objects;
@@ -51,6 +59,7 @@ import static org.hamcrest.CoreMatchers.is;
 import static org.hamcrest.MatcherAssert.assertThat;
 
 @RunWith(Parameterized.class)
+@Slf4j
 public final class CreateTableSQLGeneratorIT {
     
     private static final String POSTGRES_CASE_FILE_PATH = "postgresql/create-table-sql-generator.xml";
@@ -79,8 +88,12 @@ public final class CreateTableSQLGeneratorIT {
         this.parameterized = parameterized;
         rootEntity = JAXB.unmarshal(
                 Objects.requireNonNull(CreateTableSQLGeneratorIT.class.getClassLoader().getResource(parameterized.getScenario())), CreateTableSQLGeneratorAssertionsRootEntity.class);
-        storageContainer = (DockerStorageContainer) StorageContainerFactory.newInstance(parameterized.getDatabaseType(), parameterized.getStorageContainerImage(), "",
-                StorageContainerConfigurationFactory.newInstance(parameterized.getDatabaseType()));
+        DatabaseType databaseType = parameterized.getDatabaseType();
+        StorageContainerConfiguration storageContainerConfig = DatabaseTypeUtil.isMySQL(databaseType) && new DockerImageVersion(parameterized.getStorageContainerImage()).getMajorVersion() > 5
+                ? MySQLContainerConfigurationFactory.newInstance(null, null, Collections.singletonMap("/env/mysql/mysql8/my.cnf", StorageContainerConstants.MYSQL_CONF_IN_CONTAINER))
+                : StorageContainerConfigurationFactory.newInstance(databaseType);
+        storageContainer = (DockerStorageContainer) StorageContainerFactory.newInstance(databaseType, parameterized.getStorageContainerImage(), "",
+                storageContainerConfig);
         storageContainer.start();
     }
     
@@ -104,6 +117,7 @@ public final class CreateTableSQLGeneratorIT {
     
     @Test
     public void assertGenerateCreateTableSQL() throws SQLException {
+        log.info("generate create table sql, parameterized: {}", parameterized);
         initData();
         DataSource dataSource = storageContainer.createAccessDataSource(DEFAULT_DATABASE);
         try (