From b8318b88d19594f52c277a26c3857a346cbc7d15 Mon Sep 17 00:00:00 2001 From: "qiyuan.liu" <1043276694@qq.com> Date: Fri, 2 Feb 2024 20:56:07 +0800 Subject: [PATCH] test: add apiserver integration test (#3674) --- .github/workflows/integration-test-src.yml | 6 - .github/workflows/selfhost_intergration.yml | 145 +++++++----- .../cluster/window_and_lastjoin.yaml | 164 +++++++------- .../expression/test_type.yaml | 6 +- .../function/test_udaf_function.yaml | 72 +++--- .../join/test_lastjoin_simple.yaml | 19 +- .../long_window/test_long_window_batch.yaml | 1 + .../integration_test/window/error_window.yaml | 2 +- .../tests/hooks/test_openmldb_api_hook.py | 4 +- test/integration-test/README | 31 +++ .../openmldb-test-java/kafka_test.sh | 18 ++ .../openmldb-http-test/pom.xml | 58 +++-- .../openmldb/http_test/check/DataChecker.java | 2 +- .../http_test/common/ClusterTest.java | 6 +- .../http_test/config/FedbRestfulConfig.java | 3 +- .../executor/RestfulOnlineExecutor.java | 179 +++++++++++++++ .../openmldb/http_test/util/HttpUtil.java | 206 ++++++++++++++++++ .../openmldb/http_test/util/RowsSort.java | 61 ++++++ .../TestCluster.java} | 29 ++- .../openmldb/http_test/tmp/TestDropTable.java | 52 ----- .../http_test/tmp/TestExpression.java | 38 ++++ .../openmldb/http_test/tmp/TestFunction.java | 37 ++++ .../TestIndexOptimized.java} | 30 +-- .../openmldb/http_test/tmp/TestJoin.java | 41 ++++ .../http_test/tmp/TestLongWindow.java | 37 ++++ .../openmldb/http_test/tmp/TestMultiDB.java | 36 +++ .../openmldb/http_test/tmp/TestSelect.java | 38 ++++ .../TestInsert.java => tmp/TestTmp.java} | 28 ++- .../http_test/v230/TestProcedure.java | 42 ---- .../openmldb/http_test/v230/TestShow.java | 49 ----- .../test_suite/test_all.xml | 26 ++- .../java_sdk_test/checker/OptionsChecker.java | 2 +- .../java_sdk_test/executor/BaseExecutor.java | 3 +- .../executor/BaseSQLExecutor.java | 2 - .../executor/BatchSQLExecutor.java | 5 +- .../executor/OfflineJobExecuter.java | 7 +- .../executor/RequestQuerySQLExecutor.java | 4 + .../high_availability/HighDiskTableTest.java | 1 - .../test_common/bean/OpenMLDBResult.java | 4 + .../command/OpenMLDBCommandUtil.java | 40 ++-- .../test_common/common/BaseExecutor.java | 72 ++++++ .../openmldb/test_common/common/BaseTest.java | 7 +- .../test_common/openmldb/SDKClient.java | 8 +- .../restful/common/OpenMLDBHttp.java | 25 +++ .../test_common/restful/model/HttpData.java | 14 ++ .../test_common/util/HttpRequest.java | 44 ++-- .../openmldb/test_common/util/SDKUtil.java | 8 +- .../openmldb/test_common/util/Tool.java | 4 - test/steps/build-java-sdk.sh | 2 +- test/steps/format_config.sh | 2 +- test/steps/openmldb-apiserver-test.sh | 1 - test/steps/openmldb-integration-test.sh | 59 +++++ test/steps/openmldb-sdk-test-java-src.sh | 6 +- 53 files changed, 1312 insertions(+), 474 deletions(-) create mode 100644 test/integration-test/README create mode 100755 test/integration-test/openmldb-test-java/kafka_test.sh create mode 100644 test/integration-test/openmldb-test-java/openmldb-http-test/src/main/java/com/_4paradigm/openmldb/http_test/executor/RestfulOnlineExecutor.java create mode 100644 test/integration-test/openmldb-test-java/openmldb-http-test/src/main/java/com/_4paradigm/openmldb/http_test/util/HttpUtil.java create mode 100644 test/integration-test/openmldb-test-java/openmldb-http-test/src/main/java/com/_4paradigm/openmldb/http_test/util/RowsSort.java rename test/integration-test/openmldb-test-java/openmldb-http-test/src/test/java/com/_4paradigm/openmldb/http_test/{v030/TestDeployment.java => tmp/TestCluster.java} (52%) delete mode 100644 test/integration-test/openmldb-test-java/openmldb-http-test/src/test/java/com/_4paradigm/openmldb/http_test/tmp/TestDropTable.java create mode 100644 test/integration-test/openmldb-test-java/openmldb-http-test/src/test/java/com/_4paradigm/openmldb/http_test/tmp/TestExpression.java create mode 100644 test/integration-test/openmldb-test-java/openmldb-http-test/src/test/java/com/_4paradigm/openmldb/http_test/tmp/TestFunction.java rename test/integration-test/openmldb-test-java/openmldb-http-test/src/test/java/com/_4paradigm/openmldb/http_test/{v040/TestDeployment.java => tmp/TestIndexOptimized.java} (54%) create mode 100644 test/integration-test/openmldb-test-java/openmldb-http-test/src/test/java/com/_4paradigm/openmldb/http_test/tmp/TestJoin.java create mode 100644 test/integration-test/openmldb-test-java/openmldb-http-test/src/test/java/com/_4paradigm/openmldb/http_test/tmp/TestLongWindow.java create mode 100644 test/integration-test/openmldb-test-java/openmldb-http-test/src/test/java/com/_4paradigm/openmldb/http_test/tmp/TestMultiDB.java create mode 100644 test/integration-test/openmldb-test-java/openmldb-http-test/src/test/java/com/_4paradigm/openmldb/http_test/tmp/TestSelect.java rename test/integration-test/openmldb-test-java/openmldb-http-test/src/test/java/com/_4paradigm/openmldb/http_test/{v230/TestInsert.java => tmp/TestTmp.java} (53%) delete mode 100644 test/integration-test/openmldb-test-java/openmldb-http-test/src/test/java/com/_4paradigm/openmldb/http_test/v230/TestProcedure.java delete mode 100644 test/integration-test/openmldb-test-java/openmldb-http-test/src/test/java/com/_4paradigm/openmldb/http_test/v230/TestShow.java create mode 100644 test/integration-test/openmldb-test-java/openmldb-test-common/src/main/java/com/_4paradigm/openmldb/test_common/common/BaseExecutor.java create mode 100644 test/integration-test/openmldb-test-java/openmldb-test-common/src/main/java/com/_4paradigm/openmldb/test_common/restful/model/HttpData.java create mode 100755 test/steps/openmldb-integration-test.sh diff --git a/.github/workflows/integration-test-src.yml b/.github/workflows/integration-test-src.yml index 62d35ea6e28..d6fd1cfa526 100644 --- a/.github/workflows/integration-test-src.yml +++ b/.github/workflows/integration-test-src.yml @@ -104,7 +104,6 @@ jobs: html_body: test/integration-test/openmldb-test-java/openmldb-sdk-test/target/surefire-reports/html/overview.html to: ${{ secrets.MAIL_TO }} from: GitHub Actions - content_type: text/plain attachments: surefire-reports.tar.gz java-sdk-cluster-memory-task: @@ -148,7 +147,6 @@ jobs: html_body: file://test/integration-test/openmldb-test-java/openmldb-sdk-test/target/surefire-reports/html/overview.html to: ${{ secrets.MAIL_TO }} from: GitHub Actions - content_type: text/plain attachments: surefire-reports.tar.gz java-sdk-cluster-memory-1: @@ -191,7 +189,6 @@ jobs: body: OpenMLDB Memory 1 Test Failed to: ${{ secrets.MAIL_TO }} from: GitHub Actions - content_type: text/plain attachments: surefire-reports.tar.gz java-sdk-cluster-ssd-0: @@ -234,7 +231,6 @@ jobs: body: OpenMLDB SSD Test Failed to: ${{ secrets.MAIL_TO }} from: GitHub Actions - content_type: text/plain attachments: surefire-reports.tar.gz # java-sdk-cluster-ssd-task: @@ -320,7 +316,6 @@ jobs: body: OpenMLDB HDD Test Failed to: ${{ secrets.MAIL_TO }} from: GitHub Actions - content_type: text/plain attachments: surefire-reports.tar.gz # java-sdk-cluster-hdd-task: @@ -568,5 +563,4 @@ jobs: html_body: test/integration-test/openmldb-test-java/openmldb-sdk-test/target/surefire-reports/html/overview.html to: ${{ secrets.MAIL_TO }} from: GitHub Actions - content_type: text/plain attachments: surefire-reports.tar.gz diff --git a/.github/workflows/selfhost_intergration.yml b/.github/workflows/selfhost_intergration.yml index dcaf34cce8d..e1695f20b4f 100644 --- a/.github/workflows/selfhost_intergration.yml +++ b/.github/workflows/selfhost_intergration.yml @@ -38,6 +38,9 @@ jobs: make SQL_JAVASDK_ENABLE=ON && make SQL_JAVASDK_ENABLE=ON install mv openmldb-linux openmldb-main-linux tar -zcf openmldb-linux.tar.gz openmldb-main-linux + mv java/openmldb-batch/target/openmldb*-SNAPSHOT.jar openmldb-batch.jar + mv java/openmldb-jdbc/target/openmldb*-SNAPSHOT.jar openmldb-jdbc.jar + mv java/openmldb-native/target/openmldb*-SNAPSHOT.jar openmldb-native.jar - name: download if: ${{ env.E_VERSION != 'main' }} run: | @@ -48,9 +51,64 @@ jobs: uses: actions/upload-artifact@v3 with: name: openmldb-package - path: openmldb-linux.tar.gz + path: | + openmldb-batch.jar + openmldb-jdbc.jar + openmldb-native.jar + openmldb-linux.tar.gz - + apiserver-cluster: + needs: build-openmldb + + runs-on: [self-hosted,common-user] + steps: + - uses: actions/checkout@v3 + - name: before test + if: ${{ env.ETYPE == 'all' || env.ETYPE == 'java' }} + run: mkdir ${{ github.job }} + - name: download artifact + uses: actions/download-artifact@v3 + with: + name: openmldb-package + - name: install openmldb + run: | + tar -zxf openmldb-linux.tar.gz -C ${{ github.job }}/ + bash test/steps/format_config.sh $(pwd)/${{ github.job }}/openmldb-${{ env.E_VERSION }}-linux ${{ github.job }} 20001 21000 java + bash ${{ github.job }}/openmldb-${{ env.E_VERSION }}-linux/sbin/deploy-all.sh + bash ${{ github.job }}/openmldb-${{ env.E_VERSION }}-linux/sbin/start-all.sh + - name: test + run: bash test/steps/openmldb-integration-test.sh -j 0.0.0 -d deploy -m apiserver + - name: stop openmldb + if: always() + run: bash ${{ github.job }}/openmldb-${{ env.E_VERSION }}-linux/sbin/stop-all.sh + - name: remove openmldb + if: always() + run: bash ${{ github.job }}/openmldb-${{ env.E_VERSION }}-linux/sbin/clear-all.sh + - name: TEST Results + if: always() + uses: EnricoMi/publish-unit-test-result-action@v1 + with: + files: test/integration-test/openmldb-test-java/openmldb-sdk-test/target/surefire-reports/TEST-*.xml + check_name: "SRC apiserver-cluster Report" + comment_title: "SRC apiserver-cluster Report" + - name: tar test report + if: ${{ failure() }} + run: tar -zcvf surefire-reports.tar.gz test/integration-test/openmldb-test-java/openmldb-sdk-test/target/surefire-reports + - name: Send Email + if: ${{ failure() }} + uses: dawidd6/action-send-mail@master + with: + server_address: mail.4paradigm.com + server_port: 995 + username: ${{ secrets.MAIL_USERNAME }} + password: ${{ secrets.MAIL_PASSWORD }} + secure: true + subject: OpenMLDB Memory Test + body: OpenMLDB Memory Test Failed + html_body: test/integration-test/openmldb-test-java/openmldb-sdk-test/target/surefire-reports/html/overview.html + to: ${{ secrets.MAIL_TO }} + from: GitHub Actions + attachments: surefire-reports.tar.gz java-sdk-cluster-memory-0: needs: build-openmldb @@ -72,16 +130,12 @@ jobs: bash ${{ github.job }}/openmldb-${{ env.E_VERSION }}-linux/sbin/deploy-all.sh bash ${{ github.job }}/openmldb-${{ env.E_VERSION }}-linux/sbin/start-all.sh - name: test - run: | - mkdir mvnrepo - export MAVEN_OPTS="-Dmaven.repo.local=$(pwd)/mvnrepo" - echo $MAVEN_OPTS - bash test/steps/openmldb-sdk-test-java-src.sh -c test_cluster.xml -d deploy -l "0" -s "memory" + run: bash test/steps/openmldb-integration-test.sh -j 0.0.0 -c test_cluster.xml -d deploy -l "0" -s "memory" - name: stop openmldb if: always() run: bash ${{ github.job }}/openmldb-${{ env.E_VERSION }}-linux/sbin/stop-all.sh - name: remove openmldb - if: success() + if: always() run: bash ${{ github.job }}/openmldb-${{ env.E_VERSION }}-linux/sbin/clear-all.sh - name: TEST Results if: always() @@ -97,10 +151,11 @@ jobs: if: ${{ failure() }} uses: dawidd6/action-send-mail@master with: - server_address: smtp.partner.outlook.cn - server_port: 587 + server_address: mail.4paradigm.com + server_port: 995 username: ${{ secrets.MAIL_USERNAME }} password: ${{ secrets.MAIL_PASSWORD }} + secure: true subject: OpenMLDB Memory Test body: OpenMLDB Memory Test Failed html_body: test/integration-test/openmldb-test-java/openmldb-sdk-test/target/surefire-reports/html/overview.html @@ -129,16 +184,12 @@ jobs: bash ${{ github.job }}/openmldb-${{ env.E_VERSION }}-linux/sbin/deploy-all.sh bash ${{ github.job }}/openmldb-${{ env.E_VERSION }}-linux/sbin/start-all.sh - name: test - run: | - mkdir mvnrepo - export MAVEN_OPTS="-Dmaven.repo.local=$(pwd)/mvnrepo" - echo $MAVEN_OPTS - bash test/steps/openmldb-sdk-test-java-src.sh -c test_cluster.xml -d deploy -l "1,2,3,4,5" -s "memory" + run: bash test/steps/openmldb-integration-test.sh -j 0.0.0 -c test_cluster.xml -d deploy -l "1,2,3,4,5" -s "memory" - name: stop openmldb if: always() run: bash ${{ github.job }}/openmldb-${{ env.E_VERSION }}-linux/sbin/stop-all.sh - name: remove openmldb - if: success() + if: always() run: bash ${{ github.job }}/openmldb-${{ env.E_VERSION }}-linux/sbin/clear-all.sh - name: TEST Results if: always() @@ -154,10 +205,11 @@ jobs: if: ${{ failure() }} uses: dawidd6/action-send-mail@master with: - server_address: smtp.partner.outlook.cn - server_port: 587 + server_address: mail.4paradigm.com + server_port: 995 username: ${{ secrets.MAIL_USERNAME }} password: ${{ secrets.MAIL_PASSWORD }} + secure: true subject: OpenMLDB Memory Test body: OpenMLDB Memory Test Failed html_body: test/integration-test/openmldb-test-java/openmldb-sdk-test/target/surefire-reports/html/overview.html @@ -187,16 +239,12 @@ jobs: bash ${{ github.job }}/openmldb-${{ env.E_VERSION }}-linux/sbin/deploy-all.sh bash ${{ github.job }}/openmldb-${{ env.E_VERSION }}-linux/sbin/start-all.sh - name: test - run: | - mkdir mvnrepo - export MAVEN_OPTS="-Dmaven.repo.local=$(pwd)/mvnrepo" - echo $MAVEN_OPTS - bash test/steps/openmldb-sdk-test-java-src.sh -c test_cluster_disk.xml -d deploy -l "0" -s "hdd" + run: bash test/steps/openmldb-integration-test.sh -j 0.0.0 -c test_cluster_disk.xml -d deploy -l "0" -s "hdd" - name: stop openmldb if: always() run: bash ${{ github.job }}/openmldb-${{ env.E_VERSION }}-linux/sbin/stop-all.sh - name: remove openmldb - if: success() + if: always() run: bash ${{ github.job }}/openmldb-${{ env.E_VERSION }}-linux/sbin/clear-all.sh - name: TEST Results if: always() @@ -212,10 +260,11 @@ jobs: if: ${{ failure() }} uses: dawidd6/action-send-mail@master with: - server_address: smtp.partner.outlook.cn - server_port: 587 + server_address: mail.4paradigm.com + server_port: 995 username: ${{ secrets.MAIL_USERNAME }} password: ${{ secrets.MAIL_PASSWORD }} + secure: true subject: OpenMLDB HDD Test body: OpenMLDB HDD Test Failed html_body: test/integration-test/openmldb-test-java/openmldb-sdk-test/target/surefire-reports/html/overview.html @@ -240,20 +289,16 @@ jobs: - name: install openmldb run: | tar -zxf openmldb-linux.tar.gz -C ${{ github.job }}/ - bash test/steps/format_config.sh $(pwd)/${{ github.job }}/openmldb-${{ env.E_VERSION }}-linux java-sdk-cluster-memory-0 23001 24000 java ssd + bash test/steps/format_config.sh $(pwd)/${{ github.job }}/openmldb-${{ env.E_VERSION }}-linux ${{ github.job }} 23001 24000 java ssd bash ${{ github.job }}/openmldb-${{ env.E_VERSION }}-linux/sbin/deploy-all.sh bash ${{ github.job }}/openmldb-${{ env.E_VERSION }}-linux/sbin/start-all.sh - name: test - run: | - mkdir mvnrepo - export MAVEN_OPTS="-Dmaven.repo.local=$(pwd)/mvnrepo" - echo $MAVEN_OPTS - bash test/steps/openmldb-sdk-test-java-src.sh -c test_cluster_disk.xml -d deploy -l "0" -s "ssd" + run: bash test/steps/openmldb-integration-test.sh -j 0.0.0 -c test_cluster_disk.xml -d deploy -l "0" -s "ssd" - name: stop openmldb if: always() run: bash ${{ github.job }}/openmldb-${{ env.E_VERSION }}-linux/sbin/stop-all.sh - name: remove openmldb - if: success() + if: always() run: bash ${{ github.job }}/openmldb-${{ env.E_VERSION }}-linux/sbin/clear-all.sh - name: TEST Results if: always() @@ -269,10 +314,11 @@ jobs: if: ${{ failure() }} uses: dawidd6/action-send-mail@master with: - server_address: smtp.partner.outlook.cn - server_port: 587 + server_address: mail.4paradigm.com + server_port: 995 username: ${{ secrets.MAIL_USERNAME }} password: ${{ secrets.MAIL_PASSWORD }} + secure: true subject: OpenMLDB SSD Test body: OpenMLDB SSD Test Failed html_body: test/integration-test/openmldb-test-java/openmldb-sdk-test/target/surefire-reports/html/overview.html @@ -299,19 +345,15 @@ jobs: bash test/steps/format_config.sh $(pwd)/${{ github.job }}/openmldb-${{ env.E_VERSION }}-linux ${{ github.job }} 24001 25000 java hadoop bash ${{ github.job }}/openmldb-${{ env.E_VERSION }}-linux/sbin/deploy-all.sh bash ${{ github.job }}/openmldb-${{ env.E_VERSION }}-linux/sbin/start-all.sh - bash ${{ github.job }}/openmldb-${{ env.E_VERSION }}-linux/sbin/stop-taskmanager.sh - bash HADOOP_CONF_DIR=/mnt/hdd0/denglong/openmldb_runner_work/hadoop ${{ github.job }}/openmldb-${{ env.E_VERSION }}-linux/sbin/stop-taskmanager.sh + bash ${{ github.job }}/openmldb-${{ env.E_VERSION }}-linux/sbin/stop-taskmanagers.sh + HADOOP_CONF_DIR=/mnt/hdd0/denglong/openmldb_runner_work/hadoop ${{ github.job }}/openmldb-${{ env.E_VERSION }}-linux/sbin/stop-taskmanagers.sh - name: test - run: | - mkdir mvnrepo - export MAVEN_OPTS="-Dmaven.repo.local=$(pwd)/mvnrepo" - echo $MAVEN_OPTS - bash test/steps/openmldb-sdk-test-java-src.sh -c test_yarn.xml -d deploy -l "0" -s "memory" + run: bash test/steps/openmldb-integration-test.sh -j 0.0.0 -c test_yarn.xml -d deploy -l "0" -s "memory" - name: stop openmldb if: always() run: bash ${{ github.job }}/openmldb-${{ env.E_VERSION }}-linux/sbin/stop-all.sh - name: remove openmldb - if: success() + if: always() run: bash ${{ github.job }}/openmldb-${{ env.E_VERSION }}-linux/sbin/clear-all.sh - name: TEST Results if: always() @@ -327,10 +369,11 @@ jobs: if: ${{ failure() }} uses: dawidd6/action-send-mail@master with: - server_address: smtp.partner.outlook.cn - server_port: 587 + server_address: mail.4paradigm.com + server_port: 995 username: ${{ secrets.MAIL_USERNAME }} password: ${{ secrets.MAIL_PASSWORD }} + secure: true subject: OpenMLDB yarn Test body: OpenMLDB yarn Test Failed html_body: test/integration-test/openmldb-test-java/openmldb-sdk-test/target/surefire-reports/html/overview.html @@ -359,15 +402,12 @@ jobs: bash ${{ github.job }}/openmldb-${{ env.E_VERSION }}-linux/sbin/deploy-all.sh bash ${{ github.job }}/openmldb-${{ env.E_VERSION }}-linux/sbin/start-all.sh - name: test - run: | - mkdir mvnrepo - export MAVEN_OPTS="-Dmaven.repo.local=$(pwd)/mvnrepo" - echo $MAVEN_OPTS + run: echo "a" - name: stop openmldb if: always() run: bash ${{ github.job }}/openmldb-${{ env.E_VERSION }}-linux/sbin/stop-all.sh - name: remove openmldb - if: success() + if: always() run: bash ${{ github.job }}/openmldb-${{ env.E_VERSION }}-linux/sbin/clear-all.sh # - name: TEST Results # if: always() @@ -383,8 +423,9 @@ jobs: # if: ${{ failure() }} # uses: dawidd6/action-send-mail@master # with: - # server_address: smtp.partner.outlook.cn - # server_port: 587 + # server_address: mail.4paradigm.com + # server_port: 995 + # secure: true # username: ${{ secrets.MAIL_USERNAME }} # password: ${{ secrets.MAIL_PASSWORD }} # subject: OpenMLDB yarn Test diff --git a/cases/integration_test/cluster/window_and_lastjoin.yaml b/cases/integration_test/cluster/window_and_lastjoin.yaml index 1d629fbe1b1..45cc9599e78 100644 --- a/cases/integration_test/cluster/window_and_lastjoin.yaml +++ b/cases/integration_test/cluster/window_and_lastjoin.yaml @@ -217,16 +217,16 @@ cases: columns : ["id int", "c1 string", "c2 string", "c3 string", "c4 string", "c6 double", "c7 timestamp"] indexs: ["index1:c1:c7", "index2:c2:c7", "index3:c3:c7", "index4:c4:c7"] rows: - - [ 1, "a", "aa", "aaa", "aaaa", "1.0", 1590738990000] - - [ 2, "a", "aa", "aaa", "aaaa", "1.0", 1590738991000] - - [ 3, "a", "aa", "aaa", "bbbb", "1.0", 1590738992000] - - [ 4, "a", "aa", "aaa", "bbbb", "1.0", 1590738993000] - - [ 5, "a", "aa", "bbb", "bbbb", "1.0", 1590738994000] - - [ 6, "a", "aa", "bbb", "bbbb", "1.0", 1590738995000] - - [ 7, "a", "bb", "bbb", "bbbb", "1.0", 1590738996000 ] - - [ 8, "a", "bb", "bbb", "bbbb", "1.0", 1590738997000 ] - - [ 9, "b", "bb", "bbb", "bbbb", "1.0", 1590739998000 ] - - [10, "b", "bb", "bbb", "bbbb", "1.0", 1590739999000 ] + - [ 1, "a", "aa", "aaa", "aaaa", 1.0, 1590738990000] + - [ 2, "a", "aa", "aaa", "aaaa", 1.0, 1590738991000] + - [ 3, "a", "aa", "aaa", "bbbb", 1.0, 1590738992000] + - [ 4, "a", "aa", "aaa", "bbbb", 1.0, 1590738993000] + - [ 5, "a", "aa", "bbb", "bbbb", 1.0, 1590738994000] + - [ 6, "a", "aa", "bbb", "bbbb", 1.0, 1590738995000] + - [ 7, "a", "bb", "bbb", "bbbb", 1.0, 1590738996000 ] + - [ 8, "a", "bb", "bbb", "bbbb", 1.0, 1590738997000 ] + - [ 9, "b", "bb", "bbb", "bbbb", 1.0, 1590739998000 ] + - [10, "b", "bb", "bbb", "bbbb", 1.0, 1590739999000 ] sql: | select * from ( @@ -270,16 +270,16 @@ cases: columns : ["id int", "c1 string", "c2 string", "c3 string", "c4 string", "c6 double", "c7 timestamp"] indexs: ["index1:c1:c7", "index2:c2:c7", "index3:c3:c7", "index4:c4:c7"] rows: - - [ 1, "a", "aa", "aaa", "aaaa", "1.0", 1590738990000] - - [ 2, "a", "aa", "aaa", "aaaa", "1.0", 1590738991000] - - [ 3, "a", "aa", "aaa", "bbbb", "1.0", 1590738992000] - - [ 4, "a", "aa", "aaa", "bbbb", "1.0", 1590738993000] - - [ 5, "a", "aa", "bbb", "bbbb", "1.0", 1590738994000] - - [ 6, "a", "aa", "bbb", "bbbb", "1.0", 1590738995000] - - [ 7, "a", "bb", "bbb", "bbbb", "1.0", 1590738996000 ] - - [ 8, "a", "bb", "bbb", "bbbb", "1.0", 1590738997000 ] - - [ 9, "b", "bb", "bbb", "bbbb", "1.0", 1590739998000 ] - - [10, "b", "bb", "bbb", "bbbb", "1.0", 1590739999000 ] + - [ 1, "a", "aa", "aaa", "aaaa", 1.0, 1590738990000] + - [ 2, "a", "aa", "aaa", "aaaa", 1.0, 1590738991000] + - [ 3, "a", "aa", "aaa", "bbbb", 1.0, 1590738992000] + - [ 4, "a", "aa", "aaa", "bbbb", 1.0, 1590738993000] + - [ 5, "a", "aa", "bbb", "bbbb", 1.0, 1590738994000] + - [ 6, "a", "aa", "bbb", "bbbb", 1.0, 1590738995000] + - [ 7, "a", "bb", "bbb", "bbbb", 1.0, 1590738996000 ] + - [ 8, "a", "bb", "bbb", "bbbb", 1.0, 1590738997000 ] + - [ 9, "b", "bb", "bbb", "bbbb", 1.0, 1590739998000 ] + - [10, "b", "bb", "bbb", "bbbb", 1.0, 1590739999000 ] sql: | select * from ( @@ -299,7 +299,7 @@ cases: window w4 as (PARTITION BY {0}.c4 ORDER BY {0}.c7 ROWS_RANGE BETWEEN 10d PRECEDING AND CURRENT ROW) ) as out4 on out1_id=out4_id; request_plan: | - SIMPLE_PROJECT(sources=(out1_id, c1, w1_sum_c6, out2_id, c2, w2_sum_c6, out3_id, c3, w3_sum_c6, out4.out4_id, out4.c4, out4.w4_sum_c6)) + SIMPLE_PROJECT(sources=(out1.out1_id, out1.c1, out1.w1_sum_c6, out2.out2_id, out2.c2, out2.w2_sum_c6, out3.out3_id, out3.c3, out3.w3_sum_c6, out4.out4_id, out4.c4, out4.w4_sum_c6)) REQUEST_JOIN(type=LastJoin, condition=, left_keys=(out1_id), right_keys=(out4_id), index_keys=) REQUEST_JOIN(type=LastJoin, condition=, left_keys=(out1_id), right_keys=(out3_id), index_keys=) REQUEST_JOIN(type=LastJoin, condition=, left_keys=(out1_id), right_keys=(out2_id), index_keys=) @@ -325,7 +325,7 @@ cases: DATA_PROVIDER(type=Partition, table=auto_t0, index=index4) cluster_request_plan: | - SIMPLE_PROJECT(sources=(out1_id, c1, w1_sum_c6, out2_id, c2, w2_sum_c6, out3_id, c3, w3_sum_c6, out4.out4_id, out4.c4, out4.w4_sum_c6)) + SIMPLE_PROJECT(sources=(out1.out1_id, out1.c1, out1.w1_sum_c6, out2.out2_id, out2.c2, out2.w2_sum_c6, out3.out3_id, out3.c3, out3.w3_sum_c6, out4.out4_id, out4.c4, out4.w4_sum_c6)) REQUEST_JOIN(type=LastJoin, condition=, left_keys=(out1_id), right_keys=(out4_id), index_keys=) REQUEST_JOIN(type=LastJoin, condition=, left_keys=(out1_id), right_keys=(out3_id), index_keys=) REQUEST_JOIN(type=LastJoin, condition=, left_keys=(out1_id), right_keys=(out2_id), index_keys=) @@ -391,29 +391,29 @@ cases: columns : ["id int", "c1 string", "c2 string", "c3 string", "c4 string", "c6 double", "c7 timestamp"] indexs: ["index1:c1:c7"] rows: - - [ 1, "a", "aa", "aaa", "aaaa", "1.0", 1590738990000] - - [ 2, "a", "aa", "aaa", "aaaa", "2.0", 1590738991000] - - [ 3, "a", "aa", "aaa", "bbbb", "3.0", 1590738992000] - - [ 4, "a", "aa", "aaa", "bbbb", "4.0", 1590738993000] - - [ 5, "a", "aa", "bbb", "bbbb", "5.0", 1590738994000] - - [ 6, "a", "aa", "bbb", "bbbb", "6.0", 1590738995000] - - [ 7, "a", "bb", "bbb", "bbbb", "7.0", 1590738996000 ] - - [ 8, "a", "bb", "bbb", "bbbb", "8.0", 1590738997000 ] - - [ 9, "b", "bb", "bbb", "bbbb", "9.0", 1590738998000 ] - - [10, "b", "bb", "bbb", "bbbb", "10.0", 1590738999000 ] + - [ 1, "a", "aa", "aaa", "aaaa", 1.0, 1590738990000] + - [ 2, "a", "aa", "aaa", "aaaa", 2.0, 1590738991000] + - [ 3, "a", "aa", "aaa", "bbbb", 3.0, 1590738992000] + - [ 4, "a", "aa", "aaa", "bbbb", 4.0, 1590738993000] + - [ 5, "a", "aa", "bbb", "bbbb", 5.0, 1590738994000] + - [ 6, "a", "aa", "bbb", "bbbb", 6.0, 1590738995000] + - [ 7, "a", "bb", "bbb", "bbbb", 7.0, 1590738996000 ] + - [ 8, "a", "bb", "bbb", "bbbb", 8.0, 1590738997000 ] + - [ 9, "b", "bb", "bbb", "bbbb", 9.0, 1590738998000 ] + - [10, "b", "bb", "bbb", "bbbb", 10.0, 1590738999000 ] - columns: ["rid int", "x1 string", "x2 string", "x3 string", "x4 string", "x6 double", "x7 timestamp"] indexs: ["index1:x1:x7", "index2:x2:x7", "index3:x3:x7", "index4:x4:x7", ] rows: - - [ 1, "a", "aa", "aaa", "aaaa", "1.0", 1590738990000 ] - - [ 2, "a", "aa", "aaa", "aaaa", "1.0", 1590738991000 ] - - [ 3, "a", "aa", "aaa", "bbbb", "1.0", 1590738992000 ] - - [ 4, "a", "aa", "aaa", "bbbb", "1.0", 1590738993000 ] - - [ 5, "a", "aa", "bbb", "bbbb", "1.0", 1590738994000 ] - - [ 6, "a", "aa", "bbb", "bbbb", "1.0", 1590738995000 ] - - [ 7, "a", "bb", "bbb", "bbbb", "1.0", 1590738996000 ] - - [ 8, "a", "bb", "bbb", "bbbb", "1.0", 1590738997000 ] - - [ 9, "b", "bb", "bbb", "bbbb", "1.0", 1590738998000 ] - - [ 10, "b", "bb", "bbb", "bbbb", "1.0",1590738999000 ] + - [ 1, "a", "aa", "aaa", "aaaa", 1.0, 1590738990000 ] + - [ 2, "a", "aa", "aaa", "aaaa", 1.0, 1590738991000 ] + - [ 3, "a", "aa", "aaa", "bbbb", 1.0, 1590738992000 ] + - [ 4, "a", "aa", "aaa", "bbbb", 1.0, 1590738993000 ] + - [ 5, "a", "aa", "bbb", "bbbb", 1.0, 1590738994000 ] + - [ 6, "a", "aa", "bbb", "bbbb", 1.0, 1590738995000 ] + - [ 7, "a", "bb", "bbb", "bbbb", 1.0, 1590738996000 ] + - [ 8, "a", "bb", "bbb", "bbbb", 1.0, 1590738997000 ] + - [ 9, "b", "bb", "bbb", "bbbb", 1.0, 1590738998000 ] + - [ 10, "b", "bb", "bbb", "bbbb", 1.0,1590738999000 ] sql: | select id, c1, c2, c3, c4, c6, c7, cur_hour, today , w1_sum_c6, w1_max_c6, w1_min_c6, w1_avg_c6, w1_cnt_c6 @@ -493,16 +493,16 @@ cases: "t1_rid int32", "t2_rid int32", "t3_rid int32", "t4_rid int32"] order: id rows: - - [ 1, "a", "aa", "aaa", "aaaa", "1.0", 1590738990000, 15, 29, 1.0, 1.0, 1.0, 1.0, 1, NULL, NULL, NULL, NULL] - - [ 2, "a", "aa", "aaa", "aaaa", "2.0", 1590738991000, 15, 29, 3.0, 2.0, 1.0, 1.5, 2, 1, NULL, NULL, NULL ] - - [ 3, "a", "aa", "aaa", "bbbb", "3.0", 1590738992000, 15, 29, 6.0, 3.0, 1.0, 2.0, 3, 2 , 1, NULL, NULL] - - [ 4, "a", "aa", "aaa", "bbbb", "4.0", 1590738993000, 15, 29, 10.0, 4.0, 1.0, 2.5, 4, 3 , 2, 1, NULL] - - [ 5, "a", "aa", "bbb", "bbbb", "5.0", 1590738994000, 15, 29, 15.0, 5.0, 1.0, 3.0, 5, 4 , 3, NULL, NULL] - - [ 6, "a", "aa", "bbb", "bbbb", "6.0", 1590738995000, 15, 29, 21.0, 6.0, 1.0, 3.5, 6, 5 , 4, NULL, NULL] - - [ 7, "a", "bb", "bbb", "bbbb", "7.0", 1590738996000, 15, 29, 28.0, 7.0, 1.0, 4.0, 7, 6 , NULL, NULL, 3] - - [ 8, "a", "bb", "bbb", "bbbb", "8.0", 1590738997000, 15, 29, 36.0, 8.0, 1.0, 4.5, 8, 7 , NULL, 5, 4] - - [ 9, "b", "bb", "bbb", "bbbb", "9.0", 1590738998000, 15, 29, 9.0, 9.0, 9.0, 9.0, 1, NULL , 7, 6, 5] - - [ 10, "b", "bb", "bbb", "bbbb", "10.0",1590738999000,15, 29, 19.0, 10.0, 9.0, 9.5, 2, 9, 8, 7, 6] + - [ 1, "a", "aa", "aaa", "aaaa", 1.0, 1590738990000, 15, 29, 1.0, 1.0, 1.0, 1.0, 1, NULL, NULL, NULL, NULL] + - [ 2, "a", "aa", "aaa", "aaaa", 2.0, 1590738991000, 15, 29, 3.0, 2.0, 1.0, 1.5, 2, 1, NULL, NULL, NULL ] + - [ 3, "a", "aa", "aaa", "bbbb", 3.0, 1590738992000, 15, 29, 6.0, 3.0, 1.0, 2.0, 3, 2 , 1, NULL, NULL] + - [ 4, "a", "aa", "aaa", "bbbb", 4.0, 1590738993000, 15, 29, 10.0, 4.0, 1.0, 2.5, 4, 3 , 2, 1, NULL] + - [ 5, "a", "aa", "bbb", "bbbb", 5.0, 1590738994000, 15, 29, 15.0, 5.0, 1.0, 3.0, 5, 4 , 3, NULL, NULL] + - [ 6, "a", "aa", "bbb", "bbbb", 6.0, 1590738995000, 15, 29, 21.0, 6.0, 1.0, 3.5, 6, 5 , 4, NULL, NULL] + - [ 7, "a", "bb", "bbb", "bbbb", 7.0, 1590738996000, 15, 29, 28.0, 7.0, 1.0, 4.0, 7, 6 , NULL, NULL, 3] + - [ 8, "a", "bb", "bbb", "bbbb", 8.0, 1590738997000, 15, 29, 36.0, 8.0, 1.0, 4.5, 8, 7 , NULL, 5, 4] + - [ 9, "b", "bb", "bbb", "bbbb", 9.0, 1590738998000, 15, 29, 9.0, 9.0, 9.0, 9.0, 1, NULL , 7, 6, 5] + - [ 10, "b", "bb", "bbb", "bbbb", 10.0,1590738999000,15, 29, 19.0, 10.0, 9.0, 9.5, 2, 9, 8, 7, 6] - @@ -514,29 +514,29 @@ cases: columns : ["id int", "c1 string", "c2 string", "c3 string", "c4 string", "c6 double", "c7 timestamp"] indexs: ["index1:c1:c7"] rows: - - [ 1, "a", "aa", "aaa", "aaaa", "1.0", 1590738990000] - - [ 2, "a", "aa", "aaa", "aaaa", "2.0", 1590738991000] - - [ 3, "a", "aa", "aaa", "bbbb", "3.0", 1590738992000] - - [ 4, "a", "aa", "aaa", "bbbb", "4.0", 1590738993000] - - [ 5, "a", "aa", "bbb", "bbbb", "5.0", 1590738994000] - - [ 6, "a", "aa", "bbb", "bbbb", "6.0", 1590738995000] - - [ 7, "a", "bb", "bbb", "bbbb", "7.0", 1590738996000 ] - - [ 8, "a", "bb", "bbb", "bbbb", "8.0", 1590738997000 ] - - [ 9, "b", "bb", "bbb", "bbbb", "9.0", 1590738998000 ] - - [10, "b", "bb", "bbb", "bbbb", "10.0", 1590738999000 ] + - [ 1, "a", "aa", "aaa", "aaaa", 1.0, 1590738990000] + - [ 2, "a", "aa", "aaa", "aaaa", 2.0, 1590738991000] + - [ 3, "a", "aa", "aaa", "bbbb", 3.0, 1590738992000] + - [ 4, "a", "aa", "aaa", "bbbb", 4.0, 1590738993000] + - [ 5, "a", "aa", "bbb", "bbbb", 5.0, 1590738994000] + - [ 6, "a", "aa", "bbb", "bbbb", 6.0, 1590738995000] + - [ 7, "a", "bb", "bbb", "bbbb", 7.0, 1590738996000 ] + - [ 8, "a", "bb", "bbb", "bbbb", 8.0, 1590738997000 ] + - [ 9, "b", "bb", "bbb", "bbbb", 9.0, 1590738998000 ] + - [10, "b", "bb", "bbb", "bbbb", 10.0, 1590738999000 ] - columns: ["rid int", "x1 string", "x2 string", "x3 string", "x4 string", "x6 double", "x7 timestamp"] indexs: ["index1:x1:x7", "index2:x2:x7", "index3:x3:x7", "index4:x4:x7", ] rows: - - [ 1, "a", "aa", "aaa", "aaaa", "1.0", 1590738990000 ] - - [ 2, "a", "aa", "aaa", "aaaa", "1.0", 1590738991000 ] - - [ 3, "a", "aa", "aaa", "bbbb", "1.0", 1590738992000 ] - - [ 4, "a", "aa", "aaa", "bbbb", "1.0", 1590738993000 ] - - [ 5, "a", "aa", "bbb", "bbbb", "1.0", 1590738994000 ] - - [ 6, "a", "aa", "bbb", "bbbb", "1.0", 1590738995000 ] - - [ 7, "a", "bb", "bbb", "bbbb", "1.0", 1590738996000 ] - - [ 8, "a", "bb", "bbb", "bbbb", "1.0", 1590738997000 ] - - [ 9, "b", "bb", "bbb", "bbbb", "1.0", 1590738998000 ] - - [ 10, "b", "bb", "bbb", "bbbb", "1.0",1590738999000 ] + - [ 1, "a", "aa", "aaa", "aaaa", 1.0, 1590738990000 ] + - [ 2, "a", "aa", "aaa", "aaaa", 1.0, 1590738991000 ] + - [ 3, "a", "aa", "aaa", "bbbb", 1.0, 1590738992000 ] + - [ 4, "a", "aa", "aaa", "bbbb", 1.0, 1590738993000 ] + - [ 5, "a", "aa", "bbb", "bbbb", 1.0, 1590738994000 ] + - [ 6, "a", "aa", "bbb", "bbbb", 1.0, 1590738995000 ] + - [ 7, "a", "bb", "bbb", "bbbb", 1.0, 1590738996000 ] + - [ 8, "a", "bb", "bbb", "bbbb", 1.0, 1590738997000 ] + - [ 9, "b", "bb", "bbb", "bbbb", 1.0, 1590738998000 ] + - [ 10, "b", "bb", "bbb", "bbbb", 1.0,1590738999000 ] sql: | select id, c1, c2, c3, c4, c6, c7, cur_hour, today , w1_sum_c6, w1_max_c6, w1_min_c6, w1_avg_c6, w1_cnt_c6 @@ -616,13 +616,13 @@ cases: "t1_rid int32", "t2_rid int32", "t3_rid int32", "t4_rid int32"] order: id rows: - - [ 1, "a", "aa", "aaa", "aaaa", "1.0", 1590738990000, 15, 29, 1.0, 1.0, 1.0, 1.0, 1, NULL, NULL, NULL, NULL] - - [ 2, "a", "aa", "aaa", "aaaa", "2.0", 1590738991000, 15, 29, 3.0, 2.0, 1.0, 1.5, 2, 1, NULL, NULL, NULL ] - - [ 3, "a", "aa", "aaa", "bbbb", "3.0", 1590738992000, 15, 29, 6.0, 3.0, 1.0, 2.0, 3, 2 , 1, NULL, NULL] - - [ 4, "a", "aa", "aaa", "bbbb", "4.0", 1590738993000, 15, 29, 10.0, 4.0, 1.0, 2.5, 4, 3 , 2, 1, NULL] - - [ 5, "a", "aa", "bbb", "bbbb", "5.0", 1590738994000, 15, 29, 15.0, 5.0, 1.0, 3.0, 5, 4 , 3, NULL, NULL] - - [ 6, "a", "aa", "bbb", "bbbb", "6.0", 1590738995000, 15, 29, 21.0, 6.0, 1.0, 3.5, 6, 5 , 4, NULL, NULL] - - [ 7, "a", "bb", "bbb", "bbbb", "7.0", 1590738996000, 15, 29, 28.0, 7.0, 1.0, 4.0, 7, 6 , NULL, NULL, 3] - - [ 8, "a", "bb", "bbb", "bbbb", "8.0", 1590738997000, 15, 29, 36.0, 8.0, 1.0, 4.5, 8, 7 , NULL, 5, 4] - - [ 9, "b", "bb", "bbb", "bbbb", "9.0", 1590738998000, 15, 29, 9.0, 9.0, 9.0, 9.0, 1, NULL , 7, 6, 5] - - [ 10, "b", "bb", "bbb", "bbbb", "10.0",1590738999000,15, 29, 19.0, 10.0, 9.0, 9.5, 2, 9, 8, 7, 6] + - [ 1, "a", "aa", "aaa", "aaaa", 1.0, 1590738990000, 15, 29, 1.0, 1.0, 1.0, 1.0, 1, NULL, NULL, NULL, NULL] + - [ 2, "a", "aa", "aaa", "aaaa", 2.0, 1590738991000, 15, 29, 3.0, 2.0, 1.0, 1.5, 2, 1, NULL, NULL, NULL ] + - [ 3, "a", "aa", "aaa", "bbbb", 3.0, 1590738992000, 15, 29, 6.0, 3.0, 1.0, 2.0, 3, 2 , 1, NULL, NULL] + - [ 4, "a", "aa", "aaa", "bbbb", 4.0, 1590738993000, 15, 29, 10.0, 4.0, 1.0, 2.5, 4, 3 , 2, 1, NULL] + - [ 5, "a", "aa", "bbb", "bbbb", 5.0, 1590738994000, 15, 29, 15.0, 5.0, 1.0, 3.0, 5, 4 , 3, NULL, NULL] + - [ 6, "a", "aa", "bbb", "bbbb", 6.0, 1590738995000, 15, 29, 21.0, 6.0, 1.0, 3.5, 6, 5 , 4, NULL, NULL] + - [ 7, "a", "bb", "bbb", "bbbb", 7.0, 1590738996000, 15, 29, 28.0, 7.0, 1.0, 4.0, 7, 6 , NULL, NULL, 3] + - [ 8, "a", "bb", "bbb", "bbbb", 8.0, 1590738997000, 15, 29, 36.0, 8.0, 1.0, 4.5, 8, 7 , NULL, 5, 4] + - [ 9, "b", "bb", "bbb", "bbbb", 9.0, 1590738998000, 15, 29, 9.0, 9.0, 9.0, 9.0, 1, NULL , 7, 6, 5] + - [ 10, "b", "bb", "bbb", "bbbb", 10.0,1590738999000,15, 29, 19.0, 10.0, 9.0, 9.5, 2, 9, 8, 7, 6] diff --git a/cases/integration_test/expression/test_type.yaml b/cases/integration_test/expression/test_type.yaml index 295ba024323..9def66de50a 100644 --- a/cases/integration_test/expression/test_type.yaml +++ b/cases/integration_test/expression/test_type.yaml @@ -83,10 +83,8 @@ cases: sql: select cast(c9 as bool) as b1,cast(c2 as smallint) as b2,cast(c3 as int) as b3,cast(c4 as bigint) as b4,cast(c5 as float) as b5,cast(c6 as double) as b6,cast(c7 as timestamp) as b7,cast(c8 as date) as b8,cast(c1 as string) as b9 from {0}; expect: columns: ["b1 bool","b2 smallint","b3 int","b4 bigint","b5 float","b6 double","b7 timestamp","b8 date","b9 string"] - expectProvider: - 0: - rows: - - [false,30,30,30,30.0,30.0,1590738989000,"2020-05-01",aa] + rows: + - [false,30,30,30,30.0,30.0,null,"2020-05-01",aa] - id: 3 desc: "cast_date_正确" # tags: ["TODO","本地成功,CICD失败,原因待定位"] diff --git a/cases/integration_test/function/test_udaf_function.yaml b/cases/integration_test/function/test_udaf_function.yaml index 13cf41d9e43..70e49da5905 100644 --- a/cases/integration_test/function/test_udaf_function.yaml +++ b/cases/integration_test/function/test_udaf_function.yaml @@ -2401,15 +2401,15 @@ cases: - columns: [ "id int","ts timestamp","group1 string","val1 int" ] indexs: [ "index1:group1:ts" ] name: t1 - data: | - 1, 1612130400000, g1, 1 - 2, 1612130401000, g1, 2 - 3, 1612130402000, g1, 3 - 4, 1612130403000, g1, 4 - 5, 1612130404000, g1, 5 - 6, 1612130404000, g2, 4 - 7, 1612130405000, g2, 3 - 8, 1612130406000, g2, 2 + rows: + - [1, 1612130400000, g1, 1] + - [2, 1612130401000, g1, 2] + - [3, 1612130402000, g1, 3] + - [4, 1612130403000, g1, 4] + - [5, 1612130404000, g1, 5] + - [6, 1612130404000, g2, 4] + - [7, 1612130405000, g2, 3] + - [8, 1612130406000, g2, 2] sql: | select `id`, @@ -2440,15 +2440,15 @@ cases: - columns: [ "id int","ts timestamp","group1 string","val1 int" ] indexs: [ "index1:group1:ts" ] name: t1 - data: | - 1, 1612130400000, g1, 1 - 2, 1612130401000, g1, 2 - 3, 1612130402000, g1, 3 - 4, 1612130403000, g1, 4 - 5, 1612130404000, g1, 5 - 6, 1612130405000, g2, 4 - 7, 1612130406000, g2, 3 - 8, 1612130407000, g2, 2 + rows: + - [1, 1612130400000, g1, 1] + - [2, 1612130401000, g1, 2] + - [3, 1612130402000, g1, 3] + - [4, 1612130403000, g1, 4] + - [5, 1612130404000, g1, 5] + - [6, 1612130405000, g2, 4] + - [7, 1612130406000, g2, 3] + - [8, 1612130407000, g2, 2] sql: | select `id`, @@ -2480,15 +2480,15 @@ cases: - columns: [ "id int","ts timestamp","group1 string","val1 int" ] indexs: [ "index1:group1:ts" ] name: t1 - data: | - 1, 1612130400000, g1, 1 - 2, 1612130401000, g1, 2 - 3, 1612130402000, g1, 3 - 4, 1612130403000, g1, 4 - 5, 1612130404000, g1, 5 - 6, 1612130405000, g2, 4 - 7, 1612130406000, g2, 3 - 8, 1612130407000, g2, 2 + rows: + - [1, 1612130400000, g1, 1] + - [2, 1612130401000, g1, 2] + - [3, 1612130402000, g1, 3] + - [4, 1612130403000, g1, 4] + - [5, 1612130404000, g1, 5] + - [6, 1612130405000, g2, 4] + - [7, 1612130406000, g2, 3] + - [8, 1612130407000, g2, 2] sql: | select `id`, @@ -2519,15 +2519,15 @@ cases: - columns: [ "id int","ts timestamp","group1 string","val1 int" ] indexs: [ "index1:group1:ts" ] name: t1 - data: | - 1, 1612130400000, g1, 1 - 2, 1612130401000, g1, 2 - 3, 1612130402000, g1, 3 - 4, 1612130403000, g1, 4 - 5, 1612130404000, g1, 5 - 6, 1612130405000, g2, 4 - 7, 1612130406000, g2, 3 - 8, 1612130407000, g2, 2 + rows: + - [1, 1612130400000, g1, 1] + - [2, 1612130401000, g1, 2] + - [3, 1612130402000, g1, 3] + - [4, 1612130403000, g1, 4] + - [5, 1612130404000, g1, 5] + - [ 6, 1612130405000, g2, 4] + - [7, 1612130406000, g2, 3] + - [8, 1612130407000, g2, 2] sql: | select `id`, diff --git a/cases/integration_test/join/test_lastjoin_simple.yaml b/cases/integration_test/join/test_lastjoin_simple.yaml index fa58a927859..9795d4a0d70 100644 --- a/cases/integration_test/join/test_lastjoin_simple.yaml +++ b/cases/integration_test/join/test_lastjoin_simple.yaml @@ -123,7 +123,10 @@ cases: - [ "cc",41,121,1590738991000 ] sql: select {0}.c1,{0}.c2,{1}.c3,{1}.c4 from {0} last join {1} on {0}.c1={1}.c1; expect: - success: false + columns: [ "c1 string","c2 int","c3 bigint","c4 timestamp" ] + rows: + - [ "aa",2,13,1590738989000 ] + - [ "bb",21,131,1590738990000 ] - id: 4-2 desc: Last Join 无order by, 部分拼表条件命中索引 inputs: @@ -172,7 +175,12 @@ cases: - [ "cc",41,121,1590738991000 ] sql: select {0}.c1,{0}.c2,{1}.c3,{1}.c4 from {0} last join {1} on {0}.c1={1}.c1 and {0}.c4={1}.c4; expect: - success: false + columns: [ "c1 string","c2 int","c3 bigint","c4 timestamp" ] + rows: + - [ "aa",2,13,1590738989000 ] + - [ "aa",20,15,1590738991000 ] + - [ "bb",21,131,1590738990000 ] + - [ "dd",41,null,null ] - id: 4-4 desc: Last Join 无order by, 拼表条件命中部分的组合索引(后缀索引) mode: non-performance-sensitive-unsupport, offline-unsupport @@ -194,7 +202,12 @@ cases: - [ "cc",41,121,1590738991000 ] sql: select {0}.c1,{0}.c2,{1}.c3,{1}.c4 from {0} last join {1} on {0}.c1={1}.c1 and {0}.c4={1}.c4; expect: - success: false + columns: [ "c1 string","c2 int","c3 bigint","c4 timestamp" ] + rows: + - [ "aa",2,13,1590738989000 ] + - [ "aa",20,15,1590738991000 ] + - [ "bb",21,131,1590738990000 ] + - [ "dd",41,null,null ] - id: 4-5 desc: Last Join 无order by, 拼表条件命中索引, 副表多条命中 tags: [ "注意offline随机拼接最后一条,改变结果顺序可能导致Spark结果不符合预期" ] diff --git a/cases/integration_test/long_window/test_long_window_batch.yaml b/cases/integration_test/long_window/test_long_window_batch.yaml index 60c938490d4..497640b318f 100644 --- a/cases/integration_test/long_window/test_long_window_batch.yaml +++ b/cases/integration_test/long_window/test_long_window_batch.yaml @@ -19,6 +19,7 @@ cases: - id: 0 desc: options格式错误 + mode: apiserver-unsupport inputs: - columns : ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] diff --git a/cases/integration_test/window/error_window.yaml b/cases/integration_test/window/error_window.yaml index ce2fc32983f..798c66673d2 100644 --- a/cases/integration_test/window/error_window.yaml +++ b/cases/integration_test/window/error_window.yaml @@ -26,7 +26,7 @@ cases: sql: | SELECT id, c1, c4, count(c4) OVER w1 as w1_c4_count FROM {0} WINDOW w1 AS (PARTITION BY {0}.c8 ROWS BETWEEN 2 PRECEDING AND CURRENT ROW); expect: - success: false + success: true - id: 1 desc: no partition by inputs: diff --git a/extensions/airflow-provider-openmldb/tests/hooks/test_openmldb_api_hook.py b/extensions/airflow-provider-openmldb/tests/hooks/test_openmldb_api_hook.py index 2dcd9f447f1..b3714ade402 100644 --- a/extensions/airflow-provider-openmldb/tests/hooks/test_openmldb_api_hook.py +++ b/extensions/airflow-provider-openmldb/tests/hooks/test_openmldb_api_hook.py @@ -120,7 +120,7 @@ def test_query_api_server_without_data(self): # no data response = hook.run() res = json.loads(response.text) - assert res == {'code': -1, 'msg': 'Json parse failed'} + assert res == {'code': -1, 'msg': 'Request body json parse failed'} def test_query_api_server_with_sql(self): hook = OpenMLDBHook() @@ -133,7 +133,7 @@ def test_query_api_server_without_mode(self): response = hook.run(data='{"sql":"select 1"}') res = json.loads(response.text) assert res['code'] == -1 - assert res['msg'].startswith('Json parse failed') + assert res['msg'].startswith('Request body json parse failed') def test_query_api_server(self): hook = OpenMLDBHook() diff --git a/test/integration-test/README b/test/integration-test/README new file mode 100644 index 00000000000..1b250620412 --- /dev/null +++ b/test/integration-test/README @@ -0,0 +1,31 @@ +# README + +## 参数配置脚本 + +``` +test/format_config.sh {openmldbPath} {jobName} {portFrom} {portTo} {type} {Dependency} +``` +配置生成在 out/openmldb_info.yaml + +Dependency为hadoop时使用hadoop config + +Dependency为ssd时禁止部署在node-1 + +## 一键运行脚本 +``` +test/openmldb-integration-test.sh -c {caseXML} -d {deployMode} -j {jarVersion} -l {caseLevel} -s {tableStorageMode} -m {executeMode} +``` + +### 版本兼容性测试 +openmldb包版本设置: test/format_config.sh {openmldbPath} + +jar版本设置: test/openmldb-integration-test.sh -j {jarVersion} + +### kafka测试 +``` +test/integration-test/openmldb-test-java/kafka_test.sh +``` +环境配置于node-4: kakfa_test(docker) + +## 回归测试workflow +hadoop配置文件位于 /mnt/hdd0/denglong/openmldb_runner_work/hadoop \ No newline at end of file diff --git a/test/integration-test/openmldb-test-java/kafka_test.sh b/test/integration-test/openmldb-test-java/kafka_test.sh new file mode 100755 index 00000000000..ff585a4f93c --- /dev/null +++ b/test/integration-test/openmldb-test-java/kafka_test.sh @@ -0,0 +1,18 @@ +#! /bin/bash + +apiserver="$(awk -F '"' 'NR==7{print $2}' ../../../out/openmldb_info.yaml)" +zkc="zk=""$(awk -F '"' 'NR==2{print $2}' ../../../out/openmldb_info.yaml)" +zkpath="\&zkPath=""$(awk -F '"' 'NR==3{print $2}' ../../../out/openmldb_info.yaml)" +echo "${zkc}" +echo "${zkpath}" +zk="${zkc}""${zkpath}" + +docker exec -it kafka_test /start.sh "${zk}" +sed -i "s#\"bootstrap.servers\":.*#\"bootstrap.servers\":node-4:9092,#" openmldb-ecosystem/src/test/resources/kafka_test_cases.yml +sed -i "s#\"connect.listeners\":.*#\"connect.listeners\":http://node-4:8083,#" openmldb-ecosystem/src/test/resources/kafka_test_cases.yml +sed -i "s#apiserver.address:.*#apiserver.address: ${apiserver}#" openmldb-ecosystem/src/test/resources/kafka_test_cases.yml +sed -i "s#kafka_test?.*#kafka_test?${zk}\"#" openmldb-ecosystem/src/test/resources/kafka_test_cases.yml + +mvn test -pl openmldb-ecosystem + +docker exec -it kafka_test /stop.sh diff --git a/test/integration-test/openmldb-test-java/openmldb-http-test/pom.xml b/test/integration-test/openmldb-test-java/openmldb-http-test/pom.xml index 6a870c1d40d..bddd64a4c6a 100644 --- a/test/integration-test/openmldb-test-java/openmldb-http-test/pom.xml +++ b/test/integration-test/openmldb-test-java/openmldb-http-test/pom.xml @@ -24,6 +24,29 @@ openmldb-sdk-test ${project.version} + + org.uncommons + reportng + 1.1.4 + test + + + org.testng + testng + + + + + io.qameta.allure + allure-testng + 2.12.1 + + + com.google.inject + guice + 4.0 + test + @@ -31,10 +54,10 @@ org.apache.maven.plugins maven-surefire-plugin - 2.20.1 + 2.22.1 false - 1 + 2 ${suiteXmlFile} @@ -44,20 +67,16 @@ target/ - - - - org.aspectj - aspectjweaver - ${aspectj.version} - - - - - org.apache.maven.plugins - maven-surefire-plugin - 2.20.1 - + + + usedefaultlisteners + false + + + listener + org.uncommons.reportng.HTMLReporter, org.uncommons.reportng.JUnitXMLReporter + + caseName @@ -98,6 +117,13 @@ + + + org.aspectj + aspectjweaver + ${aspectj.version} + + diff --git a/test/integration-test/openmldb-test-java/openmldb-http-test/src/main/java/com/_4paradigm/openmldb/http_test/check/DataChecker.java b/test/integration-test/openmldb-test-java/openmldb-http-test/src/main/java/com/_4paradigm/openmldb/http_test/check/DataChecker.java index 0799e00e459..81098102ee9 100644 --- a/test/integration-test/openmldb-test-java/openmldb-http-test/src/main/java/com/_4paradigm/openmldb/http_test/check/DataChecker.java +++ b/test/integration-test/openmldb-test-java/openmldb-http-test/src/main/java/com/_4paradigm/openmldb/http_test/check/DataChecker.java @@ -35,7 +35,7 @@ public void check() throws Exception { if(MapUtils.isEmpty(data)){ return ; } - String resultData = httpResult.getData(); + String resultData = httpResult.getData().toString(); if(data.containsKey("code")){ Object expectCode = data.get("code"); Object actualCode = JsonPath.read(resultData, "$.code"); diff --git a/test/integration-test/openmldb-test-java/openmldb-http-test/src/main/java/com/_4paradigm/openmldb/http_test/common/ClusterTest.java b/test/integration-test/openmldb-test-java/openmldb-http-test/src/main/java/com/_4paradigm/openmldb/http_test/common/ClusterTest.java index b24d2de1652..fe93d1ccb32 100644 --- a/test/integration-test/openmldb-test-java/openmldb-http-test/src/main/java/com/_4paradigm/openmldb/http_test/common/ClusterTest.java +++ b/test/integration-test/openmldb-test-java/openmldb-http-test/src/main/java/com/_4paradigm/openmldb/http_test/common/ClusterTest.java @@ -28,6 +28,8 @@ import org.testng.annotations.BeforeTest; import org.testng.annotations.Optional; import org.testng.annotations.Parameters; +import com._4paradigm.openmldb.test_common.provider.YamlUtil; +import com._4paradigm.openmldb.test_common.util.Tool; @Slf4j public class ClusterTest extends BaseTest{ @@ -52,7 +54,9 @@ public void beforeTest(@Optional("qa") String env, @Optional("main") String vers openMLDBDeploy.setOpenMLDBPath(openMLDBPath); openMLDBDeploy.setCluster(false); RestfulGlobalVar.mainInfo = openMLDBDeploy.deployCluster(2, 3); - } else { + } else if(env.equalsIgnoreCase("deploy")){ + RestfulGlobalVar.mainInfo = YamlUtil.getObject(Tool.openMLDBDir().getAbsolutePath()+"/out/openmldb_info.yaml",OpenMLDBInfo.class); + } else { OpenMLDBInfo openMLDBInfo = new OpenMLDBInfo(); openMLDBInfo.setDeployType(OpenMLDBDeployType.CLUSTER); openMLDBInfo.setNsNum(2); diff --git a/test/integration-test/openmldb-test-java/openmldb-http-test/src/main/java/com/_4paradigm/openmldb/http_test/config/FedbRestfulConfig.java b/test/integration-test/openmldb-test-java/openmldb-http-test/src/main/java/com/_4paradigm/openmldb/http_test/config/FedbRestfulConfig.java index ff216bf3a93..807efaf30b1 100644 --- a/test/integration-test/openmldb-test-java/openmldb-http-test/src/main/java/com/_4paradigm/openmldb/http_test/config/FedbRestfulConfig.java +++ b/test/integration-test/openmldb-test-java/openmldb-http-test/src/main/java/com/_4paradigm/openmldb/http_test/config/FedbRestfulConfig.java @@ -77,7 +77,8 @@ public class FedbRestfulConfig { BASE_PATH = CONFIG.getProperty(RestfulGlobalVar.env + "_base_path"); // BASE_URL = CONFIG.getProperty(RestfulGlobalVar.env + "_base_url"); - DB_NAME = CONFIG.getProperty(RestfulGlobalVar.env + "_db_name"); + // DB_NAME = CONFIG.getProperty(RestfulGlobalVar.env + "_db_name"); + DB_NAME = "test_restful"; log.info("HybridSEConfig: db_name: {}", DB_NAME); String versionStr = System.getProperty("fedbVersion"); if (StringUtils.isEmpty(versionStr)) { diff --git a/test/integration-test/openmldb-test-java/openmldb-http-test/src/main/java/com/_4paradigm/openmldb/http_test/executor/RestfulOnlineExecutor.java b/test/integration-test/openmldb-test-java/openmldb-http-test/src/main/java/com/_4paradigm/openmldb/http_test/executor/RestfulOnlineExecutor.java new file mode 100644 index 00000000000..3145968e1f1 --- /dev/null +++ b/test/integration-test/openmldb-test-java/openmldb-http-test/src/main/java/com/_4paradigm/openmldb/http_test/executor/RestfulOnlineExecutor.java @@ -0,0 +1,179 @@ +package com._4paradigm.openmldb.http_test.executor; + + +import com._4paradigm.openmldb.test_common.restful.common.OpenMLDBHttp; +import com._4paradigm.openmldb.test_common.restful.model.HttpMethod; +import com._4paradigm.openmldb.test_common.model.SQLCase; +import com._4paradigm.openmldb.test_common.model.InputDesc; +import com._4paradigm.openmldb.test_common.common.BaseExecutor; +import com._4paradigm.openmldb.test_common.restful.model.HttpResult; +import com._4paradigm.openmldb.test_common.command.OpenMLDBCommandFactory; +import com._4paradigm.openmldb.http_test.util.HttpUtil; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.Random; +import org.testng.Assert; +import org.apache.commons.collections4.CollectionUtils; +import com._4paradigm.openmldb.test_common.command.OpenMLDBCommandUtil; +import com._4paradigm.openmldb.test_common.provider.YamlUtil; +import com._4paradigm.openmldb.test_common.util.Tool; +import com._4paradigm.qa.openmldb_deploy.bean.OpenMLDBInfo; +import com._4paradigm.openmldb.test_common.restful.model.HttpData; +import com.google.gson.Gson; + + +public class RestfulOnlineExecutor extends BaseExecutor { + + public RestfulOnlineExecutor(SQLCase sqlCase) { + super(sqlCase); + } + + protected List tables = sqlCase.getInputs(); + protected HttpResult httpresult; + protected String deploy; + protected OpenMLDBInfo openMLDBInfo= YamlUtil.getObject(Tool.openMLDBDir().getAbsolutePath()+"/out/openmldb_info.yaml",OpenMLDBInfo.class); + protected String defaultDb = null==sqlCase.getDb()||sqlCase.getDb().equals("null") ? "test_apiserver": sqlCase.getDb(); + String apiServerUrl; + OpenMLDBHttp openMLDBHttp = new OpenMLDBHttp(); + + @Override + public boolean verify(){ + if(null != sqlCase.getMode() && sqlCase.getMode().contains("request-unsupport")){ + return false; + } + if(null != sqlCase.getMode() && sqlCase.getMode().contains("cluster-unsupport")){ + return false; + } + if(null != sqlCase.getMode() && sqlCase.getMode().contains("hybridse-only")){ + return false; + } + if(null != sqlCase.getMode() && sqlCase.getMode().contains("apiserver-unsupport")){ + return false; + } + if(null != sqlCase.getMode() && sqlCase.getMode().contains("rtidb-unsupport")){ + return false; + } + if(null != sqlCase.getMode() && sqlCase.getMode().contains("procedure-unsupport")){ + return false; + } + + return true; + } + + @Override + public void prepare() { + dbName = defaultDb; + apiServerUrl = "http://"+openMLDBInfo.getApiServerEndpoints().get(0); + List tables = sqlCase.getInputs(); + OpenMLDBCommandUtil.createDatabases(openMLDBInfo,dbName,tables); + OpenMLDBCommandFactory.runNoInteractive(openMLDBInfo, dbName, "set @@global.execute_mode='online'"); + if (!CollectionUtils.isEmpty(tables)) { + OpenMLDBCommandUtil.createTables(openMLDBInfo, dbName, tables); + for (InputDesc table : tables) { + tableNames.add(table.getName()); + } + } + Random r = new Random(System.currentTimeMillis()); + deploy = tableNames.get(0)+String.valueOf(r.nextInt(1000000)); + String tmpSql = sqlCase.getSql().toString().replaceAll("\'","\""); + String options = sqlCase.getLongWindow()!=null? "OPTIONS(long_windows=\""+sqlCase.getLongWindow()+"\",RANGE_BIAS=\"inf\", ROWS_BIAS=\"inf\") " + :"OPTIONS(RANGE_BIAS=\"inf\", ROWS_BIAS=\"inf\") "; + tmpSql = options + tmpSql; + OpenMLDBCommandFactory.runNoInteractive(openMLDBInfo, dbName, "deploy "+deploy+" "+tmpSql); + String uri = "/dbs/"+dbName+"/deployments/"+deploy; + HttpResult result = openMLDBHttp.restfulJsonRequest(apiServerUrl,uri,"",HttpMethod.GET); + if(result.getData().contains("\"code\":-1")){ + openMLDBResult.setMsg("deploy fail"); + return; + } + + // first table and data set as request, skipped in prepare stage, other tables and data set as base, added + if (tables.size()>1){ + for (int i=1;i0? tables.get(i).getDb(): dbName; + uri = "/dbs/"+curDb+"/tables/"+tableNames.get(i); + OpenMLDBHttp openMLDBHttp = new OpenMLDBHttp(); + openMLDBHttp.restfulJsonRequest(apiServerUrl,uri,body,HttpMethod.PUT); + } + } + } + } + + @Override + @SuppressWarnings("unchecked") + public void execute(){ + if(openMLDBResult.getMsg().equals("deploy fail")){ + openMLDBResult.setOk(false); + return; + } + List> tmpResults = new ArrayList>(); + HttpResult result = new HttpResult(); + + // set row i as request line, insert row i, repeat + for (int i=0;i tmpResult = (List)data.getData().get("data").get(0); + tmpResults.add(tmpResult); + } else {break;} + body = HttpUtil.formatInputs("value",tables.get(0),i,false); + String curDb = tables.get(0).getDb().length()>0? tables.get(0).getDb(): dbName; + uri = "/dbs/"+curDb+"/tables/"+tableNames.get(0); + openMLDBHttp.restfulJsonRequest(apiServerUrl,uri,body,HttpMethod.PUT); + } + + openMLDBResult = HttpUtil.convertHttpResult(sqlCase, result,tmpResults); + } + + @Override + public void check(){ + // success check + if (!sqlCase.getExpect().getSuccess()){ + Assert.assertFalse(openMLDBResult.isOk(),"execute expect fail but success"); + return; + } + // format output + openMLDBResult.setFormattedExpectResults(HttpUtil.FormatOutputs(sqlCase.getExpect().getRows(),sqlCase.getExpect().getColumns())); + openMLDBResult.setFormattedActualResults(HttpUtil.FormatOutputs(openMLDBResult.getResult(),openMLDBResult.getColumnTypes())); + + // size check + //Assert.assertEquals(openMLDBResult.isOk(),sqlCase.getExpect().getSuccess().booleanValue(),"errror "+openMLDBResult.getMsg() ); + Assert.assertEquals(openMLDBResult.getFormattedActualResults().size(),openMLDBResult.getFormattedExpectResults().size()); + + // contents check + for (int i =0;i realColumn = openMLDBResult.getFormattedActualResults().get(i); + Map expectColumn = openMLDBResult.getFormattedExpectResults().get(i); + expectColumn.forEach((k,v)-> { + Assert.assertTrue(realColumn.containsKey(k), "column "+k+"don't exist"); + String errorMessage = String.format("key %s mismatch in case %s", k,sqlCase.getDesc().toString()); + if (v==null){ + Assert.assertNull(realColumn.get(k), errorMessage); + } else if (v instanceof Float ){ + Assert.assertEquals((float)realColumn.get(k),(float)v,1e-4,errorMessage); + } else if (v instanceof Double){ + Assert.assertEquals((double)realColumn.get(k),(double)v,1e-4,errorMessage); + } else { + Assert.assertEquals(realColumn.get(k),v,errorMessage); + } + }); + } + } + + @Override + public void tearDown(){ + OpenMLDBCommandFactory.runNoInteractive(openMLDBInfo, dbName, "drop deployment "+deploy); + for(InputDesc table:sqlCase.getInputs()){ + String curDb = table.getDb().length()>0? table.getDb(): dbName; + OpenMLDBCommandFactory.runNoInteractive(openMLDBInfo, curDb, "drop table "+table.getName()); + } + } + +} diff --git a/test/integration-test/openmldb-test-java/openmldb-http-test/src/main/java/com/_4paradigm/openmldb/http_test/util/HttpUtil.java b/test/integration-test/openmldb-test-java/openmldb-http-test/src/main/java/com/_4paradigm/openmldb/http_test/util/HttpUtil.java new file mode 100644 index 00000000000..46c44090484 --- /dev/null +++ b/test/integration-test/openmldb-test-java/openmldb-http-test/src/main/java/com/_4paradigm/openmldb/http_test/util/HttpUtil.java @@ -0,0 +1,206 @@ +/* + * Copyright 2021 4Paradigm + * + * Licensed 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 com._4paradigm.openmldb.http_test.util; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Collections; +import java.text.DateFormat; +import java.text.SimpleDateFormat; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com._4paradigm.openmldb.test_common.model.InputDesc; +import com._4paradigm.openmldb.test_common.bean.OpenMLDBResult; +import com._4paradigm.openmldb.test_common.model.SQLCase; +import com._4paradigm.openmldb.test_common.restful.model.HttpResult; +import lombok.extern.slf4j.Slf4j; +import com._4paradigm.openmldb.test_common.restful.model.HttpData; + +@Slf4j +public class HttpUtil { + public static String formatInputs(String key, InputDesc table,int cur, boolean need_schema){ + String body = ""; + Gson gson = new GsonBuilder().create(); + + List> rows = table.getRows(); + List> tmpRow = new ArrayList>(); + Map data = new HashMap<>(); + tmpRow.add(rows.get(cur)); + // for(List row : rows) { + // tmpRow.add(row); + // } + data.put(key, tmpRow); + if (need_schema){ + data.put("need_schema", true); + } + body = gson.toJson(data); + + return body; + } + + + public static List> FormatOutputs(List> rows,List columns){ + String[] nameType; + Object o; + List> resultLists = new ArrayList>(); + List resultList = new ArrayList(); + if (rows.equals(null)||rows==null||rows.size()==0){return resultLists;} + Collections.sort(rows, new RowsSort(0)); + for (int i=0;i tmp = new HashMap<>(); + for (int j=0;j httpData = data.getData().get("data"); + List> resultList = new ArrayList>(); + for (Object o : httpData) { + resultList.add((List)o); + } + if (resultList.size()>0) { + openMLDBResult.setResult(resultList); + } + + httpData = data.getData().get("schema"); + List schemaList = new ArrayList(); + for (int i = 0 ; i mp = (Map)httpData.get(i); + schemaList.add(mp.get("name")+" "+mp.get("type")); + } + openMLDBResult.setColumnTypes(schemaList); + } catch (Exception e) { + // + } + } else { + openMLDBResult.setOk(false); + // Assert.assertNotEquals(0, httpResult.getData().getCode()); + } + return openMLDBResult; + } + + @SuppressWarnings("unchecked") + public static OpenMLDBResult convertHttpResult(SQLCase sqlCase, HttpResult httpResult, List> tmpResults){ + OpenMLDBResult openMLDBResult = new OpenMLDBResult(); + Gson gson = new Gson(); + HttpData data = gson.fromJson(httpResult.getData(), HttpData.class); + openMLDBResult.setMsg(sqlCase.getDesc()+data.getMsg()); + if (httpResult.getHttpCode()!=200 || data.getCode()!=0 ){ + openMLDBResult.setOk(false); + return openMLDBResult; + } + try { + List httpData = data.getData().get("data"); + openMLDBResult.setResult(tmpResults); + httpData = data.getData().get("schema"); + List schemaList = new ArrayList(); + for (int i = 0 ; i mp = (Map)httpData.get(i); + schemaList.add(mp.get("name").replace(" ", "")+" "+mp.get("type")); + } + + openMLDBResult.setColumnTypes(schemaList); + openMLDBResult.setOk(true); + } catch (Exception e) { + e.printStackTrace(); + log.info( "erro msg is "+data.getMsg()); + openMLDBResult.setOk(false); + } + return openMLDBResult; + } + + public static String switchType(String type){ + switch(type){ + case "smallint": + return "int"; + case "int": + return "int"; + case "bigint": + return "long"; + case "int32": + return "int"; + case "int16": + return "int"; + case "int64": + return "long"; + case "float": + return "float"; + default: + return type; + } + + } + +} diff --git a/test/integration-test/openmldb-test-java/openmldb-http-test/src/main/java/com/_4paradigm/openmldb/http_test/util/RowsSort.java b/test/integration-test/openmldb-test-java/openmldb-http-test/src/main/java/com/_4paradigm/openmldb/http_test/util/RowsSort.java new file mode 100644 index 00000000000..3fd7b19d283 --- /dev/null +++ b/test/integration-test/openmldb-test-java/openmldb-http-test/src/main/java/com/_4paradigm/openmldb/http_test/util/RowsSort.java @@ -0,0 +1,61 @@ +/* + * Copyright 2021 4Paradigm + * + * Licensed 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 com._4paradigm.openmldb.http_test.util; + +import com._4paradigm.openmldb.test_common.common.ReportLog; +import lombok.extern.slf4j.Slf4j; + +import java.util.Comparator; +import java.util.List; + + +@Slf4j +public class RowsSort implements Comparator { + private int index; + private ReportLog reportLog = ReportLog.of(); + + public RowsSort(int index) { + this.index = index; + if (-1 == index) { + log.warn("compare without index"); + reportLog.warn("compare without index"); + } + } + + @Override + public int compare(List o1, List o2) { + if (-1 == index) { + + return 0; + } + Object obj1 = o1.get(index); + Object obj2 = o2.get(index); + if (obj1 == obj2) { + return 0; + } + if (obj1 == null) { + return -1; + } + if (obj2 == null) { + return 1; + } + if (obj1 instanceof Comparable && obj2 instanceof Comparable) { + return ((Comparable) obj1).compareTo(obj2); + } else { + return obj1.hashCode() - obj2.hashCode(); + } + } +} diff --git a/test/integration-test/openmldb-test-java/openmldb-http-test/src/test/java/com/_4paradigm/openmldb/http_test/v030/TestDeployment.java b/test/integration-test/openmldb-test-java/openmldb-http-test/src/test/java/com/_4paradigm/openmldb/http_test/tmp/TestCluster.java similarity index 52% rename from test/integration-test/openmldb-test-java/openmldb-http-test/src/test/java/com/_4paradigm/openmldb/http_test/v030/TestDeployment.java rename to test/integration-test/openmldb-test-java/openmldb-http-test/src/test/java/com/_4paradigm/openmldb/http_test/tmp/TestCluster.java index b50b64e4302..344c2fdd285 100644 --- a/test/integration-test/openmldb-test-java/openmldb-http-test/src/test/java/com/_4paradigm/openmldb/http_test/v030/TestDeployment.java +++ b/test/integration-test/openmldb-test-java/openmldb-http-test/src/test/java/com/_4paradigm/openmldb/http_test/tmp/TestCluster.java @@ -13,25 +13,24 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com._4paradigm.openmldb.http_test.v030; +package com._4paradigm.openmldb.http_test.tmp; -import com._4paradigm.openmldb.http_test.common.ClusterTest; -import com._4paradigm.openmldb.http_test.common.StandaloneTest; -import com._4paradigm.openmldb.http_test.executor.RestfulCliExecutor; -import com._4paradigm.openmldb.http_test.executor.RestfulExecutor; +import com._4paradigm.openmldb.http_test.executor.RestfulOnlineExecutor; import com._4paradigm.openmldb.test_common.provider.Yaml; -import com._4paradigm.openmldb.test_common.restful.model.RestfulCase; import io.qameta.allure.Feature; import io.qameta.allure.Story; import org.testng.annotations.Test; +import com._4paradigm.openmldb.test_common.common.BaseTest; +import com._4paradigm.openmldb.test_common.model.SQLCase; -@Feature("deployment") -public class TestDeployment extends StandaloneTest { - - @Test(dataProvider = "getCase") - @Yaml(filePaths = "/restful/v030/test_execute_deployment.yaml") - @Story("ExecuteDeployment") - public void testExecute(RestfulCase restfulCase){ - new RestfulCliExecutor(restfulCase).run(); +@Feature("cluster api request") +public class TestCluster { + @Test(dataProvider = "getCase",dataProviderClass = BaseTest.class) + @Yaml(filePaths = "integration_test/cluster/") + @Story("cluster api request") + public void testBatch(SQLCase sqlCase){ + new RestfulOnlineExecutor(sqlCase).run(); } -} + + +} \ No newline at end of file diff --git a/test/integration-test/openmldb-test-java/openmldb-http-test/src/test/java/com/_4paradigm/openmldb/http_test/tmp/TestDropTable.java b/test/integration-test/openmldb-test-java/openmldb-http-test/src/test/java/com/_4paradigm/openmldb/http_test/tmp/TestDropTable.java deleted file mode 100644 index 7d947bf4bb6..00000000000 --- a/test/integration-test/openmldb-test-java/openmldb-http-test/src/test/java/com/_4paradigm/openmldb/http_test/tmp/TestDropTable.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright 2021 4Paradigm - * - * Licensed 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 com._4paradigm.openmldb.http_test.tmp; - -import com._4paradigm.openmldb.test_common.openmldb.OpenMLDBClient; -import com._4paradigm.openmldb.test_common.bean.OpenMLDBResult; -import com._4paradigm.openmldb.test_common.util.SDKUtil; -import com._4paradigm.openmldb.test_common.restful.model.HttpResult; -import com._4paradigm.openmldb.test_common.util.HttpRequest; -import com.google.gson.Gson; -import com.google.gson.JsonArray; -import com.google.gson.JsonObject; -import com.google.gson.JsonParser; -import org.testng.annotations.Test; - -import java.util.HashMap; - -public class TestDropTable { - - @Test - public void testAll() throws Exception { - OpenMLDBClient fedbClient = new OpenMLDBClient("172.24.4.55:10000","/fedb"); - String apiserver = "172.24.4.55:20000"; - String dbName = "test_zw"; - String url = String.format("http://%s/dbs/%s/tables",apiserver,dbName); - HttpResult httpResult = HttpRequest.get(url, null, new HashMap<>()); -// System.out.println(httpResult.getData()); - Gson gson = new Gson(); - JsonParser parser = new JsonParser(); - JsonObject jsonObject = parser.parse(httpResult.getData()).getAsJsonObject(); - JsonArray tables = jsonObject.getAsJsonArray("tables"); - for(int i=0;i - - - + + + - - - + - - - - - + + + + + + + + - + + \ No newline at end of file diff --git a/test/integration-test/openmldb-test-java/openmldb-sdk-test/src/main/java/com/_4paradigm/openmldb/java_sdk_test/checker/OptionsChecker.java b/test/integration-test/openmldb-test-java/openmldb-sdk-test/src/main/java/com/_4paradigm/openmldb/java_sdk_test/checker/OptionsChecker.java index d903425918b..9b3b04958e1 100644 --- a/test/integration-test/openmldb-test-java/openmldb-sdk-test/src/main/java/com/_4paradigm/openmldb/java_sdk_test/checker/OptionsChecker.java +++ b/test/integration-test/openmldb-test-java/openmldb-sdk-test/src/main/java/com/_4paradigm/openmldb/java_sdk_test/checker/OptionsChecker.java @@ -54,7 +54,7 @@ public void check() throws Exception { String url = String.format("http://%s/dbs/%s/tables/%s",apiserverEndpoint,dbName,tableName); Tool.sleep(3000); HttpResult httpResult = HttpRequest.get(url); - String resultData = httpResult.getData(); + String resultData = httpResult.getData().toString(); Object partitionNum = JsonPath.read(resultData, "$.table.partition_num"); Object replicaNum = JsonPath.read(resultData, "$.table.replica_num"); Map options = expect.getOptions(); diff --git a/test/integration-test/openmldb-test-java/openmldb-sdk-test/src/main/java/com/_4paradigm/openmldb/java_sdk_test/executor/BaseExecutor.java b/test/integration-test/openmldb-test-java/openmldb-sdk-test/src/main/java/com/_4paradigm/openmldb/java_sdk_test/executor/BaseExecutor.java index adc918aa947..3b8bc0608aa 100644 --- a/test/integration-test/openmldb-test-java/openmldb-sdk-test/src/main/java/com/_4paradigm/openmldb/java_sdk_test/executor/BaseExecutor.java +++ b/test/integration-test/openmldb-test-java/openmldb-sdk-test/src/main/java/com/_4paradigm/openmldb/java_sdk_test/executor/BaseExecutor.java @@ -43,7 +43,6 @@ public void run() { String className = Thread.currentThread().getStackTrace()[2].getClassName(); String methodName = Thread.currentThread().getStackTrace()[2].getMethodName(); System.out.println(className+"."+methodName+":"+ sqlCase.getCaseFileName()+":"+ sqlCase.getDesc() + " Begin!"); - log.info(className+"."+methodName+":"+ sqlCase.getDesc() + " Begin!"); boolean verify = false; try { verify = verify(); @@ -58,7 +57,7 @@ public void run() { } catch (Exception e) { e.printStackTrace(); System.out.println(className+"."+methodName+":"+ sqlCase.getDesc() + " FAIL!"); - Assert.fail("executor run with exception"); + Assert.fail("executor run with exception "+sqlCase.getDesc()); }finally { if(verify) { tearDown(); diff --git a/test/integration-test/openmldb-test-java/openmldb-sdk-test/src/main/java/com/_4paradigm/openmldb/java_sdk_test/executor/BaseSQLExecutor.java b/test/integration-test/openmldb-test-java/openmldb-sdk-test/src/main/java/com/_4paradigm/openmldb/java_sdk_test/executor/BaseSQLExecutor.java index a821e305ede..2c46a344b65 100644 --- a/test/integration-test/openmldb-test-java/openmldb-sdk-test/src/main/java/com/_4paradigm/openmldb/java_sdk_test/executor/BaseSQLExecutor.java +++ b/test/integration-test/openmldb-test-java/openmldb-sdk-test/src/main/java/com/_4paradigm/openmldb/java_sdk_test/executor/BaseSQLExecutor.java @@ -120,7 +120,6 @@ public void tearDown() { public void tearDown(String version,SqlExecutor executor) { - log.info("version:{},begin tear down",version); List tearDown = sqlCase.getTearDown(); if(CollectionUtils.isNotEmpty(tearDown)){ tearDown.forEach(sql->{ @@ -132,7 +131,6 @@ public void tearDown(String version,SqlExecutor executor) { SDKUtil.sql(executor, dbName, sql); }); } - log.info("version:{},begin drop table",version); List tables = sqlCase.getInputs(); if (CollectionUtils.isEmpty(tables)) { return; diff --git a/test/integration-test/openmldb-test-java/openmldb-sdk-test/src/main/java/com/_4paradigm/openmldb/java_sdk_test/executor/BatchSQLExecutor.java b/test/integration-test/openmldb-test-java/openmldb-sdk-test/src/main/java/com/_4paradigm/openmldb/java_sdk_test/executor/BatchSQLExecutor.java index da0649a4190..cdb6bbe27e3 100644 --- a/test/integration-test/openmldb-test-java/openmldb-sdk-test/src/main/java/com/_4paradigm/openmldb/java_sdk_test/executor/BatchSQLExecutor.java +++ b/test/integration-test/openmldb-test-java/openmldb-sdk-test/src/main/java/com/_4paradigm/openmldb/java_sdk_test/executor/BatchSQLExecutor.java @@ -82,7 +82,7 @@ public boolean verify() { @Override public void prepare(String version,SqlExecutor executor){ - log.info("version:{} prepare begin",version); + sdkClient.createAndUseDB(dbName); sdkClient.setOnline(); boolean useFirstInputAsRequests = false; @@ -119,12 +119,10 @@ public void prepare(String version,SqlExecutor executor){ } } - log.info("version:{} prepare end",version); } @Override public OpenMLDBResult execute(String version, SqlExecutor executor){ - log.info("version:{} execute begin",version); sdkClient.useDB(dbName); OpenMLDBResult openMLDBResult = null; List sqls = sqlCase.getSqls(); @@ -150,7 +148,6 @@ public OpenMLDBResult execute(String version, SqlExecutor executor){ // openMLDBResult = SDKUtil.sql(executor, dbName, sql); openMLDBResult = sdkClient.execute(sql); } - log.info("version:{} execute end",version); return openMLDBResult; } } diff --git a/test/integration-test/openmldb-test-java/openmldb-sdk-test/src/main/java/com/_4paradigm/openmldb/java_sdk_test/executor/OfflineJobExecuter.java b/test/integration-test/openmldb-test-java/openmldb-sdk-test/src/main/java/com/_4paradigm/openmldb/java_sdk_test/executor/OfflineJobExecuter.java index a502b7746f0..99e00dba4bc 100644 --- a/test/integration-test/openmldb-test-java/openmldb-sdk-test/src/main/java/com/_4paradigm/openmldb/java_sdk_test/executor/OfflineJobExecuter.java +++ b/test/integration-test/openmldb-test-java/openmldb-sdk-test/src/main/java/com/_4paradigm/openmldb/java_sdk_test/executor/OfflineJobExecuter.java @@ -123,7 +123,12 @@ public void prepare(String version,SqlExecutor executor){ // write inputs to csv file String filePath = offlineDataPrefix+tableName+ ".csv"; - ExecUtil.exeCommand("touch "+filePath); + try { + ExecUtil.exeCommand("touch "+filePath); + } catch (Exception e) { + // TODO: handle exception + } + try { BufferedWriter bufferedWriter = new BufferedWriter( new OutputStreamWriter(new FileOutputStream(filePath), "UTF-8")); diff --git a/test/integration-test/openmldb-test-java/openmldb-sdk-test/src/main/java/com/_4paradigm/openmldb/java_sdk_test/executor/RequestQuerySQLExecutor.java b/test/integration-test/openmldb-test-java/openmldb-sdk-test/src/main/java/com/_4paradigm/openmldb/java_sdk_test/executor/RequestQuerySQLExecutor.java index 713cbf6a424..51f19b95e15 100644 --- a/test/integration-test/openmldb-test-java/openmldb-sdk-test/src/main/java/com/_4paradigm/openmldb/java_sdk_test/executor/RequestQuerySQLExecutor.java +++ b/test/integration-test/openmldb-test-java/openmldb-sdk-test/src/main/java/com/_4paradigm/openmldb/java_sdk_test/executor/RequestQuerySQLExecutor.java @@ -155,6 +155,10 @@ public boolean verify() { log.info("skip case in disk mode: {}", sqlCase.getDesc()); return false; } + if (null != sqlCase.getMode() && sqlCase.getMode().contains("procedure-unsupport")) { + log.info("skip case in procedure mode: {}", sqlCase.getDesc()); + return false; + } if (OpenMLDBConfig.isCluster() && null != sqlCase.getMode() && sqlCase.getMode().contains("cluster-unsupport")) { log.info("cluster-unsupport, skip case in cluster request mode: {}", sqlCase.getDesc()); diff --git a/test/integration-test/openmldb-test-java/openmldb-sdk-test/src/test/java/com/_4paradigm/openmldb/java_sdk_test/cluster/high_availability/HighDiskTableTest.java b/test/integration-test/openmldb-test-java/openmldb-sdk-test/src/test/java/com/_4paradigm/openmldb/java_sdk_test/cluster/high_availability/HighDiskTableTest.java index 63f1ca2e300..9b778bf2b9d 100644 --- a/test/integration-test/openmldb-test-java/openmldb-sdk-test/src/test/java/com/_4paradigm/openmldb/java_sdk_test/cluster/high_availability/HighDiskTableTest.java +++ b/test/integration-test/openmldb-test-java/openmldb-sdk-test/src/test/java/com/_4paradigm/openmldb/java_sdk_test/cluster/high_availability/HighDiskTableTest.java @@ -79,7 +79,6 @@ public static void insert10000(Statement statement,String tableName,Long lastTim } i++; } - log.info("stop stop stop"); } diff --git a/test/integration-test/openmldb-test-java/openmldb-test-common/src/main/java/com/_4paradigm/openmldb/test_common/bean/OpenMLDBResult.java b/test/integration-test/openmldb-test-java/openmldb-test-common/src/main/java/com/_4paradigm/openmldb/test_common/bean/OpenMLDBResult.java index 83c9a748704..21dcfe1d5e9 100644 --- a/test/integration-test/openmldb-test-java/openmldb-test-common/src/main/java/com/_4paradigm/openmldb/test_common/bean/OpenMLDBResult.java +++ b/test/integration-test/openmldb-test-java/openmldb-test-common/src/main/java/com/_4paradigm/openmldb/test_common/bean/OpenMLDBResult.java @@ -22,6 +22,7 @@ import org.apache.commons.collections4.CollectionUtils; import java.util.List; +import java.util.Map; /** * @author zhaowei @@ -47,6 +48,9 @@ public class OpenMLDBResult { private OpenMLDBJob openMLDBJob; private List offlineColumns; private List> offlineResult; + private List> formattedExpectResults; + private List> formattedActualResults; + @Override public String toString() { diff --git a/test/integration-test/openmldb-test-java/openmldb-test-common/src/main/java/com/_4paradigm/openmldb/test_common/command/OpenMLDBCommandUtil.java b/test/integration-test/openmldb-test-java/openmldb-test-common/src/main/java/com/_4paradigm/openmldb/test_common/command/OpenMLDBCommandUtil.java index affcfd98c19..b2549788015 100644 --- a/test/integration-test/openmldb-test-java/openmldb-test-common/src/main/java/com/_4paradigm/openmldb/test_common/command/OpenMLDBCommandUtil.java +++ b/test/integration-test/openmldb-test-java/openmldb-test-common/src/main/java/com/_4paradigm/openmldb/test_common/command/OpenMLDBCommandUtil.java @@ -34,21 +34,16 @@ public class OpenMLDBCommandUtil { private static final Logger logger = new LogProxy(log); public static OpenMLDBResult createDB(OpenMLDBInfo openMLDBInfo, String dbName) { - String sql = String.format("create database %s ;",dbName); + String sql = String.format("create database if not exists %s ;",dbName); OpenMLDBResult openMLDBResult = OpenMLDBCommandFacade.sql(openMLDBInfo,dbName,sql); return openMLDBResult; } - public static OpenMLDBResult desc(OpenMLDBInfo openMLDBInfo, String dbName, String tableName) { - String sql = String.format("desc %s ;",tableName); - OpenMLDBResult openMLDBResult = OpenMLDBCommandFacade.sql(openMLDBInfo,dbName,sql); - return openMLDBResult; - } - - public static OpenMLDBResult createAndInsert(OpenMLDBInfo openMLDBInfo, String defaultDBName, List inputs) { + public static void createDatabases(OpenMLDBInfo openMLDBInfo, String defaultDBName, List inputs) { HashSet dbNames = new HashSet<>(); if (StringUtils.isNotEmpty(defaultDBName)) { dbNames.add(defaultDBName); + OpenMLDBResult createDBResult = createDB(openMLDBInfo,defaultDBName); } if (!Objects.isNull(inputs)) { for (InputDesc input : inputs) { @@ -60,6 +55,9 @@ public static OpenMLDBResult createAndInsert(OpenMLDBInfo openMLDBInfo, String d } } } + } + + public static OpenMLDBResult createTables(OpenMLDBInfo openMLDBInfo, String defaultDBName, List inputs) { OpenMLDBResult openMLDBResult = new OpenMLDBResult(); if (inputs != null && inputs.size() > 0) { for (int i = 0; i < inputs.size(); i++) { @@ -71,13 +69,27 @@ public static OpenMLDBResult createAndInsert(OpenMLDBInfo openMLDBInfo, String d createSql = SQLCase.formatSql(createSql, i, tableName); createSql = SQLUtil.formatSql(createSql, openMLDBInfo); if (!createSql.isEmpty()) { - OpenMLDBResult res = OpenMLDBCommandFacade.sql(openMLDBInfo,dbName,createSql); - if (!res.isOk()) { - logger.error("fail to create table"); - // reportLog.error("fail to create table"); - return res; - } + openMLDBResult = OpenMLDBCommandFacade.sql(openMLDBInfo,dbName,createSql); } + } + } + return openMLDBResult; + } + + public static OpenMLDBResult desc(OpenMLDBInfo openMLDBInfo, String dbName, String tableName) { + String sql = String.format("desc %s ;",tableName); + OpenMLDBResult openMLDBResult = OpenMLDBCommandFacade.sql(openMLDBInfo,dbName,sql); + return openMLDBResult; + } + + public static OpenMLDBResult createAndInsert(OpenMLDBInfo openMLDBInfo, String defaultDBName, List inputs) { + createDatabases(openMLDBInfo,defaultDBName,inputs); + createTables(openMLDBInfo,defaultDBName,inputs); + OpenMLDBResult openMLDBResult = new OpenMLDBResult(); + if (inputs != null && inputs.size() > 0) { + for (int i = 0; i < inputs.size(); i++) { + InputDesc inputDesc = inputs.get(i); + String dbName = inputDesc.getDb().isEmpty() ? defaultDBName : inputDesc.getDb(); InputDesc input = inputs.get(i); List inserts = input.extractInserts(); for (String insertSql : inserts) { diff --git a/test/integration-test/openmldb-test-java/openmldb-test-common/src/main/java/com/_4paradigm/openmldb/test_common/common/BaseExecutor.java b/test/integration-test/openmldb-test-java/openmldb-test-common/src/main/java/com/_4paradigm/openmldb/test_common/common/BaseExecutor.java new file mode 100644 index 00000000000..729b46ddfd2 --- /dev/null +++ b/test/integration-test/openmldb-test-java/openmldb-test-common/src/main/java/com/_4paradigm/openmldb/test_common/common/BaseExecutor.java @@ -0,0 +1,72 @@ +/* + * Copyright 2021 4Paradigm + * + * Licensed 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 com._4paradigm.openmldb.test_common.common; + + +import com._4paradigm.openmldb.test_common.bean.OpenMLDBResult; +import com._4paradigm.openmldb.test_common.model.SQLCase; +import com._4paradigm.openmldb.test_common.model.SQLCaseType; +import lombok.extern.slf4j.Slf4j; +import org.testng.Assert; +import org.testng.collections.Lists; +import com._4paradigm.openmldb.test_common.common.IExecutor; + +import java.util.List; + +/** + * @author zhaowei + * @date 2021/3/13 10:18 AM + */ +@Slf4j +public abstract class BaseExecutor implements IExecutor{ +// protected static final log log = new LogProxy(log); + protected SQLCase sqlCase; + protected String dbName; + protected List tableNames = Lists.newArrayList(); + protected OpenMLDBResult openMLDBResult = new OpenMLDBResult(); + + public BaseExecutor(SQLCase sqlCase){ + this.sqlCase=sqlCase; + } + @Override + public void run() { + String className = Thread.currentThread().getStackTrace()[2].getClassName(); + String methodName = Thread.currentThread().getStackTrace()[2].getMethodName(); + System.out.println(className+"."+methodName+":"+ sqlCase.getCaseFileName()+":"+ sqlCase.getDesc() + " Begin!"); + log.info(className+"."+methodName+":"+ sqlCase.getDesc() + " Begin!"); + boolean verify = false; + try { + verify = verify(); + if(!verify) return; + if (null == sqlCase) { + Assert.fail("executor run with null case"); + return; + } + prepare(); + execute(); + check(); + } catch (Exception e) { + e.printStackTrace(); + System.out.println(className+"."+methodName+":"+ sqlCase.getDesc() + " FAIL!"); + Assert.fail("executor run with exception"+sqlCase.getDesc()); + }finally { + if(verify) { + tearDown(); + } + System.out.println(className+"."+methodName+":"+ sqlCase.getDesc() + " DONE!"); + } + } +} diff --git a/test/integration-test/openmldb-test-java/openmldb-test-common/src/main/java/com/_4paradigm/openmldb/test_common/common/BaseTest.java b/test/integration-test/openmldb-test-java/openmldb-test-common/src/main/java/com/_4paradigm/openmldb/test_common/common/BaseTest.java index b2dfe006698..3a4222946d3 100644 --- a/test/integration-test/openmldb-test-java/openmldb-test-common/src/main/java/com/_4paradigm/openmldb/test_common/common/BaseTest.java +++ b/test/integration-test/openmldb-test-java/openmldb-test-common/src/main/java/com/_4paradigm/openmldb/test_common/common/BaseTest.java @@ -22,7 +22,6 @@ import com._4paradigm.openmldb.test_common.openmldb.OpenMLDBGlobalVar; import com._4paradigm.openmldb.test_common.provider.Yaml; import lombok.extern.slf4j.Slf4j; -import org.slf4j.Logger; import org.testng.Assert; import org.testng.ITest; import org.testng.annotations.BeforeMethod; @@ -31,13 +30,9 @@ import java.io.FileNotFoundException; import java.lang.reflect.Method; -/** - * @author zhaowei - * @date 2021/3/12 7:52 AM - */ + @Slf4j public class BaseTest implements ITest { -// protected static final Logger logger = new LogProxy(log); private ThreadLocal testName = new ThreadLocal<>(); private int testNum = 0; diff --git a/test/integration-test/openmldb-test-java/openmldb-test-common/src/main/java/com/_4paradigm/openmldb/test_common/openmldb/SDKClient.java b/test/integration-test/openmldb-test-java/openmldb-test-common/src/main/java/com/_4paradigm/openmldb/test_common/openmldb/SDKClient.java index 9ac964cf8e0..cf192539a73 100644 --- a/test/integration-test/openmldb-test-java/openmldb-test-common/src/main/java/com/_4paradigm/openmldb/test_common/openmldb/SDKClient.java +++ b/test/integration-test/openmldb-test-java/openmldb-test-common/src/main/java/com/_4paradigm/openmldb/test_common/openmldb/SDKClient.java @@ -25,7 +25,7 @@ public static SDKClient of(SqlExecutor executor){ return new SDKClient(executor); } public OpenMLDBResult execute(String sql) { - log.info("execute sql:{}",sql); + log.info("execute sql:{}",sql.replaceAll("\\n", "\\r")); OpenMLDBResult openMLDBResult = new OpenMLDBResult(); openMLDBResult.setSql(sql); try { @@ -50,14 +50,14 @@ public OpenMLDBResult execute(String sql) { } } if(sql.toLowerCase().startsWith("create index")||sql.toLowerCase().startsWith("drop index")){ - Tool.sleep(20*1000); + Tool.sleep(10*1000); } } catch (SQLException e) { openMLDBResult.setOk(false); openMLDBResult.setMsg(e.getMessage()); e.printStackTrace(); } - log.info("openMLDBResult:{}",openMLDBResult); + log.debug("openMLDBResult:{}",openMLDBResult); return openMLDBResult; } public OpenMLDBResult execute(List sqlList) { @@ -117,7 +117,7 @@ public void createAndUseDB(String dbName){ List sqlList = new ArrayList<>(); if(!OpenMLDBGlobalVar.CREATE_DB_NAMES.contains(dbName)){ if (!SDKUtil.dbIsExist(statement,dbName)) { - sqlList.add(String.format("create database %s;", dbName)); + sqlList.add(String.format("create database if not exists %s;", dbName)); OpenMLDBGlobalVar.CREATE_DB_NAMES.add(dbName); } } diff --git a/test/integration-test/openmldb-test-java/openmldb-test-common/src/main/java/com/_4paradigm/openmldb/test_common/restful/common/OpenMLDBHttp.java b/test/integration-test/openmldb-test-java/openmldb-test-common/src/main/java/com/_4paradigm/openmldb/test_common/restful/common/OpenMLDBHttp.java index 1016deb01e9..3503ef22ca3 100644 --- a/test/integration-test/openmldb-test-java/openmldb-test-common/src/main/java/com/_4paradigm/openmldb/test_common/restful/common/OpenMLDBHttp.java +++ b/test/integration-test/openmldb-test-java/openmldb-test-common/src/main/java/com/_4paradigm/openmldb/test_common/restful/common/OpenMLDBHttp.java @@ -96,4 +96,29 @@ public HttpResult restfulRequest() { } return result; } + + public HttpResult restfulJsonRequest(String url, String uri, String body, HttpMethod HttpMethod){ + String realUrl = url+uri; + HttpResult result = null; + this.headMap.put("Content-Type","application/json;charset=utf-8"); + try { + switch(HttpMethod){ + case GET: + result = HttpRequest.get(realUrl,null,this.headMap); + break; + case POST: + result = HttpRequest.postJson(realUrl,body,this.headMap); + break; + case PUT: + result = HttpRequest.put(realUrl,body,this.headMap); + break; + case DELETE: + result = HttpRequest.get(realUrl,this.data,this.headMap); + break; + } + } catch (Exception e){ + e.printStackTrace(); + } + return result; + } } diff --git a/test/integration-test/openmldb-test-java/openmldb-test-common/src/main/java/com/_4paradigm/openmldb/test_common/restful/model/HttpData.java b/test/integration-test/openmldb-test-java/openmldb-test-common/src/main/java/com/_4paradigm/openmldb/test_common/restful/model/HttpData.java new file mode 100644 index 00000000000..25fb525c205 --- /dev/null +++ b/test/integration-test/openmldb-test-java/openmldb-test-common/src/main/java/com/_4paradigm/openmldb/test_common/restful/model/HttpData.java @@ -0,0 +1,14 @@ +package com._4paradigm.openmldb.test_common.restful.model; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +import lombok.Data; + +@Data +public class HttpData { + private Map> data; + private Integer code; + private String msg; + +} diff --git a/test/integration-test/openmldb-test-java/openmldb-test-common/src/main/java/com/_4paradigm/openmldb/test_common/util/HttpRequest.java b/test/integration-test/openmldb-test-java/openmldb-test-common/src/main/java/com/_4paradigm/openmldb/test_common/util/HttpRequest.java index 605423446ce..bb7ccb4052c 100644 --- a/test/integration-test/openmldb-test-java/openmldb-test-common/src/main/java/com/_4paradigm/openmldb/test_common/util/HttpRequest.java +++ b/test/integration-test/openmldb-test-java/openmldb-test-common/src/main/java/com/_4paradigm/openmldb/test_common/util/HttpRequest.java @@ -15,7 +15,10 @@ */ package com._4paradigm.openmldb.test_common.util; +import com._4paradigm.openmldb.test_common.restful.model.HttpData; import com._4paradigm.openmldb.test_common.restful.model.HttpResult; +import com.google.gson.Gson; + import lombok.extern.slf4j.Slf4j; import net.minidev.json.JSONObject; import org.apache.commons.collections4.MapUtils; @@ -58,7 +61,7 @@ public static HttpResult get(String link, Map dataMap, Map dataMap, Map dataMap, Map headMap) throws Exception { - log.info("请求的url:" + link); - log.info("请求的data:" + mapToJson(dataMap)); + log.info("request url:" + link + " data: "+mapToJson(dataMap)); CookieStore cookieStore = new BasicCookieStore(); CloseableHttpClient httpclient = HttpClients.custom().setDefaultCookieStore(cookieStore).build(); HttpPost httpost = new HttpPost(link.toString()); @@ -98,13 +99,11 @@ public static HttpResult postJson(String link, Map dataMap, Map< HttpEntity entity = response.getEntity(); // 把内容转成字符串 String resultString = EntityUtils.toString(entity); - log.info("请求的返回code:" + code); - log.info("请求的返回data:" + resultString); + log.info("response code:" + code + " data:"+ resultString); return getHttpResult(resultString, code,headers,cookies,beginTime,endTime); } public static HttpResult postJson(String link, String json, Map headMap) throws Exception { - log.info("请求的url:" + link); - log.info("请求的data:" + json); + log.info("request url:" + link + " data: "+json); CookieStore cookieStore = new BasicCookieStore(); CloseableHttpClient httpclient = HttpClients.custom().setDefaultCookieStore(cookieStore).build(); HttpPost httpPost = new HttpPost(link.toString()); @@ -124,13 +123,11 @@ public static HttpResult postJson(String link, String json, Map HttpEntity entity = response.getEntity(); // 把内容转成字符串 String resultString = EntityUtils.toString(entity); - log.info("请求的返回code:" + code); - log.info("请求的返回data:" + resultString); + log.info("response code:" + code + " data:"+ resultString); return getHttpResult(resultString, code,headers,cookies,beginTime,endTime); } public static HttpResult put(String link, String json, Map headMap) throws IOException { - log.info("请求的url:" + link); - log.info("请求的data:" + json); + log.info("request url:" + link + " data: "+json); CookieStore cookieStore = new BasicCookieStore(); CloseableHttpClient httpclient = HttpClients.custom().setDefaultCookieStore(cookieStore).build(); HttpPut httpPut = new HttpPut(link.toString()); @@ -148,8 +145,7 @@ public static HttpResult put(String link, String json, Map headM HttpEntity entity = response.getEntity(); // 把内容转成字符串 String resultString = EntityUtils.toString(entity); - log.info("请求的返回code:" + code); - log.info("请求的返回data:" + resultString); + log.info("response code:" + code + " data:"+ resultString); return getHttpResult(resultString, code,headers,cookies,beiginTime,endTime); } public static String uploadFile(String filename, String url) throws IOException { @@ -287,8 +283,7 @@ public static HttpResult post(String link, Map parameterMap,Map< } public static HttpResult put(String link, Map dataMap, Map headMap) throws IOException { - log.info("请求的url:" + link); - log.info("请求的data:" + mapToJson(dataMap)); + log.info("request url:" + link + " data: "+mapToJson(dataMap)); CookieStore cookieStore = new BasicCookieStore(); CloseableHttpClient httpclient = HttpClients.custom().setDefaultCookieStore(cookieStore).build(); HttpPut httpput = new HttpPut(link.toString()); @@ -305,8 +300,7 @@ public static HttpResult put(String link, Map dataMap, Map.*" | head -1 | sed 's#.*\(.*\).*#\1#') - sh test/steps/build-java-sdk.sh fi echo "JAVA_SDK_VERSION:${JAVA_SDK_VERSION}" echo "OPENMLDB_SERVER_VERSION:${OPENMLDB_SERVER_VERSION}" diff --git a/test/steps/openmldb-integration-test.sh b/test/steps/openmldb-integration-test.sh new file mode 100755 index 00000000000..e6e95557f41 --- /dev/null +++ b/test/steps/openmldb-integration-test.sh @@ -0,0 +1,59 @@ +#!/bin/bash +while getopts ":c:d:l:s:j:m:" opt +do + case $opt in + c) + echo "参数c的值:$OPTARG" + CASE_XML=$OPTARG + ;; + d) + echo "参数d的值:$OPTARG" + DEPLOY_MODE=$OPTARG + ;; + l) echo "参数l的值:$OPTARG" + CASE_LEVEL=$OPTARG + ;; + s) echo "参数s的值:$OPTARG" + TABLE_STORAGE_MODE=$OPTARG + ;; + j) echo "参数j的值:$OPTARG" + JAR_VERSION=$OPTARG + ;; + m) echo "参数m的值:$OPTARG" + EXECUTE_MODE=$OPTARG + ;; + ?) echo "未知参数" + exit 1 + ;; + esac +done +if [[ "${CASE_XML}" == "" ]]; then + CASE_XML="test_all.xml" +fi +if [[ "${DEPLOY_MODE}" == "" ]]; then + DEPLOY_MODE="cluster" +fi +if [[ "${CASE_LEVEL}" == "" ]]; then + CASE_LEVEL="0" +fi +if [[ "${EXECUTE_MODE}" == "" ]]; then + EXECUTE_MODE="javasdk" +fi + +#JAVA_SDK_VERSION=$(more java/pom.xml | grep ".*" | head -1 | sed 's#.*\(.*\).*#\1#') +sh test/steps/modify_java_sdk_config.sh "${CASE_XML}" "${DEPLOY_MODE}" "${JAR_VERSION}" "" "${JAR_VERSION}" "${JAR_VERSION}" "${TABLE_STORAGE_MODE}" +mkdir -p ../mvnrepo +MAVEN_REPO="-Dmaven.repo.local=$(pwd)/../mvnrepo" +export MAVEN_OPTS="${MAVEN_REPO}" +mvn install:install-file -Dfile=openmldb-batch.jar -DartifactId=openmldb-batch -DgroupId=com.4paradigm.openmldb -Dversion="${JAR_VERSION}" -Dpackaging=jar +mvn install:install-file -Dfile=openmldb-jdbc.jar -DartifactId=openmldb-jdbc -DgroupId=com.4paradigm.openmldb -Dversion="${JAR_VERSION}" -Dpackaging=jar +mvn install:install-file -Dfile=openmldb-native.jar -DartifactId=openmldb-native -DgroupId=com.4paradigm.openmldb -Dversion="${JAR_VERSION}" -Dpackaging=jar +mvn install:install-file -Dfile=openmldb-spark-connector.jar -DartifactId=openmldb-spark-connector -DgroupId=com.4paradigm.openmldb -Dversion="${JAR_VERSION}" -Dpackaging=jar + +mvn clean install -B -Dmaven.test.skip=true -f test/test-tool/command-tool/pom.xml +mvn clean install -B -Dmaven.test.skip=true -f test/integration-test/openmldb-test-java/pom.xml -Dopenmldb.native.version="${JAR_VERSION}" -Dopenmldb.jdbc.version="${JAR_VERSION}" -Dopenmldb.batch.version="${JAR_VERSION}" +if [[ "${EXECUTE_MODE}" == "javasdk" ]]; then + mvn clean test -B -e -U -DsuiteXmlFile=test_suite/"${CASE_XML}" -f test/integration-test/openmldb-test-java/openmldb-sdk-test/pom.xml -DcaseLevel="${CASE_LEVEL}" -Dopenmldb.native.version="${JAR_VERSION}" -Dopenmldb.jdbc.version="${JAR_VERSION}" -Dopenmldb.batch.version="${JAR_VERSION}" +elif [[ "${EXECUTE_MODE}" == "apiserver" ]]; then + mvn clean test -B -e -U -DsuiteXmlFile=test_suite/"${CASE_XML}" -f test/integration-test/openmldb-test-java/openmldb-http-test/pom.xml -DcaseLevel="${CASE_LEVEL}" -Dopenmldb.native.version="${JAR_VERSION}" -Dopenmldb.jdbc.version="${JAR_VERSION}" -Dopenmldb.batch.version="${JAR_VERSION}" +fi diff --git a/test/steps/openmldb-sdk-test-java-src.sh b/test/steps/openmldb-sdk-test-java-src.sh index 10d30d1f043..c31a2c46d49 100755 --- a/test/steps/openmldb-sdk-test-java-src.sh +++ b/test/steps/openmldb-sdk-test-java-src.sh @@ -88,15 +88,15 @@ echo "deploy config:" cat ${deployConfigPath} # install command tool cd test/test-tool/command-tool || exit -mvn clean install -Dmaven.test.skip=true +mvn clean install -B -Dmaven.test.skip=true cd "${ROOT_DIR}" || exit # modify config sh test/steps/modify_java_sdk_config.sh "${CASE_XML}" "${DEPLOY_MODE}" "${JAVA_SDK_VERSION}" "" "${OPENMLDB_SERVER_VERSION}" "${JAVA_NATIVE_VERSION}" "${TABLE_STORAGE_MODE}" # install jar cd test/integration-test/openmldb-test-java || exit -mvn clean install -Dmaven.test.skip=true +mvn clean install -B -Dmaven.test.skip=true cd "${ROOT_DIR}" || exit # run case cd "${ROOT_DIR}"/test/integration-test/openmldb-test-java/openmldb-sdk-test || exit -mvn clean test -e -U -DsuiteXmlFile=test_suite/"${CASE_XML}" -DcaseLevel="${CASE_LEVEL}" +mvn clean test -B -e -U -DsuiteXmlFile=test_suite/"${CASE_XML}" -DcaseLevel="${CASE_LEVEL}"