You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by me...@apache.org on 2022/02/17 23:53:20 UTC
[shardingsphere] branch master updated: Remove useless embedded databases (#15484)
This is an automated email from the ASF dual-hosted git repository.
menghaoran 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 551cf3f Remove useless embedded databases (#15484)
551cf3f is described below
commit 551cf3f7691711c21c05c98471fbdea9aba1dba6
Author: Liang Zhang <zh...@apache.org>
AuthorDate: Fri Feb 18 07:51:09 2022 +0800
Remove useless embedded databases (#15484)
* Remove useless embedded databases
* Remove useless embedded databases
---
pom.xml | 14 --
.../pom.xml | 8 --
.../shardingsphere-integration-test-suite/pom.xml | 8 --
.../integration/env/DataSourceEnvironment.java | 6 +-
.../env/database/embedded/EmbeddedDatabase.java | 39 ------
.../EmbeddedDatabaseDistributionProperties.java | 62 ---------
.../database/embedded/EmbeddedDatabaseManager.java | 91 ------------
.../embedded/type/MySQLEmbeddedDatabase.java | 108 ---------------
.../embedded/type/PostgreSQLEmbeddedDatabase.java | 153 ---------------------
.../env/dataset/DataSetEnvironmentManager.java | 2 +-
...egration.env.database.embedded.EmbeddedDatabase | 19 ---
.../resources/env/embedded-databases.properties | 39 ------
12 files changed, 4 insertions(+), 545 deletions(-)
diff --git a/pom.xml b/pom.xml
index 857d664..daafa30 100644
--- a/pom.xml
+++ b/pom.xml
@@ -111,8 +111,6 @@
<elasticjob.version>3.0.1</elasticjob.version>
<calcite.version>1.27.0</calcite.version>
- <embedded-mysql.version>4.6.1</embedded-mysql.version>
- <embedded-postgresql.version>2.10</embedded-postgresql.version>
<jaxb.version>2.3.0</jaxb.version>
<annotation-api.version>1.3.2</annotation-api.version>
@@ -583,18 +581,6 @@
<version>${spring-boot.version}</version>
<scope>test</scope>
</dependency>
- <dependency>
- <groupId>com.wix</groupId>
- <artifactId>wix-embedded-mysql</artifactId>
- <version>${embedded-mysql.version}</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>ru.yandex.qatools.embed</groupId>
- <artifactId>postgresql-embedded</artifactId>
- <version>${embedded-postgresql.version}</version>
- <scope>test</scope>
- </dependency>
</dependencies>
</dependencyManagement>
diff --git a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-fixture/pom.xml b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-fixture/pom.xml
index 9f1ea2a..df42af8 100644
--- a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-fixture/pom.xml
+++ b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-fixture/pom.xml
@@ -79,14 +79,6 @@
<scope>test</scope>
</dependency>
<dependency>
- <groupId>com.wix</groupId>
- <artifactId>wix-embedded-mysql</artifactId>
- </dependency>
- <dependency>
- <groupId>ru.yandex.qatools.embed</groupId>
- <artifactId>postgresql-embedded</artifactId>
- </dependency>
- <dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-dbcp2</artifactId>
<scope>test</scope>
diff --git a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/pom.xml b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/pom.xml
index 3600016..20657c0 100644
--- a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/pom.xml
+++ b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/pom.xml
@@ -76,14 +76,6 @@
<groupId>org.testcontainers</groupId>
<artifactId>testcontainers</artifactId>
</dependency>
- <dependency>
- <groupId>com.wix</groupId>
- <artifactId>wix-embedded-mysql</artifactId>
- </dependency>
- <dependency>
- <groupId>ru.yandex.qatools.embed</groupId>
- <artifactId>postgresql-embedded</artifactId>
- </dependency>
</dependencies>
<build>
diff --git a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/env/DataSourceEnvironment.java b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/env/DataSourceEnvironment.java
index 80ccdd5..46a093a 100644
--- a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/env/DataSourceEnvironment.java
+++ b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/env/DataSourceEnvironment.java
@@ -23,7 +23,7 @@ import org.apache.shardingsphere.infra.database.type.DatabaseType;
* Data source environment.
*/
public final class DataSourceEnvironment {
-
+
/**
* Get driver class name.
*
@@ -46,7 +46,7 @@ public final class DataSourceEnvironment {
throw new UnsupportedOperationException(databaseType.getName());
}
}
-
+
/**
* Get URL.
*
@@ -71,7 +71,7 @@ public final class DataSourceEnvironment {
throw new UnsupportedOperationException(databaseType.getName());
}
}
-
+
/**
* Get URL.
*
diff --git a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/env/database/embedded/EmbeddedDatabase.java b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/env/database/embedded/EmbeddedDatabase.java
deleted file mode 100644
index 0105419..0000000
--- a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/env/database/embedded/EmbeddedDatabase.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * 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.test.integration.env.database.embedded;
-
-import org.apache.shardingsphere.spi.typed.TypedSPI;
-
-/**
- * Embedded database.
- */
-public interface EmbeddedDatabase extends TypedSPI {
-
- /**
- * Start embedded database.
- *
- * @param embeddedDatabaseProps embedded database properties
- * @param port port of database access
- */
- void start(EmbeddedDatabaseDistributionProperties embeddedDatabaseProps, int port);
-
- /**
- * Stop embedded database.
- */
- void stop();
-}
diff --git a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/env/database/embedded/EmbeddedDatabaseDistributionProperties.java b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/env/database/embedded/EmbeddedDatabaseDistributionProperties.java
deleted file mode 100644
index 6d1d6ed..0000000
--- a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/env/database/embedded/EmbeddedDatabaseDistributionProperties.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * 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.test.integration.env.database.embedded;
-
-import lombok.RequiredArgsConstructor;
-import org.apache.shardingsphere.infra.database.type.DatabaseType;
-
-import java.util.Properties;
-
-/**
- * Embedded database distribution properties.
- */
-@RequiredArgsConstructor
-public final class EmbeddedDatabaseDistributionProperties {
-
- private final Properties props;
-
- /**
- * Get database distribution URL.
- *
- * @param databaseType database type
- * @return database distribution URL
- */
- public String getURL(final DatabaseType databaseType) {
- return props.getProperty(String.format("it.%s.distribution.url", databaseType.getName().toLowerCase()));
- }
-
- /**
- * Get database distribution version.
- *
- * @param databaseType database type
- * @return database distribution version
- */
- public String getVersion(final DatabaseType databaseType) {
- return props.getProperty(String.format("it.%s.distribution.version", databaseType.getName().toLowerCase()));
- }
-
- /**
- * Get database port.
- *
- * @param databaseType database type
- * @return database port
- */
- public int getInstancePort(final DatabaseType databaseType) {
- return Integer.parseInt(props.getProperty(String.format("it.%s.instance.port", databaseType.getName().toLowerCase())));
- }
-}
diff --git a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/env/database/embedded/EmbeddedDatabaseManager.java b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/env/database/embedded/EmbeddedDatabaseManager.java
deleted file mode 100644
index 19f1d50..0000000
--- a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/env/database/embedded/EmbeddedDatabaseManager.java
+++ /dev/null
@@ -1,91 +0,0 @@
-/*
- * 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.test.integration.env.database.embedded;
-
-import lombok.AccessLevel;
-import lombok.NoArgsConstructor;
-import org.apache.shardingsphere.infra.database.type.DatabaseType;
-import org.apache.shardingsphere.infra.database.type.DatabaseTypeRegistry;
-import org.apache.shardingsphere.infra.database.type.dialect.H2DatabaseType;
-import org.apache.shardingsphere.spi.ShardingSphereServiceLoader;
-import org.apache.shardingsphere.spi.typed.TypedSPIRegistry;
-
-import java.util.Map;
-import java.util.Properties;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.locks.Lock;
-import java.util.concurrent.locks.ReentrantLock;
-
-/**
- * Embedded database manager.
- */
-@NoArgsConstructor(access = AccessLevel.PRIVATE)
-public final class EmbeddedDatabaseManager {
-
- private static final Map<String, EmbeddedDatabase> EMBEDDED_DATABASES_CACHE = new ConcurrentHashMap<>();
-
- private static final Lock DATABASE_RESOURCE_LOCK = new ReentrantLock();
-
- static {
- ShardingSphereServiceLoader.register(EmbeddedDatabase.class);
- }
-
- /**
- * Start up embedded database.
- *
- * @param databaseType database type
- * @param scenario scenario
- * @param embeddedDatabaseProps embedded database distribution properties
- * @param port port
- */
- public static void startUp(final String databaseType, final String scenario, final EmbeddedDatabaseDistributionProperties embeddedDatabaseProps, final int port) {
- DatabaseType databaseTypeImpl = DatabaseTypeRegistry.getActualDatabaseType(databaseType);
- if (databaseTypeImpl instanceof H2DatabaseType) {
- return;
- }
- if (EMBEDDED_DATABASES_CACHE.containsKey(databaseType)) {
- return;
- }
- DATABASE_RESOURCE_LOCK.lock();
- try {
- startUpSafely(databaseType, databaseType, embeddedDatabaseProps, port);
- } finally {
- DATABASE_RESOURCE_LOCK.unlock();
- }
- }
-
- //CHECKSTYLE:OFF
- private static void startUpSafely(final String embeddedDatabaseKey, final String databaseType, final EmbeddedDatabaseDistributionProperties embeddedDatabaseProps, final int port) {
- int retries = 3;
- do {
- try {
- if (EMBEDDED_DATABASES_CACHE.containsKey(embeddedDatabaseKey)) {
- return;
- }
- EmbeddedDatabase embeddedDatabase = TypedSPIRegistry.getRegisteredService(EmbeddedDatabase.class, databaseType, new Properties());
- Runtime.getRuntime().addShutdownHook(new Thread(embeddedDatabase::stop));
- embeddedDatabase.start(embeddedDatabaseProps, port);
- EMBEDDED_DATABASES_CACHE.put(embeddedDatabaseKey, embeddedDatabase);
- break;
- } catch (Throwable e) {
- retries--;
- }
- } while (retries != 0);
- //CHECKSTYLE:ON
- }
-}
diff --git a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/env/database/embedded/type/MySQLEmbeddedDatabase.java b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/env/database/embedded/type/MySQLEmbeddedDatabase.java
deleted file mode 100644
index d38e0b4..0000000
--- a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/env/database/embedded/type/MySQLEmbeddedDatabase.java
+++ /dev/null
@@ -1,108 +0,0 @@
-/*
- * 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.test.integration.env.database.embedded.type;
-
-import com.google.common.base.Enums;
-import com.google.common.base.Preconditions;
-import com.google.common.base.Strings;
-import com.sun.jna.Platform;
-import com.wix.mysql.EmbeddedMysql;
-import com.wix.mysql.config.Charset;
-import com.wix.mysql.config.DownloadConfig;
-import com.wix.mysql.config.MysqldConfig;
-import com.wix.mysql.distribution.Version;
-import org.apache.shardingsphere.infra.database.type.DatabaseType;
-import org.apache.shardingsphere.infra.database.type.DatabaseTypeRegistry;
-import org.apache.shardingsphere.test.integration.env.database.embedded.EmbeddedDatabase;
-import org.apache.shardingsphere.test.integration.env.database.embedded.EmbeddedDatabaseDistributionProperties;
-
-import java.io.File;
-import java.util.Arrays;
-import java.util.stream.Collectors;
-
-/**
- * Embedded database for MySQL.
- */
-public final class MySQLEmbeddedDatabase implements EmbeddedDatabase {
-
- private volatile EmbeddedMysql embeddedMySQL;
-
- @Override
- public void start(final EmbeddedDatabaseDistributionProperties embeddedDatabaseProps, final int port) {
- DatabaseType databaseType = DatabaseTypeRegistry.getActualDatabaseType(getType());
- DownloadConfig downloadConfig = DownloadConfig.aDownloadConfig().withBaseUrl(embeddedDatabaseProps.getURL(databaseType)).build();
- MysqldConfig.Builder mysqldConfigBuilder = MysqldConfig.aMysqldConfig(detectVersion(embeddedDatabaseProps.getVersion(databaseType)))
- .withCharset(Charset.UTF8MB4)
- .withTempDir(new File(downloadConfig.getCacheDir(), "runtime").getPath())
- .withPort(port)
- .withUser("test", "test")
- .withServerVariable("bind-address", "0.0.0.0")
- .withServerVariable("innodb_flush_log_at_trx_commit", 2);
- if (!Platform.isWindows()) {
- mysqldConfigBuilder = mysqldConfigBuilder.withServerVariable("innodb_flush_method", "O_DIRECT");
- }
- embeddedMySQL = EmbeddedMysql.anEmbeddedMysql(mysqldConfigBuilder.build(), downloadConfig).start();
- }
-
- private Version detectVersion(final String distributionVersion) {
- Version version;
- if (Strings.isNullOrEmpty(distributionVersion) && Platform.isMac()) {
- String osName = System.getProperty("os.name");
- String osVersion = System.getProperty("os.version");
- if (osVersion.startsWith("10.6")) {
- version = Version.v5_5_40;
- } else if (osVersion.startsWith("10.9")) {
- version = Version.v5_6_24;
- } else if (osVersion.startsWith("10.10")) {
- version = Version.v5_7_10;
- } else if (osVersion.startsWith("10.11")) {
- version = Version.v5_7_16;
- } else if (osVersion.startsWith("10.12")) {
- version = Version.v5_7_19;
- } else if (osVersion.startsWith("10.13")) {
- version = Version.v8_0_11;
- } else if (osVersion.startsWith("10.14") || osVersion.startsWith("10.15")) {
- version = Version.v5_7_27;
- } else {
- throw new UnsupportedOperationException(String.format("%s-%s is not supported", osName, osVersion));
- }
- } else if (Strings.isNullOrEmpty(distributionVersion) && com.sun.jna.Platform.isLinux()) {
- version = Version.v5_7_latest;
- } else if (Strings.isNullOrEmpty(distributionVersion) && com.sun.jna.Platform.isWindows()) {
- version = Version.v5_7_latest;
- } else {
- version = Enums.getIfPresent(Version.class, distributionVersion).orNull();
- Preconditions.checkArgument(null != version, String.format("The current setup version %s is not supported, only the following versions [%s] are currently supported",
- distributionVersion, Arrays.stream(Version.values()).map(v -> String.join(".", v.getMajorVersion(), v.getMinorVersion() + "")).collect(Collectors.joining(", "))));
- }
- return version;
- }
-
- @Override
- public void stop() {
- if (null != embeddedMySQL) {
- embeddedMySQL.stop();
- embeddedMySQL = null;
- }
- }
-
- @Override
- public String getType() {
- return "MySQL";
- }
-}
diff --git a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/env/database/embedded/type/PostgreSQLEmbeddedDatabase.java b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/env/database/embedded/type/PostgreSQLEmbeddedDatabase.java
deleted file mode 100644
index d826018..0000000
--- a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/env/database/embedded/type/PostgreSQLEmbeddedDatabase.java
+++ /dev/null
@@ -1,153 +0,0 @@
-/*
- * 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.test.integration.env.database.embedded.type;
-
-import com.google.common.base.Enums;
-import com.google.common.base.Preconditions;
-import com.google.common.base.Strings;
-import de.flapdoodle.embed.process.config.IRuntimeConfig;
-import de.flapdoodle.embed.process.distribution.Platform;
-import de.flapdoodle.embed.process.io.directories.FixedPath;
-import de.flapdoodle.embed.process.runtime.ICommandLinePostProcessor;
-import de.flapdoodle.embed.process.store.PostgresArtifactStoreBuilder;
-import lombok.SneakyThrows;
-import org.apache.shardingsphere.infra.database.type.DatabaseType;
-import org.apache.shardingsphere.infra.database.type.DatabaseTypeRegistry;
-import org.apache.shardingsphere.test.integration.env.database.embedded.EmbeddedDatabase;
-import org.apache.shardingsphere.test.integration.env.database.embedded.EmbeddedDatabaseDistributionProperties;
-import ru.yandex.qatools.embed.postgresql.Command;
-import ru.yandex.qatools.embed.postgresql.EmbeddedPostgres;
-import ru.yandex.qatools.embed.postgresql.PackagePaths;
-import ru.yandex.qatools.embed.postgresql.config.PostgresDownloadConfigBuilder;
-import ru.yandex.qatools.embed.postgresql.config.RuntimeConfigBuilder;
-import ru.yandex.qatools.embed.postgresql.distribution.Version;
-
-import java.io.File;
-import java.util.Arrays;
-import java.util.List;
-import java.util.UUID;
-import java.util.stream.Collectors;
-
-/**
- * Embedded database for PostgreSQL.
- */
-public final class PostgreSQLEmbeddedDatabase implements EmbeddedDatabase {
-
- private volatile EmbeddedPostgres embeddedPostgres;
-
- @SneakyThrows
- @Override
- public void start(final EmbeddedDatabaseDistributionProperties embeddedDatabaseProps, final int port) {
- String cacheDir = new File(System.getProperty("user.home"), ".embedpostgresql").getPath();
- DatabaseType databaseType = DatabaseTypeRegistry.getActualDatabaseType(getType());
- Version version = detectVersion(embeddedDatabaseProps.getVersion(databaseType));
- String extractedDir = new File(cacheDir, "extracted").getPath();
- String instanceDir = new File(cacheDir, "runtime" + File.separator + "PostgreSQL-" + version.name() + File.separator + UUID.randomUUID()).getPath();
- embeddedPostgres = new EmbeddedPostgres(version, new File(instanceDir).getPath());
- Command cmd = Command.Postgres;
- FixedPath extractedCache = new FixedPath(extractedDir);
- IRuntimeConfig runtimeConfig = new RuntimeConfigBuilder()
- .defaults(cmd)
- .artifactStore(new PostgresArtifactStoreBuilder()
- .defaults(cmd)
- .useCache(true)
- .tempDir(extractedCache)
- .download(new PostgresDownloadConfigBuilder()
- .defaultsForCommand(cmd)
- .downloadPath(embeddedDatabaseProps.getURL(DatabaseTypeRegistry.getActualDatabaseType(getType())))
- .packageResolver(new PackagePaths(cmd, extractedCache))
- .build()))
- .commandLinePostProcessor(privilegedWindowsRunasPostprocessor())
- .build();
- List<String> additionalParams = Arrays.asList(
- "-E", "UTF-8",
- "--lc-collate=en_US.UTF-8",
- "--lc-ctype=en_US.UTF-8");
- List<String> additionalPostgresParams = Arrays.asList(
- "-c", "max_connections=512",
- "-c", "logging_collector=on",
- "-c", "log_directory=log",
- "-c", "fsync=off"
- );
- embeddedPostgres.start(runtimeConfig, "127.0.0.1", port, EmbeddedPostgres.DEFAULT_DB_NAME,
- EmbeddedPostgres.DEFAULT_USER, EmbeddedPostgres.DEFAULT_PASSWORD, additionalParams, additionalPostgresParams);
- }
-
- private Version detectVersion(final String distributionVersion) {
- Version version;
- if (Strings.isNullOrEmpty(distributionVersion) && com.sun.jna.Platform.isMac()) {
- String osName = System.getProperty("os.name");
- String osVersion = System.getProperty("os.version");
- if (osVersion.startsWith("10.10") || osVersion.startsWith("10.11") || osVersion.startsWith("10.12")) {
- version = Version.V10_6;
- } else if (osVersion.startsWith("10.13") || osVersion.startsWith("10.14") || osVersion.startsWith("10.15")) {
- version = Version.V11_1;
- } else {
- throw new UnsupportedOperationException(String.format("%s-%s is not supported", osName, osVersion));
- }
- } else if (Strings.isNullOrEmpty(distributionVersion) && com.sun.jna.Platform.isLinux()) {
- version = Version.V10_6;
- } else if (Strings.isNullOrEmpty(distributionVersion) && com.sun.jna.Platform.isWindows()) {
- version = Version.V11_1;
- } else {
- version = Enums.getIfPresent(Version.class, distributionVersion).orNull();
- Preconditions.checkArgument(null != version, String.format("The current setup version %s is not supported, only the following versions [%s] are currently supported",
- distributionVersion, Arrays.stream(Version.values()).map(Enum::name).collect(Collectors.joining(", "))));
- }
- return version;
- }
-
- @SneakyThrows
- private ICommandLinePostProcessor privilegedWindowsRunasPostprocessor() {
- if (Platform.Windows == Platform.detect()) {
- // Based on https://stackoverflow.com/a/11995662
- int adminCommandResult = Runtime.getRuntime().exec("net session").waitFor();
- if (0 == adminCommandResult) {
- return runWithoutPrivileges();
- }
- }
- return doNothing();
- }
-
- private ICommandLinePostProcessor runWithoutPrivileges() {
- return (distribution, args) -> {
- if (!args.isEmpty() && args.get(0).endsWith("postgres.exe")) {
- return Arrays.asList("runas", "/trustlevel:0x20000", String.format("\"%s\"", String.join(" ", args)));
- }
- return args;
- };
- }
-
- private static ICommandLinePostProcessor doNothing() {
- return (distribution, args) -> args;
- }
-
- @SneakyThrows
- @Override
- public void stop() {
- if (null != embeddedPostgres) {
- embeddedPostgres.stop();
- embeddedPostgres = null;
- }
- }
-
- @Override
- public String getType() {
- return "PostgreSQL";
- }
-}
diff --git a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/env/dataset/DataSetEnvironmentManager.java b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/env/dataset/DataSetEnvironmentManager.java
index ad27f48..969da4d 100644
--- a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/env/dataset/DataSetEnvironmentManager.java
+++ b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/env/dataset/DataSetEnvironmentManager.java
@@ -179,7 +179,7 @@ public final class DataSetEnvironmentManager {
private final String insertSQL;
private final Collection<SQLValueGroup> sqlValueGroups;
-
+
@Override
public Void call() throws SQLException {
try (Connection connection = dataSource.getConnection(); PreparedStatement preparedStatement = connection.prepareStatement(insertSQL)) {
diff --git a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/resources/META-INF/services/org.apache.shardingsphere.test.integration.env.database.embedded.EmbeddedDatabase b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/resources/META-INF/services/org.apache.shardingsphere.test.integration.env.database.embedded.EmbeddedDatabase
deleted file mode 100644
index 6a0431d..0000000
--- a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/resources/META-INF/services/org.apache.shardingsphere.test.integration.env.database.embedded.EmbeddedDatabase
+++ /dev/null
@@ -1,19 +0,0 @@
-#
-# 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.
-#
-
-org.apache.shardingsphere.test.integration.env.database.embedded.type.MySQLEmbeddedDatabase
-org.apache.shardingsphere.test.integration.env.database.embedded.type.PostgreSQLEmbeddedDatabase
diff --git a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/resources/env/embedded-databases.properties b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/resources/env/embedded-databases.properties
deleted file mode 100644
index 6092c2b..0000000
--- a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/resources/env/embedded-databases.properties
+++ /dev/null
@@ -1,39 +0,0 @@
-#
-# 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.
-#
-
-it.mysql.distribution.url=https://dev.mysql.com/get/Downloads
-#it.mysql.distribution.url=http://mirrors.ustc.edu.cn/mysql-ftp/Downloads
-# Windows|Linux v5_5_latest | v5_6_latest | v5_7_latest | v8_0_latest
-# MacOSVersion MySQLVersion
-# 10.6 v5_5_40
-# 10.9 v5_6_24
-# 10.10 v5_7_10
-# 10.11 v5_7_16
-# 10.12 v5_7_19
-# 10.13 v8_0_11
-# 10.14|10.15 v5_7_27
-it.mysql.distribution.version=
-it.mysql.instance.port=6033
-
-it.postgresql.distribution.url=https://get.enterprisedb.com/postgresql/
-# V11_1: on Mac OS X and Windows 64 bit
-# V9_6_11|V10_6: on Linux, Windows, Mac OS X
-# MacOSVersion PostgreSQLVersion
-# 10.10-10.12 V9_6_11|V10_6
-# 10.12-10.14 V11_1
-it.postgresql.distribution.version=
-it.postgresql.instance.port=5432