You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by xi...@apache.org on 2021/02/04 06:53:33 UTC
[shardingsphere] branch master updated: Merge it.databases.embedded
and it.env.type (#9316)
This is an automated email from the ASF dual-hosted git repository.
xiaoyu 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 4cb157e Merge it.databases.embedded and it.env.type (#9316)
4cb157e is described below
commit 4cb157eb8087707d9f46e69c6a40e74697d90131
Author: Liang Zhang <te...@163.com>
AuthorDate: Thu Feb 4 14:52:57 2021 +0800
Merge it.databases.embedded and it.env.type (#9316)
* Add EnvironmentType
* Merge it.databases.embedded and it.env.type
* Merge IntegrationTestEnvironment.isEnvironmentPrepared and isDatabasesEmbedded to envType
---
.../shardingsphere-integration-test-suite/pom.xml | 2 +-
.../test/integration/engine/it/BaseIT.java | 5 +++--
.../test/integration/env/EnvironmentType.java | 26 ++++++++++++++++++++++
.../env/IntegrationTestEnvironment.java | 17 +++++---------
.../src/test/resources/env/engine-env.properties | 3 ++-
5 files changed, 38 insertions(+), 15 deletions(-)
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 9c74ce5..4378705 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
@@ -85,7 +85,7 @@
<profile>
<id>it.env.docker</id>
<properties>
- <it.env>docker</it.env>
+ <it.env>DOCKER</it.env>
</properties>
<build>
<plugins>
diff --git a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/it/BaseIT.java b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/it/BaseIT.java
index 09b6124..e814cbe 100644
--- a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/it/BaseIT.java
+++ b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/it/BaseIT.java
@@ -25,6 +25,7 @@ import org.apache.shardingsphere.infra.database.type.DatabaseType;
import org.apache.shardingsphere.test.integration.engine.junit.ITRunnerWithParametersFactory;
import org.apache.shardingsphere.test.integration.engine.junit.ParallelParameterized;
import org.apache.shardingsphere.test.integration.env.EnvironmentPath;
+import org.apache.shardingsphere.test.integration.env.EnvironmentType;
import org.apache.shardingsphere.test.integration.env.IntegrationTestEnvironment;
import org.apache.shardingsphere.test.integration.env.database.DatabaseEnvironmentManager;
import org.apache.shardingsphere.test.integration.env.datasource.builder.ActualDataSourceBuilder;
@@ -94,14 +95,14 @@ public abstract class BaseIT {
((AutoCloseable) dataSource).close();
//CHECKSTYLE:OFF
} catch (final Exception ignored) {
+ //CHECKSTYLE:ON
}
- //CHECKSTYLE:ON
});
}
@BeforeClass
public static void executeInitSQLs() throws IOException, JAXBException, SQLException {
- if (!IntegrationTestEnvironment.getInstance().isEnvironmentPrepared()) {
+ if (EnvironmentType.DOCKER != IntegrationTestEnvironment.getInstance().getEnvType()) {
DatabaseEnvironmentManager.executeInitSQLs();
}
}
diff --git a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/env/EnvironmentType.java b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/env/EnvironmentType.java
new file mode 100644
index 0000000..bac2e9d
--- /dev/null
+++ b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/env/EnvironmentType.java
@@ -0,0 +1,26 @@
+/*
+ * 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;
+
+/**
+ * Environment type.
+ */
+public enum EnvironmentType {
+
+ EMBEDDED, DOCKER, NATIVE
+}
diff --git a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/env/IntegrationTestEnvironment.java b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/env/IntegrationTestEnvironment.java
index c724195..73364ee 100644
--- a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/env/IntegrationTestEnvironment.java
+++ b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/env/IntegrationTestEnvironment.java
@@ -50,7 +50,7 @@ public final class IntegrationTestEnvironment {
private static final IntegrationTestEnvironment INSTANCE = new IntegrationTestEnvironment();
- private final boolean isEnvironmentPrepared;
+ private final EnvironmentType envType;
private final Collection<String> adapters;
@@ -62,23 +62,20 @@ public final class IntegrationTestEnvironment {
private final Map<String, DatabaseEnvironment> proxyEnvironments;
- private final boolean isDatabasesEmbedded;
-
private IntegrationTestEnvironment() {
Properties engineEnvProps = EnvironmentProperties.loadProperties("env/engine-env.properties");
- isEnvironmentPrepared = "docker".equals(engineEnvProps.getProperty("it.env.type"));
+ envType = EnvironmentType.valueOf(engineEnvProps.getProperty("it.env.type"));
adapters = Splitter.on(",").trimResults().splitToList(engineEnvProps.getProperty("it.adapters"));
runAdditionalTestCases = Boolean.parseBoolean(engineEnvProps.getProperty("it.run.additional.cases"));
- isDatabasesEmbedded = Boolean.parseBoolean(engineEnvProps.getProperty("it.databases.embedded"));
scenarios = getScenarios(engineEnvProps);
EmbeddedDatabaseDistributionProperties embeddedDatabaseProps = getEmbeddedDatabaseDistributionProperties();
Map<String, DatabaseScenarioProperties> databaseProps = getDatabaseScenarioProperties();
databaseEnvironments = createDatabaseEnvironments(getDatabaseTypes(engineEnvProps), embeddedDatabaseProps, databaseProps);
- if (isDatabasesEmbedded) {
+ if (EnvironmentType.EMBEDDED == envType) {
createEmbeddedDatabaseResources();
}
proxyEnvironments = createProxyEnvironments(databaseProps);
- if (isEnvironmentPrepared) {
+ if (EnvironmentType.DOCKER == envType) {
for (String each : scenarios) {
waitForEnvironmentReady(each);
}
@@ -134,10 +131,8 @@ public final class IntegrationTestEnvironment {
}
private void createEmbeddedDatabaseResources() {
- if (!isEnvironmentPrepared) {
- for (Entry<DatabaseType, Map<String, DatabaseEnvironment>> entry : databaseEnvironments.entrySet()) {
- createEmbeddedDatabaseResources(entry.getKey(), entry.getValue());
- }
+ for (Entry<DatabaseType, Map<String, DatabaseEnvironment>> entry : databaseEnvironments.entrySet()) {
+ createEmbeddedDatabaseResources(entry.getKey(), entry.getValue());
}
}
diff --git a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/resources/env/engine-env.properties b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/resources/env/engine-env.properties
index 54fffc5..68174f1 100644
--- a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/resources/env/engine-env.properties
+++ b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/resources/env/engine-env.properties
@@ -15,7 +15,9 @@
# limitations under the License.
#
+# EMBEDDED, DOCKER, NATIVE
it.env.type=${it.env}
+
it.adapters=jdbc
#it.scenarios=db,tbl,dbtbl_with_replica_query,replica_query,shadow
@@ -23,6 +25,5 @@ it.scenarios=db,tbl,dbtbl_with_replica_query,replica_query
#it.databases=H2,MySQL,Oracle,SQLServer,PostgreSQL
it.databases=H2
-it.databases.embedded=false
it.run.additional.cases=false