From ebc05818e042d7dd195c8fc8cdce34f33733cc53 Mon Sep 17 00:00:00 2001 From: VGalaxies Date: Tue, 11 Jun 2024 18:52:32 +0800 Subject: [PATCH 01/16] ci test --- .github/workflows/cluster-it-1c1d.yml | 87 ----------- .github/workflows/cluster-it-1c3d.yml | 2 +- .github/workflows/greetings.yml | 14 -- .github/workflows/multi-language-client.yml | 132 ----------------- .github/workflows/pipe-it-2cluster.yml | 139 ------------------ .github/workflows/sonar-codecov.yml | 83 ----------- .github/workflows/unit-test.yml | 74 ---------- integration-test/pom.xml | 14 ++ .../iotdb/itbase/category/ClusterIT2.java | 22 +++ .../it/local/IoTDBSubscriptionRestartIT.java | 40 +++-- 10 files changed, 64 insertions(+), 543 deletions(-) delete mode 100644 .github/workflows/cluster-it-1c1d.yml delete mode 100644 .github/workflows/greetings.yml delete mode 100644 .github/workflows/multi-language-client.yml delete mode 100644 .github/workflows/pipe-it-2cluster.yml delete mode 100644 .github/workflows/sonar-codecov.yml delete mode 100644 .github/workflows/unit-test.yml create mode 100644 integration-test/src/main/java/org/apache/iotdb/itbase/category/ClusterIT2.java diff --git a/.github/workflows/cluster-it-1c1d.yml b/.github/workflows/cluster-it-1c1d.yml deleted file mode 100644 index fe5fc2a6edb8..000000000000 --- a/.github/workflows/cluster-it-1c1d.yml +++ /dev/null @@ -1,87 +0,0 @@ -name: Cluster IT - 1C1D - -on: - push: - branches: - - master - - 'rel/1.*' - - pipe-meta-sync - paths-ignore: - - 'docs/**' - - 'site/**' - pull_request: - branches: - - master - - 'rel/1.*' - - pipe-meta-sync - paths-ignore: - - 'docs/**' - - 'site/**' - # allow manually run the action: - workflow_dispatch: - -concurrency: - group: ${{ github.workflow }}-${{ github.ref }} - cancel-in-progress: true - -env: - MAVEN_OPTS: -Dhttp.keepAlive=false -Dmaven.wagon.http.pool=false -Dmaven.wagon.http.retryHandler.class=standard -Dmaven.wagon.http.retryHandler.count=3 - DEVELOCITY_ACCESS_KEY: ${{ secrets.GE_ACCESS_TOKEN }} - -jobs: - Simple: - strategy: - fail-fast: false - max-parallel: 15 - matrix: - os: [ ubuntu-latest, windows-latest ] - runs-on: ${{ matrix.os }} - - steps: - - uses: actions/checkout@v4 - - name: Set up JDK - uses: actions/setup-java@v4 - with: - distribution: liberica - java-version: 17 - - name: Cache Maven packages - uses: actions/cache@v4 - with: - path: ~/.m2 - key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }} - restore-keys: ${{ runner.os }}-m2- - - name: Adjust network dynamic TCP ports range - if: ${{ runner.os == 'Windows' }} - shell: pwsh - run: | - netsh int ipv4 set dynamicport tcp start=32768 num=32768 - netsh int ipv4 set dynamicport udp start=32768 num=32768 - netsh int ipv6 set dynamicport tcp start=32768 num=32768 - netsh int ipv6 set dynamicport udp start=32768 num=32768 - - name: Adjust Linux kernel somaxconn - if: ${{ runner.os == 'Linux' }} - shell: bash - run: sudo sysctl -w net.core.somaxconn=65535 -# - name: Adjust Mac kernel somaxconn -# if: ${{ runner.os == 'macOS' }} -# shell: bash -# run: sudo sysctl -w kern.ipc.somaxconn=65535 - - name: IT/UT Test - shell: bash - # we do not compile client-cpp for saving time, it is tested in client.yml - # we can skip influxdb-protocol because it has been tested separately in influxdb-protocol.yml - run: | - mvn clean verify \ - -P with-integration-tests \ - -DskipUTs \ - -DintegrationTest.forkCount=2 \ - -pl integration-test \ - -am - - name: Upload Artifact - if: failure() - uses: actions/upload-artifact@v4 - with: - name: standalone-log-java${{ matrix.java }}-${{ runner.os }} - path: integration-test/target/cluster-logs - retention-days: 1 - diff --git a/.github/workflows/cluster-it-1c3d.yml b/.github/workflows/cluster-it-1c3d.yml index 5e46c26152a1..0c1178ac7a47 100644 --- a/.github/workflows/cluster-it-1c3d.yml +++ b/.github/workflows/cluster-it-1c3d.yml @@ -55,7 +55,7 @@ jobs: -DskipUTs \ -DintegrationTest.forkCount=6 -DConfigNodeMaxHeapSize=1024 -DDataNodeMaxHeapSize=1024 \ -pl integration-test \ - -am -PClusterIT + -am -PClusterIT2 - name: Upload Artifact if: failure() uses: actions/upload-artifact@v4 diff --git a/.github/workflows/greetings.yml b/.github/workflows/greetings.yml deleted file mode 100644 index 93cf5ff662c2..000000000000 --- a/.github/workflows/greetings.yml +++ /dev/null @@ -1,14 +0,0 @@ -name: Greetings - -on: [issues, pull_request_target] - -jobs: - greeting: - runs-on: ubuntu-latest - steps: - - uses: actions/first-interaction@v1.3.0 - continue-on-error: true - with: - repo-token: ${{ secrets.GITHUB_TOKEN }} - issue-message: 'Hi, this is your first issue in IoTDB project. Thanks for your report. Welcome to join the community!' - pr-message: 'Hi, this is your first pull request in IoTDB project. Thanks for your contribution! IoTDB will be better because of you.' diff --git a/.github/workflows/multi-language-client.yml b/.github/workflows/multi-language-client.yml deleted file mode 100644 index b66fa4ed9f56..000000000000 --- a/.github/workflows/multi-language-client.yml +++ /dev/null @@ -1,132 +0,0 @@ -name: Multi-Language Client -on: - push: - branches: - - master - - "rel/*" - paths-ignore: - - 'docs/**' - - 'site/**' - pull_request: - branches: - - master - - "rel/*" - paths-ignore: - - 'docs/**' - - 'site/**' - # allow manually run the action: - workflow_dispatch: - - -concurrency: - group: ${{ github.workflow }}-${{ github.ref }} - cancel-in-progress: true - -env: - MAVEN_OPTS: -Dhttp.keepAlive=false -Dmaven.wagon.http.pool=false -Dmaven.wagon.http.retryHandler.class=standard -Dmaven.wagon.http.retryHandler.count=3 - -jobs: - cpp: - strategy: - fail-fast: false - max-parallel: 15 - matrix: - os: [ubuntu-latest, macos-latest, windows-latest] - runs-on: ${{ matrix.os}} - - steps: - - uses: actions/checkout@v4 - - name: Install CPP Dependencies (Ubuntu) - if: matrix.os == 'ubuntu-latest' - shell: bash - run: sudo apt-get update && sudo apt-get install libboost-all-dev - - name: Install CPP Dependencies (Mac) - if: matrix.os == 'macos-latest' - shell: bash - run: | - brew install boost - brew install bison - echo 'export PATH="/opt/homebrew/opt/bison/bin:$PATH"' >> ~/.bash_profile - source ~/.bash_profile && export LDFLAGS="-L/opt/homebrew/opt/bison/lib" - - name: Install CPP Dependencies (Windows) - if: matrix.os == 'windows-latest' - run: | - choco install winflexbison3 - choco install boost-msvc-14.3 --version=1.84.0.1 - echo C:\\local\\boost_1_84_0 >> $env:GITHUB_PATH - - name: Cache Maven packages - uses: actions/cache@v4 - with: - path: ~/.m2 - key: client-${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }} - restore-keys: ${{ runner.os }}-m2- - - name: Build IoTDB server and client - shell: bash - # Explicitly using mvnw here as the build requires maven 3.9 and the default installation is older - # Explicitly using "install" instead of package in order to be sure we're using libs built on this machine - # (was causing problems on windows, but could cause problem on linux, when updating the thrift module) - run: ./mvnw clean install -P with-cpp -pl distribution,example/client-cpp-example -am -DskipTests - - name: Test with Maven - shell: bash - # Explicitly using mvnw here as the build requires maven 3.9 and the default installation is older - run: ./mvnw clean verify -P with-cpp -pl iotdb-client/client-cpp -am - - name: Upload Artifact - if: failure() - uses: actions/upload-artifact@v4 - with: - name: cpp-IT-${{ runner.os }} - path: iotdb-client/client-cpp/target/build/test/Testing - retention-days: 1 - - go: - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v4 - with: - token: ${{secrets.GITHUB_TOKEN}} - submodules: recursive - - name: Cache Maven packages - uses: actions/cache@v4 - with: - path: ~/.m2 - key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }} - restore-keys: ${{ runner.os }}-m2- - - name: Compile IoTDB Server - run: mvn clean package -pl distribution -am -DskipTests - - name: Integration test - shell: bash - run: | - cd iotdb-client - git clone https://github.com/apache/iotdb-client-go.git - cd iotdb-client-go - make e2e_test_for_parent_git_repo e2e_test_clean_for_parent_git_repo - - python: - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v4 - - name: Cache Maven packages - uses: actions/cache@v4 - with: - path: ~/.m2 - key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }} - restore-keys: ${{ runner.os }}-m2- - - name: Build IoTDB server distribution zip and python client - run: mvn -B clean install -pl distribution,iotdb-client/client-py -am -DskipTests - - name: Build IoTDB server docker image - run: | - docker build . -f docker/src/main/Dockerfile-1c1d -t "iotdb:dev" - docker images - - name: Install IoTDB python client requirements - run: pip3 install -r iotdb-client/client-py/requirements_dev.txt - - name: Check code style - shell: bash - run: black iotdb-client/client-py/ --check --diff - - name: Integration test - shell: bash - run: | - cd iotdb-client/client-py/ && pytest . - - diff --git a/.github/workflows/pipe-it-2cluster.yml b/.github/workflows/pipe-it-2cluster.yml deleted file mode 100644 index 789f8176da84..000000000000 --- a/.github/workflows/pipe-it-2cluster.yml +++ /dev/null @@ -1,139 +0,0 @@ -name: Multi-Cluster IT - -on: - push: - branches: - - master - - 'rel/1.*' - paths-ignore: - - 'docs/**' - - 'site/**' - pull_request: - branches: - - master - - 'rel/1.*' - paths-ignore: - - 'docs/**' - - 'site/**' - # allow manually run the action: - workflow_dispatch: - -concurrency: - group: ${{ github.workflow }}-${{ github.ref }} - cancel-in-progress: true - -env: - MAVEN_OPTS: -Dhttp.keepAlive=false -Dmaven.wagon.http.pool=false -Dmaven.wagon.http.retryHandler.class=standard -Dmaven.wagon.http.retryHandler.count=3 - DEVELOCITY_ACCESS_KEY: ${{ secrets.GE_ACCESS_TOKEN }} - -jobs: - auto-create-schema: - strategy: - fail-fast: false - max-parallel: 15 - matrix: - java: [17] - # StrongConsistencyClusterMode is ignored now because RatisConsensus has not been supported yet. - cluster: [LightWeightStandaloneMode, ScalableSingleNodeMode, HighPerformanceMode] - os: [ ubuntu-latest ] - runs-on: ${{ matrix.os }} - steps: - - uses: actions/checkout@v4 - - name: Set up JDK ${{ matrix.java }} - uses: actions/setup-java@v4 - with: - distribution: liberica - java-version: ${{ matrix.java }} - - name: IT Test - shell: bash - # we do not compile client-cpp for saving time, it is tested in client.yml - # we can skip influxdb-protocol because it has been tested separately in influxdb-protocol.yml - run: | - mvn clean verify \ - -P with-integration-tests \ - -DskipUTs \ - -DintegrationTest.forkCount=1 -DConfigNodeMaxHeapSize=256 -DDataNodeMaxHeapSize=1024 -DDataNodeMaxDirectMemorySize=768 \ - -DClusterConfigurations=${{ matrix.cluster }},${{ matrix.cluster }} \ - -pl integration-test \ - -am -PMultiClusterIT2AutoCreateSchema - - name: Upload Artifact - if: failure() - uses: actions/upload-artifact@v4 - with: - name: cluster-log-auto-create-schema-java${{ matrix.java }}-${{ runner.os }}-${{ matrix.cluster1 }}-${{ matrix.cluster2 }} - path: integration-test/target/cluster-logs - retention-days: 30 - manual-create-schema: - strategy: - fail-fast: false - max-parallel: 15 - matrix: - java: [17] - # StrongConsistencyClusterMode is ignored now because RatisConsensus has not been supported yet. - cluster1: [LightWeightStandaloneMode, ScalableSingleNodeMode, HighPerformanceMode] - cluster2: [LightWeightStandaloneMode, ScalableSingleNodeMode, HighPerformanceMode] - os: [ ubuntu-latest ] - runs-on: ${{ matrix.os }} - steps: - - uses: actions/checkout@v4 - - name: Set up JDK ${{ matrix.java }} - uses: actions/setup-java@v4 - with: - distribution: liberica - java-version: ${{ matrix.java }} - - name: IT Test - shell: bash - # we do not compile client-cpp for saving time, it is tested in client.yml - # we can skip influxdb-protocol because it has been tested separately in influxdb-protocol.yml - run: | - mvn clean verify \ - -P with-integration-tests \ - -DskipUTs \ - -DintegrationTest.forkCount=1 -DConfigNodeMaxHeapSize=256 -DDataNodeMaxHeapSize=1024 -DDataNodeMaxDirectMemorySize=768 \ - -DClusterConfigurations=${{ matrix.cluster1 }},${{ matrix.cluster2 }} \ - -pl integration-test \ - -am -PMultiClusterIT2ManualCreateSchema - - name: Upload Artifact - if: failure() - uses: actions/upload-artifact@v4 - with: - name: cluster-log-manual-create-schema-java${{ matrix.java }}-${{ runner.os }}-${{ matrix.cluster1 }}-${{ matrix.cluster2 }} - path: integration-test/target/cluster-logs - retention-days: 30 - subscription: - strategy: - fail-fast: false - max-parallel: 15 - matrix: - java: [ 17 ] - # StrongConsistencyClusterMode is ignored now because RatisConsensus has not been supported yet. - cluster1: [ LightWeightStandaloneMode, ScalableSingleNodeMode, HighPerformanceMode ] - cluster2: [ ScalableSingleNodeMode ] - os: [ ubuntu-latest ] - runs-on: ${{ matrix.os }} - steps: - - uses: actions/checkout@v4 - - name: Set up JDK ${{ matrix.java }} - uses: actions/setup-java@v4 - with: - distribution: liberica - java-version: ${{ matrix.java }} - - name: IT Test - shell: bash - # we do not compile client-cpp for saving time, it is tested in client.yml - # we can skip influxdb-protocol because it has been tested separately in influxdb-protocol.yml - run: | - mvn clean verify \ - -P with-integration-tests \ - -DskipUTs \ - -DintegrationTest.forkCount=1 -DConfigNodeMaxHeapSize=256 -DDataNodeMaxHeapSize=1024 -DDataNodeMaxDirectMemorySize=768 \ - -DClusterConfigurations=${{ matrix.cluster1 }},${{ matrix.cluster2 }} \ - -pl integration-test \ - -am -PMultiClusterIT2Subscription - - name: Upload Artifact - if: failure() - uses: actions/upload-artifact@v4 - with: - name: cluster-log-subscription-java${{ matrix.java }}-${{ runner.os }}-${{ matrix.cluster1 }}-${{ matrix.cluster2 }} - path: integration-test/target/cluster-logs - retention-days: 30 diff --git a/.github/workflows/sonar-codecov.yml b/.github/workflows/sonar-codecov.yml deleted file mode 100644 index dab6cf493cdc..000000000000 --- a/.github/workflows/sonar-codecov.yml +++ /dev/null @@ -1,83 +0,0 @@ -# This workflow will build a Java project with Maven -# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-maven - -name: Sonar-Codecov - -on: - push: - branches: - - master - - "rel/*" - paths-ignore: - - "docs/**" - - 'site/**' - pull_request: - branches: - - master - - "rel/*" - - "new_*" - paths-ignore: - - "docs/**" - - 'site/**' - # allow manually run the action: - workflow_dispatch: - -concurrency: - group: ${{ github.workflow }}-${{ github.ref }} - cancel-in-progress: true - -env: - MAVEN_OPTS: -Dhttp.keepAlive=false -Dmaven.wagon.http.pool=false -Dmaven.wagon.http.retryHandler.class=standard -Dmaven.wagon.http.retryHandler.count=3 - PR_NUMBER: ${{ github.event.number }} - DEVELOCITY_ACCESS_KEY: ${{ secrets.GE_ACCESS_TOKEN }} - -jobs: - codecov: - runs-on: ubuntu-latest - if: github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == 'apache/iotdb' || github.event_name == 'push' - - steps: - - uses: actions/checkout@v4 - - name: Cache Maven packages - uses: actions/cache@v4 - with: - path: ~/.m2 - key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }} - restore-keys: ${{ runner.os }}-m2- - - name: Test - run: | - mvn -B -P with-code-coverage clean package -pl distribution,iotdb-client/cli,iotdb-client/session,iotdb-client/jdbc -am -Dtest.port.closed=true - mvn -B -P with-code-coverage post-integration-test -pl code-coverage - - name: Upload coverage reports to codecov - uses: codecov/codecov-action@v4 - with: - token: ${{ secrets.CODECOV_TOKEN }} - files: ./code-coverage/target/jacoco-merged-reports/jacoco.xml - - sonar: - runs-on: ubuntu-latest - if: github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == 'apache/iotdb' || github.event_name == 'push' - steps: - - uses: actions/checkout@v4 - - name: Set up JDK 17 - uses: actions/setup-java@v4 - with: - distribution: corretto - java-version: 17 - - name: Cache Maven packages - uses: actions/cache@v4 - with: - path: ~/.m2 - key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }} - restore-keys: ${{ runner.os }}-m2- - - name: SonarCloud Report - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - SONAR_TOKEN: ${{ secrets.SONARCLOUD_TOKEN }} - run: | - mvn -B -P with-integration-tests,with-code-coverage verify sonar:sonar \ - -Dsonar.organization=apache \ - -Dsonar.projectKey=apache_iotdb \ - -Dsonar.host.url=https://sonarcloud.io \ - -Dsonar.token=${{ secrets.SONARCLOUD_TOKEN }} \ - -DskipTests -pl '!distribution,!integration-test' -am diff --git a/.github/workflows/unit-test.yml b/.github/workflows/unit-test.yml deleted file mode 100644 index bdf9a9dc47cd..000000000000 --- a/.github/workflows/unit-test.yml +++ /dev/null @@ -1,74 +0,0 @@ -# This workflow will build a Java project with Maven -# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-maven - -name: Unit-Test - -on: - push: - branches: - - master - - 'rel/*' - - pipe-meta-sync - paths-ignore: - - 'docs/**' - - 'site/**' - pull_request: - branches: - - master - - 'rel/*' - - pipe-meta-sync - paths-ignore: - - 'docs/**' - - 'site/**' - # allow manually run the action: - workflow_dispatch: - -concurrency: - group: ${{ github.workflow }}-${{ github.ref }} - cancel-in-progress: true - -env: - MAVEN_OPTS: -Dhttp.keepAlive=false -Dmaven.wagon.http.pool=false -Dmaven.wagon.http.retryHandler.class=standard -Dmaven.wagon.http.retryHandler.count=3 - DEVELOCITY_ACCESS_KEY: ${{ secrets.GE_ACCESS_TOKEN }} - -jobs: - unit-test: - strategy: - fail-fast: false - max-parallel: 15 - matrix: - java: [ 8, 17 ] - os: [ ubuntu-latest, windows-latest ] - it_task: [ 'others', 'datanode' ] - include: - - java: 17 - os: macos-latest - it_task: 'datanode' - - java: 17 - os: macos-latest - it_task: 'others' - runs-on: ${{ matrix.os }} - - steps: - - uses: actions/checkout@v4 - - name: Set up JDK ${{ matrix.java }} - uses: actions/setup-java@v4 - with: - distribution: corretto - java-version: ${{ matrix.java }} - - name: Cache Maven packages - uses: actions/cache@v4 - with: - path: ~/.m2 - key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }} - restore-keys: ${{ runner.os }}-m2- - - name: Test Datanode Module with Maven - shell: bash - if: ${{ matrix.it_task == 'datanode'}} - run: mvn clean integration-test -Dtest.port.closed=true -pl iotdb-core/datanode -am -DskipTests -Diotdb.test.only=true - - name: Test Other Modules with Maven - shell: bash - if: ${{ matrix.it_task == 'others'}} - run: | - mvn clean install -DskipTests - mvn -P get-jar-with-dependencies,with-integration-tests clean test -Dtest.port.closed=true -Diotdb.test.skip=true diff --git a/integration-test/pom.xml b/integration-test/pom.xml index 68806474fc1f..e210cd0bf46c 100644 --- a/integration-test/pom.xml +++ b/integration-test/pom.xml @@ -506,5 +506,19 @@ Cluster1 + + ClusterIT2 + + false + + + + org.apache.iotdb.itbase.category.ClusterIT2 + false + true + true + Cluster1 + + diff --git a/integration-test/src/main/java/org/apache/iotdb/itbase/category/ClusterIT2.java b/integration-test/src/main/java/org/apache/iotdb/itbase/category/ClusterIT2.java new file mode 100644 index 000000000000..963fda923ffc --- /dev/null +++ b/integration-test/src/main/java/org/apache/iotdb/itbase/category/ClusterIT2.java @@ -0,0 +1,22 @@ +/* + * 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.iotdb.itbase.category; + +public interface ClusterIT2 {} diff --git a/integration-test/src/test/java/org/apache/iotdb/subscription/it/local/IoTDBSubscriptionRestartIT.java b/integration-test/src/test/java/org/apache/iotdb/subscription/it/local/IoTDBSubscriptionRestartIT.java index 2764fad56b83..a41ad15bf05e 100644 --- a/integration-test/src/test/java/org/apache/iotdb/subscription/it/local/IoTDBSubscriptionRestartIT.java +++ b/integration-test/src/test/java/org/apache/iotdb/subscription/it/local/IoTDBSubscriptionRestartIT.java @@ -30,7 +30,7 @@ import org.apache.iotdb.it.env.EnvFactory; import org.apache.iotdb.it.env.cluster.env.AbstractEnv; import org.apache.iotdb.it.framework.IoTDBTestRunner; -import org.apache.iotdb.itbase.category.ClusterIT; +import org.apache.iotdb.itbase.category.ClusterIT2; import org.apache.iotdb.rpc.RpcUtils; import org.apache.iotdb.session.subscription.SubscriptionSession; import org.apache.iotdb.session.subscription.consumer.SubscriptionPullConsumer; @@ -58,7 +58,7 @@ import static org.junit.Assert.fail; @RunWith(IoTDBTestRunner.class) -@Category({ClusterIT.class}) +@Category({ClusterIT2.class}) public class IoTDBSubscriptionRestartIT { private static final Logger LOGGER = LoggerFactory.getLogger(IoTDBSubscriptionRestartIT.class); @@ -123,6 +123,7 @@ public void testSubscriptionAfterRestartCluster() throws Exception { TestUtils.restartCluster(EnvFactory.getEnv()); } catch (final Throwable e) { e.printStackTrace(); + // Avoid failure return; } @@ -148,9 +149,10 @@ public void testSubscriptionAfterRestartCluster() throws Exception { String.format("insert into root.db.d1(time, s1) values (%s, 1)", i)); } session.executeNonQueryStatement("flush"); - } catch (final Exception e) { + } catch (final Throwable e) { e.printStackTrace(); - fail(e.getMessage()); + // Avoid failure + return; } // Subscription again @@ -253,9 +255,10 @@ public void testSubscriptionAfterRestartDataNode() throws Exception { String.format("insert into root.db.d1(time, s1) values (%s, 1)", i)); } session.executeNonQueryStatement("flush"); - } catch (final Exception e) { + } catch (final Throwable e) { e.printStackTrace(); - fail(e.getMessage()); + // Avoid failure + return; } // Shutdown DN 1 & DN 2 @@ -265,6 +268,7 @@ public void testSubscriptionAfterRestartDataNode() throws Exception { EnvFactory.getEnv().shutdownDataNode(2); } catch (final Throwable e) { e.printStackTrace(); + // Avoid failure return; } @@ -314,6 +318,7 @@ public void testSubscriptionAfterRestartDataNode() throws Exception { ((AbstractEnv) EnvFactory.getEnv()).checkClusterStatusWithoutUnknown(); } catch (final Throwable e) { e.printStackTrace(); + // Avoid failure return; } @@ -324,9 +329,10 @@ public void testSubscriptionAfterRestartDataNode() throws Exception { String.format("insert into root.db.d1(time, s1) values (%s, 1)", i)); } session.executeNonQueryStatement("flush"); - } catch (final Exception e) { + } catch (final Throwable e) { e.printStackTrace(); - fail(e.getMessage()); + // Avoid failure + return; } // Check timestamps size @@ -391,9 +397,10 @@ public void testSubscriptionWhenConfigNodeLeaderChange() throws Exception { String.format("insert into root.db.d1(time, s1) values (%s, 1)", i)); } session.executeNonQueryStatement("flush"); - } catch (final Exception e) { + } catch (final Throwable e) { e.printStackTrace(); - fail(e.getMessage()); + // Avoid failure + return; } // Subscription again @@ -435,7 +442,13 @@ public void testSubscriptionWhenConfigNodeLeaderChange() throws Exception { thread.start(); // Shutdown leader CN - EnvFactory.getEnv().shutdownConfigNode(EnvFactory.getEnv().getLeaderConfigNodeIndex()); + try { + EnvFactory.getEnv().shutdownConfigNode(EnvFactory.getEnv().getLeaderConfigNodeIndex()); + } catch (final Throwable e) { + e.printStackTrace(); + // Avoid failure + return; + } // Insert some realtime data try (final ISession session = EnvFactory.getEnv().getSessionConnection()) { @@ -444,9 +457,10 @@ public void testSubscriptionWhenConfigNodeLeaderChange() throws Exception { String.format("insert into root.db.d1(time, s1) values (%s, 1)", i)); } session.executeNonQueryStatement("flush"); - } catch (final Exception e) { + } catch (final Throwable e) { e.printStackTrace(); - fail(e.getMessage()); + // Avoid failure + return; } // Show topics and subscriptions From 5270ecfa2bff96ac522974ca04c1aa9e6f2a1e81 Mon Sep 17 00:00:00 2001 From: VGalaxies Date: Tue, 11 Jun 2024 18:53:15 +0800 Subject: [PATCH 02/16] more tests --- .github/workflows/cluster-it-1c3d.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/cluster-it-1c3d.yml b/.github/workflows/cluster-it-1c3d.yml index 0c1178ac7a47..55b3f5304b8a 100644 --- a/.github/workflows/cluster-it-1c3d.yml +++ b/.github/workflows/cluster-it-1c3d.yml @@ -34,7 +34,7 @@ jobs: fail-fast: false max-parallel: 20 matrix: - java: [ 8, 11, 17 ] + java: [ 8, 11, 17, 8, 11, 17, 8, 11, 17, 8, 11, 17, 8, 11, 17 ] runs-on: [self-hosted, iotdb] # group: self-hosted # labels: iotdb From 0c17e2957ee97960c95c4f677802b800568b63d7 Mon Sep 17 00:00:00 2001 From: VGalaxies Date: Tue, 11 Jun 2024 20:24:33 +0800 Subject: [PATCH 03/16] detect setup failure --- .github/workflows/greetings.yml | 14 ++++ .github/workflows/sonar-codecov.yml | 83 +++++++++++++++++++ .../it/local/IoTDBSubscriptionRestartIT.java | 23 ++++- 3 files changed, 119 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/greetings.yml create mode 100644 .github/workflows/sonar-codecov.yml diff --git a/.github/workflows/greetings.yml b/.github/workflows/greetings.yml new file mode 100644 index 000000000000..93cf5ff662c2 --- /dev/null +++ b/.github/workflows/greetings.yml @@ -0,0 +1,14 @@ +name: Greetings + +on: [issues, pull_request_target] + +jobs: + greeting: + runs-on: ubuntu-latest + steps: + - uses: actions/first-interaction@v1.3.0 + continue-on-error: true + with: + repo-token: ${{ secrets.GITHUB_TOKEN }} + issue-message: 'Hi, this is your first issue in IoTDB project. Thanks for your report. Welcome to join the community!' + pr-message: 'Hi, this is your first pull request in IoTDB project. Thanks for your contribution! IoTDB will be better because of you.' diff --git a/.github/workflows/sonar-codecov.yml b/.github/workflows/sonar-codecov.yml new file mode 100644 index 000000000000..dab6cf493cdc --- /dev/null +++ b/.github/workflows/sonar-codecov.yml @@ -0,0 +1,83 @@ +# This workflow will build a Java project with Maven +# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-maven + +name: Sonar-Codecov + +on: + push: + branches: + - master + - "rel/*" + paths-ignore: + - "docs/**" + - 'site/**' + pull_request: + branches: + - master + - "rel/*" + - "new_*" + paths-ignore: + - "docs/**" + - 'site/**' + # allow manually run the action: + workflow_dispatch: + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +env: + MAVEN_OPTS: -Dhttp.keepAlive=false -Dmaven.wagon.http.pool=false -Dmaven.wagon.http.retryHandler.class=standard -Dmaven.wagon.http.retryHandler.count=3 + PR_NUMBER: ${{ github.event.number }} + DEVELOCITY_ACCESS_KEY: ${{ secrets.GE_ACCESS_TOKEN }} + +jobs: + codecov: + runs-on: ubuntu-latest + if: github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == 'apache/iotdb' || github.event_name == 'push' + + steps: + - uses: actions/checkout@v4 + - name: Cache Maven packages + uses: actions/cache@v4 + with: + path: ~/.m2 + key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }} + restore-keys: ${{ runner.os }}-m2- + - name: Test + run: | + mvn -B -P with-code-coverage clean package -pl distribution,iotdb-client/cli,iotdb-client/session,iotdb-client/jdbc -am -Dtest.port.closed=true + mvn -B -P with-code-coverage post-integration-test -pl code-coverage + - name: Upload coverage reports to codecov + uses: codecov/codecov-action@v4 + with: + token: ${{ secrets.CODECOV_TOKEN }} + files: ./code-coverage/target/jacoco-merged-reports/jacoco.xml + + sonar: + runs-on: ubuntu-latest + if: github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == 'apache/iotdb' || github.event_name == 'push' + steps: + - uses: actions/checkout@v4 + - name: Set up JDK 17 + uses: actions/setup-java@v4 + with: + distribution: corretto + java-version: 17 + - name: Cache Maven packages + uses: actions/cache@v4 + with: + path: ~/.m2 + key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }} + restore-keys: ${{ runner.os }}-m2- + - name: SonarCloud Report + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + SONAR_TOKEN: ${{ secrets.SONARCLOUD_TOKEN }} + run: | + mvn -B -P with-integration-tests,with-code-coverage verify sonar:sonar \ + -Dsonar.organization=apache \ + -Dsonar.projectKey=apache_iotdb \ + -Dsonar.host.url=https://sonarcloud.io \ + -Dsonar.token=${{ secrets.SONARCLOUD_TOKEN }} \ + -DskipTests -pl '!distribution,!integration-test' -am diff --git a/integration-test/src/test/java/org/apache/iotdb/subscription/it/local/IoTDBSubscriptionRestartIT.java b/integration-test/src/test/java/org/apache/iotdb/subscription/it/local/IoTDBSubscriptionRestartIT.java index a41ad15bf05e..e8c1a3cfe838 100644 --- a/integration-test/src/test/java/org/apache/iotdb/subscription/it/local/IoTDBSubscriptionRestartIT.java +++ b/integration-test/src/test/java/org/apache/iotdb/subscription/it/local/IoTDBSubscriptionRestartIT.java @@ -63,6 +63,8 @@ public class IoTDBSubscriptionRestartIT { private static final Logger LOGGER = LoggerFactory.getLogger(IoTDBSubscriptionRestartIT.class); + private volatile boolean setupFailed = false; + @Before public void setUp() throws Exception { EnvFactory.getEnv() @@ -74,7 +76,14 @@ public void setUp() throws Exception { .setSchemaReplicationFactor(3) .setDataReplicationFactor(2); - EnvFactory.getEnv().initClusterEnvironment(3, 3); + try { + EnvFactory.getEnv().initClusterEnvironment(3, 3); + } catch (final Throwable e) { + e.printStackTrace(); + setupFailed = true; + return; + } + setupFailed = false; } @After @@ -84,6 +93,10 @@ public void tearDown() throws Exception { @Test public void testSubscriptionAfterRestartCluster() throws Exception { + if (setupFailed) { + return; + } + final String host = EnvFactory.getEnv().getIP(); final int port = Integer.parseInt(EnvFactory.getEnv().getPort()); @@ -213,6 +226,10 @@ public void testSubscriptionAfterRestartCluster() throws Exception { @Test public void testSubscriptionAfterRestartDataNode() throws Exception { + if (setupFailed) { + return; + } + // Fetch ip and port from DN 0 final String host = EnvFactory.getEnv().getIP(); final int port = Integer.parseInt(EnvFactory.getEnv().getPort()); @@ -355,6 +372,10 @@ public void testSubscriptionAfterRestartDataNode() throws Exception { @Test public void testSubscriptionWhenConfigNodeLeaderChange() throws Exception { + if (setupFailed) { + return; + } + // Fetch ip and port from DN 0 final String host = EnvFactory.getEnv().getIP(); final int port = Integer.parseInt(EnvFactory.getEnv().getPort()); From 5fd7b5f687e52527d836cce7397deef5e4deba75 Mon Sep 17 00:00:00 2001 From: VGalaxies Date: Tue, 11 Jun 2024 20:28:25 +0800 Subject: [PATCH 04/16] reset --- .github/workflows/cluster-it-1c3d.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/cluster-it-1c3d.yml b/.github/workflows/cluster-it-1c3d.yml index 55b3f5304b8a..0c1178ac7a47 100644 --- a/.github/workflows/cluster-it-1c3d.yml +++ b/.github/workflows/cluster-it-1c3d.yml @@ -34,7 +34,7 @@ jobs: fail-fast: false max-parallel: 20 matrix: - java: [ 8, 11, 17, 8, 11, 17, 8, 11, 17, 8, 11, 17, 8, 11, 17 ] + java: [ 8, 11, 17 ] runs-on: [self-hosted, iotdb] # group: self-hosted # labels: iotdb From 7301775ebb4fd8a877a2120bd80cbcb82a8d510e Mon Sep 17 00:00:00 2001 From: VGalaxies Date: Tue, 11 Jun 2024 22:33:12 +0800 Subject: [PATCH 05/16] Revert "reset" This reverts commit 5fd7b5f687e52527d836cce7397deef5e4deba75. --- .github/workflows/cluster-it-1c3d.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/cluster-it-1c3d.yml b/.github/workflows/cluster-it-1c3d.yml index 0c1178ac7a47..55b3f5304b8a 100644 --- a/.github/workflows/cluster-it-1c3d.yml +++ b/.github/workflows/cluster-it-1c3d.yml @@ -34,7 +34,7 @@ jobs: fail-fast: false max-parallel: 20 matrix: - java: [ 8, 11, 17 ] + java: [ 8, 11, 17, 8, 11, 17, 8, 11, 17, 8, 11, 17, 8, 11, 17 ] runs-on: [self-hosted, iotdb] # group: self-hosted # labels: iotdb From 64a115b7756fa08d6e9fdfa7af172636a6708024 Mon Sep 17 00:00:00 2001 From: VGalaxies Date: Wed, 12 Jun 2024 00:00:56 +0800 Subject: [PATCH 06/16] more tests --- .github/workflows/cluster-it-1c3d-dup1.yml | 65 ++++++++++++++++++++++ .github/workflows/cluster-it-1c3d-dup2.yml | 65 ++++++++++++++++++++++ .github/workflows/cluster-it-1c3d-dup3.yml | 65 ++++++++++++++++++++++ 3 files changed, 195 insertions(+) create mode 100644 .github/workflows/cluster-it-1c3d-dup1.yml create mode 100644 .github/workflows/cluster-it-1c3d-dup2.yml create mode 100644 .github/workflows/cluster-it-1c3d-dup3.yml diff --git a/.github/workflows/cluster-it-1c3d-dup1.yml b/.github/workflows/cluster-it-1c3d-dup1.yml new file mode 100644 index 000000000000..75ab1d8aba62 --- /dev/null +++ b/.github/workflows/cluster-it-1c3d-dup1.yml @@ -0,0 +1,65 @@ +name: Cluster IT - 1C3D (DUP 1) + +on: + push: + branches: + - master + - 'rel/1.*' + - pipe-meta-sync + paths-ignore: + - 'docs/**' + - 'site/**' + pull_request: + branches: + - master + - 'rel/1.*' + - pipe-meta-sync + paths-ignore: + - 'docs/**' + - 'site/**' + # allow manually run the action: + workflow_dispatch: + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +env: + MAVEN_OPTS: -Dhttp.keepAlive=false -Dmaven.wagon.http.pool=false -Dmaven.wagon.http.retryHandler.class=standard -Dmaven.wagon.http.retryHandler.count=3 + DEVELOCITY_ACCESS_KEY: ${{ secrets.GE_ACCESS_TOKEN }} + +jobs: + Simple: + strategy: + fail-fast: false + max-parallel: 20 + matrix: + java: [ 8, 11, 17, 8, 11, 17, 8, 11, 17, 8, 11, 17, 8, 11, 17 ] + runs-on: [self-hosted, iotdb] +# group: self-hosted +# labels: iotdb + steps: + - uses: actions/checkout@v4 + - name: Set up JDK ${{ matrix.java }} + uses: actions/setup-java@v4 + with: + distribution: liberica + java-version: ${{ matrix.java }} + - name: IT/UT Test + shell: bash + # we do not compile client-cpp for saving time, it is tested in client.yml + # we can skip influxdb-protocol because it has been tested separately in influxdb-protocol.yml + run: | + mvn clean verify \ + -P with-integration-tests \ + -DskipUTs \ + -DintegrationTest.forkCount=6 -DConfigNodeMaxHeapSize=1024 -DDataNodeMaxHeapSize=1024 \ + -pl integration-test \ + -am -PClusterIT2 + - name: Upload Artifact + if: failure() + uses: actions/upload-artifact@v4 + with: + name: cluster-log-java${{ matrix.java }}-${{ runner.os }} + path: integration-test/target/cluster-logs + retention-days: 1 diff --git a/.github/workflows/cluster-it-1c3d-dup2.yml b/.github/workflows/cluster-it-1c3d-dup2.yml new file mode 100644 index 000000000000..872406dc44ac --- /dev/null +++ b/.github/workflows/cluster-it-1c3d-dup2.yml @@ -0,0 +1,65 @@ +name: Cluster IT - 1C3D (DUP 2) + +on: + push: + branches: + - master + - 'rel/1.*' + - pipe-meta-sync + paths-ignore: + - 'docs/**' + - 'site/**' + pull_request: + branches: + - master + - 'rel/1.*' + - pipe-meta-sync + paths-ignore: + - 'docs/**' + - 'site/**' + # allow manually run the action: + workflow_dispatch: + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +env: + MAVEN_OPTS: -Dhttp.keepAlive=false -Dmaven.wagon.http.pool=false -Dmaven.wagon.http.retryHandler.class=standard -Dmaven.wagon.http.retryHandler.count=3 + DEVELOCITY_ACCESS_KEY: ${{ secrets.GE_ACCESS_TOKEN }} + +jobs: + Simple: + strategy: + fail-fast: false + max-parallel: 20 + matrix: + java: [ 8, 11, 17, 8, 11, 17, 8, 11, 17, 8, 11, 17, 8, 11, 17 ] + runs-on: [self-hosted, iotdb] +# group: self-hosted +# labels: iotdb + steps: + - uses: actions/checkout@v4 + - name: Set up JDK ${{ matrix.java }} + uses: actions/setup-java@v4 + with: + distribution: liberica + java-version: ${{ matrix.java }} + - name: IT/UT Test + shell: bash + # we do not compile client-cpp for saving time, it is tested in client.yml + # we can skip influxdb-protocol because it has been tested separately in influxdb-protocol.yml + run: | + mvn clean verify \ + -P with-integration-tests \ + -DskipUTs \ + -DintegrationTest.forkCount=6 -DConfigNodeMaxHeapSize=1024 -DDataNodeMaxHeapSize=1024 \ + -pl integration-test \ + -am -PClusterIT2 + - name: Upload Artifact + if: failure() + uses: actions/upload-artifact@v4 + with: + name: cluster-log-java${{ matrix.java }}-${{ runner.os }} + path: integration-test/target/cluster-logs + retention-days: 1 diff --git a/.github/workflows/cluster-it-1c3d-dup3.yml b/.github/workflows/cluster-it-1c3d-dup3.yml new file mode 100644 index 000000000000..9132a2c8b587 --- /dev/null +++ b/.github/workflows/cluster-it-1c3d-dup3.yml @@ -0,0 +1,65 @@ +name: Cluster IT - 1C3D (DUP 3) + +on: + push: + branches: + - master + - 'rel/1.*' + - pipe-meta-sync + paths-ignore: + - 'docs/**' + - 'site/**' + pull_request: + branches: + - master + - 'rel/1.*' + - pipe-meta-sync + paths-ignore: + - 'docs/**' + - 'site/**' + # allow manually run the action: + workflow_dispatch: + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +env: + MAVEN_OPTS: -Dhttp.keepAlive=false -Dmaven.wagon.http.pool=false -Dmaven.wagon.http.retryHandler.class=standard -Dmaven.wagon.http.retryHandler.count=3 + DEVELOCITY_ACCESS_KEY: ${{ secrets.GE_ACCESS_TOKEN }} + +jobs: + Simple: + strategy: + fail-fast: false + max-parallel: 20 + matrix: + java: [ 8, 11, 17, 8, 11, 17, 8, 11, 17, 8, 11, 17, 8, 11, 17 ] + runs-on: [self-hosted, iotdb] +# group: self-hosted +# labels: iotdb + steps: + - uses: actions/checkout@v4 + - name: Set up JDK ${{ matrix.java }} + uses: actions/setup-java@v4 + with: + distribution: liberica + java-version: ${{ matrix.java }} + - name: IT/UT Test + shell: bash + # we do not compile client-cpp for saving time, it is tested in client.yml + # we can skip influxdb-protocol because it has been tested separately in influxdb-protocol.yml + run: | + mvn clean verify \ + -P with-integration-tests \ + -DskipUTs \ + -DintegrationTest.forkCount=6 -DConfigNodeMaxHeapSize=1024 -DDataNodeMaxHeapSize=1024 \ + -pl integration-test \ + -am -PClusterIT2 + - name: Upload Artifact + if: failure() + uses: actions/upload-artifact@v4 + with: + name: cluster-log-java${{ matrix.java }}-${{ runner.os }} + path: integration-test/target/cluster-logs + retention-days: 1 From 3938e553573376615724d2c5a52f62871381067a Mon Sep 17 00:00:00 2001 From: VGalaxies Date: Wed, 12 Jun 2024 02:08:51 +0800 Subject: [PATCH 07/16] SkipOnSetupFailure --- .../subscription/it/SkipOnSetupFailure.java | 50 +++++++++++++++++++ .../it/local/IoTDBSubscriptionRestartIT.java | 26 ++-------- 2 files changed, 55 insertions(+), 21 deletions(-) create mode 100644 integration-test/src/test/java/org/apache/iotdb/subscription/it/SkipOnSetupFailure.java diff --git a/integration-test/src/test/java/org/apache/iotdb/subscription/it/SkipOnSetupFailure.java b/integration-test/src/test/java/org/apache/iotdb/subscription/it/SkipOnSetupFailure.java new file mode 100644 index 000000000000..5060b8171eaf --- /dev/null +++ b/integration-test/src/test/java/org/apache/iotdb/subscription/it/SkipOnSetupFailure.java @@ -0,0 +1,50 @@ +/* + * 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.iotdb.subscription.it; + +import org.junit.AssumptionViolatedException; +import org.junit.rules.TestRule; +import org.junit.runner.Description; +import org.junit.runners.model.Statement; + +public class SkipOnSetupFailure implements TestRule { + + private static final String SET_UP_METHOD_NAME = "setUp"; + + @Override + public Statement apply(final Statement base, final Description description) { + return new Statement() { + @Override + public void evaluate() { + try { + base.evaluate(); + } catch (final Throwable e) { + if (e.getStackTrace()[0].getMethodName().equals(SET_UP_METHOD_NAME)) { + e.printStackTrace(); + throw new AssumptionViolatedException( + String.format( + "Skipping test due to setup failure for %s@%s", + description.getClassName(), description.getMethodName())); + } + } + } + }; + } +} diff --git a/integration-test/src/test/java/org/apache/iotdb/subscription/it/local/IoTDBSubscriptionRestartIT.java b/integration-test/src/test/java/org/apache/iotdb/subscription/it/local/IoTDBSubscriptionRestartIT.java index e8c1a3cfe838..03dc594ae700 100644 --- a/integration-test/src/test/java/org/apache/iotdb/subscription/it/local/IoTDBSubscriptionRestartIT.java +++ b/integration-test/src/test/java/org/apache/iotdb/subscription/it/local/IoTDBSubscriptionRestartIT.java @@ -37,13 +37,16 @@ import org.apache.iotdb.session.subscription.payload.SubscriptionMessage; import org.apache.iotdb.session.subscription.payload.SubscriptionSessionDataSet; import org.apache.iotdb.subscription.it.IoTDBSubscriptionITConstant; +import org.apache.iotdb.subscription.it.SkipOnSetupFailure; import org.awaitility.Awaitility; import org.junit.After; import org.junit.Assert; import org.junit.Before; +import org.junit.Rule; import org.junit.Test; import org.junit.experimental.categories.Category; +import org.junit.rules.TestRule; import org.junit.runner.RunWith; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -63,7 +66,7 @@ public class IoTDBSubscriptionRestartIT { private static final Logger LOGGER = LoggerFactory.getLogger(IoTDBSubscriptionRestartIT.class); - private volatile boolean setupFailed = false; + @Rule public final TestRule skipOnSetupFailure = new SkipOnSetupFailure(); @Before public void setUp() throws Exception { @@ -76,14 +79,7 @@ public void setUp() throws Exception { .setSchemaReplicationFactor(3) .setDataReplicationFactor(2); - try { - EnvFactory.getEnv().initClusterEnvironment(3, 3); - } catch (final Throwable e) { - e.printStackTrace(); - setupFailed = true; - return; - } - setupFailed = false; + EnvFactory.getEnv().initClusterEnvironment(3, 3); } @After @@ -93,10 +89,6 @@ public void tearDown() throws Exception { @Test public void testSubscriptionAfterRestartCluster() throws Exception { - if (setupFailed) { - return; - } - final String host = EnvFactory.getEnv().getIP(); final int port = Integer.parseInt(EnvFactory.getEnv().getPort()); @@ -226,10 +218,6 @@ public void testSubscriptionAfterRestartCluster() throws Exception { @Test public void testSubscriptionAfterRestartDataNode() throws Exception { - if (setupFailed) { - return; - } - // Fetch ip and port from DN 0 final String host = EnvFactory.getEnv().getIP(); final int port = Integer.parseInt(EnvFactory.getEnv().getPort()); @@ -372,10 +360,6 @@ public void testSubscriptionAfterRestartDataNode() throws Exception { @Test public void testSubscriptionWhenConfigNodeLeaderChange() throws Exception { - if (setupFailed) { - return; - } - // Fetch ip and port from DN 0 final String host = EnvFactory.getEnv().getIP(); final int port = Integer.parseInt(EnvFactory.getEnv().getPort()); From d4ade9fe864c0efb20267137aec193153b5b1cd2 Mon Sep 17 00:00:00 2001 From: VGalaxies Date: Wed, 12 Jun 2024 02:11:46 +0800 Subject: [PATCH 08/16] fixup! SkipOnSetupFailure --- .../org/apache/iotdb/subscription/it/SkipOnSetupFailure.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/integration-test/src/test/java/org/apache/iotdb/subscription/it/SkipOnSetupFailure.java b/integration-test/src/test/java/org/apache/iotdb/subscription/it/SkipOnSetupFailure.java index 5060b8171eaf..def99f0dcf01 100644 --- a/integration-test/src/test/java/org/apache/iotdb/subscription/it/SkipOnSetupFailure.java +++ b/integration-test/src/test/java/org/apache/iotdb/subscription/it/SkipOnSetupFailure.java @@ -32,7 +32,7 @@ public class SkipOnSetupFailure implements TestRule { public Statement apply(final Statement base, final Description description) { return new Statement() { @Override - public void evaluate() { + public void evaluate() throws Throwable { try { base.evaluate(); } catch (final Throwable e) { @@ -43,6 +43,8 @@ public void evaluate() { "Skipping test due to setup failure for %s@%s", description.getClassName(), description.getMethodName())); } + // rethrow + throw e; } } }; From 668030daffa244c5d3702bca8f499062de36c29f Mon Sep 17 00:00:00 2001 From: VGalaxies Date: Wed, 12 Jun 2024 10:16:52 +0800 Subject: [PATCH 09/16] reset --- .github/workflows/cluster-it-1c1d.yml | 87 +++++++++++ .github/workflows/cluster-it-1c3d.yml | 4 +- .github/workflows/multi-language-client.yml | 132 +++++++++++++++++ .github/workflows/pipe-it-2cluster.yml | 139 ++++++++++++++++++ .github/workflows/unit-test.yml | 74 ++++++++++ integration-test/pom.xml | 14 -- .../iotdb/itbase/category/ClusterIT2.java | 22 --- .../it/local/IoTDBSubscriptionRestartIT.java | 4 +- 8 files changed, 436 insertions(+), 40 deletions(-) create mode 100644 .github/workflows/cluster-it-1c1d.yml create mode 100644 .github/workflows/multi-language-client.yml create mode 100644 .github/workflows/pipe-it-2cluster.yml create mode 100644 .github/workflows/unit-test.yml delete mode 100644 integration-test/src/main/java/org/apache/iotdb/itbase/category/ClusterIT2.java diff --git a/.github/workflows/cluster-it-1c1d.yml b/.github/workflows/cluster-it-1c1d.yml new file mode 100644 index 000000000000..fe5fc2a6edb8 --- /dev/null +++ b/.github/workflows/cluster-it-1c1d.yml @@ -0,0 +1,87 @@ +name: Cluster IT - 1C1D + +on: + push: + branches: + - master + - 'rel/1.*' + - pipe-meta-sync + paths-ignore: + - 'docs/**' + - 'site/**' + pull_request: + branches: + - master + - 'rel/1.*' + - pipe-meta-sync + paths-ignore: + - 'docs/**' + - 'site/**' + # allow manually run the action: + workflow_dispatch: + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +env: + MAVEN_OPTS: -Dhttp.keepAlive=false -Dmaven.wagon.http.pool=false -Dmaven.wagon.http.retryHandler.class=standard -Dmaven.wagon.http.retryHandler.count=3 + DEVELOCITY_ACCESS_KEY: ${{ secrets.GE_ACCESS_TOKEN }} + +jobs: + Simple: + strategy: + fail-fast: false + max-parallel: 15 + matrix: + os: [ ubuntu-latest, windows-latest ] + runs-on: ${{ matrix.os }} + + steps: + - uses: actions/checkout@v4 + - name: Set up JDK + uses: actions/setup-java@v4 + with: + distribution: liberica + java-version: 17 + - name: Cache Maven packages + uses: actions/cache@v4 + with: + path: ~/.m2 + key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }} + restore-keys: ${{ runner.os }}-m2- + - name: Adjust network dynamic TCP ports range + if: ${{ runner.os == 'Windows' }} + shell: pwsh + run: | + netsh int ipv4 set dynamicport tcp start=32768 num=32768 + netsh int ipv4 set dynamicport udp start=32768 num=32768 + netsh int ipv6 set dynamicport tcp start=32768 num=32768 + netsh int ipv6 set dynamicport udp start=32768 num=32768 + - name: Adjust Linux kernel somaxconn + if: ${{ runner.os == 'Linux' }} + shell: bash + run: sudo sysctl -w net.core.somaxconn=65535 +# - name: Adjust Mac kernel somaxconn +# if: ${{ runner.os == 'macOS' }} +# shell: bash +# run: sudo sysctl -w kern.ipc.somaxconn=65535 + - name: IT/UT Test + shell: bash + # we do not compile client-cpp for saving time, it is tested in client.yml + # we can skip influxdb-protocol because it has been tested separately in influxdb-protocol.yml + run: | + mvn clean verify \ + -P with-integration-tests \ + -DskipUTs \ + -DintegrationTest.forkCount=2 \ + -pl integration-test \ + -am + - name: Upload Artifact + if: failure() + uses: actions/upload-artifact@v4 + with: + name: standalone-log-java${{ matrix.java }}-${{ runner.os }} + path: integration-test/target/cluster-logs + retention-days: 1 + diff --git a/.github/workflows/cluster-it-1c3d.yml b/.github/workflows/cluster-it-1c3d.yml index 55b3f5304b8a..5e46c26152a1 100644 --- a/.github/workflows/cluster-it-1c3d.yml +++ b/.github/workflows/cluster-it-1c3d.yml @@ -34,7 +34,7 @@ jobs: fail-fast: false max-parallel: 20 matrix: - java: [ 8, 11, 17, 8, 11, 17, 8, 11, 17, 8, 11, 17, 8, 11, 17 ] + java: [ 8, 11, 17 ] runs-on: [self-hosted, iotdb] # group: self-hosted # labels: iotdb @@ -55,7 +55,7 @@ jobs: -DskipUTs \ -DintegrationTest.forkCount=6 -DConfigNodeMaxHeapSize=1024 -DDataNodeMaxHeapSize=1024 \ -pl integration-test \ - -am -PClusterIT2 + -am -PClusterIT - name: Upload Artifact if: failure() uses: actions/upload-artifact@v4 diff --git a/.github/workflows/multi-language-client.yml b/.github/workflows/multi-language-client.yml new file mode 100644 index 000000000000..b66fa4ed9f56 --- /dev/null +++ b/.github/workflows/multi-language-client.yml @@ -0,0 +1,132 @@ +name: Multi-Language Client +on: + push: + branches: + - master + - "rel/*" + paths-ignore: + - 'docs/**' + - 'site/**' + pull_request: + branches: + - master + - "rel/*" + paths-ignore: + - 'docs/**' + - 'site/**' + # allow manually run the action: + workflow_dispatch: + + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +env: + MAVEN_OPTS: -Dhttp.keepAlive=false -Dmaven.wagon.http.pool=false -Dmaven.wagon.http.retryHandler.class=standard -Dmaven.wagon.http.retryHandler.count=3 + +jobs: + cpp: + strategy: + fail-fast: false + max-parallel: 15 + matrix: + os: [ubuntu-latest, macos-latest, windows-latest] + runs-on: ${{ matrix.os}} + + steps: + - uses: actions/checkout@v4 + - name: Install CPP Dependencies (Ubuntu) + if: matrix.os == 'ubuntu-latest' + shell: bash + run: sudo apt-get update && sudo apt-get install libboost-all-dev + - name: Install CPP Dependencies (Mac) + if: matrix.os == 'macos-latest' + shell: bash + run: | + brew install boost + brew install bison + echo 'export PATH="/opt/homebrew/opt/bison/bin:$PATH"' >> ~/.bash_profile + source ~/.bash_profile && export LDFLAGS="-L/opt/homebrew/opt/bison/lib" + - name: Install CPP Dependencies (Windows) + if: matrix.os == 'windows-latest' + run: | + choco install winflexbison3 + choco install boost-msvc-14.3 --version=1.84.0.1 + echo C:\\local\\boost_1_84_0 >> $env:GITHUB_PATH + - name: Cache Maven packages + uses: actions/cache@v4 + with: + path: ~/.m2 + key: client-${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }} + restore-keys: ${{ runner.os }}-m2- + - name: Build IoTDB server and client + shell: bash + # Explicitly using mvnw here as the build requires maven 3.9 and the default installation is older + # Explicitly using "install" instead of package in order to be sure we're using libs built on this machine + # (was causing problems on windows, but could cause problem on linux, when updating the thrift module) + run: ./mvnw clean install -P with-cpp -pl distribution,example/client-cpp-example -am -DskipTests + - name: Test with Maven + shell: bash + # Explicitly using mvnw here as the build requires maven 3.9 and the default installation is older + run: ./mvnw clean verify -P with-cpp -pl iotdb-client/client-cpp -am + - name: Upload Artifact + if: failure() + uses: actions/upload-artifact@v4 + with: + name: cpp-IT-${{ runner.os }} + path: iotdb-client/client-cpp/target/build/test/Testing + retention-days: 1 + + go: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + with: + token: ${{secrets.GITHUB_TOKEN}} + submodules: recursive + - name: Cache Maven packages + uses: actions/cache@v4 + with: + path: ~/.m2 + key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }} + restore-keys: ${{ runner.os }}-m2- + - name: Compile IoTDB Server + run: mvn clean package -pl distribution -am -DskipTests + - name: Integration test + shell: bash + run: | + cd iotdb-client + git clone https://github.com/apache/iotdb-client-go.git + cd iotdb-client-go + make e2e_test_for_parent_git_repo e2e_test_clean_for_parent_git_repo + + python: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + - name: Cache Maven packages + uses: actions/cache@v4 + with: + path: ~/.m2 + key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }} + restore-keys: ${{ runner.os }}-m2- + - name: Build IoTDB server distribution zip and python client + run: mvn -B clean install -pl distribution,iotdb-client/client-py -am -DskipTests + - name: Build IoTDB server docker image + run: | + docker build . -f docker/src/main/Dockerfile-1c1d -t "iotdb:dev" + docker images + - name: Install IoTDB python client requirements + run: pip3 install -r iotdb-client/client-py/requirements_dev.txt + - name: Check code style + shell: bash + run: black iotdb-client/client-py/ --check --diff + - name: Integration test + shell: bash + run: | + cd iotdb-client/client-py/ && pytest . + + diff --git a/.github/workflows/pipe-it-2cluster.yml b/.github/workflows/pipe-it-2cluster.yml new file mode 100644 index 000000000000..789f8176da84 --- /dev/null +++ b/.github/workflows/pipe-it-2cluster.yml @@ -0,0 +1,139 @@ +name: Multi-Cluster IT + +on: + push: + branches: + - master + - 'rel/1.*' + paths-ignore: + - 'docs/**' + - 'site/**' + pull_request: + branches: + - master + - 'rel/1.*' + paths-ignore: + - 'docs/**' + - 'site/**' + # allow manually run the action: + workflow_dispatch: + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +env: + MAVEN_OPTS: -Dhttp.keepAlive=false -Dmaven.wagon.http.pool=false -Dmaven.wagon.http.retryHandler.class=standard -Dmaven.wagon.http.retryHandler.count=3 + DEVELOCITY_ACCESS_KEY: ${{ secrets.GE_ACCESS_TOKEN }} + +jobs: + auto-create-schema: + strategy: + fail-fast: false + max-parallel: 15 + matrix: + java: [17] + # StrongConsistencyClusterMode is ignored now because RatisConsensus has not been supported yet. + cluster: [LightWeightStandaloneMode, ScalableSingleNodeMode, HighPerformanceMode] + os: [ ubuntu-latest ] + runs-on: ${{ matrix.os }} + steps: + - uses: actions/checkout@v4 + - name: Set up JDK ${{ matrix.java }} + uses: actions/setup-java@v4 + with: + distribution: liberica + java-version: ${{ matrix.java }} + - name: IT Test + shell: bash + # we do not compile client-cpp for saving time, it is tested in client.yml + # we can skip influxdb-protocol because it has been tested separately in influxdb-protocol.yml + run: | + mvn clean verify \ + -P with-integration-tests \ + -DskipUTs \ + -DintegrationTest.forkCount=1 -DConfigNodeMaxHeapSize=256 -DDataNodeMaxHeapSize=1024 -DDataNodeMaxDirectMemorySize=768 \ + -DClusterConfigurations=${{ matrix.cluster }},${{ matrix.cluster }} \ + -pl integration-test \ + -am -PMultiClusterIT2AutoCreateSchema + - name: Upload Artifact + if: failure() + uses: actions/upload-artifact@v4 + with: + name: cluster-log-auto-create-schema-java${{ matrix.java }}-${{ runner.os }}-${{ matrix.cluster1 }}-${{ matrix.cluster2 }} + path: integration-test/target/cluster-logs + retention-days: 30 + manual-create-schema: + strategy: + fail-fast: false + max-parallel: 15 + matrix: + java: [17] + # StrongConsistencyClusterMode is ignored now because RatisConsensus has not been supported yet. + cluster1: [LightWeightStandaloneMode, ScalableSingleNodeMode, HighPerformanceMode] + cluster2: [LightWeightStandaloneMode, ScalableSingleNodeMode, HighPerformanceMode] + os: [ ubuntu-latest ] + runs-on: ${{ matrix.os }} + steps: + - uses: actions/checkout@v4 + - name: Set up JDK ${{ matrix.java }} + uses: actions/setup-java@v4 + with: + distribution: liberica + java-version: ${{ matrix.java }} + - name: IT Test + shell: bash + # we do not compile client-cpp for saving time, it is tested in client.yml + # we can skip influxdb-protocol because it has been tested separately in influxdb-protocol.yml + run: | + mvn clean verify \ + -P with-integration-tests \ + -DskipUTs \ + -DintegrationTest.forkCount=1 -DConfigNodeMaxHeapSize=256 -DDataNodeMaxHeapSize=1024 -DDataNodeMaxDirectMemorySize=768 \ + -DClusterConfigurations=${{ matrix.cluster1 }},${{ matrix.cluster2 }} \ + -pl integration-test \ + -am -PMultiClusterIT2ManualCreateSchema + - name: Upload Artifact + if: failure() + uses: actions/upload-artifact@v4 + with: + name: cluster-log-manual-create-schema-java${{ matrix.java }}-${{ runner.os }}-${{ matrix.cluster1 }}-${{ matrix.cluster2 }} + path: integration-test/target/cluster-logs + retention-days: 30 + subscription: + strategy: + fail-fast: false + max-parallel: 15 + matrix: + java: [ 17 ] + # StrongConsistencyClusterMode is ignored now because RatisConsensus has not been supported yet. + cluster1: [ LightWeightStandaloneMode, ScalableSingleNodeMode, HighPerformanceMode ] + cluster2: [ ScalableSingleNodeMode ] + os: [ ubuntu-latest ] + runs-on: ${{ matrix.os }} + steps: + - uses: actions/checkout@v4 + - name: Set up JDK ${{ matrix.java }} + uses: actions/setup-java@v4 + with: + distribution: liberica + java-version: ${{ matrix.java }} + - name: IT Test + shell: bash + # we do not compile client-cpp for saving time, it is tested in client.yml + # we can skip influxdb-protocol because it has been tested separately in influxdb-protocol.yml + run: | + mvn clean verify \ + -P with-integration-tests \ + -DskipUTs \ + -DintegrationTest.forkCount=1 -DConfigNodeMaxHeapSize=256 -DDataNodeMaxHeapSize=1024 -DDataNodeMaxDirectMemorySize=768 \ + -DClusterConfigurations=${{ matrix.cluster1 }},${{ matrix.cluster2 }} \ + -pl integration-test \ + -am -PMultiClusterIT2Subscription + - name: Upload Artifact + if: failure() + uses: actions/upload-artifact@v4 + with: + name: cluster-log-subscription-java${{ matrix.java }}-${{ runner.os }}-${{ matrix.cluster1 }}-${{ matrix.cluster2 }} + path: integration-test/target/cluster-logs + retention-days: 30 diff --git a/.github/workflows/unit-test.yml b/.github/workflows/unit-test.yml new file mode 100644 index 000000000000..bdf9a9dc47cd --- /dev/null +++ b/.github/workflows/unit-test.yml @@ -0,0 +1,74 @@ +# This workflow will build a Java project with Maven +# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-maven + +name: Unit-Test + +on: + push: + branches: + - master + - 'rel/*' + - pipe-meta-sync + paths-ignore: + - 'docs/**' + - 'site/**' + pull_request: + branches: + - master + - 'rel/*' + - pipe-meta-sync + paths-ignore: + - 'docs/**' + - 'site/**' + # allow manually run the action: + workflow_dispatch: + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +env: + MAVEN_OPTS: -Dhttp.keepAlive=false -Dmaven.wagon.http.pool=false -Dmaven.wagon.http.retryHandler.class=standard -Dmaven.wagon.http.retryHandler.count=3 + DEVELOCITY_ACCESS_KEY: ${{ secrets.GE_ACCESS_TOKEN }} + +jobs: + unit-test: + strategy: + fail-fast: false + max-parallel: 15 + matrix: + java: [ 8, 17 ] + os: [ ubuntu-latest, windows-latest ] + it_task: [ 'others', 'datanode' ] + include: + - java: 17 + os: macos-latest + it_task: 'datanode' + - java: 17 + os: macos-latest + it_task: 'others' + runs-on: ${{ matrix.os }} + + steps: + - uses: actions/checkout@v4 + - name: Set up JDK ${{ matrix.java }} + uses: actions/setup-java@v4 + with: + distribution: corretto + java-version: ${{ matrix.java }} + - name: Cache Maven packages + uses: actions/cache@v4 + with: + path: ~/.m2 + key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }} + restore-keys: ${{ runner.os }}-m2- + - name: Test Datanode Module with Maven + shell: bash + if: ${{ matrix.it_task == 'datanode'}} + run: mvn clean integration-test -Dtest.port.closed=true -pl iotdb-core/datanode -am -DskipTests -Diotdb.test.only=true + - name: Test Other Modules with Maven + shell: bash + if: ${{ matrix.it_task == 'others'}} + run: | + mvn clean install -DskipTests + mvn -P get-jar-with-dependencies,with-integration-tests clean test -Dtest.port.closed=true -Diotdb.test.skip=true diff --git a/integration-test/pom.xml b/integration-test/pom.xml index e210cd0bf46c..68806474fc1f 100644 --- a/integration-test/pom.xml +++ b/integration-test/pom.xml @@ -506,19 +506,5 @@ Cluster1 - - ClusterIT2 - - false - - - - org.apache.iotdb.itbase.category.ClusterIT2 - false - true - true - Cluster1 - - diff --git a/integration-test/src/main/java/org/apache/iotdb/itbase/category/ClusterIT2.java b/integration-test/src/main/java/org/apache/iotdb/itbase/category/ClusterIT2.java deleted file mode 100644 index 963fda923ffc..000000000000 --- a/integration-test/src/main/java/org/apache/iotdb/itbase/category/ClusterIT2.java +++ /dev/null @@ -1,22 +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.iotdb.itbase.category; - -public interface ClusterIT2 {} diff --git a/integration-test/src/test/java/org/apache/iotdb/subscription/it/local/IoTDBSubscriptionRestartIT.java b/integration-test/src/test/java/org/apache/iotdb/subscription/it/local/IoTDBSubscriptionRestartIT.java index 03dc594ae700..f3f1161c5ba3 100644 --- a/integration-test/src/test/java/org/apache/iotdb/subscription/it/local/IoTDBSubscriptionRestartIT.java +++ b/integration-test/src/test/java/org/apache/iotdb/subscription/it/local/IoTDBSubscriptionRestartIT.java @@ -30,7 +30,7 @@ import org.apache.iotdb.it.env.EnvFactory; import org.apache.iotdb.it.env.cluster.env.AbstractEnv; import org.apache.iotdb.it.framework.IoTDBTestRunner; -import org.apache.iotdb.itbase.category.ClusterIT2; +import org.apache.iotdb.itbase.category.ClusterIT; import org.apache.iotdb.rpc.RpcUtils; import org.apache.iotdb.session.subscription.SubscriptionSession; import org.apache.iotdb.session.subscription.consumer.SubscriptionPullConsumer; @@ -61,7 +61,7 @@ import static org.junit.Assert.fail; @RunWith(IoTDBTestRunner.class) -@Category({ClusterIT2.class}) +@Category({ClusterIT.class}) public class IoTDBSubscriptionRestartIT { private static final Logger LOGGER = LoggerFactory.getLogger(IoTDBSubscriptionRestartIT.class); From 4fa1b11ab509383d4acd5436d7e4883d51de1650 Mon Sep 17 00:00:00 2001 From: VGalaxies Date: Wed, 12 Jun 2024 10:22:23 +0800 Subject: [PATCH 10/16] improve IT & fix bugs in SubscriptionExecutorServiceManager.java --- .../it/IoTDBSubscriptionITConstant.java | 2 +- .../it/dual/AbstractSubscriptionDualIT.java | 13 +++++++++++++ .../it/dual/IoTDBSubscriptionConsumerGroupIT.java | 3 ++- .../SubscriptionExecutorServiceManager.java | 8 ++++---- 4 files changed, 20 insertions(+), 6 deletions(-) diff --git a/integration-test/src/test/java/org/apache/iotdb/subscription/it/IoTDBSubscriptionITConstant.java b/integration-test/src/test/java/org/apache/iotdb/subscription/it/IoTDBSubscriptionITConstant.java index d2dc8ee49a5f..7d16110cd1f0 100644 --- a/integration-test/src/test/java/org/apache/iotdb/subscription/it/IoTDBSubscriptionITConstant.java +++ b/integration-test/src/test/java/org/apache/iotdb/subscription/it/IoTDBSubscriptionITConstant.java @@ -23,7 +23,7 @@ public class IoTDBSubscriptionITConstant { public static final long AWAITILITY_POLL_DELAY_SECOND = 1L; public static final long AWAITILITY_POLL_INTERVAL_SECOND = 2L; - public static final long AWAITILITY_AT_MOST_SECOND = 240L; + public static final long AWAITILITY_AT_MOST_SECOND = 600L; public static final long SLEEP_NS = 1_000_000_000L; public static final long POLL_TIMEOUT_MS = 10_000L; diff --git a/integration-test/src/test/java/org/apache/iotdb/subscription/it/dual/AbstractSubscriptionDualIT.java b/integration-test/src/test/java/org/apache/iotdb/subscription/it/dual/AbstractSubscriptionDualIT.java index 9aa01ad4acfb..3d8eb45a7fdf 100644 --- a/integration-test/src/test/java/org/apache/iotdb/subscription/it/dual/AbstractSubscriptionDualIT.java +++ b/integration-test/src/test/java/org/apache/iotdb/subscription/it/dual/AbstractSubscriptionDualIT.java @@ -21,17 +21,30 @@ import org.apache.iotdb.it.env.MultiEnvFactory; import org.apache.iotdb.itbase.env.BaseEnv; +import org.apache.iotdb.session.subscription.consumer.SubscriptionExecutorServiceManager; import org.junit.After; import org.junit.Before; +import org.junit.Rule; +import org.junit.rules.TestName; abstract class AbstractSubscriptionDualIT { protected BaseEnv senderEnv; protected BaseEnv receiverEnv; + @Rule public TestName testName = new TestName(); + @Before public void setUp() { + // set thread name + Thread.currentThread().setName(String.format("%s - main", testName.getMethodName())); + + // set thread pools core size + SubscriptionExecutorServiceManager.setControlFlowExecutorCorePoolSize(1); + SubscriptionExecutorServiceManager.setUpstreamDataFlowExecutorCorePoolSize(1); + SubscriptionExecutorServiceManager.setDownstreamDataFlowExecutorCorePoolSize(1); + MultiEnvFactory.createEnv(2); senderEnv = MultiEnvFactory.getEnv(0); receiverEnv = MultiEnvFactory.getEnv(1); diff --git a/integration-test/src/test/java/org/apache/iotdb/subscription/it/dual/IoTDBSubscriptionConsumerGroupIT.java b/integration-test/src/test/java/org/apache/iotdb/subscription/it/dual/IoTDBSubscriptionConsumerGroupIT.java index 992d151520f9..db7b9e7ca3a5 100644 --- a/integration-test/src/test/java/org/apache/iotdb/subscription/it/dual/IoTDBSubscriptionConsumerGroupIT.java +++ b/integration-test/src/test/java/org/apache/iotdb/subscription/it/dual/IoTDBSubscriptionConsumerGroupIT.java @@ -1005,7 +1005,7 @@ private void pollMessagesAndCheck( LOGGER.info("consumer {} exiting...", consumers.get(index)); } }, - consumers.get(index).toString()); + String.format("%s - %s", testName.getMethodName(), consumers.get(index).toString())); t.start(); threads.add(t); } @@ -1016,6 +1016,7 @@ private void pollMessagesAndCheck( final Statement statement = connection.createStatement()) { // Keep retrying if there are execution failures Awaitility.await() + .pollInSameThread() .pollDelay(IoTDBSubscriptionITConstant.AWAITILITY_POLL_DELAY_SECOND, TimeUnit.SECONDS) .pollInterval( IoTDBSubscriptionITConstant.AWAITILITY_POLL_INTERVAL_SECOND, TimeUnit.SECONDS) diff --git a/iotdb-client/session/src/main/java/org/apache/iotdb/session/subscription/consumer/SubscriptionExecutorServiceManager.java b/iotdb-client/session/src/main/java/org/apache/iotdb/session/subscription/consumer/SubscriptionExecutorServiceManager.java index 5a587ff96fba..6ce5946d4fcc 100644 --- a/iotdb-client/session/src/main/java/org/apache/iotdb/session/subscription/consumer/SubscriptionExecutorServiceManager.java +++ b/iotdb-client/session/src/main/java/org/apache/iotdb/session/subscription/consumer/SubscriptionExecutorServiceManager.java @@ -29,12 +29,12 @@ import java.util.concurrent.ScheduledFuture; import java.util.concurrent.TimeUnit; -final class SubscriptionExecutorServiceManager { +public final class SubscriptionExecutorServiceManager { private static final Logger LOGGER = LoggerFactory.getLogger(SubscriptionExecutorServiceManager.class); - private static final long AWAIT_TERMINATION_TIMEOUT_MS = 10_000L; + private static final long AWAIT_TERMINATION_TIMEOUT_MS = 15_000L; private static final String CONTROL_FLOW_EXECUTOR_NAME = "SubscriptionControlFlowExecutor"; private static final String UPSTREAM_DATA_FLOW_EXECUTOR_NAME = @@ -172,9 +172,9 @@ boolean isShutdown() { } void setCorePoolSize(final int corePoolSize) { - if (!isShutdown()) { + if (isShutdown()) { synchronized (this) { - if (!isShutdown()) { + if (isShutdown()) { this.corePoolSize = corePoolSize; return; } From 831a86f6b53424932f10be5fb04209da9a504517 Mon Sep 17 00:00:00 2001 From: VGalaxies Date: Wed, 12 Jun 2024 10:24:03 +0800 Subject: [PATCH 11/16] remove dups CI --- .github/workflows/cluster-it-1c3d-dup1.yml | 65 ---------------------- .github/workflows/cluster-it-1c3d-dup2.yml | 65 ---------------------- .github/workflows/cluster-it-1c3d-dup3.yml | 65 ---------------------- 3 files changed, 195 deletions(-) delete mode 100644 .github/workflows/cluster-it-1c3d-dup1.yml delete mode 100644 .github/workflows/cluster-it-1c3d-dup2.yml delete mode 100644 .github/workflows/cluster-it-1c3d-dup3.yml diff --git a/.github/workflows/cluster-it-1c3d-dup1.yml b/.github/workflows/cluster-it-1c3d-dup1.yml deleted file mode 100644 index 75ab1d8aba62..000000000000 --- a/.github/workflows/cluster-it-1c3d-dup1.yml +++ /dev/null @@ -1,65 +0,0 @@ -name: Cluster IT - 1C3D (DUP 1) - -on: - push: - branches: - - master - - 'rel/1.*' - - pipe-meta-sync - paths-ignore: - - 'docs/**' - - 'site/**' - pull_request: - branches: - - master - - 'rel/1.*' - - pipe-meta-sync - paths-ignore: - - 'docs/**' - - 'site/**' - # allow manually run the action: - workflow_dispatch: - -concurrency: - group: ${{ github.workflow }}-${{ github.ref }} - cancel-in-progress: true - -env: - MAVEN_OPTS: -Dhttp.keepAlive=false -Dmaven.wagon.http.pool=false -Dmaven.wagon.http.retryHandler.class=standard -Dmaven.wagon.http.retryHandler.count=3 - DEVELOCITY_ACCESS_KEY: ${{ secrets.GE_ACCESS_TOKEN }} - -jobs: - Simple: - strategy: - fail-fast: false - max-parallel: 20 - matrix: - java: [ 8, 11, 17, 8, 11, 17, 8, 11, 17, 8, 11, 17, 8, 11, 17 ] - runs-on: [self-hosted, iotdb] -# group: self-hosted -# labels: iotdb - steps: - - uses: actions/checkout@v4 - - name: Set up JDK ${{ matrix.java }} - uses: actions/setup-java@v4 - with: - distribution: liberica - java-version: ${{ matrix.java }} - - name: IT/UT Test - shell: bash - # we do not compile client-cpp for saving time, it is tested in client.yml - # we can skip influxdb-protocol because it has been tested separately in influxdb-protocol.yml - run: | - mvn clean verify \ - -P with-integration-tests \ - -DskipUTs \ - -DintegrationTest.forkCount=6 -DConfigNodeMaxHeapSize=1024 -DDataNodeMaxHeapSize=1024 \ - -pl integration-test \ - -am -PClusterIT2 - - name: Upload Artifact - if: failure() - uses: actions/upload-artifact@v4 - with: - name: cluster-log-java${{ matrix.java }}-${{ runner.os }} - path: integration-test/target/cluster-logs - retention-days: 1 diff --git a/.github/workflows/cluster-it-1c3d-dup2.yml b/.github/workflows/cluster-it-1c3d-dup2.yml deleted file mode 100644 index 872406dc44ac..000000000000 --- a/.github/workflows/cluster-it-1c3d-dup2.yml +++ /dev/null @@ -1,65 +0,0 @@ -name: Cluster IT - 1C3D (DUP 2) - -on: - push: - branches: - - master - - 'rel/1.*' - - pipe-meta-sync - paths-ignore: - - 'docs/**' - - 'site/**' - pull_request: - branches: - - master - - 'rel/1.*' - - pipe-meta-sync - paths-ignore: - - 'docs/**' - - 'site/**' - # allow manually run the action: - workflow_dispatch: - -concurrency: - group: ${{ github.workflow }}-${{ github.ref }} - cancel-in-progress: true - -env: - MAVEN_OPTS: -Dhttp.keepAlive=false -Dmaven.wagon.http.pool=false -Dmaven.wagon.http.retryHandler.class=standard -Dmaven.wagon.http.retryHandler.count=3 - DEVELOCITY_ACCESS_KEY: ${{ secrets.GE_ACCESS_TOKEN }} - -jobs: - Simple: - strategy: - fail-fast: false - max-parallel: 20 - matrix: - java: [ 8, 11, 17, 8, 11, 17, 8, 11, 17, 8, 11, 17, 8, 11, 17 ] - runs-on: [self-hosted, iotdb] -# group: self-hosted -# labels: iotdb - steps: - - uses: actions/checkout@v4 - - name: Set up JDK ${{ matrix.java }} - uses: actions/setup-java@v4 - with: - distribution: liberica - java-version: ${{ matrix.java }} - - name: IT/UT Test - shell: bash - # we do not compile client-cpp for saving time, it is tested in client.yml - # we can skip influxdb-protocol because it has been tested separately in influxdb-protocol.yml - run: | - mvn clean verify \ - -P with-integration-tests \ - -DskipUTs \ - -DintegrationTest.forkCount=6 -DConfigNodeMaxHeapSize=1024 -DDataNodeMaxHeapSize=1024 \ - -pl integration-test \ - -am -PClusterIT2 - - name: Upload Artifact - if: failure() - uses: actions/upload-artifact@v4 - with: - name: cluster-log-java${{ matrix.java }}-${{ runner.os }} - path: integration-test/target/cluster-logs - retention-days: 1 diff --git a/.github/workflows/cluster-it-1c3d-dup3.yml b/.github/workflows/cluster-it-1c3d-dup3.yml deleted file mode 100644 index 9132a2c8b587..000000000000 --- a/.github/workflows/cluster-it-1c3d-dup3.yml +++ /dev/null @@ -1,65 +0,0 @@ -name: Cluster IT - 1C3D (DUP 3) - -on: - push: - branches: - - master - - 'rel/1.*' - - pipe-meta-sync - paths-ignore: - - 'docs/**' - - 'site/**' - pull_request: - branches: - - master - - 'rel/1.*' - - pipe-meta-sync - paths-ignore: - - 'docs/**' - - 'site/**' - # allow manually run the action: - workflow_dispatch: - -concurrency: - group: ${{ github.workflow }}-${{ github.ref }} - cancel-in-progress: true - -env: - MAVEN_OPTS: -Dhttp.keepAlive=false -Dmaven.wagon.http.pool=false -Dmaven.wagon.http.retryHandler.class=standard -Dmaven.wagon.http.retryHandler.count=3 - DEVELOCITY_ACCESS_KEY: ${{ secrets.GE_ACCESS_TOKEN }} - -jobs: - Simple: - strategy: - fail-fast: false - max-parallel: 20 - matrix: - java: [ 8, 11, 17, 8, 11, 17, 8, 11, 17, 8, 11, 17, 8, 11, 17 ] - runs-on: [self-hosted, iotdb] -# group: self-hosted -# labels: iotdb - steps: - - uses: actions/checkout@v4 - - name: Set up JDK ${{ matrix.java }} - uses: actions/setup-java@v4 - with: - distribution: liberica - java-version: ${{ matrix.java }} - - name: IT/UT Test - shell: bash - # we do not compile client-cpp for saving time, it is tested in client.yml - # we can skip influxdb-protocol because it has been tested separately in influxdb-protocol.yml - run: | - mvn clean verify \ - -P with-integration-tests \ - -DskipUTs \ - -DintegrationTest.forkCount=6 -DConfigNodeMaxHeapSize=1024 -DDataNodeMaxHeapSize=1024 \ - -pl integration-test \ - -am -PClusterIT2 - - name: Upload Artifact - if: failure() - uses: actions/upload-artifact@v4 - with: - name: cluster-log-java${{ matrix.java }}-${{ runner.os }} - path: integration-test/target/cluster-logs - retention-days: 1 From d1824a45379552cf74780e4dece442ad4a493756 Mon Sep 17 00:00:00 2001 From: VGalaxies Date: Wed, 12 Jun 2024 10:50:24 +0800 Subject: [PATCH 12/16] improve SkipOnSetUpFailure --- .../subscription/it/SkipOnSetUpFailure.java | 73 +++++++++++++++++++ .../subscription/it/SkipOnSetupFailure.java | 52 ------------- .../it/local/IoTDBSubscriptionRestartIT.java | 8 +- 3 files changed, 79 insertions(+), 54 deletions(-) create mode 100644 integration-test/src/test/java/org/apache/iotdb/subscription/it/SkipOnSetUpFailure.java delete mode 100644 integration-test/src/test/java/org/apache/iotdb/subscription/it/SkipOnSetupFailure.java diff --git a/integration-test/src/test/java/org/apache/iotdb/subscription/it/SkipOnSetUpFailure.java b/integration-test/src/test/java/org/apache/iotdb/subscription/it/SkipOnSetUpFailure.java new file mode 100644 index 000000000000..7d6e2509f670 --- /dev/null +++ b/integration-test/src/test/java/org/apache/iotdb/subscription/it/SkipOnSetUpFailure.java @@ -0,0 +1,73 @@ +/* + * 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.iotdb.subscription.it; + +import org.checkerframework.checker.nullness.qual.NonNull; +import org.junit.AssumptionViolatedException; +import org.junit.rules.TestRule; +import org.junit.runner.Description; +import org.junit.runners.model.Statement; + +public class SkipOnSetUpFailure implements TestRule { + + private final String setUpMethodName; + private final String declaringClassName; + + /** + * @param setUpMethodName Should be exactly the same as the method name decorated with @Before. + * @param declaringClassName The name of the test class. + */ + public SkipOnSetUpFailure( + @NonNull final String setUpMethodName, @NonNull final String declaringClassName) { + this.setUpMethodName = setUpMethodName; + this.declaringClassName = declaringClassName; + } + + @Override + public Statement apply(final Statement base, final Description description) { + return new Statement() { + @Override + public void evaluate() throws Throwable { + try { + base.evaluate(); + } catch (final Throwable e) { + // Trace back the exception stack to determine whether the exception was thrown during the + // setUp phase. + for (final StackTraceElement stackTraceElement : e.getStackTrace()) { + if (setUpMethodName.equals(stackTraceElement.getMethodName()) + && declaringClassName.equals(stackTraceElement.getClassName())) { + e.printStackTrace(); + // Skip this test. + throw new AssumptionViolatedException( + String.format( + "Skipping test due to setup failure for %s#%s", + description.getClassName(), description.getMethodName())); + } + } + // Re-throw the exception (which means the test has failed). + throw e; + + // Regardless of the circumstances, the method decorated with @After will always be + // executed. + } + } + }; + } +} diff --git a/integration-test/src/test/java/org/apache/iotdb/subscription/it/SkipOnSetupFailure.java b/integration-test/src/test/java/org/apache/iotdb/subscription/it/SkipOnSetupFailure.java deleted file mode 100644 index def99f0dcf01..000000000000 --- a/integration-test/src/test/java/org/apache/iotdb/subscription/it/SkipOnSetupFailure.java +++ /dev/null @@ -1,52 +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.iotdb.subscription.it; - -import org.junit.AssumptionViolatedException; -import org.junit.rules.TestRule; -import org.junit.runner.Description; -import org.junit.runners.model.Statement; - -public class SkipOnSetupFailure implements TestRule { - - private static final String SET_UP_METHOD_NAME = "setUp"; - - @Override - public Statement apply(final Statement base, final Description description) { - return new Statement() { - @Override - public void evaluate() throws Throwable { - try { - base.evaluate(); - } catch (final Throwable e) { - if (e.getStackTrace()[0].getMethodName().equals(SET_UP_METHOD_NAME)) { - e.printStackTrace(); - throw new AssumptionViolatedException( - String.format( - "Skipping test due to setup failure for %s@%s", - description.getClassName(), description.getMethodName())); - } - // rethrow - throw e; - } - } - }; - } -} diff --git a/integration-test/src/test/java/org/apache/iotdb/subscription/it/local/IoTDBSubscriptionRestartIT.java b/integration-test/src/test/java/org/apache/iotdb/subscription/it/local/IoTDBSubscriptionRestartIT.java index f3f1161c5ba3..38d61c72d06e 100644 --- a/integration-test/src/test/java/org/apache/iotdb/subscription/it/local/IoTDBSubscriptionRestartIT.java +++ b/integration-test/src/test/java/org/apache/iotdb/subscription/it/local/IoTDBSubscriptionRestartIT.java @@ -37,7 +37,7 @@ import org.apache.iotdb.session.subscription.payload.SubscriptionMessage; import org.apache.iotdb.session.subscription.payload.SubscriptionSessionDataSet; import org.apache.iotdb.subscription.it.IoTDBSubscriptionITConstant; -import org.apache.iotdb.subscription.it.SkipOnSetupFailure; +import org.apache.iotdb.subscription.it.SkipOnSetUpFailure; import org.awaitility.Awaitility; import org.junit.After; @@ -66,7 +66,9 @@ public class IoTDBSubscriptionRestartIT { private static final Logger LOGGER = LoggerFactory.getLogger(IoTDBSubscriptionRestartIT.class); - @Rule public final TestRule skipOnSetupFailure = new SkipOnSetupFailure(); + @Rule + public final TestRule skipOnSetupFailure = + new SkipOnSetUpFailure("setUp", IoTDBSubscriptionRestartIT.class.getName()); @Before public void setUp() throws Exception { @@ -214,6 +216,8 @@ public void testSubscriptionAfterRestartCluster() throws Exception { isClosed.set(true); thread.join(); } + + throw new Exception("tmp"); } @Test From 00b180c63e22dabdf984c56faff7746a64301593 Mon Sep 17 00:00:00 2001 From: VGalaxies Date: Wed, 12 Jun 2024 10:51:37 +0800 Subject: [PATCH 13/16] add empty space --- .../org/apache/iotdb/subscription/it/SkipOnSetUpFailure.java | 1 + 1 file changed, 1 insertion(+) diff --git a/integration-test/src/test/java/org/apache/iotdb/subscription/it/SkipOnSetUpFailure.java b/integration-test/src/test/java/org/apache/iotdb/subscription/it/SkipOnSetUpFailure.java index 7d6e2509f670..1b4fccdd7136 100644 --- a/integration-test/src/test/java/org/apache/iotdb/subscription/it/SkipOnSetUpFailure.java +++ b/integration-test/src/test/java/org/apache/iotdb/subscription/it/SkipOnSetUpFailure.java @@ -61,6 +61,7 @@ public void evaluate() throws Throwable { description.getClassName(), description.getMethodName())); } } + // Re-throw the exception (which means the test has failed). throw e; From 80cd9a3a291394dc19ce4ebbdb492917c02dbeb9 Mon Sep 17 00:00:00 2001 From: VGalaxies Date: Wed, 12 Jun 2024 10:54:25 +0800 Subject: [PATCH 14/16] rename --- .../iotdb/subscription/it/local/IoTDBSubscriptionRestartIT.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/integration-test/src/test/java/org/apache/iotdb/subscription/it/local/IoTDBSubscriptionRestartIT.java b/integration-test/src/test/java/org/apache/iotdb/subscription/it/local/IoTDBSubscriptionRestartIT.java index 38d61c72d06e..cbcb61812066 100644 --- a/integration-test/src/test/java/org/apache/iotdb/subscription/it/local/IoTDBSubscriptionRestartIT.java +++ b/integration-test/src/test/java/org/apache/iotdb/subscription/it/local/IoTDBSubscriptionRestartIT.java @@ -67,7 +67,7 @@ public class IoTDBSubscriptionRestartIT { private static final Logger LOGGER = LoggerFactory.getLogger(IoTDBSubscriptionRestartIT.class); @Rule - public final TestRule skipOnSetupFailure = + public final TestRule skipOnSetUpFailure = new SkipOnSetUpFailure("setUp", IoTDBSubscriptionRestartIT.class.getName()); @Before From b1c7d1c65c7be6e7c69d0f3b9d071493b6ab58fe Mon Sep 17 00:00:00 2001 From: VGalaxies Date: Wed, 12 Jun 2024 10:58:31 +0800 Subject: [PATCH 15/16] remove tmp ex --- .../iotdb/subscription/it/local/IoTDBSubscriptionRestartIT.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/integration-test/src/test/java/org/apache/iotdb/subscription/it/local/IoTDBSubscriptionRestartIT.java b/integration-test/src/test/java/org/apache/iotdb/subscription/it/local/IoTDBSubscriptionRestartIT.java index cbcb61812066..493ed9184e33 100644 --- a/integration-test/src/test/java/org/apache/iotdb/subscription/it/local/IoTDBSubscriptionRestartIT.java +++ b/integration-test/src/test/java/org/apache/iotdb/subscription/it/local/IoTDBSubscriptionRestartIT.java @@ -216,8 +216,6 @@ public void testSubscriptionAfterRestartCluster() throws Exception { isClosed.set(true); thread.join(); } - - throw new Exception("tmp"); } @Test From 2df42406e8b5390896e26ef01489234c788be52f Mon Sep 17 00:00:00 2001 From: VGalaxies Date: Wed, 12 Jun 2024 11:11:45 +0800 Subject: [PATCH 16/16] add checker for before annotation --- .../subscription/it/SkipOnSetUpFailure.java | 20 +++++++++++++------ .../it/local/IoTDBSubscriptionRestartIT.java | 4 +--- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/integration-test/src/test/java/org/apache/iotdb/subscription/it/SkipOnSetUpFailure.java b/integration-test/src/test/java/org/apache/iotdb/subscription/it/SkipOnSetUpFailure.java index 1b4fccdd7136..add7b7c1e2b8 100644 --- a/integration-test/src/test/java/org/apache/iotdb/subscription/it/SkipOnSetUpFailure.java +++ b/integration-test/src/test/java/org/apache/iotdb/subscription/it/SkipOnSetUpFailure.java @@ -25,19 +25,17 @@ import org.junit.runner.Description; import org.junit.runners.model.Statement; +import java.lang.reflect.Method; + public class SkipOnSetUpFailure implements TestRule { private final String setUpMethodName; - private final String declaringClassName; /** * @param setUpMethodName Should be exactly the same as the method name decorated with @Before. - * @param declaringClassName The name of the test class. */ - public SkipOnSetUpFailure( - @NonNull final String setUpMethodName, @NonNull final String declaringClassName) { + public SkipOnSetUpFailure(@NonNull final String setUpMethodName) { this.setUpMethodName = setUpMethodName; - this.declaringClassName = declaringClassName; } @Override @@ -52,7 +50,8 @@ public void evaluate() throws Throwable { // setUp phase. for (final StackTraceElement stackTraceElement : e.getStackTrace()) { if (setUpMethodName.equals(stackTraceElement.getMethodName()) - && declaringClassName.equals(stackTraceElement.getClassName())) { + && description.getClassName().equals(stackTraceElement.getClassName()) + && isMethodAnnotationWithBefore(stackTraceElement.getMethodName())) { e.printStackTrace(); // Skip this test. throw new AssumptionViolatedException( @@ -69,6 +68,15 @@ public void evaluate() throws Throwable { // executed. } } + + private boolean isMethodAnnotationWithBefore(final String methodName) { + try { + final Method method = description.getTestClass().getDeclaredMethod(methodName); + return method.isAnnotationPresent(org.junit.Before.class); + } catch (final Throwable ignored) { + return false; + } + } }; } } diff --git a/integration-test/src/test/java/org/apache/iotdb/subscription/it/local/IoTDBSubscriptionRestartIT.java b/integration-test/src/test/java/org/apache/iotdb/subscription/it/local/IoTDBSubscriptionRestartIT.java index 493ed9184e33..d3680219578a 100644 --- a/integration-test/src/test/java/org/apache/iotdb/subscription/it/local/IoTDBSubscriptionRestartIT.java +++ b/integration-test/src/test/java/org/apache/iotdb/subscription/it/local/IoTDBSubscriptionRestartIT.java @@ -66,9 +66,7 @@ public class IoTDBSubscriptionRestartIT { private static final Logger LOGGER = LoggerFactory.getLogger(IoTDBSubscriptionRestartIT.class); - @Rule - public final TestRule skipOnSetUpFailure = - new SkipOnSetUpFailure("setUp", IoTDBSubscriptionRestartIT.class.getName()); + @Rule public final TestRule skipOnSetUpFailure = new SkipOnSetUpFailure("setUp"); @Before public void setUp() throws Exception {