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/11/05 16:24:15 UTC
[shardingsphere] branch master updated: Add : add github action for sql parsert IT (#21976)
This is an automated email from the ASF dual-hosted git repository.
zhangliang 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 f92fe0fb3e3 Add : add github action for sql parsert IT (#21976)
f92fe0fb3e3 is described below
commit f92fe0fb3e3b7a2a6e05212ea8c9382f424f5d30
Author: 孙念君 Nianjun Sun <su...@apache.org>
AuthorDate: Sun Nov 6 00:24:09 2022 +0800
Add : add github action for sql parsert IT (#21976)
* Add : add parser test switch
* Add : add github action for sql parser test
* Add : add push trigger
* push
* push
* Refactor : change schedule to trigger sql parser IT
---
.github/workflows/nightly-sql-parser.yml | 54 +++++++++++++++++++
...MySQLHAGeneralIT.java => MySQLHaGeneralIT.java} | 4 +-
test/integration-test/sql-parser/pom.xml | 26 +++++++++
.../sql/parser/env/IntegrationTestEnvironment.java | 61 ++++++++++++++++++++++
.../src/test/resources/env/it-env.properties | 19 +++++++
.../cases/readonly/SetReadOnlyTestCase.java | 2 +-
6 files changed, 163 insertions(+), 3 deletions(-)
diff --git a/.github/workflows/nightly-sql-parser.yml b/.github/workflows/nightly-sql-parser.yml
new file mode 100644
index 00000000000..a94b32f00f4
--- /dev/null
+++ b/.github/workflows/nightly-sql-parser.yml
@@ -0,0 +1,54 @@
+#
+# 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.
+#
+
+name: Nightly - SQL Parser
+
+on:
+ schedule:
+ - cron: '0 18 */1 * *' # once a day. UTC time
+
+env:
+ MAVEN_OPTS: -Dhttp.keepAlive=false -Dmaven.wagon.http.pool=false -Dmaven.wagon.http.retryHandler.class=standard -Dmaven.wagon.http.retryHandler.count=3 -Dcheckstyle.skip=true -Dspotless.apply.skip=true -Dmaven.javadoc.skip=true -Djacoco.skip=true
+
+jobs:
+ ci:
+# if: github.repository == 'apache/shardingsphere'
+ name: CI - JDK ${{ matrix.java-version }} on ${{ matrix.os }}
+ runs-on: ${{ matrix.os }}
+ timeout-minutes: 90
+ strategy:
+ fail-fast: false
+ matrix:
+ os: [ ubuntu-latest ]
+ java-version: [ 8 ]
+ steps:
+ - uses: actions/checkout@v3
+ - uses: actions/setup-java@v3
+ with:
+ distribution: 'temurin'
+ java-version: ${{ matrix.java-version }}
+ - uses: actions/cache@v3
+ with:
+ path: ~/.m2/repository
+ key: shardingsphere-maven-third-party-cache-${{ github.sha }}
+ restore-keys: |
+ shardingsphere-maven-third-party-cache-
+ shardingsphere-maven-third-party-
+ - name: Build prod with Maven
+ run: ./mvnw -T1C -B -ntp clean install
+ - name: Run SQL parser
+ run: ./mvnw -nsu -B install -f test/integration-test/sql-parser/pom.xml -Dsql.parser.it.enabled=true
diff --git a/test/integration-test/ha/src/test/java/org/apache/shardingsphere/test/integration/ha/cases/mysql/MySQLHAGeneralIT.java b/test/integration-test/ha/src/test/java/org/apache/shardingsphere/test/integration/ha/cases/mysql/MySQLHaGeneralIT.java
similarity index 95%
rename from test/integration-test/ha/src/test/java/org/apache/shardingsphere/test/integration/ha/cases/mysql/MySQLHAGeneralIT.java
rename to test/integration-test/ha/src/test/java/org/apache/shardingsphere/test/integration/ha/cases/mysql/MySQLHaGeneralIT.java
index 9b90880ec29..7cb851ba66c 100644
--- a/test/integration-test/ha/src/test/java/org/apache/shardingsphere/test/integration/ha/cases/mysql/MySQLHAGeneralIT.java
+++ b/test/integration-test/ha/src/test/java/org/apache/shardingsphere/test/integration/ha/cases/mysql/MySQLHaGeneralIT.java
@@ -36,11 +36,11 @@ import java.util.List;
*/
@Slf4j
@RunWith(Parameterized.class)
-public final class MySQLHAGeneralIT extends BaseITCase {
+public final class MySQLHaGeneralIT extends BaseITCase {
private final HAParameterized haParameterized;
- public MySQLHAGeneralIT(final HAParameterized haParameterized) {
+ public MySQLHaGeneralIT(final HAParameterized haParameterized) {
super(haParameterized);
this.haParameterized = haParameterized;
}
diff --git a/test/integration-test/sql-parser/pom.xml b/test/integration-test/sql-parser/pom.xml
index c727bb21978..cbba3f5ef6e 100644
--- a/test/integration-test/sql-parser/pom.xml
+++ b/test/integration-test/sql-parser/pom.xml
@@ -38,4 +38,30 @@
<artifactId>junit</artifactId>
</dependency>
</dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-resources-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>copy-resources</id>
+ <goals>
+ <goal>copy-resources</goal>
+ </goals>
+ <phase>validate</phase>
+ <configuration>
+ <outputDirectory>target/test-classes</outputDirectory>
+ <resources>
+ <resource>
+ <directory>src/test/resources</directory>
+ <filtering>true</filtering>
+ </resource>
+ </resources>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
</project>
diff --git a/test/integration-test/sql-parser/src/test/java/org/apache/shardingsphere/sql/parser/env/IntegrationTestEnvironment.java b/test/integration-test/sql-parser/src/test/java/org/apache/shardingsphere/sql/parser/env/IntegrationTestEnvironment.java
new file mode 100644
index 00000000000..c0f271a7917
--- /dev/null
+++ b/test/integration-test/sql-parser/src/test/java/org/apache/shardingsphere/sql/parser/env/IntegrationTestEnvironment.java
@@ -0,0 +1,61 @@
+/*
+ * 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.sql.parser.env;
+
+import lombok.Getter;
+import lombok.SneakyThrows;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Properties;
+
+@Getter
+public final class IntegrationTestEnvironment {
+
+ private static final IntegrationTestEnvironment INSTANCE = new IntegrationTestEnvironment();
+
+ private final Properties props;
+
+ private final boolean sqlParserITEnabled;
+
+ private IntegrationTestEnvironment() {
+ props = loadProperties();
+ String sqlParserITEnabledStr = null == System.getProperty("sql.parser.it.enabled") ? System.getProperty("sql.parser.it.enabled") : props.get("sql.parser.it.enabled").toString();
+ sqlParserITEnabled = null != sqlParserITEnabledStr && Boolean.getBoolean(sqlParserITEnabledStr);
+ }
+
+ /**
+ * Get instance.
+ *
+ * @return singleton instance
+ */
+ public static IntegrationTestEnvironment getInstance() {
+ return INSTANCE;
+ }
+
+ @SneakyThrows(IOException.class)
+ private Properties loadProperties() {
+ Properties result = new Properties();
+ try (InputStream inputStream = IntegrationTestEnvironment.class.getClassLoader().getResourceAsStream("env/it-env.properties")) {
+ result.load(inputStream);
+ }
+ for (String each : System.getProperties().stringPropertyNames()) {
+ result.setProperty(each, System.getProperty(each));
+ }
+ return result;
+ }
+}
diff --git a/test/integration-test/sql-parser/src/test/resources/env/it-env.properties b/test/integration-test/sql-parser/src/test/resources/env/it-env.properties
new file mode 100644
index 00000000000..cf74c29c267
--- /dev/null
+++ b/test/integration-test/sql-parser/src/test/resources/env/it-env.properties
@@ -0,0 +1,19 @@
+#
+# 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.
+#
+# sql.parser.it.enabled=true,false
+sql.parser.it.enabled=false
+
diff --git a/test/integration-test/transaction/src/test/java/org/apache/shardingsphere/integration/transaction/cases/readonly/SetReadOnlyTestCase.java b/test/integration-test/transaction/src/test/java/org/apache/shardingsphere/integration/transaction/cases/readonly/SetReadOnlyTestCase.java
index 89e181303c2..7f053eb347f 100644
--- a/test/integration-test/transaction/src/test/java/org/apache/shardingsphere/integration/transaction/cases/readonly/SetReadOnlyTestCase.java
+++ b/test/integration-test/transaction/src/test/java/org/apache/shardingsphere/integration/transaction/cases/readonly/SetReadOnlyTestCase.java
@@ -42,7 +42,7 @@ public abstract class SetReadOnlyTestCase extends BaseTransactionTestCase {
Connection conn = getDataSource().getConnection();
assertQueryBalance(conn);
executeUpdateWithLog(conn, "update account set balance = 101 where id = 2;");
- ResultSet resultSet = executeQueryWithLog(conn, "select * from account where id = 2");
+ ResultSet resultSet = executeQueryWithLog(conn, "select * from account where id = 2");
if (!resultSet.next()) {
fail("Should have a result.");
}